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 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC vs.
Revision 2220 by chrisfen, Thu May 5 14:47:35 2005 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines