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 1948 by gezelter, Fri Jan 14 20:31:16 2005 UTC vs.
Revision 2204 by gezelter, Fri Apr 15 22:04:00 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 105 | Line 105 | module simulation
105    public :: SimRequiresPrepairCalc
106    public :: SimRequiresPostpairCalc
107  
108 <  
108 >
109   contains
110 <  
110 >
111    subroutine SimulationSetup(setThisSim, CnGlobal, CnLocal, c_idents, &
112         CnLocalExcludes, CexcludesLocal, CnGlobalExcludes, CexcludesGlobal, &
113         CmolMembership, Cmfact, CnGroups, CglobalGroupMembership, &
# Line 180 | 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 213 | 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 252 | Line 252 | contains
252         status = -1
253         return
254      endif
255 <    
255 >
256      glPointer = 1
257  
258      do i = 1, nGroupsInRow
# Line 291 | 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 351 | 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 383 | 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
403 <             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
410 <    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
450 <    
451 <    do i = 1, nExcludes_Global
452 <       excludesGlobal(i) = CexcludesGlobal(i)
453 <    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
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
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
482 <  end function getDielect
483 <      
484 <  function SimUsesPBC() result(doesit)
485 <    logical :: doesit
486 <    doesit = thisSim%SIM_uses_PBC
487 <  end function SimUsesPBC
455 >          do i = 1, nGlobal
456 >             molMemberShipList(i) = CmolMembership(i)
457 >          enddo
458  
459 <  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
459 >          if (status == 0) simulation_setup_complete = .true.
460  
461 <  function SimUsesLennardJones() result(doesit)
496 <    logical :: doesit
497 <    doesit = thisSim%SIM_uses_LennardJones
498 <  end function SimUsesLennardJones
461 >        end subroutine SimulationSetup
462  
463 <  function SimUsesElectrostatics() result(doesit)
464 <    logical :: doesit
465 <    doesit = thisSim%SIM_uses_Electrostatics
466 <  end function SimUsesElectrostatics
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 SimUsesCharges() result(doesit)
469 <    logical :: doesit
470 <    doesit = thisSim%SIM_uses_Charges
471 <  end function SimUsesCharges
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 SimUsesDipoles() result(doesit)
477 <    logical :: doesit
512 <    doesit = thisSim%SIM_uses_Dipoles
513 <  end function SimUsesDipoles
476 >          return    
477 >        end subroutine setBox
478  
479 <  function SimUsesSticky() result(doesit)
480 <    logical :: doesit
481 <    doesit = thisSim%SIM_uses_Sticky
482 <  end function SimUsesSticky
519 <
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
479 >        function getDielect() result(dielect)
480 >          real( kind = dp ) :: dielect
481 >          dielect = thisSim%dielect
482 >        end function getDielect
483  
484 <  function SimUsesShapes() result(doesit)
485 <    logical :: doesit
486 <    doesit = thisSim%SIM_uses_Shapes
487 <  end function SimUsesShapes
484 >        function SimUsesPBC() result(doesit)
485 >          logical :: doesit
486 >          doesit = thisSim%SIM_uses_PBC
487 >        end function SimUsesPBC
488  
489 <  function SimUsesFLARB() result(doesit)
490 <    logical :: doesit
491 <    doesit = thisSim%SIM_uses_FLARB
492 <  end function SimUsesFLARB
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 SimUsesRF() result(doesit)
496 <    logical :: doesit
497 <    doesit = thisSim%SIM_uses_RF
498 <  end function SimUsesRF
495 >        function SimUsesLennardJones() result(doesit)
496 >          logical :: doesit
497 >          doesit = thisSim%SIM_uses_LennardJones
498 >        end function SimUsesLennardJones
499  
500 <  function SimRequiresPrepairCalc() result(doesit)
501 <    logical :: doesit
502 <    doesit = thisSim%SIM_uses_EAM
503 <  end function SimRequiresPrepairCalc
500 >        function SimUsesElectrostatics() result(doesit)
501 >          logical :: doesit
502 >          doesit = thisSim%SIM_uses_Electrostatics
503 >        end function SimUsesElectrostatics
504  
505 <  function SimRequiresPostpairCalc() result(doesit)
506 <    logical :: doesit
507 <    doesit = thisSim%SIM_uses_RF
508 <  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
505 >        function SimUsesCharges() result(doesit)
506 >          logical :: doesit
507 >          doesit = thisSim%SIM_uses_Charges
508 >        end function SimUsesCharges
509  
510 <    allocate(molMembershipList(nGlobal), stat=alloc_stat)
511 <    if (alloc_stat /= 0 ) then
512 <       thisStat = -1
513 <       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.
510 >        function SimUsesDipoles() result(doesit)
511 >          logical :: doesit
512 >          doesit = thisSim%SIM_uses_Dipoles
513 >        end function SimUsesDipoles
514  
515 <    if (allocated(skipsForAtom)) deallocate(skipsForAtom)
516 <    if (allocated(nSkipsForAtom)) deallocate(nSkipsForAtom)
517 <    if (allocated(mfactLocal)) deallocate(mfactLocal)
518 <    if (allocated(mfactCol)) deallocate(mfactCol)
519 <    if (allocated(mfactRow)) deallocate(mfactRow)
520 <    if (allocated(groupListCol)) deallocate(groupListCol)    
521 <    if (allocated(groupListRow)) deallocate(groupListRow)    
522 <    if (allocated(groupStartCol)) deallocate(groupStartCol)
523 <    if (allocated(groupStartRow)) deallocate(groupStartRow)    
524 <    if (allocated(molMembershipList)) deallocate(molMembershipList)    
525 <    if (allocated(excludesGlobal)) deallocate(excludesGlobal)
526 <    if (allocated(excludesLocal)) deallocate(excludesLocal)
527 <    
528 <  end subroutine FreeSimGlobals
529 <  
530 <  pure function getNlocal() result(n)
531 <    integer :: n
532 <    n = nLocal
533 <  end function getNlocal
534 <  
535 < end module simulation
515 >        function SimUsesSticky() result(doesit)
516 >          logical :: doesit
517 >          doesit = thisSim%SIM_uses_Sticky
518 >        end function SimUsesSticky
519 >
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