Dear Prof. Taylor,
Thanks for your reply. My algorithm works like this
PARTition
1,1,0
0,0,1
1,1,1
macr
...
STAG,allo
...
dt,,tt
part,,1
tran,expl
mass lump
form accel
loop,step,km
loop,ohne,ko
part,,1
tran,expl
time,expl,tf,0.9
loop,STAG,10
STAG,set,0.0
part,,1
tran,centr
loop,,1
mati
form,expl
next
part,,2
tran,off
loop,iter,15
mati
tang
form
solve
next,iter
Monolithic
STAG,prin
STAG,chec,1.0E-3 !should exit loop/stag if tolerance 1.0E-3 is reached
next,stag
next,ohne
next,step
end
The relevant part of the user macro STAG is
if (pcomp(lct,'chec',4)) then
call pgetd('USER5',beg1,len1,prec1,found1)
if(found1) then
if ((abs(hr(beg1)-hr(beg1+1))/abs(hr(beg1))).le.ctl(1)) then
hr(beg1+1)=hr(beg1) ! --> converged Etotal_old=Etotal
??? ! Here I want to exit the STAG loop.
else
hr(beg1+1)=hr(beg1) ! --> not converged Etotal_old=Etotal
endif
else
write(iow,*),'USER5 NOT ALLOCATED - ERROR!'
endif
endif
STAG checks whether the solution is converged in the sense that the relative change of some global energy is small enough.
I am just not sure how to set the relevant loop counter to exit the STAG loop. Thanks for your help!
EDIT:
I have realized that the algorithm can actually be implemented by setting (and resetting) the flag ljump correctly:
loop,stag,100
part,,1
tran,centr
loop,,1
mati
form,expl
next
part,,2
tran,off
loop,iter,15
mati
tang
form
solve
next,iter
PART,,3
STAG,set,0.0
RESId
STAG,chec,1.0E-3
next,stag
STAG,NOJU
and
if (pcomp(lct,'chec',4)) then
call pgetd('USER5',beg1,len1,prec1,found1)
if(found1) then
encur=hr(beg1)
enold=hr(beg1+1)
if ((abs(encur-enold)/abs(enold)).le.ctl(1)) then
hr(beg1+1)=encur ! --> converged Etotal_old=Etotal
ljump=.true.
else
hr(beg1+1)=encur ! --> not converged Etotal_old=Etotal
endif
else
write(iow,*),'USER5 NOT ALLOCATED - ERROR4!'
endif
endif
if (pcomp(lct,'noju',4)) then
call pgetd('USER5',beg1,len1,prec1,found1)
if(found1) then
ljump=.false.
else
write(iow,*),'USER5 NOT ALLOCATED - ERROR4a!'
endif
endif
Seems to work so far. Thank you!