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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines