Skip to content

Commit fbcac75

Browse files
committed
further fix around array allocation for SETTLE
1 parent 6c65c30 commit fbcac75

1 file changed

Lines changed: 9 additions & 15 deletions

File tree

source/settle.f

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,16 @@ subroutine settle (dt,xold,yold,zold)
6868
real*8 xold(*)
6969
real*8 yold(*)
7070
real*8 zold(*)
71-
logical dovel
7271
c
7372
c
74-
c check for the availability of atomic velocities
73+
c check for prior allocation of atomic velocities
7574
c
76-
dovel = .false.
77-
if (allocated(v)) then
78-
if (size(v) .ne. 0) dovel = .true.
79-
else
80-
allocate (v(3,0))
81-
end if
75+
if (.not. allocated(v)) allocate (v(0,0))
8276
c
8377
c OpenMP directives for the major loop structure
8478
c
8579
!$OMP PARALLEL default(private) shared(nwat,iwat,kwat,mass,
86-
!$OMP& x,y,z,xold,yold,zold,dt,dovel)
80+
!$OMP& x,y,z,xold,yold,zold,dt)
8781
!$OMP& shared(v)
8882
!$OMP DO reduction(+:v)
8983
c
@@ -218,7 +212,7 @@ subroutine settle (dt,xold,yold,zold)
218212
c
219213
c use velocity correction derived from position movement
220214
c
221-
if (dovel) then
215+
if (dt .ne. 0.0d0) then
222216
v(1,ia) = v(1,ia) + (x(ia)-xia0)/dt
223217
v(2,ia) = v(2,ia) + (y(ia)-yia0)/dt
224218
v(3,ia) = v(3,ia) + (z(ia)-zia0)/dt
@@ -239,7 +233,7 @@ subroutine settle (dt,xold,yold,zold)
239233
c set position and velocity for four-site water extra sites
240234
c
241235
if (nwat4 .ne. 0) then
242-
call watfour (dovel)
236+
call watfour (dt)
243237
end if
244238
return
245239
end
@@ -698,20 +692,20 @@ subroutine solve3 (a,b,p)
698692
c extra site of rigid planar four-site water molecules
699693
c
700694
c
701-
subroutine watfour (dovel)
695+
subroutine watfour (dt)
702696
use atoms
703697
use freeze
704698
use moldyn
705699
implicit none
706700
integer i
707701
integer ia,ib,ic,id
702+
real*8 dt
708703
real*8 oterm,hterm
709-
logical dovel
710704
c
711705
c
712706
c OpenMP directives for the major loop structure
713707
c
714-
!$OMP PARALLEL default(private) shared(nwat4,iwat4,kwat4,x,y,z,v,dovel)
708+
!$OMP PARALLEL default(private) shared(nwat4,iwat4,kwat4,x,y,z,v,dt)
715709
!$OMP DO
716710
c
717711
c set the position of four-site water extra centers
@@ -726,7 +720,7 @@ subroutine watfour (dovel)
726720
x(id) = oterm*x(ia) + hterm*(x(ib)+x(ic))
727721
y(id) = oterm*y(ia) + hterm*(y(ib)+y(ic))
728722
z(id) = oterm*z(ia) + hterm*(z(ib)+z(ic))
729-
if (dovel) then
723+
if (dt .ne. 0.0d0) then
730724
v(1,id) = 0.0d0
731725
v(2,id) = 0.0d0
732726
v(3,id) = 0.0d0

0 commit comments

Comments
 (0)