4 |
|
|
5 |
|
!! @author Charles F. Vardeman II |
6 |
|
!! @author Matthew Meineke |
7 |
< |
!! @version $Id: do_Forces.F90,v 1.62 2004-05-26 16:41:23 gezelter Exp $, $Date: 2004-05-26 16:41:23 $, $Name: not supported by cvs2svn $, $Revision: 1.62 $ |
7 |
> |
!! @version $Id: do_Forces.F90,v 1.64 2004-05-27 15:21:20 gezelter Exp $, $Date: 2004-05-27 15:21:20 $, $Name: not supported by cvs2svn $, $Revision: 1.64 $ |
8 |
|
|
9 |
|
module do_Forces |
10 |
|
use force_globals |
375 |
|
!! Position array provided by C, dimensioned by getNlocal |
376 |
|
real ( kind = dp ), dimension(3, nLocal) :: q |
377 |
|
!! molecular center-of-mass position array |
378 |
< |
real ( kind = dp ), dimension(3, nGroup) :: q_group |
378 |
> |
real ( kind = dp ), dimension(3, nGroups) :: q_group |
379 |
|
!! Rotation Matrix for each long range particle in simulation. |
380 |
|
real( kind = dp), dimension(9, nLocal) :: A |
381 |
|
!! Unit vectors for dipoles (lab frame) |
394 |
|
logical :: in_switching_region |
395 |
|
#ifdef IS_MPI |
396 |
|
real( kind = DP ) :: pot_local |
397 |
< |
integer :: nrow |
398 |
< |
integer :: ncol |
397 |
> |
integer :: nAtomsInRow |
398 |
> |
integer :: nAtomsInCol |
399 |
|
integer :: nprocs |
400 |
< |
integer :: nrow_group |
401 |
< |
integer :: ncol_group |
400 |
> |
integer :: nGroupsInRow |
401 |
> |
integer :: nGroupsInCol |
402 |
|
#endif |
403 |
|
integer :: natoms |
404 |
|
logical :: update_nlist |
424 |
|
|
425 |
|
#ifdef IS_MPI |
426 |
|
pot_local = 0.0_dp |
427 |
< |
nrow = getNrow(plan_row) |
428 |
< |
ncol = getNcol(plan_col) |
429 |
< |
nrow_group = getNrowGroup(plan_row) |
430 |
< |
ncol_group = getNcolGroup(plan_col) |
427 |
> |
nAtomsInRow = getNatomsInRow(plan_atom_row) |
428 |
> |
nAtomsInCol = getNatomsInCol(plan_atom_col) |
429 |
> |
nGroupsInRow = getNgroupsInRow(plan_group_row) |
430 |
> |
nGroupsInCol = getNgroupsInCol(plan_group_col) |
431 |
|
#else |
432 |
|
natoms = nlocal |
433 |
|
#endif |
447 |
|
|
448 |
|
#ifdef IS_MPI |
449 |
|
|
450 |
< |
call gather(q, q_Row, plan_row3d) |
451 |
< |
call gather(q, q_Col, plan_col3d) |
450 |
> |
call gather(q, q_Row, plan_atom_row_3d) |
451 |
> |
call gather(q, q_Col, plan_atom_col_3d) |
452 |
|
|
453 |
< |
call gather(q_group, q_group_Row, plan_row_Group_3d) |
454 |
< |
call gather(q_group, q_group_Col, plan_col_Group_3d) |
453 |
> |
call gather(q_group, q_group_Row, plan_group_row_3d) |
454 |
> |
call gather(q_group, q_group_Col, plan_group_col_3d) |
455 |
|
|
456 |
|
if (FF_UsesDirectionalAtoms() .and. SIM_uses_directional_atoms) then |
457 |
< |
call gather(u_l,u_l_Row,plan_row3d) |
458 |
< |
call gather(u_l,u_l_Col,plan_col3d) |
457 |
> |
call gather(u_l, u_l_Row, plan_atom_row_3d) |
458 |
> |
call gather(u_l, u_l_Col, plan_atom_col_3d) |
459 |
|
|
460 |
< |
call gather(A,A_Row,plan_row_rotation) |
461 |
< |
call gather(A,A_Col,plan_col_rotation) |
460 |
> |
call gather(A, A_Row, plan_atom_row_rotation) |
461 |
> |
call gather(A, A_Col, plan_atom_col_rotation) |
462 |
|
endif |
463 |
|
|
464 |
|
#endif |
481 |
|
! See if we need to update neighbor lists |
482 |
|
! (but only on the first time through): |
483 |
|
if (loop .eq. loopStart) then |
484 |
< |
call checkNeighborList(nGroup, q_group, listSkin, update_nlist) |
484 |
> |
call checkNeighborList(nGroups, q_group, listSkin, update_nlist) |
485 |
|
endif |
486 |
|
|
487 |
|
if (update_nlist) then |
488 |
|
!! save current configuration and construct neighbor list |
489 |
< |
call saveNeighborList(nGroup, q_group) |
489 |
> |
#ifdef IS_MPI |
490 |
> |
call saveNeighborList(nGroupsInRow, q_group) |
491 |
> |
#else |
492 |
> |
call saveNeighborList(nGroups, q_group) |
493 |
> |
#endif |
494 |
|
neighborListSize = size(list) |
495 |
|
nlist = 0 |
496 |
|
endif |
497 |
|
|
498 |
|
istart = 1 |
499 |
|
#ifdef IS_MPI |
500 |
< |
iend = nrow_group |
500 |
> |
iend = nGroupsInRow |
501 |
|
#else |
502 |
< |
iend = nGroup - 1 |
502 |
> |
iend = nGroups - 1 |
503 |
|
#endif |
504 |
|
outer: do i = istart, iend |
505 |
|
|
506 |
|
if (update_nlist) point(i) = nlist + 1 |
507 |
|
|
508 |
< |
n_in_i = groupStart(i+1) - groupStart(i) |
508 |
> |
n_in_i = groupStartRow(i+1) - groupStartRow(i) |
509 |
|
|
510 |
|
if (update_nlist) then |
511 |
|
#ifdef IS_MPI |
512 |
|
jstart = 1 |
513 |
< |
jend = ncol_group |
513 |
> |
jend = nGroupsInCol |
514 |
|
#else |
515 |
|
jstart = i+1 |
516 |
< |
jend = nGroup |
516 |
> |
jend = nGroups |
517 |
|
#endif |
518 |
|
else |
519 |
|
jstart = point(i) |
528 |
|
else |
529 |
|
j = list(jnab) |
530 |
|
endif |
531 |
+ |
|
532 |
|
#ifdef IS_MPI |
533 |
|
call get_interatomic_vector(q_group_Row(:,i), & |
534 |
|
q_group_Col(:,j), d_grp, rgrpsq) |
536 |
|
call get_interatomic_vector(q_group(:,i), & |
537 |
|
q_group(:,j), d_grp, rgrpsq) |
538 |
|
#endif |
539 |
+ |
|
540 |
|
if (rgrpsq < rlistsq) then |
541 |
|
if (update_nlist) then |
542 |
|
nlist = nlist + 1 |
543 |
|
|
544 |
|
if (nlist > neighborListSize) then |
545 |
< |
call expandNeighborList(nGroup, listerror) |
545 |
> |
#ifdef IS_MPI |
546 |
> |
call expandNeighborList(nGroupsInRow, listerror) |
547 |
> |
#else |
548 |
> |
call expandNeighborList(nGroups, listerror) |
549 |
> |
#endif |
550 |
|
if (listerror /= 0) then |
551 |
|
error = -1 |
552 |
|
write(DEFAULT_ERROR,*) "ERROR: nlist > list size and max allocations exceeded." |
566 |
|
call get_switch(rgrpsq, sw, dswdr, rgrp, group_switch, & |
567 |
|
in_switching_region) |
568 |
|
|
569 |
< |
n_in_j = groupStart(j+1) - groupStart(j) |
569 |
> |
n_in_j = groupStartCol(j+1) - groupStartCol(j) |
570 |
|
|
571 |
< |
do ia = groupStart(i), groupStart(i+1)-1 |
571 |
> |
do ia = groupStartRow(i), groupStartRow(i+1)-1 |
572 |
|
|
573 |
< |
atom1 = groupList(ia) |
573 |
> |
atom1 = groupListRow(ia) |
574 |
|
|
575 |
< |
inner: do jb = groupStart(j), groupStart(j+1)-1 |
575 |
> |
inner: do jb = groupStartCol(j), groupStartCol(j+1)-1 |
576 |
|
|
577 |
< |
atom2 = groupList(jb) |
577 |
> |
atom2 = groupListCol(jb) |
578 |
|
|
579 |
|
if (skipThisPair(atom1, atom2)) cycle inner |
580 |
|
|
623 |
|
fij(2) = fij(2) + swderiv*d_grp(2) |
624 |
|
fij(3) = fij(3) + swderiv*d_grp(3) |
625 |
|
|
626 |
< |
do ia=groupStart(i), groupStart(i+1)-1 |
627 |
< |
atom1=groupList(ia) |
628 |
< |
mf = mfact(atom1) |
626 |
> |
do ia=groupStartRow(i), groupStartRow(i+1)-1 |
627 |
> |
atom1=groupListRow(ia) |
628 |
> |
mf = mfactRow(atom1) |
629 |
|
#ifdef IS_MPI |
630 |
|
f_Row(1,atom1) = f_Row(1,atom1) + swderiv*d_grp(1)*mf |
631 |
|
f_Row(2,atom1) = f_Row(2,atom1) + swderiv*d_grp(2)*mf |
637 |
|
#endif |
638 |
|
enddo |
639 |
|
|
640 |
< |
do jb=groupStart(j), groupStart(j+1)-1 |
641 |
< |
atom2=groupList(jb) |
642 |
< |
mf = mfact(atom2) |
640 |
> |
do jb=groupStartCol(j), groupStartCol(j+1)-1 |
641 |
> |
atom2=groupListCol(jb) |
642 |
> |
mf = mfactCol(atom2) |
643 |
|
#ifdef IS_MPI |
644 |
|
f_Col(1,atom2) = f_Col(1,atom2) - swderiv*d_grp(1)*mf |
645 |
|
f_Col(2,atom2) = f_Col(2,atom2) - swderiv*d_grp(2)*mf |
660 |
|
|
661 |
|
if (update_nlist) then |
662 |
|
#ifdef IS_MPI |
663 |
< |
point(nrow_group + 1) = nlist + 1 |
663 |
> |
point(nGroupsInRow + 1) = nlist + 1 |
664 |
|
#else |
665 |
< |
point(nGroup) = nlist + 1 |
665 |
> |
point(nGroups) = nlist + 1 |
666 |
|
#endif |
667 |
|
if (loop .eq. PREPAIR_LOOP) then |
668 |
|
! we just did the neighbor list update on the first |
688 |
|
!!distribute forces |
689 |
|
|
690 |
|
f_temp = 0.0_dp |
691 |
< |
call scatter(f_Row,f_temp,plan_row3d) |
691 |
> |
call scatter(f_Row,f_temp,plan_atom_row_3d) |
692 |
|
do i = 1,nlocal |
693 |
|
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
694 |
|
end do |
695 |
|
|
696 |
|
f_temp = 0.0_dp |
697 |
< |
call scatter(f_Col,f_temp,plan_col3d) |
697 |
> |
call scatter(f_Col,f_temp,plan_atom_col_3d) |
698 |
|
do i = 1,nlocal |
699 |
|
f(1:3,i) = f(1:3,i) + f_temp(1:3,i) |
700 |
|
end do |
701 |
|
|
702 |
|
if (FF_UsesDirectionalAtoms() .and. SIM_uses_directional_atoms) then |
703 |
|
t_temp = 0.0_dp |
704 |
< |
call scatter(t_Row,t_temp,plan_row3d) |
704 |
> |
call scatter(t_Row,t_temp,plan_atom_row_3d) |
705 |
|
do i = 1,nlocal |
706 |
|
t(1:3,i) = t(1:3,i) + t_temp(1:3,i) |
707 |
|
end do |
708 |
|
t_temp = 0.0_dp |
709 |
< |
call scatter(t_Col,t_temp,plan_col3d) |
709 |
> |
call scatter(t_Col,t_temp,plan_atom_col_3d) |
710 |
|
|
711 |
|
do i = 1,nlocal |
712 |
|
t(1:3,i) = t(1:3,i) + t_temp(1:3,i) |
715 |
|
|
716 |
|
if (do_pot) then |
717 |
|
! scatter/gather pot_row into the members of my column |
718 |
< |
call scatter(pot_Row, pot_Temp, plan_row) |
718 |
> |
call scatter(pot_Row, pot_Temp, plan_atom_row) |
719 |
|
|
720 |
|
! scatter/gather pot_local into all other procs |
721 |
|
! add resultant to get total pot |
725 |
|
|
726 |
|
pot_Temp = 0.0_DP |
727 |
|
|
728 |
< |
call scatter(pot_Col, pot_Temp, plan_col) |
728 |
> |
call scatter(pot_Col, pot_Temp, plan_atom_col) |
729 |
|
do i = 1, nlocal |
730 |
|
pot_local = pot_local + pot_Temp(i) |
731 |
|
enddo |
738 |
|
if (FF_uses_RF .and. SIM_uses_RF) then |
739 |
|
|
740 |
|
#ifdef IS_MPI |
741 |
< |
call scatter(rf_Row,rf,plan_row3d) |
742 |
< |
call scatter(rf_Col,rf_Temp,plan_col3d) |
741 |
> |
call scatter(rf_Row,rf,plan_atom_row_3d) |
742 |
> |
call scatter(rf_Col,rf_Temp,plan_atom_col_3d) |
743 |
|
do i = 1,nlocal |
744 |
|
rf(1:3,i) = rf(1:3,i) + rf_Temp(1:3,i) |
745 |
|
end do |
825 |
|
fpair(1:3) = 0.0d0 |
826 |
|
|
827 |
|
#ifdef IS_MPI |
828 |
< |
if (tagRow(i) .eq. tagColumn(j)) then |
829 |
< |
write(0,*) 'do_pair is doing', i , j, tagRow(i), tagColumn(j) |
828 |
> |
if (AtomRowToGlobal(i) .eq. AtomColToGlobal(j)) then |
829 |
> |
write(0,*) 'do_pair is doing', i , j, AtomRowToGlobal(i), AtomColToGlobal(j) |
830 |
|
endif |
831 |
|
me_i = atid_row(i) |
832 |
|
me_j = atid_col(j) |
929 |
|
|
930 |
|
|
931 |
|
#ifdef IS_MPI |
932 |
< |
if (tagRow(i) .eq. tagColumn(j)) then |
933 |
< |
write(0,*) 'do_prepair is doing', i , j, tagRow(i), tagColumn(j) |
932 |
> |
if (AtomRowToGlobal(i) .eq. AtomColToGlobal(j)) then |
933 |
> |
write(0,*) 'do_prepair is doing', i , j, AtomRowToGlobal(i), AtomColToGlobal(j) |
934 |
|
endif |
935 |
|
|
936 |
|
me_i = atid_row(i) |
1077 |
|
|
1078 |
|
#ifdef IS_MPI |
1079 |
|
!! in MPI, we have to look up the unique IDs for each atom |
1080 |
< |
unique_id_1 = tagRow(atom1) |
1080 |
> |
unique_id_1 = AtomRowToGlobal(atom1) |
1081 |
|
#else |
1082 |
|
!! in the normal loop, the atom numbers are unique |
1083 |
|
unique_id_1 = atom1 |
1096 |
|
end if |
1097 |
|
|
1098 |
|
#ifdef IS_MPI |
1099 |
< |
unique_id_2 = tagColumn(atom2) |
1099 |
> |
unique_id_2 = AtomColToGlobal(atom2) |
1100 |
|
#else |
1101 |
|
unique_id_2 = atom2 |
1102 |
|
#endif |