ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/md_code/lj_FF.F90
(Generate patch)

Comparing trunk/mdtools/md_code/lj_FF.F90 (file contents):
Revision 252 by chuckv, Tue Jan 28 22:16:55 2003 UTC vs.
Revision 253 by chuckv, Thu Jan 30 15:20:21 2003 UTC

# Line 2 | Line 2
2   !! Corresponds to the force field defined in lj_FF.cpp
3   !! @author Charles F. Vardeman II
4   !! @author Matthew Meineke
5 < !! @version $Id: lj_FF.F90,v 1.12 2003-01-28 22:16:55 chuckv Exp $, $Date: 2003-01-28 22:16:55 $, $Name: not supported by cvs2svn $, $Revision: 1.12 $
5 > !! @version $Id: lj_FF.F90,v 1.13 2003-01-30 15:20:21 chuckv Exp $, $Date: 2003-01-30 15:20:21 $, $Name: not supported by cvs2svn $, $Revision: 1.13 $
6  
7  
8  
# Line 36 | Line 36 | module lj_ff
36    integer :: nListAllocs = 0
37    integer, parameter :: maxListAllocs = 5
38  
39 +  logical, save :: firstTime = .True.
40  
41   !! Atype identity pointer lists
42   #ifdef IS_MPI
43   !! Row lj_atype pointer list
44 <  type (lj_atypePtr), dimension(:), pointer :: identPtrListRow => null()
44 >  type (lj_identPtrList), dimension(:), pointer :: identPtrListRow => null()
45   !! Column lj_atype pointer list
46 <  type (lj_atypePtr), dimension(:), pointer :: identPtrListColumn => null()
46 >  type (lj_identPtrList), dimension(:), pointer :: identPtrListColumn => null()
47   #else
48    type( lj_identPtrList ), dimension(:), pointer :: identPtrList => null()
49   #endif
# Line 128 | Line 129 | contains
129      integer, allocatable, dimension(:) :: identCol
130      integer :: nrow
131      integer :: ncol
131    integer :: alloc_stat
132   #endif
133      status = 0
134   !! if were're not in MPI, we just update ljatypePtrList
# Line 184 | Line 184 | contains
184         return
185      endif
186  
187 <    call create_IdentPtrlst(identCol,ljListTail,identPtrListCol,thisStat)
187 >    call create_IdentPtrlst(identCol,ljListTail,identPtrListColumn,thisStat)
188      if (thisStat /= 0 ) then
189         status = -1
190         return
# Line 342 | Line 342 | contains
342      type(lj_atype), pointer :: ljAtype_i
343      type(lj_atype), pointer :: ljAtype_j
344  
345 < #ifdef MPI
345 > #ifdef IS_MPI
346    real( kind = DP ), dimension(3,getNcol()) :: efr
347    real( kind = DP ) :: pot_local
348   #else
# Line 356 | Line 356 | contains
356  
357    real(kind = dp), dimension(3:getNrow()) :: fRow
358    real(kind = dp), dimension(3:getNcol()) :: fCol
359 +  real(kind = dp), dimension(3:getNlocal()) :: fMPITemp
360  
361    real(kind = dp), dimension(getNrow()) :: eRow
362    real(kind = dp), dimension(getNcol()) :: eCol
# Line 387 | Line 388 | contains
388    integer :: ncol
389    integer :: natoms
390  
391 +
392 +
393 +
394   ! Make sure we are properly initialized.
395    if (.not. isljFFInit) then
396       write(default_error,*) "ERROR: lj_FF has not been properly initialized"
# Line 403 | Line 407 | contains
407    natoms = getNlocal()
408    call getRcut(rcut,rcut2=rcutsq)
409    call getRlist(rlist,rlistsq)
410 +
411   #ifndef IS_MPI
412    nrow = natoms - 1
413    ncol = natoms
# Line 416 | Line 421 | contains
421    
422   !! See if we need to update neighbor lists
423    call check(q,update_nlist)
424 +  if (firstTime) then
425 +     update_nlist = .true.
426 +     firstTime = .false.
427 +  endif
428  
429   !--------------WARNING...........................
430   ! Zero variables, NOTE:::: Forces are zeroed in C
# Line 427 | Line 436 | contains
436    pe = 0.0E0_DP
437  
438   #else
439 <    f_row = 0.0E0_DP
440 <    f_col = 0.0E0_DP
439 >    fRow = 0.0E0_DP
440 >    fCol = 0.0E0_DP
441  
442      pe_local = 0.0E0_DP
443  
# Line 439 | Line 448 | contains
448      efr = 0.0E0_DP
449  
450   ! communicate MPI positions
451 < #ifdef MPI    
452 <    call gather(q,qRow,plan_row3)
453 <    call gather(q,qCol,plan_col3)
451 > #ifdef IS_MPI    
452 >    call gather(q,qRow,plan_row3d)
453 >    call gather(q,qCol,plan_col3d)
454   #endif
455  
456  
# Line 453 | Line 462 | contains
462      
463       nlist = 0
464      
465 <    
465 >    
466  
467       do i = 1, nrow
468          point(i) = nlist + 1
469 < #ifdef MPI
469 > #ifdef IS_MPI
470          ljAtype_i => identPtrListRow(i)%this
471          tag_i = tagRow(i)
472          rxi = qRow(1,i)
# Line 472 | Line 481 | contains
481   #endif
482  
483          inner: do j = j_start, ncol
484 < #ifdef MPI
484 > #ifdef IS_MPI
485   ! Assign identity pointers and tags
486             ljAtype_j => identPtrListColumn(j)%this
487             tag_j = tagCol(j)
# Line 496 | Line 505 | contains
505   #endif          
506             rijsq = rxij*rxij + ryij*ryij + rzij*rzij
507  
508 < #ifdef MPI
508 > #ifdef IS_MPI
509               if (rijsq <=  rlistsq .AND. &
510                    tag_j /= tag_i) then
511   #else
512 +          
513               if (rijsq <  rlistsq) then
514   #endif
515              
# Line 510 | Line 520 | contains
520                endif
521                list(nlist) = j
522  
523 <              
523 >    
524                if (rijsq <  rcutsq) then
525                  
526                   r = dsqrt(rijsq)
527        
528                   call getLJPot(r,pot,dudr,ljAtype_i,ljAtype_j)
529        
530 < #ifdef MPI
530 > #ifdef IS_MPI
531                  eRow(i) = eRow(i) + pot*0.5
532                  eCol(i) = eCol(i) + pot*0.5
533   #else
534 <                pe = pe + pot
534 >                    pe = pe + pot
535   #endif                
536              
537                   efr(1,j) = -rxij
# Line 535 | Line 545 | contains
545                      ftmp = dudr * drdx1
546  
547  
548 < #ifdef MPI
548 > #ifdef IS_MPI
549                      fCol(dim,j) = fCol(dim,j) - ftmp
550                      fRow(dim,i) = fRow(dim,i) + ftmp
551   #else                    
# Line 550 | Line 560 | contains
560          enddo inner
561       enddo
562  
563 < #ifdef MPI
563 > #ifdef IS_MPI
564       point(nrow + 1) = nlist + 1
565   #else
566       point(natoms) = nlist + 1
# Line 564 | Line 574 | contains
574          JEND = POINT(i+1) - 1
575          ! check thiat molecule i has neighbors
576          if (jbeg .le. jend) then
577 < #ifdef MPI
577 > #ifdef IS_MPI
578             ljAtype_i => identPtrListRow(i)%this
579             rxi = qRow(1,i)
580             ryi = qRow(2,i)
# Line 577 | Line 587 | contains
587   #endif
588             do jnab = jbeg, jend
589                j = list(jnab)
590 < #ifdef MPI
590 > #ifdef IS_MPI
591                ljAtype_j = identPtrListColumn(j)%this
592                rxij = wrap(rxi - q_col(1,j), 1)
593                ryij = wrap(ryi - q_col(2,j), 2)
# Line 595 | Line 605 | contains
605                   r = dsqrt(rijsq)
606                  
607                   call getLJPot(r,pot,dudr,ljAtype_i,ljAtype_j)
608 < #ifdef MPI
608 > #ifdef IS_MPI
609                  eRow(i) = eRow(i) + pot*0.5
610                  eCol(i) = eCol(i) + pot*0.5
611   #else
# Line 611 | Line 621 | contains
621                      
622                      drdx1 = efr(dim,j) / r
623                      ftmp = dudr * drdx1
624 < #ifdef MPI
624 > #ifdef IS_MPI
625                      fCol(dim,j) = fCol(dim,j) - ftmp
626                      fRow(dim,i) = fRow(dim,i) + ftmp
627   #else                    
# Line 627 | Line 637 | contains
637  
638  
639  
640 < #ifdef MPI
640 > #ifdef IS_MPI
641      !!distribute forces
642 <    call scatter(fRow,f,plan_row3)
642 >    call scatter(fRow,f,plan_row3d)
643  
644 <    call scatter(fCol,f_tmp,plan_col3)
644 >    call scatter(fCol,fMPITemp,plan_col3d)
645  
646      do i = 1,nlocal
647 <       f(1:3,i) = f(1:3,i) + f_tmp(1:3,i)
647 >       f(1:3,i) = f(1:3,i) + fMPITemp(1:3,i)
648      end do
649  
650  
651      
652      if (do_pot) then
653   ! scatter/gather pot_row into the members of my column
654 <       call scatter(e_row,e_tmp,plan_row)
654 >       call scatter(eRow,eTemp,plan_row)
655        
656         ! scatter/gather pot_local into all other procs
657         ! add resultant to get total pot
658         do i = 1, nlocal
659 <          pe_local = pe_local + e_tmp(i)
659 >          pe_local = pe_local + eTemp(i)
660         enddo
661         if (newtons_thrd) then
662 <          e_tmp = 0.0E0_DP
663 <          call scatter(e_col,e_tmp,plan_col)
662 >          eTemp = 0.0E0_DP
663 >          call scatter(eCol,eTemp,plan_col)
664            do i = 1, nlocal
665 <             pe_local = pe_local + e_tmp(i)
665 >             pe_local = pe_local + eTemp(i)
666            enddo
667         endif
668      endif
# Line 661 | Line 671 | contains
671  
672      potE = pe
673  
674 +  
675  
676 +
677    end subroutine do_lj_ff
678  
679   !! Calculates the potential between two lj particles based on two lj_atype pointers, optionally returns second
# Line 717 | Line 729 | contains
729      epsilon  = ljMixed(atype1%atype_ident,atype2%atype_ident)%epsilon
730  
731  
732 <
732 >    
733 >
734      call getRcut(rcut,rcut2=rcut2,rcut6=rcut6,status=errorStat)
735      
736      r2 = r * r

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines