ROMS
Loading...
Searching...
No Matches
stdinp_mod.F
Go to the documentation of this file.
1#include "cppdefs.h"
2 MODULE stdinp_mod
3!
4!git $Id$
5!================================================== Hernan G. Arango ===
6! Copyright (c) 2002-2025 The ROMS Group !
7! Licensed under a MIT/X style license !
8! See License_ROMS.md !
9!=======================================================================
10! !
11! This module contains several routines to read requested KeyWord !
12! parameter from ROMS standard input file. It is used to process !
13! specific parameters before the normal call to read all of them. !
14! !
15! getpar_i Reads requested integer parameter. !
16! !
17! getpar_l Reads requested logical parameter. !
18! !
19! getpar_r Reads requested floating-point (real) parameter. !
20! !
21! getpar_r Reads requested string parameter. !
22! !
23! stdinp_unit Determines input unit. If distributed-memory, it !
24! opens standard input file for reading. !
25! !
26!=======================================================================
27!
28 USE mod_kinds
30!
32 USE mod_scalars, ONLY : exit_flag
33#ifdef DISTRIBUTE
34!
35 USE distribute_mod, ONLY : mp_bcasts
36#endif
37 USE strings_mod, ONLY : founderror
38!
39 INTERFACE getpar_i
40 MODULE PROCEDURE getpar_0d_i
41 MODULE PROCEDURE getpar_1d_i
42 END INTERFACE getpar_i
43
44 INTERFACE getpar_l
45 MODULE PROCEDURE getpar_0d_l
46 MODULE PROCEDURE getpar_1d_l
47 END INTERFACE getpar_l
48
49 INTERFACE getpar_r
50 MODULE PROCEDURE getpar_0d_r
51 MODULE PROCEDURE getpar_1d_r
52 END INTERFACE getpar_r
53
54 INTERFACE getpar_s
55 MODULE PROCEDURE getpar_0d_s
56 END INTERFACE getpar_s
57!
58 PUBLIC :: getpar_i
59 PUBLIC :: getpar_l
60 PUBLIC :: getpar_r
61 PUBLIC :: getpar_s
62 PUBLIC :: stdinp_unit
63 PRIVATE
64!
65 CONTAINS
66!
67 FUNCTION stdinp_unit (MyMaster, GotFile) RESULT (InpUnit)
68!
69!***********************************************************************
70! !
71! This function determines ROMS standard input unit to process its !
72! parameters. If distributed-memory, it gets standard input filename !
73! and open it for processing. !
74! !
75! On Input: !
76! !
77! MyMaster Switch indicating Master process (logical) !
78! !
79! On Output: !
80! !
81! GotFile Standard input filename is known (logical) !
82! !
83!***********************************************************************
84!
85! Imported variable declarations.
86!
87 logical, intent(in) :: mymaster
88 logical, intent(out) :: gotfile
89!
90! Local variable declararions
91!
92 integer :: inpunit, io_err
93!
94 character (len=256) :: io_errmsg
95 character (len=*), parameter :: myfile = &
96 & __FILE__//", stdout_unit"
97!
98 sourcefile=myfile
99!
100!-----------------------------------------------------------------------
101! Determine ROMS standard input unit.
102!-----------------------------------------------------------------------
103#ifdef DISTRIBUTE
104! The ROMS standard input 'roms.in' script filename (Iname) is read
105! from the execution command and opened as a regular formatted file in
106! distributed-memory configurations using the 'my_getarg' function.
107! Then, it is read and processed by all parallel nodes to avoid complex
108! broadcasting of the ROMS input parameters to all nodes.
109# ifdef MODEL_COUPLING
110! During native ROMS ESM coupling, the execution command uses the
111! input script 'coupling.in', and the Iname filename is assigned
112! elsewhere during the coupling configuration.
113# endif
114# ifdef JEDI
115! In the ROMSJEDI interface, the Iname filename is processed from the
116! input configuration YAML file.
117# endif
118!
119 inpunit=1
120 io_err=0
121# if !(defined MODEL_COUPLING || defined JEDI)
122 IF (mymaster) CALL my_getarg (1, iname)
123 CALL mp_bcasts (1, 1, iname)
124# endif
125 OPEN (inpunit, file=trim(iname), form='formatted', status='old', &
126 & iostat=io_err, iomsg=io_errmsg)
127 IF (io_err.ne.0) THEN
128 IF (mymaster) WRITE (stdout,10) trim(io_errmsg)
129 exit_flag=2
130 RETURN
131 ELSE
132 gotfile=.true.
133 END IF
134#else
135!
136! The ROMS stardard input file is read from Fortran default standard
137! input unit.
138!
139 inpunit=stdinp
140 gotfile=.false.
141#endif
142!
143 10 FORMAT (/,' STDINP_UNIT - Unable to open ROMS input script', &
144 & ' file.',/, &
145 & /,11x,'ERROR: ',a,/, &
146 & /,11x,'In distributed-memory applications, the input', &
147 & /,11x,'script file is processed in parallel. The Unix', &
148 & /,11x,'routine GETARG is used to get script file name.', &
149 & /,11x,'For example, in MPI applications make sure that', &
150 & /,11x,'command line is something like:',/, &
151 & /,11x,'mpirun -np 4 romsM roms.in',/,/,11x,'and not',/, &
152 & /,11x,'mpirun -np 4 romsM < roms.in',/)
153!
154 END FUNCTION stdinp_unit
155!
156 SUBROUTINE getpar_0d_i (MyMaster, Value, KeyWord, InpName)
157!
158!***********************************************************************
159! !
160! Reads a scalar integer parameter from ROMS standard input file. !
161! !
162! On Input: !
163! !
164! MyMaster Switch indicating Master process (logical) !
165! KeyWord Keyword associated with input parameter (string) !
166! InpName Standard input filename (string; OPTIONAL) !
167! !
168! On Output: !
169! !
170! Value Standard input parameter value (integer) !
171! !
172!***********************************************************************
173!
174! Imported variable declarations.
175!
176 logical, intent(in) :: MyMaster
177!
178 integer, intent(out) :: Value
179!
180 character (len=*), intent(in) :: KeyWord
181 character (len=*), intent(in), optional :: InpName
182!
183! Local variable declarations.
184!
185 logical :: foundit, GotFile
186!
187 integer :: InpUnit, Npts, Nval, io_err, status
188 integer :: Ivalue(1)
189!
190 real(dp), dimension(nRval) :: Rval
191!
192 character (len= 40) :: string
193 character (len=256) :: io_errmsg, line
194 character (len=256), dimension(nCval) :: Cval
195!
196!-----------------------------------------------------------------------
197! Read requested ROMS standard input integer parameter.
198!-----------------------------------------------------------------------
199!
200! Get standard input unit.
201!
202 io_err=0
203 IF (PRESENT(inpname)) THEN
204 inpunit=1
205 OPEN (inpunit, file=trim(inpname), form='formatted', &
206 & status='old', iostat=io_err, iomsg=io_errmsg)
207 IF (io_err.ne.0) THEN
208 IF (mymaster) WRITE (stdout,10) trim(inpname), &
209 & trim(io_errmsg)
210 10 FORMAT (/,' GETPAR_0D_I - Unable to open input script: ',a, &
211 & /,15x,'ERROR: ',a)
212 exit_flag=2
213 RETURN
214 ELSE
215 gotfile=.true.
216 END IF
217 ELSE
218 inpunit=stdinp_unit(mymaster, gotfile)
219 END IF
220!
221! Process requested parameter.
222!
223 foundit=.false.
224 DO WHILE (.true.)
225 READ (inpunit,'(a)',err=20,END=40) line
226 status=decode_line(line, string, nval, cval, rval)
227 IF (status.gt.0) THEN
228 IF (trim(string).eq.trim(keyword)) THEN
229 npts=load_i(nval, rval, 1, ivalue)
230 Value=ivalue(1)
231 foundit=.true.
232 END IF
233 END IF
234 END DO
235 20 IF (mymaster) THEN
236 WRITE (stdout,30) line
237 30 FORMAT (/,' GETPAR_0D_I - Error while processing line: ',/,a)
238 END IF
239 exit_flag=4
240 40 CONTINUE
241 IF (.not.foundit) THEN
242 IF (mymaster) THEN
243 WRITE (stdout,50) trim(keyword)
244 50 FORMAT (/,' GETPAR_0D_I - unable to find KeyWord: ',a, &
245 & /,15x,'in ROMS standard input file.')
246 END IF
247 exit_flag=5
248 END IF
249 IF (gotfile) THEN
250 CLOSE (inpunit)
251 END IF
252!
253 RETURN
254 END SUBROUTINE getpar_0d_i
255!
256 SUBROUTINE getpar_1d_i (MyMaster, Ndim, Value, KeyWord, InpName)
257!
258!***********************************************************************
259! !
260! Reads a 1D integer parameter from ROMS standard input file. !
261! !
262! On Input: !
263! !
264! MyMaster Switch indicating Master process (logical) !
265! Ndim Size integer variable dimension !
266! KeyWord Keyword associated with input parameter (string) !
267! InpName Standard input filename (string; OPTIONAL) !
268! !
269! On Output: !
270! !
271! Value Standard input parameter value (integer 1D array) !
272! !
273!***********************************************************************
274!
275! Imported variable declarations.
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! Local variable declarations.
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! Read requested ROMS standard input 1D integer parameter.
299!-----------------------------------------------------------------------
300!
301! Get standard input unit.
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! Process requested parameter.
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
354 END SUBROUTINE getpar_1d_i
355!
356 SUBROUTINE getpar_0d_l (MyMaster, Value, KeyWord, InpName)
357!
358!***********************************************************************
359! !
360! Reads a scalar logical parameter from ROMS standard input file. !
361! !
362! On Input: !
363! !
364! MyMaster Switch indicating Master process (logical) !
365! KeyWord Keyword associated with input parameter (string) !
366! InpName Standard input filename (string; OPTIONAL) !
367! !
368! On Output: !
369! !
370! Value Standard input parameter value (logical) !
371! !
372!***********************************************************************
373!
374! Imported variable declarations.
375!
376 logical, intent(in) :: MyMaster
377 logical, intent(out) :: Value
378!
379 character (len=*), intent(in) :: KeyWord
380 character (len=*), intent(in), optional :: InpName
381!
382! Local variable declarations.
383!
384 logical :: foundit, GotFile
385 logical :: Lvalue(1)
386!
387 integer :: InpUnit, Npts, Nval, io_err, status
388!
389 real(dp), dimension(nRval) :: Rval
390!
391 character (len= 40) :: string
392 character (len=256) :: io_errmsg, line
393 character (len=256), dimension(nCval) :: Cval
394!
395!-----------------------------------------------------------------------
396! Read requested ROMS standard input logical parameter.
397!-----------------------------------------------------------------------
398!
399! Get standard input unit.
400!
401 io_err=0
402 IF (PRESENT(inpname)) THEN
403 inpunit=1
404 OPEN (inpunit, file=trim(inpname), form='formatted', &
405 & status='old', iostat=io_err, iomsg=io_errmsg)
406 IF (io_err.ne.0) THEN
407 IF (mymaster) WRITE (stdout,10) trim(inpname), &
408 & trim(io_errmsg)
409 10 FORMAT (/,' GETPAR_0D_L - Unable to open input script: ',a, &
410 & /,15x,'ERROR: ',a)
411 exit_flag=5
412 RETURN
413 ELSE
414 gotfile=.true.
415 END IF
416 ELSE
417 inpunit=stdinp_unit(mymaster, gotfile)
418 END IF
419!
420! Process requested parameter.
421!
422 foundit=.false.
423 DO WHILE (.true.)
424 READ (inpunit,'(a)',err=20,END=40) line
425 status=decode_line(line, string, nval, cval, rval)
426 IF (status.gt.0) THEN
427 IF (trim(string).eq.trim(keyword)) THEN
428 npts=load_l(nval, cval, 1, lvalue)
429 Value=lvalue(1)
430 foundit=.true.
431 END IF
432 END IF
433 END DO
434 20 IF (mymaster) THEN
435 WRITE (stdout,30) line
436 30 FORMAT (/,' GETPAR_0D_L - Error while processing line: ',/,a)
437 END IF
438 exit_flag=4
439 40 CONTINUE
440 IF (.not.foundit) THEN
441 IF (mymaster) THEN
442 WRITE (stdout,50) trim(keyword)
443 50 FORMAT (/,' GETPAR_0D_L - unable to find KeyWord: ',a, &
444 & /,15x,'in ROMS standard input file.')
445 END IF
446 exit_flag=5
447 END IF
448 IF (gotfile) THEN
449 CLOSE (inpunit)
450 END IF
451!
452 RETURN
453 END SUBROUTINE getpar_0d_l
454!
455 SUBROUTINE getpar_1d_l (MyMaster, Ndim, Value, KeyWord, InpName)
456!
457!***********************************************************************
458! !
459! Reads a 1D logical parameter from ROMS standard input file. !
460! !
461! On Input: !
462! !
463! MyMaster Switch indicating Master process (logical) !
464! Ndim Size logical variable dimension !
465! KeyWord Keyword associated with input parameter (string) !
466! InpName Standard input filename (string; OPTIONAL) !
467! !
468! On Output: !
469! !
470! Value Standard input parameter value (logical 1D array) !
471! !
472!***********************************************************************
473!
474! Imported variable declarations.
475!
476 logical, intent(in) :: MyMaster
477 logical, intent(out) :: Value(:)
478!
479 integer, intent(in) :: Ndim
480!
481 character (len=*), intent(in) :: KeyWord
482 character (len=*), intent(in), optional :: InpName
483!
484! Local variable declarations.
485!
486 logical :: foundit, GotFile
487!
488 integer :: InpUnit, Npts, Nval, io_err, status
489!
490 real(dp), dimension(nRval) :: Rval
491!
492 character (len= 40) :: string
493 character (len=256) :: io_errmsg, line
494 character (len=256), dimension(nCval) :: Cval
495!
496!-----------------------------------------------------------------------
497! Read requested ROMS standard input 1D logical parameter.
498!-----------------------------------------------------------------------
499!
500! Get standard input unit.
501!
502 io_err=0
503 IF (PRESENT(inpname)) THEN
504 inpunit=1
505 OPEN (inpunit, file=trim(inpname), form='formatted', &
506 & status='old', iostat=io_err, iomsg=io_errmsg)
507 IF (io_err.ne.0) THEN
508 IF (mymaster) WRITE (stdout,10) trim(inpname), &
509 & trim(io_errmsg)
510 10 FORMAT (/,' GETPAR_1D_L - Unable to open input script: ',a, &
511 & /,15x,'ERROR: ',a)
512 exit_flag=5
513 RETURN
514 ELSE
515 gotfile=.true.
516 END IF
517 ELSE
518 inpunit=stdinp_unit(mymaster, gotfile)
519 END IF
520!
521! Process requested parameter.
522!
523 foundit=.false.
524 DO WHILE (.true.)
525 READ (inpunit,'(a)',err=20,END=40) line
526 status=decode_line(line, string, nval, cval, rval)
527 IF (status.gt.0) THEN
528 IF (trim(string).eq.trim(keyword)) THEN
529 npts=load_l(nval, cval, ndim, Value)
530 foundit=.true.
531 END IF
532 END IF
533 END DO
534 20 IF (mymaster) THEN
535 WRITE (stdout,30) line
536 30 FORMAT (/,' GETPAR_1D_L - Error while processing line: ',/,a)
537 END IF
538 exit_flag=4
539 40 CONTINUE
540 IF (.not.foundit) THEN
541 IF (mymaster) THEN
542 WRITE (stdout,50) trim(keyword)
543 50 FORMAT (/,' GETPAR_1D_L - unable to find KeyWord: ',a, &
544 & /,15x,'in ROMS standard input file.')
545 END IF
546 exit_flag=5
547 END IF
548 IF (gotfile) THEN
549 CLOSE (inpunit)
550 END IF
551!
552 RETURN
553 END SUBROUTINE getpar_1d_l
554!
555 SUBROUTINE getpar_0d_r (MyMaster, Value, KeyWord, InpName)
556!
557!***********************************************************************
558! !
559! Reads a scalar floating-point parameter from ROMS standard input !
560! file. !
561! !
562! On Input: !
563! !
564! MyMaster Switch indicating Master process (logical) !
565! KeyWord Keyword associated with input parameter (string) !
566! InpName Standard input filename (string; OPTIONAL) !
567! !
568! On Output: !
569! !
570! Value Standard input parameter value (real) !
571! !
572!***********************************************************************
573!
574! Imported variable declarations.
575!
576 logical, intent(in) :: MyMaster
577!
578 real(r8), intent(out) :: Value
579!
580 character (len=*), intent(in) :: KeyWord
581 character (len=*), intent(in), optional :: InpName
582!
583! Local variable declarations.
584!
585 logical :: foundit, GotFile
586
587 integer :: InpUnit, Npts, Nval, io_err, status
588
589 real(r8) :: Rvalue(1)
590
591 real(dp), dimension(nRval) :: Rval
592!
593 character (len= 40) :: string
594 character (len=256) :: io_errmsg, line
595 character (len=256), dimension(nCval) :: Cval
596!
597!-----------------------------------------------------------------------
598! Read requested ROMS standard input floating-point parameter.
599!-----------------------------------------------------------------------
600!
601! Get standard input unit.
602!
603 io_err=0
604 IF (PRESENT(inpname)) THEN
605 inpunit=1
606 OPEN (inpunit, file=trim(inpname), form='formatted', &
607 & status='old', iostat=io_err, iomsg=io_errmsg)
608 IF (io_err.ne.0) THEN
609 IF (mymaster) WRITE (stdout,10) trim(inpname), &
610 & trim(io_errmsg)
611 10 FORMAT (/,' GETPAR_0D_R - Unable to open input script: ',a, &
612 & /,15x,'ERROR: ',a)
613 exit_flag=5
614 RETURN
615 ELSE
616 gotfile=.true.
617 END IF
618 ELSE
619 inpunit=stdinp_unit(mymaster, gotfile)
620 END IF
621!
622! Process requested parameter.
623!
624 foundit=.false.
625 DO WHILE (.true.)
626 READ (inpunit,'(a)',err=20,END=40) line
627 status=decode_line(line, string, nval, cval, rval)
628 IF (status.gt.0) THEN
629 IF (trim(string).eq.trim(keyword)) THEN
630 npts=load_r(nval, rval, 1, rvalue)
631 Value=rvalue(1)
632 foundit=.true.
633 END IF
634 END IF
635 END DO
636 20 IF (mymaster) THEN
637 WRITE (stdout,30) line
638 30 FORMAT (/,' GETPAR_0D_R - Error while processing line: ',/,a)
639 END IF
640 exit_flag=4
641 40 CONTINUE
642 IF (.not.foundit) THEN
643 IF (mymaster) THEN
644 WRITE (stdout,50) trim(keyword)
645 50 FORMAT (/,' GETPAR_0D_R - unable to find KeyWord: ',a, &
646 & /,15x,'in ROMS standard input file.')
647 END IF
648 exit_flag=5
649 END IF
650 IF (gotfile) THEN
651 CLOSE (inpunit)
652 END IF
653!
654 RETURN
655 END SUBROUTINE getpar_0d_r
656!
657 SUBROUTINE getpar_1d_r (MyMaster, Ndim, Value, KeyWord, InpName)
658!
659!***********************************************************************
660! !
661! Reads a 1D floating-point parameter from ROMS standard input file. !
662! !
663! On Input: !
664! !
665! MyMaster Switch indicating Master process (logical) !
666! Ndim Size integer variable dimension !
667! KeyWord Keyword associated with input parameter (string) !
668! InpName Standard input filename (string; OPTIONAL) !
669! !
670! On Output: !
671! !
672! Value Standard input parameter value (real 1D array) !
673! !
674!***********************************************************************
675!
676! Imported variable declarations.
677!
678 logical, intent(in) :: MyMaster
679!
680 integer, intent(in) :: Ndim
681!
682 real(r8), intent(out) :: Value(:)
683!
684 character (len=*), intent(in) :: KeyWord
685 character (len=*), intent(in), optional :: InpName
686!
687! Local variable declarations.
688!
689 logical :: foundit, GotFile
690!
691 integer :: InpUnit, Npts, Nval, io_err, status
692!
693 real(dp), dimension(nRval) :: Rval
694!
695 character (len= 40) :: string
696 character (len=256) :: io_errmsg, line
697 character (len=256), dimension(nCval) :: Cval
698!
699!-----------------------------------------------------------------------
700! Read requested ROMS standard input 1D floating-point parameter.
701!-----------------------------------------------------------------------
702!
703! Get standard input unit.
704!
705 io_err=0
706 IF (PRESENT(inpname)) THEN
707 inpunit=1
708 OPEN (inpunit, file=trim(inpname), form='formatted', &
709 & status='old', iostat=io_err, iomsg=io_errmsg)
710 IF (io_err.ne.0) THEN
711 IF (mymaster) WRITE (stdout,10) trim(inpname), &
712 & trim(io_errmsg)
713 10 FORMAT (/,' GETPAR_1D_R - Unable to open input script: ',a, &
714 & /,15x,'ERROR: ',a)
715 exit_flag=5
716 RETURN
717 ELSE
718 gotfile=.true.
719 END IF
720 ELSE
721 inpunit=stdinp_unit(mymaster, gotfile)
722 END IF
723!
724! Process requested parameter.
725!
726 foundit=.false.
727 DO WHILE (.true.)
728 READ (inpunit,'(a)',err=20,END=40) line
729 status=decode_line(line, string, nval, cval, rval)
730 IF (status.gt.0) THEN
731 IF (trim(string).eq.trim(keyword)) THEN
732 npts=load_r(nval, rval, ndim, Value)
733 foundit=.true.
734 END IF
735 END IF
736 END DO
737 20 IF (mymaster) THEN
738 WRITE (stdout,30) line
739 30 FORMAT (/,' GETPAR_1D_R - Error while processing line: ',/,a)
740 END IF
741 exit_flag=4
742 40 CONTINUE
743 IF (.not.foundit) THEN
744 IF (mymaster) THEN
745 WRITE (stdout,50) trim(keyword)
746 50 FORMAT (/,' GETPAR_1D_R - unable to find KeyWord: ',a, &
747 & /,15x,'in ROMS standard input file.')
748 END IF
749 exit_flag=5
750 END IF
751 IF (gotfile) THEN
752 CLOSE (inpunit)
753 END IF
754!
755 RETURN
756 END SUBROUTINE getpar_1d_r
757!
758 SUBROUTINE getpar_0d_s (MyMaster, Value, KeyWord, InpName)
759!
760!***********************************************************************
761! !
762! Reads a scalar string from ROMS standard input file. !
763! !
764! On Input: !
765! !
766! MyMaster Switch indicating Master process (logical) !
767! KeyWord Keyword associated with input parameter (string) !
768! InpName Standard input filename (string; OPTIONAL) !
769! !
770! On Output: !
771! !
772! Value Standard input parameter value (string) !
773! !
774!***********************************************************************
775!
776! Imported variable declarations.
777!
778 logical, intent(in) :: MyMaster
779!
780 character (len=*), intent( in) :: KeyWord
781 character (len=*), intent(out) :: Value
782 character (len=*), intent( in), optional :: InpName
783!
784! Local variable declarations.
785!
786 logical :: foundit, GotFile
787!
788 integer :: InpUnit, Npts, Nval, i, io_err, status
789!
790 real(dp), dimension(nRval) :: Rval
791!
792 character (len=1 ), parameter :: blank = ' '
793 character (len= 40) :: string
794 character (len=256) :: io_errmsg, line
795 character (len=256), dimension(nCval) :: Cval
796!
797!-----------------------------------------------------------------------
798! Read requested ROMS standard input integer parameter.
799!-----------------------------------------------------------------------
800!
801! Get standard input unit.
802!
803 io_err=0
804 IF (PRESENT(inpname)) THEN
805 inpunit=1
806 OPEN (inpunit, file=trim(inpname), form='formatted', &
807 & status='old', iostat=io_err, iomsg=io_errmsg)
808 IF (io_err.ne.0) THEN
809 IF (mymaster) WRITE (stdout,10) trim(inpname), &
810 & trim(io_errmsg)
811 10 FORMAT (/,' GETPAR_0D_S - Unable to open input script: ',a, &
812 & /,15x,'ERROR: ',a)
813 exit_flag=5
814 RETURN
815 ELSE
816 gotfile=.true.
817 END IF
818 ELSE
819 inpunit=stdinp_unit(mymaster, gotfile)
820 END IF
821!
822! Process requested parameter.
823!
824 foundit=.false.
825 DO WHILE (.true.)
826 READ (inpunit,'(a)',err=20,END=40) line
827 status=decode_line(line, string, nval, cval, rval)
828 IF (status.gt.0) THEN
829 IF (trim(string).eq.trim(keyword)) THEN
830 DO i=1,len(Value)
831 value(i:i)=blank
832 END DO
833 Value=trim(adjustl(cval(nval)))
834 foundit=.true.
835 END IF
836 END IF
837 END DO
838 20 IF (mymaster) THEN
839 WRITE (stdout,30) line
840 30 FORMAT (/,' GETPAR_0D_S - Error while processing line: ',/,a)
841 END IF
842 exit_flag=4
843 40 CONTINUE
844 IF (.not.foundit) THEN
845 IF (mymaster) THEN
846 WRITE (stdout,50) trim(keyword)
847 50 FORMAT (/,' GETPAR_0D_S - unable to find KeyWord: ',a, &
848 & /,15x,'in ROMS standard input file.')
849 END IF
850 exit_flag=5
851 END IF
852 IF (gotfile) THEN
853 CLOSE (inpunit)
854 END IF
855!
856 RETURN
857 END SUBROUTINE getpar_0d_s
858!
859 END MODULE stdinp_mod
subroutine my_getarg(iarg, carg)
Definition mp_routines.F:28
integer function decode_line(line_text, keyword, nval, cval, rval)
Definition inp_decode.F:97
integer stdinp
type(t_io), dimension(:), allocatable err
character(len=256) iname
integer stdout
character(len=256) sourcefile
integer exit_flag
subroutine getpar_0d_s(mymaster, value, keyword, inpname)
Definition stdinp_mod.F:759
subroutine getpar_1d_i(mymaster, ndim, value, keyword, inpname)
Definition stdinp_mod.F:257
integer function, public stdinp_unit(mymaster, gotfile)
Definition stdinp_mod.F:68
subroutine getpar_0d_l(mymaster, value, keyword, inpname)
Definition stdinp_mod.F:357
subroutine getpar_0d_i(mymaster, value, keyword, inpname)
Definition stdinp_mod.F:157
subroutine getpar_1d_l(mymaster, ndim, value, keyword, inpname)
Definition stdinp_mod.F:456
subroutine getpar_1d_r(mymaster, ndim, value, keyword, inpname)
Definition stdinp_mod.F:658
subroutine getpar_0d_r(mymaster, value, keyword, inpname)
Definition stdinp_mod.F:556
logical function, public founderror(flag, noerr, line, routine)
Definition strings.F:52