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 1608 by gezelter, Wed Oct 20 04:02:48 2004 UTC vs.
Revision 2262 by chuckv, Sun Jul 3 20:53:43 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 41 | Line 82 | module simulation
82    real(kind=dp), allocatable, dimension(:), public :: mfactCol
83    real(kind=dp), allocatable, dimension(:), public :: mfactLocal
84  
85 +  logical, allocatable, dimension(:) :: simHasAtypeMap
86    real(kind=dp), public, dimension(3,3), save :: Hmat, HmatInv
87    logical, public, save :: boxIsOrthorhombic
88 <  
88 >
89    public :: SimulationSetup
90    public :: getNlocal
91    public :: setBox
92    public :: getDielect
93    public :: SimUsesPBC
94 <  public :: SimUsesLJ
94 >
95 >  public :: SimUsesDirectionalAtoms
96 >  public :: SimUsesLennardJones
97 >  public :: SimUsesElectrostatics
98    public :: SimUsesCharges
99    public :: SimUsesDipoles
100    public :: SimUsesSticky
101 <  public :: SimUsesRF
102 <  public :: SimUsesGB
101 >  public :: SimUsesStickyPower
102 >  public :: SimUsesGayBerne
103    public :: SimUsesEAM
104 +  public :: SimUsesShapes
105 +  public :: SimUsesFLARB
106 +  public :: SimUsesRF
107    public :: SimRequiresPrepairCalc
108    public :: SimRequiresPostpairCalc
109 <  public :: SimUsesDirectionalAtoms
110 <  
109 >  public :: SimHasAtype
110 >
111   contains
112 <  
112 >
113    subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
114         CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
115         CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
# Line 134 | Line 182 | contains
182      nGroupsInRow = getNgroupsInRow(plan_group_row)
183      nGroupsInCol = getNgroupsInCol(plan_group_col)
184      mynode = getMyNode()
185 <    
185 >
186      allocate(c_idents_Row(nAtomsInRow),stat=alloc_stat)
187      if (alloc_stat /= 0 ) then
188         status = -1
# Line 167 | Line 215 | contains
215      if (allocated(c_idents_Row)) then
216         deallocate(c_idents_Row)
217      endif
218 <  
218 >
219   #endif
220  
221   #ifdef IS_MPI
# Line 206 | Line 254 | contains
254         status = -1
255         return
256      endif
257 <    
257 >
258      glPointer = 1
259  
260      do i = 1, nGroupsInRow
# Line 245 | Line 293 | contains
293  
294      call gather(mfactLocal,      mfactRow,      plan_atom_row)
295      call gather(mfactLocal,      mfactCol,      plan_atom_col)
296 <    
296 >
297      if (allocated(mfactLocal)) then
298         deallocate(mfactLocal)
299      end if
# Line 305 | Line 353 | contains
353         mfactRow(i) = Cmfact(i)
354         mfactCol(i) = Cmfact(i)
355      end do
356 <    
356 >
357   #endif
358  
359  
360 < ! We build the local atid's for both mpi and nonmpi
360 >    ! We build the local atid's for both mpi and nonmpi
361      do i = 1, nLocal
362 <      
362 >
363         me = getFirstMatchingElement(atypes, "c_ident", c_idents(i))
364         atid(i) = me
365 <  
365 >
366      enddo
367  
368      do i = 1, nExcludes_Local
# Line 337 | Line 385 | contains
385   #ifdef IS_MPI
386      do j = 1, nAtomsInRow
387   #else
388 <    do j = 1, nLocal
388 >       do j = 1, nLocal
389   #endif
390 <       nSkipsForAtom(j) = 0
390 >          nSkipsForAtom(j) = 0
391   #ifdef IS_MPI
392 <       id1 = AtomRowToGlobal(j)
393 < #else
394 <       id1 = j
392 >          id1 = AtomRowToGlobal(j)
393 > #else
394 >          id1 = j
395   #endif
396 <       do i = 1, nExcludes_Local
397 <          if (excludesLocal(1,i) .eq. id1 ) then
398 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
396 >          do i = 1, nExcludes_Local
397 >             if (excludesLocal(1,i) .eq. id1 ) then
398 >                nSkipsForAtom(j) = nSkipsForAtom(j) + 1
399  
400 <             if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
401 <                maxSkipsForAtom = nSkipsForAtom(j)
400 >                if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
401 >                   maxSkipsForAtom = nSkipsForAtom(j)
402 >                endif
403               endif
404 <          endif
405 <          if (excludesLocal(2,i) .eq. id1 ) then
357 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
404 >             if (excludesLocal(2,i) .eq. id1 ) then
405 >                nSkipsForAtom(j) = nSkipsForAtom(j) + 1
406  
407 <             if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
408 <                maxSkipsForAtom = nSkipsForAtom(j)
407 >                if (nSkipsForAtom(j) .gt. maxSkipsForAtom) then
408 >                   maxSkipsForAtom = nSkipsForAtom(j)
409 >                endif
410               endif
411 <          endif
412 <       end do
364 <    enddo
411 >          end do
412 >       enddo
413  
414   #ifdef IS_MPI
415 <    allocate(skipsForAtom(nAtomsInRow, maxSkipsForAtom), stat=alloc_stat)
415 >       allocate(skipsForAtom(nAtomsInRow, maxSkipsForAtom), stat=alloc_stat)
416   #else
417 <    allocate(skipsForAtom(nLocal, maxSkipsForAtom), stat=alloc_stat)
417 >       allocate(skipsForAtom(nLocal, maxSkipsForAtom), stat=alloc_stat)
418   #endif
419 <    if (alloc_stat /= 0 ) then
420 <       write(*,*) 'Could not allocate skipsForAtom array'
421 <       return
422 <    endif
419 >       if (alloc_stat /= 0 ) then
420 >          write(*,*) 'Could not allocate skipsForAtom array'
421 >          return
422 >       endif
423  
424   #ifdef IS_MPI
425 <    do j = 1, nAtomsInRow
425 >       do j = 1, nAtomsInRow
426   #else
427 <    do j = 1, nLocal
427 >          do j = 1, nLocal
428   #endif
429 <       nSkipsForAtom(j) = 0
429 >             nSkipsForAtom(j) = 0
430   #ifdef IS_MPI
431 <       id1 = AtomRowToGlobal(j)
431 >             id1 = AtomRowToGlobal(j)
432   #else
433 <       id1 = j
433 >             id1 = j
434   #endif
435 <       do i = 1, nExcludes_Local
436 <          if (excludesLocal(1,i) .eq. id1 ) then
437 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
438 <             ! exclude lists have global ID's so this line is
439 <             ! the same in MPI and non-MPI
440 <             id2 = excludesLocal(2,i)
441 <             skipsForAtom(j, nSkipsForAtom(j)) = id2
442 <          endif
443 <          if (excludesLocal(2, i) .eq. id1 ) then
444 <             nSkipsForAtom(j) = nSkipsForAtom(j) + 1
445 <             ! exclude lists have global ID's so this line is
446 <             ! the same in MPI and non-MPI
447 <             id2 = excludesLocal(1,i)
448 <             skipsForAtom(j, nSkipsForAtom(j)) = id2
449 <          endif
450 <       end do
451 <    enddo
404 <    
405 <    do i = 1, nExcludes_Global
406 <       excludesGlobal(i) = CexcludesGlobal(i)
407 <    enddo
435 >             do i = 1, nExcludes_Local
436 >                if (excludesLocal(1,i) .eq. id1 ) then
437 >                   nSkipsForAtom(j) = nSkipsForAtom(j) + 1
438 >                   ! exclude lists have global ID's so this line is
439 >                   ! the same in MPI and non-MPI
440 >                   id2 = excludesLocal(2,i)
441 >                   skipsForAtom(j, nSkipsForAtom(j)) = id2
442 >                endif
443 >                if (excludesLocal(2, i) .eq. id1 ) then
444 >                   nSkipsForAtom(j) = nSkipsForAtom(j) + 1
445 >                   ! exclude lists have global ID's so this line is
446 >                   ! the same in MPI and non-MPI
447 >                   id2 = excludesLocal(1,i)
448 >                   skipsForAtom(j, nSkipsForAtom(j)) = id2
449 >                endif
450 >             end do
451 >          enddo
452  
453 <    do i = 1, nGlobal
454 <       molMemberShipList(i) = CmolMembership(i)
455 <    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
453 >          do i = 1, nExcludes_Global
454 >             excludesGlobal(i) = CexcludesGlobal(i)
455 >          enddo
456  
457 <  function getDielect() result(dielect)
458 <    real( kind = dp ) :: dielect
459 <    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
457 >          do i = 1, nGlobal
458 >             molMemberShipList(i) = CmolMembership(i)
459 >          enddo
460  
461 <  function SimUsesLJ() result(doesit)
462 <    logical :: doesit
463 <    doesit = thisSim%SIM_uses_LJ
464 <  end function SimUsesLJ
461 >         call createSimHasAtype(alloc_stat)
462 >         if (alloc_stat /= 0) then
463 >            status = -1
464 >         end if
465 >        
466 >         if (status == 0) simulation_setup_complete = .true.
467  
468 <  function SimUsesSticky() result(doesit)
449 <    logical :: doesit
450 <    doesit = thisSim%SIM_uses_sticky
451 <  end function SimUsesSticky
468 >        end subroutine SimulationSetup
469  
470 <  function SimUsesCharges() result(doesit)
471 <    logical :: doesit
472 <    doesit = thisSim%SIM_uses_charges
473 <  end function SimUsesCharges
470 >        subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
471 >          real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
472 >          integer :: cBoxIsOrthorhombic
473 >          integer :: smallest, status, i
474  
475 <  function SimUsesDipoles() result(doesit)
476 <    logical :: doesit
477 <    doesit = thisSim%SIM_uses_dipoles
478 <  end function SimUsesDipoles
475 >          Hmat = cHmat
476 >          HmatInv = cHmatInv
477 >          if (cBoxIsOrthorhombic .eq. 0 ) then
478 >             boxIsOrthorhombic = .false.
479 >          else
480 >             boxIsOrthorhombic = .true.
481 >          endif
482  
483 <  function SimUsesRF() result(doesit)
484 <    logical :: doesit
465 <    doesit = thisSim%SIM_uses_RF
466 <  end function SimUsesRF
483 >          return    
484 >        end subroutine setBox
485  
486 <  function SimUsesGB() result(doesit)
487 <    logical :: doesit
488 <    doesit = thisSim%SIM_uses_GB
489 <  end function SimUsesGB
486 >        function getDielect() result(dielect)
487 >          real( kind = dp ) :: dielect
488 >          dielect = thisSim%dielect
489 >        end function getDielect
490  
491 <  function SimUsesEAM() result(doesit)
492 <    logical :: doesit
493 <    doesit = thisSim%SIM_uses_EAM
494 <  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
491 >        function SimUsesPBC() result(doesit)
492 >          logical :: doesit
493 >          doesit = thisSim%SIM_uses_PBC
494 >        end function SimUsesPBC
495  
496 <  function SimRequiresPrepairCalc() result(doesit)
497 <    logical :: doesit
498 <    doesit = thisSim%SIM_uses_EAM
499 <  end function SimRequiresPrepairCalc
496 >        function SimUsesDirectionalAtoms() result(doesit)
497 >          logical :: doesit
498 >          doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_Sticky .or. &
499 >               thisSim%SIM_uses_StickyPower .or. &
500 >               thisSim%SIM_uses_GayBerne .or. thisSim%SIM_uses_Shapes
501 >        end function SimUsesDirectionalAtoms
502  
503 <  function SimRequiresPostpairCalc() result(doesit)
504 <    logical :: doesit
505 <    doesit = thisSim%SIM_uses_RF
506 <  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
503 >        function SimUsesLennardJones() result(doesit)
504 >          logical :: doesit
505 >          doesit = thisSim%SIM_uses_LennardJones
506 >        end function SimUsesLennardJones
507  
508 <    allocate(molMembershipList(nGlobal), stat=alloc_stat)
509 <    if (alloc_stat /= 0 ) then
510 <       thisStat = -1
511 <       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.
508 >        function SimUsesElectrostatics() result(doesit)
509 >          logical :: doesit
510 >          doesit = thisSim%SIM_uses_Electrostatics
511 >        end function SimUsesElectrostatics
512  
513 <    if (allocated(skipsForAtom)) deallocate(skipsForAtom)
514 <    if (allocated(nSkipsForAtom)) deallocate(nSkipsForAtom)
515 <    if (allocated(mfactLocal)) deallocate(mfactLocal)
516 <    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
513 >        function SimUsesCharges() result(doesit)
514 >          logical :: doesit
515 >          doesit = thisSim%SIM_uses_Charges
516 >        end function SimUsesCharges
517  
518 +        function SimUsesDipoles() result(doesit)
519 +          logical :: doesit
520 +          doesit = thisSim%SIM_uses_Dipoles
521 +        end function SimUsesDipoles
522  
523 < subroutine setFortranSim(setThisSim, CnGlobal, CnLocal, c_idents, &
524 <       CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
525 <       CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
526 <       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
523 >        function SimUsesSticky() result(doesit)
524 >          logical :: doesit
525 >          doesit = thisSim%SIM_uses_Sticky
526 >        end function SimUsesSticky
527  
528 <    integer :: CnLocalExcludes
529 <    integer, dimension(2,CnLocalExcludes), intent(inout) :: CexcludesLocal
530 <    integer :: CnGlobalExcludes
531 <    integer, dimension(CnGlobalExcludes), intent(inout) :: CexcludesGlobal
532 <    integer, dimension(CnGlobal),intent(inout) :: CmolMembership
533 <    !!  Result status, success = 0, status = -1
534 <    integer, intent(inout) :: status
535 <    
536 <    !! mass factors used for molecular cutoffs
537 <    real ( kind = dp ), dimension(CnLocal) :: Cmfact
538 <    integer, intent(in):: CnGroups
539 <    integer, dimension(CnGlobal), intent(inout):: CglobalGroupMembership
540 <    integer :: status
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
528 >        function SimUsesStickyPower() result(doesit)
529 >          logical :: doesit
530 >          doesit = thisSim%SIM_uses_StickyPower
531 >        end function SimUsesStickyPower
532 >
533 >        function SimUsesGayBerne() result(doesit)
534 >          logical :: doesit
535 >          doesit = thisSim%SIM_uses_GayBerne
536 >        end function SimUsesGayBerne
537 >
538 >        function SimUsesEAM() result(doesit)
539 >          logical :: doesit
540 >          doesit = thisSim%SIM_uses_EAM
541 >        end function SimUsesEAM
542 >
543 >        function SimUsesShapes() result(doesit)
544 >          logical :: doesit
545 >          doesit = thisSim%SIM_uses_Shapes
546 >        end function SimUsesShapes
547 >
548 >        function SimUsesFLARB() result(doesit)
549 >          logical :: doesit
550 >          doesit = thisSim%SIM_uses_FLARB
551 >        end function SimUsesFLARB
552 >
553 >        function SimUsesRF() result(doesit)
554 >          logical :: doesit
555 >          doesit = thisSim%SIM_uses_RF
556 >        end function SimUsesRF
557 >
558 >        function SimRequiresPrepairCalc() result(doesit)
559 >          logical :: doesit
560 >          doesit = thisSim%SIM_uses_EAM
561 >        end function SimRequiresPrepairCalc
562 >
563 >        function SimRequiresPostpairCalc() result(doesit)
564 >          logical :: doesit
565 >          doesit = thisSim%SIM_uses_RF
566 >        end function SimRequiresPostpairCalc
567 >
568 > ! Function returns true if the simulation has this atype
569 >        function SimHasAtype(thisAtype) result(doesit)
570 >          logical :: doesit
571 >          integer :: thisAtype
572 >          doesit = .false.
573 >          if(.not.allocated(SimHasAtypeMap)) return
574 >
575 >          doesit = SimHasAtypeMap(thisAtype)
576 >            
577 >        end function SimHasAtype
578 >
579 >        subroutine createSimHasAtype(status)
580 >          integer, intent(out) :: status
581 >          integer :: alloc_stat
582 >          integer :: me_i
583 >          integer :: mpiErrors
584 >          integer :: nAtypes
585 >          status = 0
586 >
587 >          nAtypes = getSize(atypes)
588 >          ! Setup logical map for atypes in simulation
589 >          if (.not.allocated(SimHasAtypeMap)) then
590 >             allocate(SimHasAtypeMap(nAtypes),stat=alloc_stat)
591 >             if (alloc_stat /= 0 ) then
592 >                status = -1
593 >                return
594 >             end if
595 >             SimHasAtypeMap = .false.
596 >          end if
597 > ! Loop through the local atoms and grab the atypes present        
598 >          do me_i = 1,nLocal
599 >             SimHasAtypeMap(atid(me_i)) = .true.
600 >          end do
601 > ! For MPI, we need to know all possible atypes present in simulation on all
602 > ! processors. Use LOR operation to set map.
603 > #ifdef IS_MPI
604 >          call mpi_allreduce(SimHasAtypeMap, SimHasAtypeMap, nAtypes, mpi_logical, &
605 >               MPI_LOR, mpi_comm_world, mpiErrors)
606 > #endif
607 >
608 >        end subroutine createSimHasAtype
609  
610 < subroutine setFortranBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
611 <    use simulation, only : setBox
612 <    use definitions, ONLY : dp
613 <    real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
614 <    integer :: cBoxIsOrthorhombic
615 <  
616 <   call setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
617 <    
618 < end subroutine setFortranBox
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