ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/UseTheForce/DarkSide/simulation.F90
(Generate patch)

Comparing trunk/OOPSE-4/src/UseTheForce/DarkSide/simulation.F90 (file contents):
Revision 1609 by gezelter, Wed Oct 20 04:12:01 2004 UTC vs.
Revision 2310 by chrisfen, Mon Sep 19 23:21:46 2005 UTC

# Line 1 | Line 1
1 + !!
2 + !! Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 + !!
4 + !! The University of Notre Dame grants you ("Licensee") a
5 + !! non-exclusive, royalty free, license to use, modify and
6 + !! redistribute this software in source and binary code form, provided
7 + !! that the following conditions are met:
8 + !!
9 + !! 1. Acknowledgement of the program authors must be made in any
10 + !!    publication of scientific results based in part on use of the
11 + !!    program.  An acceptable form of acknowledgement is citation of
12 + !!    the article in which the program was described (Matthew
13 + !!    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 + !!    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 + !!    Parallel Simulation Engine for Molecular Dynamics,"
16 + !!    J. Comput. Chem. 26, pp. 252-271 (2005))
17 + !!
18 + !! 2. Redistributions of source code must retain the above copyright
19 + !!    notice, this list of conditions and the following disclaimer.
20 + !!
21 + !! 3. Redistributions in binary form must reproduce the above copyright
22 + !!    notice, this list of conditions and the following disclaimer in the
23 + !!    documentation and/or other materials provided with the
24 + !!    distribution.
25 + !!
26 + !! This software is provided "AS IS," without a warranty of any
27 + !! kind. All express or implied conditions, representations and
28 + !! warranties, including any implied warranty of merchantability,
29 + !! fitness for a particular purpose or non-infringement, are hereby
30 + !! excluded.  The University of Notre Dame and its licensors shall not
31 + !! be liable for any damages suffered by licensee as a result of
32 + !! using, modifying or distributing the software or its
33 + !! derivatives. In no event will the University of Notre Dame or its
34 + !! licensors be liable for any lost revenue, profit or data, or for
35 + !! direct, indirect, special, consequential, incidental or punitive
36 + !! damages, however caused and regardless of the theory of liability,
37 + !! arising out of the use of or inability to use software, even if the
38 + !! University of Notre Dame has been advised of the possibility of
39 + !! such damages.
40 + !!
41 +
42   !! Fortran interface to C entry plug.
43  
44   module simulation
# Line 17 | Line 58 | module simulation
58   #define __FORTRAN90
59   #include "brains/fSimulation.h"
60   #include "UseTheForce/fSwitchingFunction.h"
61 + #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h"
62  
63    type (simtype), public, save :: thisSim
64  
# Line 41 | Line 83 | module simulation
83    real(kind=dp), allocatable, dimension(:), public :: mfactCol
84    real(kind=dp), allocatable, dimension(:), public :: mfactLocal
85  
86 +  logical, allocatable, dimension(:) :: simHasAtypeMap
87    real(kind=dp), public, dimension(3,3), save :: Hmat, HmatInv
88    logical, public, save :: boxIsOrthorhombic
89 <  
89 >
90    public :: SimulationSetup
91    public :: getNlocal
92    public :: setBox
93    public :: getDielect
94    public :: SimUsesPBC
95 <  public :: SimUsesLJ
95 >
96 >  public :: SimUsesDirectionalAtoms
97 >  public :: SimUsesLennardJones
98 >  public :: SimUsesElectrostatics
99    public :: SimUsesCharges
100    public :: SimUsesDipoles
101    public :: SimUsesSticky
102 <  public :: SimUsesRF
103 <  public :: SimUsesGB
102 >  public :: SimUsesStickyPower
103 >  public :: SimUsesGayBerne
104    public :: SimUsesEAM
105 +  public :: SimUsesShapes
106 +  public :: SimUsesFLARB
107 +  public :: SimUsesRF
108    public :: SimRequiresPrepairCalc
109    public :: SimRequiresPostpairCalc
110 <  public :: SimUsesDirectionalAtoms
111 <  
110 >  public :: SimHasAtype
111 >
112   contains
113 <  
113 >
114    subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
115         CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
116         CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
# Line 134 | Line 183 | contains
183      nGroupsInRow = getNgroupsInRow(plan_group_row)
184      nGroupsInCol = getNgroupsInCol(plan_group_col)
185      mynode = getMyNode()
186 <    
186 >
187      allocate(c_idents_Row(nAtomsInRow),stat=alloc_stat)
188      if (alloc_stat /= 0 ) then
189         status = -1
# Line 167 | Line 216 | contains
216      if (allocated(c_idents_Row)) then
217         deallocate(c_idents_Row)
218      endif
219 <  
219 >
220   #endif
221  
222   #ifdef IS_MPI
# Line 206 | Line 255 | contains
255         status = -1
256         return
257      endif
258 <    
258 >
259      glPointer = 1
260  
261      do i = 1, nGroupsInRow
# Line 245 | Line 294 | contains
294  
295      call gather(mfactLocal,      mfactRow,      plan_atom_row)
296      call gather(mfactLocal,      mfactCol,      plan_atom_col)
297 <    
297 >
298      if (allocated(mfactLocal)) then
299         deallocate(mfactLocal)
300      end if
# Line 305 | Line 354 | contains
354         mfactRow(i) = Cmfact(i)
355         mfactCol(i) = Cmfact(i)
356      end do
357 <    
357 >
358   #endif
359  
360  
361 < ! We build the local atid's for both mpi and nonmpi
361 >    ! We build the local atid's for both mpi and nonmpi
362      do i = 1, nLocal
363 <      
363 >
364         me = getFirstMatchingElement(atypes, "c_ident", c_idents(i))
365         atid(i) = me
366 <  
366 >
367      enddo
368  
369      do i = 1, nExcludes_Local
# Line 337 | Line 386 | contains
386   #ifdef IS_MPI
387      do j = 1, nAtomsInRow
388   #else
389 <    do j = 1, nLocal
341 < #endif
342 <       nSkipsForAtom(j) = 0
343 < #ifdef IS_MPI
344 <       id1 = AtomRowToGlobal(j)
345 < #else
346 <       id1 = j
389 >       do j = 1, nLocal
390   #endif
391 <       do i = 1, nExcludes_Local
392 <          if (excludesLocal(1,i) .eq. id1 ) then
393 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
391 >          nSkipsForAtom(j) = 0
392 > #ifdef IS_MPI
393 >          id1 = AtomRowToGlobal(j)
394 > #else
395 >          id1 = j
396 > #endif
397 >          do i = 1, nExcludes_Local
398 >             if (excludesLocal(1,i) .eq. id1 ) then
399 >                nSkipsForAtom(j) = nSkipsForAtom(j) + 1
400  
401 <             if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
402 <                maxSkipsForAtom = nSkipsForAtom(j)
401 >                if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
402 >                   maxSkipsForAtom = nSkipsForAtom(j)
403 >                endif
404               endif
405 <          endif
406 <          if (excludesLocal(2,i) .eq. id1 ) then
357 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
405 >             if (excludesLocal(2,i) .eq. id1 ) then
406 >                nSkipsForAtom(j) = nSkipsForAtom(j) + 1
407  
408 <             if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
409 <                maxSkipsForAtom = nSkipsForAtom(j)
408 >                if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
409 >                   maxSkipsForAtom = nSkipsForAtom(j)
410 >                endif
411               endif
412 <          endif
413 <       end do
364 <    enddo
412 >          end do
413 >       enddo
414  
415   #ifdef IS_MPI
416 <    allocate(skipsForAtom(nAtomsInRow, maxSkipsForAtom), stat=alloc_stat)
416 >       allocate(skipsForAtom(nAtomsInRow, maxSkipsForAtom), stat=alloc_stat)
417   #else
418 <    allocate(skipsForAtom(nLocal, maxSkipsForAtom), stat=alloc_stat)
418 >       allocate(skipsForAtom(nLocal, maxSkipsForAtom), stat=alloc_stat)
419   #endif
420 <    if (alloc_stat /= 0 ) then
421 <       write(*,*) 'Could not allocate skipsForAtom array'
422 <       return
423 <    endif
420 >       if (alloc_stat /= 0 ) then
421 >          write(*,*) 'Could not allocate skipsForAtom array'
422 >          return
423 >       endif
424  
425   #ifdef IS_MPI
426 <    do j = 1, nAtomsInRow
426 >       do j = 1, nAtomsInRow
427   #else
428 <    do j = 1, nLocal
428 >          do j = 1, nLocal
429   #endif
430 <       nSkipsForAtom(j) = 0
430 >             nSkipsForAtom(j) = 0
431   #ifdef IS_MPI
432 <       id1 = AtomRowToGlobal(j)
432 >             id1 = AtomRowToGlobal(j)
433   #else
434 <       id1 = j
434 >             id1 = j
435   #endif
436 <       do i = 1, nExcludes_Local
437 <          if (excludesLocal(1,i) .eq. id1 ) then
438 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
439 <             ! exclude lists have global ID's so this line is
440 <             ! the same in MPI and non-MPI
441 <             id2 = excludesLocal(2,i)
442 <             skipsForAtom(j, nSkipsForAtom(j)) = id2
443 <          endif
444 <          if (excludesLocal(2, i) .eq. id1 ) then
445 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
446 <             ! exclude lists have global ID's so this line is
447 <             ! the same in MPI and non-MPI
448 <             id2 = excludesLocal(1,i)
449 <             skipsForAtom(j, nSkipsForAtom(j)) = id2
450 <          endif
451 <       end do
452 <    enddo
404 <    
405 <    do i = 1, nExcludes_Global
406 <       excludesGlobal(i) = CexcludesGlobal(i)
407 <    enddo
436 >             do i = 1, nExcludes_Local
437 >                if (excludesLocal(1,i) .eq. id1 ) then
438 >                   nSkipsForAtom(j) = nSkipsForAtom(j) + 1
439 >                   ! exclude lists have global ID's so this line is
440 >                   ! the same in MPI and non-MPI
441 >                   id2 = excludesLocal(2,i)
442 >                   skipsForAtom(j, nSkipsForAtom(j)) = id2
443 >                endif
444 >                if (excludesLocal(2, i) .eq. id1 ) then
445 >                   nSkipsForAtom(j) = nSkipsForAtom(j) + 1
446 >                   ! exclude lists have global ID's so this line is
447 >                   ! the same in MPI and non-MPI
448 >                   id2 = excludesLocal(1,i)
449 >                   skipsForAtom(j, nSkipsForAtom(j)) = id2
450 >                endif
451 >             end do
452 >          enddo
453  
454 <    do i = 1, nGlobal
455 <       molMemberShipList(i) = CmolMembership(i)
456 <    enddo
412 <    
413 <    if (status == 0) simulation_setup_complete = .true.
414 <    
415 <  end subroutine SimulationSetup
416 <  
417 <  subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
418 <    real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
419 <    integer :: cBoxIsOrthorhombic
420 <    integer :: smallest, status, i
421 <    
422 <    Hmat = cHmat
423 <    HmatInv = cHmatInv
424 <    if (cBoxIsOrthorhombic .eq. 0 ) then
425 <       boxIsOrthorhombic = .false.
426 <    else
427 <       boxIsOrthorhombic = .true.
428 <    endif
429 <    
430 <    return    
431 <  end subroutine setBox
454 >          do i = 1, nExcludes_Global
455 >             excludesGlobal(i) = CexcludesGlobal(i)
456 >          enddo
457  
458 <  function getDielect() result(dielect)
459 <    real( kind = dp ) :: dielect
460 <    dielect = thisSim%dielect
436 <  end function getDielect
437 <      
438 <  function SimUsesPBC() result(doesit)
439 <    logical :: doesit
440 <    doesit = thisSim%SIM_uses_PBC
441 <  end function SimUsesPBC
458 >          do i = 1, nGlobal
459 >             molMemberShipList(i) = CmolMembership(i)
460 >          enddo
461  
462 <  function SimUsesLJ() result(doesit)
463 <    logical :: doesit
464 <    doesit = thisSim%SIM_uses_LJ
465 <  end function SimUsesLJ
462 >         call createSimHasAtype(alloc_stat)
463 >         if (alloc_stat /= 0) then
464 >            status = -1
465 >         end if
466 >        
467 >         if (status == 0) simulation_setup_complete = .true.
468  
469 <  function SimUsesSticky() result(doesit)
449 <    logical :: doesit
450 <    doesit = thisSim%SIM_uses_sticky
451 <  end function SimUsesSticky
469 >        end subroutine SimulationSetup
470  
471 <  function SimUsesCharges() result(doesit)
472 <    logical :: doesit
473 <    doesit = thisSim%SIM_uses_charges
474 <  end function SimUsesCharges
471 >        subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
472 >          real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
473 >          integer :: cBoxIsOrthorhombic
474 >          integer :: smallest, status, i
475  
476 <  function SimUsesDipoles() result(doesit)
477 <    logical :: doesit
478 <    doesit = thisSim%SIM_uses_dipoles
479 <  end function SimUsesDipoles
476 >          Hmat = cHmat
477 >          HmatInv = cHmatInv
478 >          if (cBoxIsOrthorhombic .eq. 0 ) then
479 >             boxIsOrthorhombic = .false.
480 >          else
481 >             boxIsOrthorhombic = .true.
482 >          endif
483  
484 <  function SimUsesRF() result(doesit)
485 <    logical :: doesit
465 <    doesit = thisSim%SIM_uses_RF
466 <  end function SimUsesRF
484 >          return    
485 >        end subroutine setBox
486  
487 <  function SimUsesGB() result(doesit)
488 <    logical :: doesit
489 <    doesit = thisSim%SIM_uses_GB
490 <  end function SimUsesGB
487 >        function getDielect() result(dielect)
488 >          real( kind = dp ) :: dielect
489 >          dielect = thisSim%dielect
490 >        end function getDielect
491  
492 <  function SimUsesEAM() result(doesit)
493 <    logical :: doesit
494 <    doesit = thisSim%SIM_uses_EAM
495 <  end function SimUsesEAM
477 <
478 <  function SimUsesDirectionalAtoms() result(doesit)
479 <    logical :: doesit
480 <    doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_sticky .or. &
481 <         thisSim%SIM_uses_GB .or. thisSim%SIM_uses_RF
482 <  end function SimUsesDirectionalAtoms
492 >        function SimUsesPBC() result(doesit)
493 >          logical :: doesit
494 >          doesit = thisSim%SIM_uses_PBC
495 >        end function SimUsesPBC
496  
497 <  function SimRequiresPrepairCalc() result(doesit)
498 <    logical :: doesit
499 <    doesit = thisSim%SIM_uses_EAM
500 <  end function SimRequiresPrepairCalc
497 >        function SimUsesDirectionalAtoms() result(doesit)
498 >          logical :: doesit
499 >          doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_Sticky .or. &
500 >               thisSim%SIM_uses_StickyPower .or. &
501 >               thisSim%SIM_uses_GayBerne .or. thisSim%SIM_uses_Shapes
502 >        end function SimUsesDirectionalAtoms
503  
504 <  function SimRequiresPostpairCalc() result(doesit)
505 <    logical :: doesit
506 <    doesit = thisSim%SIM_uses_RF
507 <  end function SimRequiresPostpairCalc
493 <  
494 <  subroutine InitializeSimGlobals(thisStat)
495 <    integer, intent(out) :: thisStat
496 <    integer :: alloc_stat
497 <    
498 <    thisStat = 0
499 <    
500 <    call FreeSimGlobals()    
501 <    
502 <    allocate(excludesLocal(2,nExcludes_Local), stat=alloc_stat)
503 <    if (alloc_stat /= 0 ) then
504 <       thisStat = -1
505 <       return
506 <    endif
507 <    
508 <    allocate(excludesGlobal(nExcludes_Global), stat=alloc_stat)
509 <    if (alloc_stat /= 0 ) then
510 <       thisStat = -1
511 <       return
512 <    endif
504 >        function SimUsesLennardJones() result(doesit)
505 >          logical :: doesit
506 >          doesit = thisSim%SIM_uses_LennardJones
507 >        end function SimUsesLennardJones
508  
509 <    allocate(molMembershipList(nGlobal), stat=alloc_stat)
510 <    if (alloc_stat /= 0 ) then
511 <       thisStat = -1
512 <       return
518 <    endif
519 <    
520 <  end subroutine InitializeSimGlobals
521 <  
522 <  subroutine FreeSimGlobals()
523 <    
524 <    !We free in the opposite order in which we allocate in.
509 >        function SimUsesElectrostatics() result(doesit)
510 >          logical :: doesit
511 >          doesit = thisSim%SIM_uses_Electrostatics
512 >        end function SimUsesElectrostatics
513  
514 <    if (allocated(skipsForAtom)) deallocate(skipsForAtom)
515 <    if (allocated(nSkipsForAtom)) deallocate(nSkipsForAtom)
516 <    if (allocated(mfactLocal)) deallocate(mfactLocal)
517 <    if (allocated(mfactCol)) deallocate(mfactCol)
530 <    if (allocated(mfactRow)) deallocate(mfactRow)
531 <    if (allocated(groupListCol)) deallocate(groupListCol)    
532 <    if (allocated(groupListRow)) deallocate(groupListRow)    
533 <    if (allocated(groupStartCol)) deallocate(groupStartCol)
534 <    if (allocated(groupStartRow)) deallocate(groupStartRow)    
535 <    if (allocated(molMembershipList)) deallocate(molMembershipList)    
536 <    if (allocated(excludesGlobal)) deallocate(excludesGlobal)
537 <    if (allocated(excludesLocal)) deallocate(excludesLocal)
538 <    
539 <  end subroutine FreeSimGlobals
540 <  
541 <  pure function getNlocal() result(n)
542 <    integer :: n
543 <    n = nLocal
544 <  end function getNlocal
545 <  
546 <  
547 < end module simulation
514 >        function SimUsesCharges() result(doesit)
515 >          logical :: doesit
516 >          doesit = thisSim%SIM_uses_Charges
517 >        end function SimUsesCharges
518  
519 +        function SimUsesDipoles() result(doesit)
520 +          logical :: doesit
521 +          doesit = thisSim%SIM_uses_Dipoles
522 +        end function SimUsesDipoles
523  
524 < subroutine setFortranSim(setThisSim, CnGlobal, CnLocal, c_idents, &
525 <       CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
526 <       CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
527 <       status)
554 <       use definitions, ONLY : dp    
555 <       use simulation
556 <    
557 <    type (simtype) :: setThisSim
558 <    integer, intent(inout) :: CnGlobal, CnLocal
559 <    integer, dimension(CnLocal),intent(inout) :: c_idents
524 >        function SimUsesSticky() result(doesit)
525 >          logical :: doesit
526 >          doesit = thisSim%SIM_uses_Sticky
527 >        end function SimUsesSticky
528  
529 <    integer :: CnLocalExcludes
530 <    integer, dimension(2,CnLocalExcludes), intent(inout) :: CexcludesLocal
531 <    integer :: CnGlobalExcludes
532 <    integer, dimension(CnGlobalExcludes), intent(inout) :: CexcludesGlobal
533 <    integer, dimension(CnGlobal),intent(inout) :: CmolMembership
534 <    !!  Result status, success = 0, status = -1
535 <    integer, intent(inout) :: status
536 <    
537 <    !! mass factors used for molecular cutoffs
538 <    real ( kind = dp ), dimension(CnLocal) :: Cmfact
539 <    integer, intent(in):: CnGroups
540 <    integer, dimension(CnGlobal), intent(inout):: CglobalGroupMembership
541 <    
542 <    call SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
543 <       CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
544 <       CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
545 <       status)
546 < end subroutine setFortranSim
547 <
548 < subroutine setFortranBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
549 <    use simulation, only : setBox
550 <    use definitions, ONLY : dp
551 <    real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
552 <    integer :: cBoxIsOrthorhombic
553 <  
554 <   call setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
555 <    
556 < end subroutine setFortranBox
529 >        function SimUsesStickyPower() result(doesit)
530 >          logical :: doesit
531 >          doesit = thisSim%SIM_uses_StickyPower
532 >        end function SimUsesStickyPower
533 >
534 >        function SimUsesGayBerne() result(doesit)
535 >          logical :: doesit
536 >          doesit = thisSim%SIM_uses_GayBerne
537 >        end function SimUsesGayBerne
538 >
539 >        function SimUsesEAM() result(doesit)
540 >          logical :: doesit
541 >          doesit = thisSim%SIM_uses_EAM
542 >        end function SimUsesEAM
543 >
544 >        function SimUsesShapes() result(doesit)
545 >          logical :: doesit
546 >          doesit = thisSim%SIM_uses_Shapes
547 >        end function SimUsesShapes
548 >
549 >        function SimUsesFLARB() result(doesit)
550 >          logical :: doesit
551 >          doesit = thisSim%SIM_uses_FLARB
552 >        end function SimUsesFLARB
553 >
554 >        function SimUsesRF() result(doesit)
555 >          logical :: doesit
556 >          doesit = thisSim%SIM_uses_RF
557 >        end function SimUsesRF
558 >
559 >        function SimRequiresPrepairCalc() result(doesit)
560 >          logical :: doesit
561 >          doesit = thisSim%SIM_uses_EAM
562 >        end function SimRequiresPrepairCalc
563 >
564 >        function SimRequiresPostpairCalc() result(doesit)
565 >          logical :: doesit
566 >          doesit = thisSim%SIM_uses_RF
567 >        end function SimRequiresPostpairCalc
568 >
569 >        ! Function returns true if the simulation has this atype
570 >        function SimHasAtype(thisAtype) result(doesit)
571 >          logical :: doesit
572 >          integer :: thisAtype
573 >          doesit = .false.
574 >          if(.not.allocated(SimHasAtypeMap)) return
575 >
576 >          doesit = SimHasAtypeMap(thisAtype)
577 >            
578 >        end function SimHasAtype
579 >
580 >        subroutine createSimHasAtype(status)
581 >          integer, intent(out) :: status
582 >          integer :: alloc_stat
583 >          integer :: me_i
584 >          integer :: mpiErrors
585 >          integer :: nAtypes
586 >          status = 0
587 >
588 >          nAtypes = getSize(atypes)
589 >          ! Setup logical map for atypes in simulation
590 >          if (.not.allocated(SimHasAtypeMap)) then
591 >             allocate(SimHasAtypeMap(nAtypes),stat=alloc_stat)
592 >             if (alloc_stat /= 0 ) then
593 >                status = -1
594 >                return
595 >             end if
596 >             SimHasAtypeMap = .false.
597 >          end if
598 >          ! Loop through the local atoms and grab the atypes present        
599 >          do me_i = 1,nLocal
600 >             SimHasAtypeMap(atid(me_i)) = .true.
601 >          end do
602 >          ! For MPI, we need to know all possible atypes present in
603 >          ! simulation on all processors. Use LOR operation to set map.
604 > #ifdef IS_MPI
605 >          call mpi_allreduce(SimHasAtypeMap, SimHasAtypeMap, nAtypes, &
606 >               mpi_logical, MPI_LOR, mpi_comm_world, mpiErrors)
607 > #endif          
608 >        end subroutine createSimHasAtype
609 >        
610 >       subroutine InitializeSimGlobals(thisStat)
611 >          integer, intent(out) :: thisStat
612 >          integer :: alloc_stat
613 >
614 >          thisStat = 0
615 >
616 >          call FreeSimGlobals()    
617 >
618 >          allocate(excludesLocal(2,nExcludes_Local), stat=alloc_stat)
619 >          if (alloc_stat /= 0 ) then
620 >             thisStat = -1
621 >             return
622 >          endif
623 >
624 >          allocate(excludesGlobal(nExcludes_Global), stat=alloc_stat)
625 >          if (alloc_stat /= 0 ) then
626 >             thisStat = -1
627 >             return
628 >          endif
629 >
630 >          allocate(molMembershipList(nGlobal), stat=alloc_stat)
631 >          if (alloc_stat /= 0 ) then
632 >             thisStat = -1
633 >             return
634 >          endif
635 >
636 >        end subroutine InitializeSimGlobals
637 >
638 >        subroutine FreeSimGlobals()
639 >
640 >          !We free in the opposite order in which we allocate in.
641 >
642 >          if (allocated(skipsForAtom)) deallocate(skipsForAtom)
643 >          if (allocated(nSkipsForAtom)) deallocate(nSkipsForAtom)
644 >          if (allocated(mfactLocal)) deallocate(mfactLocal)
645 >          if (allocated(mfactCol)) deallocate(mfactCol)
646 >          if (allocated(mfactRow)) deallocate(mfactRow)
647 >          if (allocated(groupListCol)) deallocate(groupListCol)    
648 >          if (allocated(groupListRow)) deallocate(groupListRow)    
649 >          if (allocated(groupStartCol)) deallocate(groupStartCol)
650 >          if (allocated(groupStartRow)) deallocate(groupStartRow)    
651 >          if (allocated(molMembershipList)) deallocate(molMembershipList)    
652 >          if (allocated(excludesGlobal)) deallocate(excludesGlobal)
653 >          if (allocated(excludesLocal)) deallocate(excludesLocal)
654 >
655 >        end subroutine FreeSimGlobals
656 >
657 >        pure function getNlocal() result(n)
658 >          integer :: n
659 >          n = nLocal
660 >        end function getNlocal
661 >
662 >
663 >
664 >
665 >
666 >      end module simulation

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines