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.2 2003-02-26 18:45:57 mmeineke Exp $, $Date: 2003-02-26 18:45:57 $, $Name: not supported by cvs2svn $, $Revision: 1.2 $ |
5 |
> |
!! @version $Id: lj_FF.F90,v 1.3 2003-02-27 18:42:52 chuckv Exp $, $Date: 2003-02-27 18:42:52 $, $Name: not supported by cvs2svn $, $Revision: 1.3 $ |
6 |
|
|
7 |
|
|
8 |
|
|
10 |
|
use simulation |
11 |
|
use definitions |
12 |
|
use generic_atypes |
13 |
+ |
use neighborLists |
14 |
|
#ifdef IS_MPI |
15 |
|
use mpiSimulation |
16 |
|
#endif |
29 |
|
type (lj_atype), dimension(:,:), pointer :: ljMixed => null() |
30 |
|
|
31 |
|
|
31 |
– |
!! Neighbor list and commom arrays |
32 |
– |
!! This should eventally get moved to a neighbor list type |
33 |
– |
integer, allocatable, dimension(:) :: point |
34 |
– |
integer, allocatable, dimension(:) :: list |
35 |
– |
integer, parameter :: listMultiplier = 80 |
36 |
– |
integer :: nListAllocs = 0 |
37 |
– |
integer, parameter :: maxListAllocs = 5 |
38 |
– |
|
32 |
|
logical, save :: firstTime = .True. |
33 |
|
|
34 |
|
!! Atype identity pointer lists |
202 |
|
end if |
203 |
|
if (allocated(identCol)) then |
204 |
|
deallocate(identRow) |
212 |
– |
endif |
213 |
– |
|
214 |
– |
!! Allocate neighbor lists for mpi simulations. |
215 |
– |
if (.not. allocated(point)) then |
216 |
– |
allocate(point(nrow),stat=alloc_stat) |
217 |
– |
if (alloc_stat /=0) then |
218 |
– |
status = -1 |
219 |
– |
return |
220 |
– |
endif |
221 |
– |
|
222 |
– |
allocate(list(ncol*listMultiplier),stat=alloc_stat) |
223 |
– |
if (alloc_stat /=0) then |
224 |
– |
status = -1 |
225 |
– |
return |
226 |
– |
endif |
227 |
– |
else |
228 |
– |
deallocate(list) |
229 |
– |
deallocate(point) |
230 |
– |
allocate(point(nrow),stat=alloc_stat) |
231 |
– |
if (alloc_stat /=0) then |
232 |
– |
status = -1 |
233 |
– |
return |
234 |
– |
endif |
235 |
– |
|
236 |
– |
allocate(list(ncol*listMultiplier),stat=alloc_stat) |
237 |
– |
if (alloc_stat /=0) then |
238 |
– |
status = -1 |
239 |
– |
return |
240 |
– |
endif |
205 |
|
endif |
206 |
|
|
207 |
|
#endif |
211 |
|
status = -1 |
212 |
|
return |
213 |
|
endif |
214 |
+ |
!! Create neighbor lists |
215 |
+ |
call expandList(thisStat) |
216 |
+ |
if (thisStat /= 0) then |
217 |
+ |
status = -1 |
218 |
+ |
return |
219 |
+ |
endif |
220 |
+ |
|
221 |
|
isljFFinit = .true. |
222 |
|
|
223 |
|
|
319 |
|
|
320 |
|
!! FORCE routine Calculates Lennard Jones forces. |
321 |
|
!-------------------------------------------------------------> |
322 |
< |
subroutine do_lj_ff(q,f,potE,tau,do_pot) |
322 |
> |
subroutine do_lj_ff(q,f,potE,tau,do_pot,FFerror) |
323 |
|
!! Position array provided by C, dimensioned by getNlocal |
324 |
|
real ( kind = dp ), dimension(3,getNlocal()) :: q |
325 |
|
!! Force array provided by C, dimensioned by getNlocal |
329 |
|
real( kind = dp), dimension(9) :: tauTemp |
330 |
|
real ( kind = dp ) :: potE |
331 |
|
logical ( kind = 2) :: do_pot |
332 |
+ |
integer :: FFerror |
333 |
+ |
|
334 |
|
|
335 |
|
type(lj_atype), pointer :: ljAtype_i |
336 |
|
type(lj_atype), pointer :: ljAtype_j |
383 |
|
integer :: nrow |
384 |
|
integer :: ncol |
385 |
|
integer :: natoms |
386 |
+ |
integer :: neighborListSize |
387 |
+ |
integer :: listerror |
388 |
|
!! should we calculate the stress tensor |
389 |
|
logical :: do_stress = .false. |
390 |
|
|
391 |
|
|
392 |
< |
|
392 |
> |
FFerror = 0 |
393 |
|
! Make sure we are properly initialized. |
394 |
|
if (.not. isljFFInit) then |
395 |
|
write(default_error,*) "ERROR: lj_FF has not been properly initialized" |
396 |
+ |
FFerror = -1 |
397 |
|
return |
398 |
|
endif |
399 |
|
#ifdef IS_MPI |
400 |
|
if (.not. isMPISimSet()) then |
401 |
|
write(default_error,*) "ERROR: mpiSimulation has not been properly initialized" |
402 |
+ |
FFerror = -1 |
403 |
|
return |
404 |
|
endif |
405 |
|
#endif |
424 |
|
|
425 |
|
!! See if we need to update neighbor lists |
426 |
|
call check(q,update_nlist) |
427 |
< |
if (firstTime) then |
428 |
< |
update_nlist = .true. |
429 |
< |
firstTime = .false. |
430 |
< |
endif |
427 |
> |
! if (firstTime) then |
428 |
> |
! update_nlist = .true. |
429 |
> |
! firstTime = .false. |
430 |
> |
! endif |
431 |
|
|
432 |
|
!--------------WARNING........................... |
433 |
|
! Zero variables, NOTE:::: Forces are zeroed in C |
460 |
|
|
461 |
|
! save current configuration, contruct neighbor list, |
462 |
|
! and calculate forces |
463 |
< |
call save_nlist(q) |
463 |
> |
call save_neighborList(q) |
464 |
|
|
465 |
+ |
neighborListSize = getNeighborListSize() |
466 |
|
nlist = 0 |
467 |
|
|
468 |
|
|
517 |
|
#endif |
518 |
|
|
519 |
|
nlist = nlist + 1 |
520 |
< |
if (nlist > size(list)) then |
521 |
< |
!! "Change how nlist size is done" |
522 |
< |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size" |
520 |
> |
if (nlist > neighborListSize) then |
521 |
> |
call expandList(listerror) |
522 |
> |
if (listerror /= 0) then |
523 |
> |
FFerror = -1 |
524 |
> |
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
525 |
> |
return |
526 |
> |
end if |
527 |
|
endif |
528 |
|
list(nlist) = j |
529 |
|
|