257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277 logical, intent(in) :: MyMaster
278
279 integer, intent(in) :: Ndim
280 integer, intent(out) :: Value(:)
281
282 character (len=*), intent(in) :: KeyWord
283 character (len=*), intent(in), optional :: InpName
284
285
286
287 logical :: foundit, GotFile
288
289 integer :: InpUnit, Npts, Nval, io_err, status
290
291 real(dp), dimension(nRval) :: Rval
292
293 character (len= 40) :: string
294 character (len=256) :: io_errmsg, line
295 character (len=256), dimension(nCval) :: Cval
296
297
298
299
300
301
302
303 io_err=0
304 IF (PRESENT(inpname)) THEN
305 inpunit=1
306 OPEN (inpunit, file=trim(inpname), form='formatted', &
307 & status='old', iostat=io_err, iomsg=io_errmsg)
308 IF (io_err.ne.0) THEN
309 IF (mymaster) WRITE (stdout,10) trim(inpname), &
310 & trim(io_errmsg)
311 10 FORMAT (/,' GETPAR_1D_I - Unable to open input script: ',a, &
312 & /,15x,'ERROR: ',a)
313 exit_flag=5
314 RETURN
315 ELSE
316 gotfile=.true.
317 END IF
318 ELSE
319 inpunit=stdinp_unit(mymaster, gotfile)
320 END IF
321
322
323
324 foundit=.false.
325 DO WHILE (.true.)
326 READ (inpunit,'(a)',err=20,END=40) line
327 status=decode_line(line, string, nval, cval, rval)
328 IF (status.gt.0) THEN
329 IF (trim(string).eq.trim(keyword)) THEN
330 npts=load_i(nval, rval, ndim, Value)
331 foundit=.true.
332 END IF
333 END IF
334 END DO
335 20 IF (mymaster) THEN
336 WRITE (stdout,30) line
337 30 FORMAT (/,' GETPAR_1D_I - Error while processing line: ',/,a)
338 END IF
339 exit_flag=4
340 40 CONTINUE
341 IF (.not.foundit) THEN
342 IF (mymaster) THEN
343 WRITE (stdout,50) trim(keyword)
344 50 FORMAT (/,' GETPAR_1D_I - unable to find KeyWord: ',a, &
345 & /,15x,'in ROMS standard input file.')
346 END IF
347 exit_flag=5
348 END IF
349 IF (gotfile) THEN
350 CLOSE (inpunit)
351 END IF
352
353 RETURN