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 1633 by gezelter, Fri Oct 22 20:22: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
# Line 56 | Line 98 | module simulation
98    public :: SimUsesCharges
99    public :: SimUsesDipoles
100    public :: SimUsesSticky
101 +  public :: SimUsesStickyPower
102    public :: SimUsesGayBerne
103    public :: SimUsesEAM
104    public :: SimUsesShapes
# Line 63 | Line 106 | module simulation
106    public :: SimUsesRF
107    public :: SimRequiresPrepairCalc
108    public :: SimRequiresPostpairCalc
109 +  public :: SimHasAtype
110  
67  
111   contains
112 <  
112 >
113    subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
114         CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
115         CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
# Line 139 | 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 172 | 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 211 | Line 254 | contains
254         status = -1
255         return
256      endif
257 <    
257 >
258      glPointer = 1
259  
260      do i = 1, nGroupsInRow
# Line 250 | 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 310 | 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 342 | 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)
392 >          id1 = AtomRowToGlobal(j)
393   #else
394 <       id1 = j
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
362 <             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
369 <    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
409 <    
410 <    do i = 1, nExcludes_Global
411 <       excludesGlobal(i) = CexcludesGlobal(i)
412 <    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
417 <    
418 <    if (status == 0) simulation_setup_complete = .true.
419 <    
420 <  end subroutine SimulationSetup
421 <  
422 <  subroutine setBox(cHmat, cHmatInv, cBoxIsOrthorhombic)
423 <    real(kind=dp), dimension(3,3) :: cHmat, cHmatInv
424 <    integer :: cBoxIsOrthorhombic
425 <    integer :: smallest, status, i
426 <    
427 <    Hmat = cHmat
428 <    HmatInv = cHmatInv
429 <    if (cBoxIsOrthorhombic .eq. 0 ) then
430 <       boxIsOrthorhombic = .false.
431 <    else
432 <       boxIsOrthorhombic = .true.
433 <    endif
434 <    
435 <    return    
436 <  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
441 <  end function getDielect
442 <      
443 <  function SimUsesPBC() result(doesit)
444 <    logical :: doesit
445 <    doesit = thisSim%SIM_uses_PBC
446 <  end function SimUsesPBC
457 >          do i = 1, nGlobal
458 >             molMemberShipList(i) = CmolMembership(i)
459 >          enddo
460  
461 <  function SimUsesDirectionalAtoms() result(doesit)
462 <    logical :: doesit
463 <    doesit = thisSim%SIM_uses_dipoles .or. thisSim%SIM_uses_sticky .or. &
464 <         thisSim%SIM_uses_GayBerne .or. thisSim%SIM_uses_Shapes
465 <  end function SimUsesDirectionalAtoms
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 SimUsesLennardJones() result(doesit)
455 <    logical :: doesit
456 <    doesit = thisSim%SIM_uses_LennardJones
457 <  end function SimUsesLennardJones
468 >        end subroutine SimulationSetup
469  
470 <  function SimUsesElectrostatics() result(doesit)
471 <    logical :: doesit
472 <    doesit = thisSim%SIM_uses_Electrostatics
473 <  end function SimUsesElectrostatics
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 SimUsesCharges() result(doesit)
476 <    logical :: doesit
477 <    doesit = thisSim%SIM_uses_Charges
478 <  end function SimUsesCharges
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 SimUsesDipoles() result(doesit)
484 <    logical :: doesit
471 <    doesit = thisSim%SIM_uses_Dipoles
472 <  end function SimUsesDipoles
483 >          return    
484 >        end subroutine setBox
485  
486 <  function SimUsesSticky() result(doesit)
487 <    logical :: doesit
488 <    doesit = thisSim%SIM_uses_Sticky
489 <  end function SimUsesSticky
486 >        function getDielect() result(dielect)
487 >          real( kind = dp ) :: dielect
488 >          dielect = thisSim%dielect
489 >        end function getDielect
490  
491 <  function SimUsesGayBerne() result(doesit)
492 <    logical :: doesit
493 <    doesit = thisSim%SIM_uses_GayBerne
494 <  end function SimUsesGayBerne
483 <  
484 <  function SimUsesEAM() result(doesit)
485 <    logical :: doesit
486 <    doesit = thisSim%SIM_uses_EAM
487 <  end function SimUsesEAM
491 >        function SimUsesPBC() result(doesit)
492 >          logical :: doesit
493 >          doesit = thisSim%SIM_uses_PBC
494 >        end function SimUsesPBC
495  
496 <  function SimUsesShapes() result(doesit)
497 <    logical :: doesit
498 <    doesit = thisSim%SIM_uses_Shapes
499 <  end function SimUsesShapes
500 <
501 <  function SimUsesFLARB() result(doesit)
495 <    logical :: doesit
496 <    doesit = thisSim%SIM_uses_FLARB
497 <  end function SimUsesFLARB
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 SimUsesRF() result(doesit)
504 <    logical :: doesit
505 <    doesit = thisSim%SIM_uses_RF
506 <  end function SimUsesRF
503 >        function SimUsesLennardJones() result(doesit)
504 >          logical :: doesit
505 >          doesit = thisSim%SIM_uses_LennardJones
506 >        end function SimUsesLennardJones
507  
508 <  function SimRequiresPrepairCalc() result(doesit)
509 <    logical :: doesit
510 <    doesit = thisSim%SIM_uses_EAM
511 <  end function SimRequiresPrepairCalc
508 >        function SimUsesElectrostatics() result(doesit)
509 >          logical :: doesit
510 >          doesit = thisSim%SIM_uses_Electrostatics
511 >        end function SimUsesElectrostatics
512  
513 <  function SimRequiresPostpairCalc() result(doesit)
514 <    logical :: doesit
515 <    doesit = thisSim%SIM_uses_RF
516 <  end function SimRequiresPostpairCalc
513 <  
514 <  subroutine InitializeSimGlobals(thisStat)
515 <    integer, intent(out) :: thisStat
516 <    integer :: alloc_stat
517 <    
518 <    thisStat = 0
519 <    
520 <    call FreeSimGlobals()    
521 <    
522 <    allocate(excludesLocal(2,nExcludes_Local), stat=alloc_stat)
523 <    if (alloc_stat /= 0 ) then
524 <       thisStat = -1
525 <       return
526 <    endif
527 <    
528 <    allocate(excludesGlobal(nExcludes_Global), stat=alloc_stat)
529 <    if (alloc_stat /= 0 ) then
530 <       thisStat = -1
531 <       return
532 <    endif
513 >        function SimUsesCharges() result(doesit)
514 >          logical :: doesit
515 >          doesit = thisSim%SIM_uses_Charges
516 >        end function SimUsesCharges
517  
518 <    allocate(molMembershipList(nGlobal), stat=alloc_stat)
519 <    if (alloc_stat /= 0 ) then
520 <       thisStat = -1
521 <       return
538 <    endif
539 <    
540 <  end subroutine InitializeSimGlobals
541 <  
542 <  subroutine FreeSimGlobals()
543 <    
544 <    !We free in the opposite order in which we allocate in.
518 >        function SimUsesDipoles() result(doesit)
519 >          logical :: doesit
520 >          doesit = thisSim%SIM_uses_Dipoles
521 >        end function SimUsesDipoles
522  
523 <    if (allocated(skipsForAtom)) deallocate(skipsForAtom)
524 <    if (allocated(nSkipsForAtom)) deallocate(nSkipsForAtom)
525 <    if (allocated(mfactLocal)) deallocate(mfactLocal)
526 <    if (allocated(mfactCol)) deallocate(mfactCol)
550 <    if (allocated(mfactRow)) deallocate(mfactRow)
551 <    if (allocated(groupListCol)) deallocate(groupListCol)    
552 <    if (allocated(groupListRow)) deallocate(groupListRow)    
553 <    if (allocated(groupStartCol)) deallocate(groupStartCol)
554 <    if (allocated(groupStartRow)) deallocate(groupStartRow)    
555 <    if (allocated(molMembershipList)) deallocate(molMembershipList)    
556 <    if (allocated(excludesGlobal)) deallocate(excludesGlobal)
557 <    if (allocated(excludesLocal)) deallocate(excludesLocal)
558 <    
559 <  end subroutine FreeSimGlobals
560 <  
561 <  pure function getNlocal() result(n)
562 <    integer :: n
563 <    n = nLocal
564 <  end function getNlocal
565 <  
566 <  
567 < end module simulation
523 >        function SimUsesSticky() result(doesit)
524 >          logical :: doesit
525 >          doesit = thisSim%SIM_uses_Sticky
526 >        end function SimUsesSticky
527  
528 +        function SimUsesStickyPower() result(doesit)
529 +          logical :: doesit
530 +          doesit = thisSim%SIM_uses_StickyPower
531 +        end function SimUsesStickyPower
532  
533 < subroutine setFortranSim(setThisSim, CnGlobal, CnLocal, c_idents, &
534 <       CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
535 <       CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
536 <       status)
574 <       use definitions, ONLY : dp    
575 <       use simulation
576 <    
577 <    type (simtype) :: setThisSim
578 <    integer, intent(inout) :: CnGlobal, CnLocal
579 <    integer, dimension(CnLocal),intent(inout) :: c_idents
533 >        function SimUsesGayBerne() result(doesit)
534 >          logical :: doesit
535 >          doesit = thisSim%SIM_uses_GayBerne
536 >        end function SimUsesGayBerne
537  
538 <    integer :: CnLocalExcludes
539 <    integer, dimension(2,CnLocalExcludes), intent(inout) :: CexcludesLocal
540 <    integer :: CnGlobalExcludes
541 <    integer, dimension(CnGlobalExcludes), intent(inout) :: CexcludesGlobal
542 <    integer, dimension(CnGlobal),intent(inout) :: CmolMembership
543 <    !!  Result status, success = 0, status = -1
544 <    integer, intent(inout) :: status
545 <    
546 <    !! mass factors used for molecular cutoffs
547 <    real ( kind = dp ), dimension(CnLocal) :: Cmfact
548 <    integer, intent(in):: CnGroups
549 <    integer, dimension(CnGlobal), intent(inout):: CglobalGroupMembership
550 <    
551 <    call SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
552 <       CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
553 <       CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
554 <       status)
555 < end subroutine setFortranSim
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