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 2432 by chuckv, Tue Nov 15 16:01:06 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 + #ifdef IS_MPI
88 +  logical, allocatable, dimension(:) :: simHasAtypeMapTemp
89 + #endif
90 +
91    real(kind=dp), public, dimension(3,3), save :: Hmat, HmatInv
92    logical, public, save :: boxIsOrthorhombic
93 <  
93 >
94    public :: SimulationSetup
95    public :: getNlocal
96    public :: setBox
97    public :: getDielect
98    public :: SimUsesPBC
99 <  public :: SimUsesLJ
99 >
100 >  public :: SimUsesDirectionalAtoms
101 >  public :: SimUsesLennardJones
102 >  public :: SimUsesElectrostatics
103    public :: SimUsesCharges
104    public :: SimUsesDipoles
105    public :: SimUsesSticky
106 <  public :: SimUsesRF
107 <  public :: SimUsesGB
106 >  public :: SimUsesStickyPower
107 >  public :: SimUsesGayBerne
108    public :: SimUsesEAM
109 +  public :: SimUsesShapes
110 +  public :: SimUsesFLARB
111 +  public :: SimUsesRF
112 +  public :: SimUsesSF
113    public :: SimRequiresPrepairCalc
114    public :: SimRequiresPostpairCalc
115 <  public :: SimUsesDirectionalAtoms
116 <  
115 >  public :: SimHasAtype
116 >  public :: SimUsesSC
117 >  public :: SimUsesMEAM
118 >
119   contains
120 <  
120 >
121    subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
122         CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
123         CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
# Line 134 | Line 190 | contains
190      nGroupsInRow = getNgroupsInRow(plan_group_row)
191      nGroupsInCol = getNgroupsInCol(plan_group_col)
192      mynode = getMyNode()
193 <    
193 >
194      allocate(c_idents_Row(nAtomsInRow),stat=alloc_stat)
195      if (alloc_stat /= 0 ) then
196         status = -1
# Line 167 | Line 223 | contains
223      if (allocated(c_idents_Row)) then
224         deallocate(c_idents_Row)
225      endif
226 <  
226 >
227   #endif
228  
229   #ifdef IS_MPI
# Line 206 | Line 262 | contains
262         status = -1
263         return
264      endif
265 <    
265 >
266      glPointer = 1
267  
268      do i = 1, nGroupsInRow
# Line 245 | Line 301 | contains
301  
302      call gather(mfactLocal,      mfactRow,      plan_atom_row)
303      call gather(mfactLocal,      mfactCol,      plan_atom_col)
304 <    
304 >
305      if (allocated(mfactLocal)) then
306         deallocate(mfactLocal)
307      end if
# Line 305 | Line 361 | contains
361         mfactRow(i) = Cmfact(i)
362         mfactCol(i) = Cmfact(i)
363      end do
364 <    
364 >
365   #endif
366  
367  
368 < ! We build the local atid's for both mpi and nonmpi
368 >    ! We build the local atid's for both mpi and nonmpi
369      do i = 1, nLocal
370 <      
370 >
371         me = getFirstMatchingElement(atypes, "c_ident", c_idents(i))
372         atid(i) = me
373 <  
373 >
374      enddo
375  
376      do i = 1, nExcludes_Local
# Line 337 | Line 393 | contains
393   #ifdef IS_MPI
394      do j = 1, nAtomsInRow
395   #else
396 <    do j = 1, nLocal
396 >       do j = 1, nLocal
397   #endif
398 <       nSkipsForAtom(j) = 0
398 >          nSkipsForAtom(j) = 0
399   #ifdef IS_MPI
400 <       id1 = AtomRowToGlobal(j)
400 >          id1 = AtomRowToGlobal(j)
401   #else
402 <       id1 = j
402 >          id1 = j
403   #endif
404 <       do i = 1, nExcludes_Local
405 <          if (excludesLocal(1,i) .eq. id1 ) then
406 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
404 >          do i = 1, nExcludes_Local
405 >             if (excludesLocal(1,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 <          if (excludesLocal(2,i) .eq. id1 ) then
357 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
412 >             if (excludesLocal(2,i) .eq. id1 ) then
413 >                nSkipsForAtom(j) = nSkipsForAtom(j) + 1
414  
415 <             if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
416 <                maxSkipsForAtom = nSkipsForAtom(j)
415 >                if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
416 >                   maxSkipsForAtom = nSkipsForAtom(j)
417 >                endif
418               endif
419 <          endif
420 <       end do
364 <    enddo
419 >          end do
420 >       enddo
421  
422   #ifdef IS_MPI
423 <    allocate(skipsForAtom(nAtomsInRow, maxSkipsForAtom), stat=alloc_stat)
423 >       allocate(skipsForAtom(nAtomsInRow, maxSkipsForAtom), stat=alloc_stat)
424   #else
425 <    allocate(skipsForAtom(nLocal, maxSkipsForAtom), stat=alloc_stat)
425 >       allocate(skipsForAtom(nLocal, maxSkipsForAtom), stat=alloc_stat)
426   #endif
427 <    if (alloc_stat /= 0 ) then
428 <       write(*,*) 'Could not allocate skipsForAtom array'
429 <       return
430 <    endif
427 >       if (alloc_stat /= 0 ) then
428 >          write(*,*) 'Could not allocate skipsForAtom array'
429 >          return
430 >       endif
431  
432   #ifdef IS_MPI
433 <    do j = 1, nAtomsInRow
433 >       do j = 1, nAtomsInRow
434   #else
435 <    do j = 1, nLocal
435 >          do j = 1, nLocal
436   #endif
437 <       nSkipsForAtom(j) = 0
437 >             nSkipsForAtom(j) = 0
438   #ifdef IS_MPI
439 <       id1 = AtomRowToGlobal(j)
439 >             id1 = AtomRowToGlobal(j)
440   #else
441 <       id1 = j
441 >             id1 = j
442   #endif
443 <       do i = 1, nExcludes_Local
444 <          if (excludesLocal(1,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(2,i)
449 <             skipsForAtom(j, nSkipsForAtom(j)) = id2
450 <          endif
451 <          if (excludesLocal(2, i) .eq. id1 ) then
452 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
453 <             ! exclude lists have global ID's so this line is
454 <             ! the same in MPI and non-MPI
455 <             id2 = excludesLocal(1,i)
456 <             skipsForAtom(j, nSkipsForAtom(j)) = id2
457 <          endif
458 <       end do
459 <    enddo
404 <    
405 <    do i = 1, nExcludes_Global
406 <       excludesGlobal(i) = CexcludesGlobal(i)
407 <    enddo
443 >             do i = 1, nExcludes_Local
444 >                if (excludesLocal(1,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(2,i)
449 >                   skipsForAtom(j, nSkipsForAtom(j)) = id2
450 >                endif
451 >                if (excludesLocal(2, i) .eq. id1 ) then
452 >                   nSkipsForAtom(j) = nSkipsForAtom(j) + 1
453 >                   ! exclude lists have global ID's so this line is
454 >                   ! the same in MPI and non-MPI
455 >                   id2 = excludesLocal(1,i)
456 >                   skipsForAtom(j, nSkipsForAtom(j)) = id2
457 >                endif
458 >             end do
459 >          enddo
460  
461 <    do i = 1, nGlobal
462 <       molMemberShipList(i) = CmolMembership(i)
463 <    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
461 >          do i = 1, nExcludes_Global
462 >             excludesGlobal(i) = CexcludesGlobal(i)
463 >          enddo
464  
465 <  function getDielect() result(dielect)
466 <    real( kind = dp ) :: dielect
467 <    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
465 >          do i = 1, nGlobal
466 >             molMemberShipList(i) = CmolMembership(i)
467 >          enddo
468  
469 <  function SimUsesLJ() result(doesit)
470 <    logical :: doesit
471 <    doesit = thisSim%SIM_uses_LJ
472 <  end function SimUsesLJ
469 >         call createSimHasAtype(alloc_stat)
470 >         if (alloc_stat /= 0) then
471 >            status = -1
472 >         end if
473 >        
474 >         if (status == 0) simulation_setup_complete = .true.
475  
476 <  function SimUsesSticky() result(doesit)
449 <    logical :: doesit
450 <    doesit = thisSim%SIM_uses_sticky
451 <  end function SimUsesSticky
476 >        end subroutine SimulationSetup
477  
478 <  function SimUsesCharges() result(doesit)
479 <    logical :: doesit
480 <    doesit = thisSim%SIM_uses_charges
481 <  end function SimUsesCharges
478 >        subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
479 >          real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
480 >          integer :: cBoxIsOrthorhombic
481 >          integer :: smallest, status, i
482  
483 <  function SimUsesDipoles() result(doesit)
484 <    logical :: doesit
485 <    doesit = thisSim%SIM_uses_dipoles
486 <  end function SimUsesDipoles
483 >          Hmat = cHmat
484 >          HmatInv = cHmatInv
485 >          if (cBoxIsOrthorhombic .eq. 0 ) then
486 >             boxIsOrthorhombic = .false.
487 >          else
488 >             boxIsOrthorhombic = .true.
489 >          endif
490  
491 <  function SimUsesRF() result(doesit)
492 <    logical :: doesit
465 <    doesit = thisSim%SIM_uses_RF
466 <  end function SimUsesRF
491 >          return    
492 >        end subroutine setBox
493  
494 <  function SimUsesGB() result(doesit)
495 <    logical :: doesit
496 <    doesit = thisSim%SIM_uses_GB
497 <  end function SimUsesGB
494 >        function getDielect() result(dielect)
495 >          real( kind = dp ) :: dielect
496 >          dielect = thisSim%dielect
497 >        end function getDielect
498  
499 <  function SimUsesEAM() result(doesit)
500 <    logical :: doesit
501 <    doesit = thisSim%SIM_uses_EAM
502 <  end function SimUsesEAM
499 >        function SimUsesPBC() result(doesit)
500 >          logical :: doesit
501 >          doesit = thisSim%SIM_uses_PBC
502 >        end function SimUsesPBC
503  
504 <  function SimUsesDirectionalAtoms() result(doesit)
505 <    logical :: doesit
506 <    doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_sticky .or. &
507 <         thisSim%SIM_uses_GB .or. thisSim%SIM_uses_RF
508 <  end function SimUsesDirectionalAtoms
504 >        function SimUsesDirectionalAtoms() result(doesit)
505 >          logical :: doesit
506 >          doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_Sticky .or. &
507 >               thisSim%SIM_uses_StickyPower .or. &
508 >               thisSim%SIM_uses_GayBerne .or. thisSim%SIM_uses_Shapes
509 >        end function SimUsesDirectionalAtoms
510  
511 <  function SimRequiresPrepairCalc() result(doesit)
512 <    logical :: doesit
513 <    doesit = thisSim%SIM_uses_EAM
514 <  end function SimRequiresPrepairCalc
511 >        function SimUsesLennardJones() result(doesit)
512 >          logical :: doesit
513 >          doesit = thisSim%SIM_uses_LennardJones
514 >        end function SimUsesLennardJones
515  
516 <  function SimRequiresPostpairCalc() result(doesit)
517 <    logical :: doesit
518 <    doesit = thisSim%SIM_uses_RF
519 <  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
516 >        function SimUsesElectrostatics() result(doesit)
517 >          logical :: doesit
518 >          doesit = thisSim%SIM_uses_Electrostatics
519 >        end function SimUsesElectrostatics
520  
521 <    allocate(molMembershipList(nGlobal), stat=alloc_stat)
522 <    if (alloc_stat /= 0 ) then
523 <       thisStat = -1
524 <       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.
521 >        function SimUsesCharges() result(doesit)
522 >          logical :: doesit
523 >          doesit = thisSim%SIM_uses_Charges
524 >        end function SimUsesCharges
525  
526 <    if (allocated(skipsForAtom)) deallocate(skipsForAtom)
527 <    if (allocated(nSkipsForAtom)) deallocate(nSkipsForAtom)
528 <    if (allocated(mfactLocal)) deallocate(mfactLocal)
529 <    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
526 >        function SimUsesDipoles() result(doesit)
527 >          logical :: doesit
528 >          doesit = thisSim%SIM_uses_Dipoles
529 >        end function SimUsesDipoles
530  
531 +        function SimUsesSticky() result(doesit)
532 +          logical :: doesit
533 +          doesit = thisSim%SIM_uses_Sticky
534 +        end function SimUsesSticky
535  
536 < subroutine setFortranSim(setThisSim, CnGlobal, CnLocal, c_idents, &
537 <       CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
538 <       CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
539 <       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
536 >        function SimUsesStickyPower() result(doesit)
537 >          logical :: doesit
538 >          doesit = thisSim%SIM_uses_StickyPower
539 >        end function SimUsesStickyPower
540  
541 <    integer :: CnLocalExcludes
542 <    integer, dimension(2,CnLocalExcludes), intent(inout) :: CexcludesLocal
543 <    integer :: CnGlobalExcludes
544 <    integer, dimension(CnGlobalExcludes), intent(inout) :: CexcludesGlobal
545 <    integer, dimension(CnGlobal),intent(inout) :: CmolMembership
546 <    !!  Result status, success = 0, status = -1
547 <    integer, intent(inout) :: status
548 <    
549 <    !! mass factors used for molecular cutoffs
550 <    real ( kind = dp ), dimension(CnLocal) :: Cmfact
551 <    integer, intent(in):: CnGroups
552 <    integer, dimension(CnGlobal), intent(inout):: CglobalGroupMembership
553 <    
554 <    call SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
555 <       CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
556 <       CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
557 <       status)
558 < end subroutine setFortranSim
559 <
560 < subroutine setFortranBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
561 <    use simulation, only : setBox
562 <    use definitions, ONLY : dp
563 <    real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
564 <    integer :: cBoxIsOrthorhombic
565 <  
566 <   call setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
567 <    
568 < end subroutine setFortranBox
541 >        function SimUsesGayBerne() result(doesit)
542 >          logical :: doesit
543 >          doesit = thisSim%SIM_uses_GayBerne
544 >        end function SimUsesGayBerne
545 >
546 >        function SimUsesEAM() result(doesit)
547 >          logical :: doesit
548 >          doesit = thisSim%SIM_uses_EAM
549 >        end function SimUsesEAM
550 >
551 >
552 >        function SimUsesSC() result(doesit)
553 >          logical :: doesit
554 >          doesit = thisSim%SIM_uses_SC
555 >        end function SimUsesSC
556 >
557 >        function SimUsesMEAM() result(doesit)
558 >          logical :: doesit
559 >          doesit = thisSim%SIM_uses_MEAM
560 >        end function SimUsesMEAM
561 >
562 >
563 >        function SimUsesShapes() result(doesit)
564 >          logical :: doesit
565 >          doesit = thisSim%SIM_uses_Shapes
566 >        end function SimUsesShapes
567 >
568 >        function SimUsesFLARB() result(doesit)
569 >          logical :: doesit
570 >          doesit = thisSim%SIM_uses_FLARB
571 >        end function SimUsesFLARB
572 >
573 >        function SimUsesRF() result(doesit)
574 >          logical :: doesit
575 >          doesit = thisSim%SIM_uses_RF
576 >        end function SimUsesRF
577 >
578 >        function SimUsesSF() result(doesit)
579 >          logical :: doesit
580 >          doesit = thisSim%SIM_uses_SF
581 >        end function SimUsesSF
582 >
583 >        function SimRequiresPrepairCalc() result(doesit)
584 >          logical :: doesit
585 >          doesit = thisSim%SIM_uses_EAM .or. thisSim%SIM_uses_SC &
586 >               .or. thisSim%SIM_uses_MEAM
587 >        end function SimRequiresPrepairCalc
588 >        
589 >        function SimRequiresPostpairCalc() result(doesit)
590 >          logical :: doesit
591 >          doesit = thisSim%SIM_uses_RF .or. thisSim%SIM_uses_SF
592 >        end function SimRequiresPostpairCalc
593 >
594 >        ! Function returns true if the simulation has this atype
595 >        function SimHasAtype(thisAtype) result(doesit)
596 >          logical :: doesit
597 >          integer :: thisAtype
598 >          doesit = .false.
599 >          if(.not.allocated(SimHasAtypeMap)) return
600 >
601 >          doesit = SimHasAtypeMap(thisAtype)
602 >            
603 >        end function SimHasAtype
604 >
605 >        subroutine createSimHasAtype(status)
606 >          integer, intent(out) :: status
607 >          integer :: alloc_stat
608 >          integer :: me_i
609 >          integer :: mpiErrors
610 >          integer :: nAtypes
611 >          status = 0
612 >
613 >          nAtypes = getSize(atypes)
614 >          ! Setup logical map for atypes in simulation
615 >          if (.not.allocated(SimHasAtypeMap)) then
616 >             allocate(SimHasAtypeMap(nAtypes),stat=alloc_stat)
617 >             if (alloc_stat /= 0 ) then
618 >                status = -1
619 >                return
620 >             end if
621 >             SimHasAtypeMap = .false.
622 >          end if
623 >          
624 >          ! Loop through the local atoms and grab the atypes present        
625 >          do me_i = 1,nLocal
626 >             SimHasAtypeMap(atid(me_i)) = .true.
627 >          end do
628 >          ! For MPI, we need to know all possible atypes present in
629 >          ! simulation on all processors. Use LOR operation to set map.
630 > #ifdef IS_MPI
631 >          if (.not.allocated(SimHasAtypeMapTemp)) then
632 >             allocate(SimHasAtypeMapTemp(nAtypes),stat=alloc_stat)
633 >             if (alloc_stat /= 0 ) then
634 >                status = -1
635 >                return
636 >             end if
637 >          end if
638 >          call mpi_allreduce(SimHasAtypeMap, SimHasAtypeMaptemp, nAtypes, &
639 >               mpi_logical, MPI_LOR, mpi_comm_world, mpiErrors)
640 >          simHasAtypeMap = simHasAtypeMapTemp
641 >          deallocate(simHasAtypeMapTemp)
642 > #endif          
643 >        end subroutine createSimHasAtype
644 >        
645 >       subroutine InitializeSimGlobals(thisStat)
646 >          integer, intent(out) :: thisStat
647 >          integer :: alloc_stat
648 >
649 >          thisStat = 0
650 >
651 >          call FreeSimGlobals()    
652 >
653 >          allocate(excludesLocal(2,nExcludes_Local), stat=alloc_stat)
654 >          if (alloc_stat /= 0 ) then
655 >             thisStat = -1
656 >             return
657 >          endif
658 >
659 >          allocate(excludesGlobal(nExcludes_Global), stat=alloc_stat)
660 >          if (alloc_stat /= 0 ) then
661 >             thisStat = -1
662 >             return
663 >          endif
664 >
665 >          allocate(molMembershipList(nGlobal), stat=alloc_stat)
666 >          if (alloc_stat /= 0 ) then
667 >             thisStat = -1
668 >             return
669 >          endif
670 >
671 >        end subroutine InitializeSimGlobals
672 >
673 >        subroutine FreeSimGlobals()
674 >
675 >          !We free in the opposite order in which we allocate in.
676 >
677 >          if (allocated(skipsForAtom)) deallocate(skipsForAtom)
678 >          if (allocated(nSkipsForAtom)) deallocate(nSkipsForAtom)
679 >          if (allocated(mfactLocal)) deallocate(mfactLocal)
680 >          if (allocated(mfactCol)) deallocate(mfactCol)
681 >          if (allocated(mfactRow)) deallocate(mfactRow)
682 >          if (allocated(groupListCol)) deallocate(groupListCol)    
683 >          if (allocated(groupListRow)) deallocate(groupListRow)    
684 >          if (allocated(groupStartCol)) deallocate(groupStartCol)
685 >          if (allocated(groupStartRow)) deallocate(groupStartRow)    
686 >          if (allocated(molMembershipList)) deallocate(molMembershipList)    
687 >          if (allocated(excludesGlobal)) deallocate(excludesGlobal)
688 >          if (allocated(excludesLocal)) deallocate(excludesLocal)
689 >
690 >        end subroutine FreeSimGlobals
691 >
692 >        pure function getNlocal() result(n)
693 >          integer :: n
694 >          n = nLocal
695 >        end function getNlocal
696 >
697 >
698 >
699 >
700 >
701 >      end module simulation

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines