-
Notifications
You must be signed in to change notification settings - Fork 0
/
intchk.src
309 lines (304 loc) · 8.54 KB
/
intchk.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#include "zeus2d.def"
c=======================================================================
c/////////////////////////// SUBROUTINE INTCHK \\\\\\\\\\\\\\\\\\\\\\\
c
subroutine intchk(iswres,iswhdf,iswhst,iswusr,icode)
c
c PURPOSE: Reads the buffer for valid interrupt messages and takes
c appropriate action. Also checks stopping criteria, and sets ifsen=1
c if stop condition is detected.
c
c Modified by NSH to include a returned exit code, so that zeus
c can communicate with a controlling python script
c
c INPUT ARGUMENTS: none
c
c OUTPUT ARGUMENTS: iswres,iswhdf,iswhst,iswusr=switches for restart,
c hdf, history, and USER dumps; set to 1 if dump to be made in DATAIO
c
c EXTERNALS: CHECKIN, BCDFLT, FINDNO, [ETIME,SECOND]
c
c LOCALS:
c-----------------------------------------------------------------------
implicit NONE
#include "param.h"
#include "root.h"
#include "control.h"
c-----------------------------------------------------------------------
integer iswres,iswhdf,iswhst,iswusr,icode
c
integer i,nchar,istrt,iend
real*8 valnew
character*80 msg
c
integer checkin
external checkin,bcdflt,findno
#ifdef UNIX
real*8 tarray(2),etime
external etime
#endif
#ifdef UNICOS
external second
#endif
c List of valid interrupt messages
character*3 intmsg(14)
data intmsg / 'sto','? ','pau','abo','tli','nli','dum'
& ,'dtd','hdf','dtf','hst','dth','usr','dtu' /
c\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\////////////////////////////////
c=======================================================================
c Check stopping criteria
c
#ifdef UNIX
c tused = etime(tarray)
c- D.Proga 18.Feb.98 modif. intchk did not on the VX
c tused = 1.
c-
#endif
#ifdef UNICOS
call second(tused)
#endif
if (tlim .gt. 0.0 .and. time .ge. tlim) then
write(6,"(/1x,'terminating on time limit',
& /1x,'tlim=',1pe12.5,' nlim=',i7,
& /1x,'time=', 1e12.5,' cycle=',i7,' tused=',1e12.5)")
& tlim,nlim,time,nhy,tused
icode = 2
ifsen = 1
endif
if (nlim .gt. 0 .and. nhy .ge. nlim) then
write(6,"(/1x,'terminating on cycle limit',
& /1x,'tlim=',1pe12.5,' nlim=',i7,
& /1x,'time=', 1e12.5,' cycle=',i7,' tused=',1e12.5)")
& tlim,nlim,time,nhy,tused
ifsen = 1
icode = 3
endif
c Lines below abort execution if the flag call_py has been set in pdv.src
c which will occur if more than a certain number of cells have changed rho or
c temperature since the last call to python.
#ifdef PYHYDRO
if (call_py .eq.1 ) then
ifsen=1
icode=0
write(6,"(/1x,'terminating to call python',
& /1x,'tlim=',1pe12.5,' nlim=',i7,
& /1x,'time=', 1e12.5,' cycle=',i7,' tused=',1e12.5)")
& tlim,nlim,time,nhy,tused
endif
c if (call_py .eq.2 ) then
c ifsen=1
c icode=5
c write(6,"(/1x,'terminating to call python for 1 run',
c & /1x,'tlim=',1pe12.5,' nlim=',i7,
c & /1x,'time=', 1e12.5,' cycle=',i7,' tused=',1e12.5)")
c & tlim,nlim,time,nhy,tused
c endif
#endif
if (ifsen .eq. 1) return
c
c Check for interrupt messages. If none or illegal message found
c then return
c
nchar = checkin(msg,1)
if (nchar .eq. 0) return
do i=1,14
if (msg(1:3) .eq. intmsg(i)) goto 20
enddo
c- write(6,"(1x,a3,' is not an interrupt message. Legal messages ',
c- &'are:',/1x,'sto ? pau abo tli nli dum dtd hdf dtf hst dth usr',
c- &' dtu')") msg(1:3)
return
20 continue
c
c Legal interrupt message found, process it
c
c stop command
c
if (msg(1:3) .eq. 'sto') then
write(6,"(1x,a3,': execution stopped with',
& /1x,'tlim=',1pe12.5,' nlim=',i7,
& /1x,'time=', 1e12.5,' cycle=',i7,' tused=',1e12.5)")
& msg,tlim,nlim,time,nhy,tused
icode = 2
ifsen = 1
return
endif
c
c status command
c
if (msg(1:3) .eq. '? ') then
write(6,"(1x,a3,': execution continuing with',
& /1x,'tlim=',1pe12.5,' nlim=',i7,
& /1x,'time=', 1e12.5,' cycle=',i7,' tused=',1e12.5)")
& msg,tlim,nlim,time,nhy,tused
return
endif
c
c pause command
c
if (msg(1:3) .eq. 'pau') then
write(6,"(1x,a3,': execution halted with',
& /1x,'tlim=',1pe12.5,' nlim=',i7,
& /1x,'time=', 1e12.5,' cycle=',i7,' tused=',1e12.5,
& /1x,'Hit any key to restart execution')")
& msg,tlim,nlim,time,nhy,tused
icode = 0
nchar = checkin(msg,0)
return
endif
c
c abort command
c
if (msg(1:3) .eq. 'abo') then
write(6,"(a3,': ABORT! do you really want to abort execution?',
& ' (type yes or no)')") msg
nchar = checkin(msg,0)
if (nchar .eq. 0) return
if (msg(1:3) .ne. 'yes') then
write(6,"('Abort cancelled, continuing execution ...')")
return
else
write(6,"('ABORT.................')")
stop
endif
endif
c
c reset physical time limit (tlim) command
c
if (msg(1:3) .eq. 'tli') then
call findno(msg,istrt,iend)
if (istrt .lt. 0) then
write(6,2000) msg
return
endif
call bcdflt(msg,valnew,(istrt-1),(iend-istrt+1))
if (valnew .lt. 0.0 .or. valnew .ge. huge) then
write(6,2000) msg
2000 format(1x,a3,': could not read reset number; execution ',
& 'continuing')
return
endif
tlim = valnew
write(6,"(a3,': tlim reset to ',1pe12.5)") msg,tlim
return
endif
c
c reset cycle limit (nlim) command
c
if (msg(1:3) .eq. 'nli') then
call findno(msg,istrt,iend)
if (istrt .lt. 0) then
write(6,2000) msg
return
endif
call bcdflt(msg,valnew,(istrt-1),(iend-istrt+1))
if (valnew .lt. 0.0 .or. valnew .ge. huge) then
write(6,2000) msg
return
endif
nlim = nint(valnew)
write(6,"(a3,': nlim reset to ',i12)") msg,nlim
endif
c
c turn restart dump switch on
c
if (msg(1:3) .eq. 'dum') then
write(6,"(a3,': restart dump switch on')") msg
iswres = 1
return
endif
c
c reset dump frequency (dtdump) command
c
if (msg(1:3) .eq. 'dtd') then
call findno(msg,istrt,iend)
if (istrt .lt. 0) then
write(6,2000) msg
return
endif
call bcdflt(msg,valnew,(istrt-1),(iend-istrt+1))
if (valnew .lt. 0.0 .or. valnew .ge. huge) then
write(6,2000) msg
return
endif
dtdump = valnew
write(6,"(a3,': dtdump reset to ',1pe12.5)") msg,dtdump
endif
c
c turn hdf dumps on
c
if (msg(1:3) .eq. 'hdf') then
write(6,"(a3,': hdf dump switch on')") msg
iswhdf = 1
return
endif
c
c reset hdf dump frequency (dthdf) command
c
if (msg(1:3) .eq. 'dtf') then
call findno(msg,istrt,iend)
if (istrt .lt. 0) then
write(6,2000) msg
return
endif
call bcdflt(msg,valnew,(istrt-1),(iend-istrt+1))
if (valnew .lt. 0.0 .or. valnew .ge. huge) then
write(6,2000) msg
return
endif
dthdf = valnew
write(6,"(a3,': dthdf reset to ',1pe12.5)") msg,dthdf
endif
c
c turn history dumps on
c
if (msg(1:3) .eq. 'hst') then
write(6,"(a3,': history dump switch on')") msg
iswhst = 1
return
endif
c
c reset history dump frequency (dth) command
c
if (msg(1:3) .eq. 'dth') then
call findno(msg,istrt,iend)
if (istrt .lt. 0) then
write(6,2000) msg
return
endif
call bcdflt(msg,valnew,(istrt-1),(iend-istrt+1))
if (valnew .lt. 0.0 .or. valnew .ge. huge) then
write(6,2000) msg
return
endif
dthist = valnew
write(6,"(a3,': dthist reset to ',1pe12.5)") msg,dthist
endif
c
c turn USER dumps on
c
if (msg(1:3) .eq. 'usr') then
write(6,"(a3,': USER dump switch on')") msg
iswusr = 1
return
endif
c
c reset USER dump frequency (dtu) command
c
if (msg(1:3) .eq. 'dtu') then
call findno(msg,istrt,iend)
if (istrt .lt. 0) then
write(6,2000) msg
return
endif
call bcdflt(msg,valnew,(istrt-1),(iend-istrt+1))
if (valnew .lt. 0.0 .or. valnew .ge. huge) then
write(6,2000) msg
return
endif
dtusr = valnew
write(6,"(a3,': dtusr reset to ',1pe12.5)") msg,dtusr
endif
c
return
end