48 use mom_coms, only : root_pe, broadcast
51 use mom_time_manager, only : set_time, get_time, time_type, get_ticks_per_second
58 implicit none ;
private 76 integer :: num_lines = 0
77 character(len=INPUT_STR_LENGTH),
pointer,
dimension(:) :: line => null()
78 logical,
pointer,
dimension(:) :: line_used => null()
83 character(len=80) :: name
84 logical :: hasissuedoverridewarning = .false.
88 character(len=240) :: name =
'' 107 logical :: log_open = .false.
108 integer :: stdout, stdlog
109 character(len=240) :: doc_file
146 subroutine open_param_file(filename, CS, checkable, component, doc_file_dir)
147 character(len=*),
intent(in) :: filename
149 logical,
optional,
intent(in) :: checkable
150 character(len=*),
optional,
intent(in) :: component
151 character(len=*),
optional,
intent(in) :: doc_file_dir
153 logical :: file_exists, unit_in_use, Netcdf_file, may_check
154 integer :: ios, iounit, strlen, i
155 character(len=240) :: doc_path
158 may_check = .true. ;
if (
present(checkable)) may_check = checkable
161 strlen = len_trim(filename)
162 if (strlen == 0)
then 163 call mom_error(fatal,
"open_param_file: Input file has not been specified.")
167 if (cs%nfiles > 0)
then 168 inquire(file=trim(filename), number=iounit)
169 if (iounit /= -1)
then 171 if (cs%iounit(i) == iounit)
then 172 if (trim(cs%filename(1)) /= trim(filename))
then 173 call mom_error(fatal, &
174 "open_param_file: internal inconsistency! "//trim(filename)// &
175 " is registered as open but has the wrong unit number!")
177 call mom_error(warning, &
178 "open_param_file: file "//trim(filename)// &
179 " has already been opened. This should NOT happen!"// &
180 " Did you specify the same file twice in a namelist?")
189 inquire(file=trim(filename), exist=file_exists)
190 if (.not.file_exists)
call mom_error(fatal, &
191 "open_param_file: Input file "// trim(filename)//
" does not exist.")
193 netcdf_file = .false.
195 if (filename(strlen-2:strlen) ==
".nc") netcdf_file = .true.
199 call mom_error(fatal,
"open_param_file: NetCDF files are not yet supported.")
204 INQUIRE(iounit,opened=unit_in_use) ;
if (.not.unit_in_use)
exit 206 if (iounit >= 512)
call mom_error(fatal, &
207 "open_param_file: No unused file unit could be found.")
210 open(iounit, file=trim(filename), access=
'SEQUENTIAL', &
211 form=
'FORMATTED', action=
'READ', position=
'REWIND', iostat=ios)
212 if (ios /= 0)
call mom_error(fatal,
"open_param_file: Error opening "// &
221 cs%iounit(i) = iounit
222 cs%filename(i) = filename
223 cs%NetCDF_file(i) = netcdf_file
224 allocate(block) ; block%name =
'' ; cs%blockName => block
226 call mom_mesg(
"open_param_file: "// trim(filename)// &
227 " has been opened successfully.", 5)
231 call read_param(cs,
"SEND_LOG_TO_STDOUT",cs%log_to_stdout)
232 call read_param(cs,
"REPORT_UNUSED_PARAMS",cs%report_unused)
233 call read_param(cs,
"FATAL_UNUSED_PARAMS",cs%unused_params_fatal)
234 cs%doc_file =
"MOM_parameter_doc" 235 if (
present(component)) cs%doc_file = trim(component)//
"_parameter_doc" 236 call read_param(cs,
"DOCUMENT_FILE", cs%doc_file)
237 if (.not.may_check)
then 238 cs%report_unused = .false.
239 cs%unused_params_fatal = .false.
243 cs%stdlog = stdlog() ; cs%stdout = stdout()
244 cs%log_open = (stdlog() > 0)
246 doc_path = cs%doc_file
247 if (len_trim(cs%doc_file) > 0)
then 249 call read_param(cs,
"COMPLETE_DOCUMENTATION", cs%complete_doc)
251 call read_param(cs,
"MINIMAL_DOCUMENTATION", cs%minimal_doc)
252 if (
present(doc_file_dir))
then ;
if (len_trim(doc_file_dir) > 0)
then 253 doc_path = trim(slasher(doc_file_dir))//trim(cs%doc_file)
256 cs%complete_doc = .false.
257 cs%minimal_doc = .false.
259 call doc_init(doc_path, cs%doc, cs%minimal_doc, cs%complete_doc)
265 logical,
optional,
intent(in) :: quiet_close
266 character(len=*),
optional,
intent(in) :: component
271 #include "version_variable.h" 272 character(len=128) :: docfile_default
273 character(len=40) :: mdl
274 integer :: i, n, num_unused
276 if (
present(quiet_close))
then ;
if (quiet_close)
then 279 call mom_mesg(
"close_param_file: "// trim(cs%filename(i))// &
280 " has been closed successfully.", 5)
283 cs%NetCDF_file(i) = .false.
284 deallocate (cs%param_data(i)%line)
285 deallocate (cs%param_data(i)%line_used)
287 cs%log_open = .false.
293 mdl =
"MOM_file_parser" 295 call log_param(cs, mdl,
"SEND_LOG_TO_STDOUT", &
297 "If true, all log messages are also sent to stdout.", &
299 call log_param(cs, mdl,
"REPORT_UNUSED_PARAMS", &
301 "If true, report any parameter lines that are not used \n"//&
303 call log_param(cs, mdl,
"FATAL_UNUSED_PARAMS", &
304 cs%unused_params_fatal, &
305 "If true, kill the run if there are any unused \n"//&
307 docfile_default =
"MOM_parameter_doc" 308 if (
present(component)) docfile_default = trim(component)//
"_parameter_doc" 309 call log_param(cs, mdl,
"DOCUMENT_FILE", cs%doc_file, &
310 "The basename for files where run-time parameters, their\n"//&
311 "settings, units and defaults are documented. Blank will\n"//&
312 "disable all parameter documentation.", default=docfile_default)
313 if (len_trim(cs%doc_file) > 0)
then 314 call log_param(cs, mdl,
"COMPLETE_DOCUMENTATION", &
316 "If true, all run-time parameters are\n"//&
317 "documented in "//trim(cs%doc_file)//&
319 call log_param(cs, mdl,
"MINIMAL_DOCUMENTATION", &
321 "If true, non-default run-time parameters are\n"//&
322 "documented in "//trim(cs%doc_file)//&
328 if (
is_root_pe() .and. (cs%report_unused .or. &
329 cs%unused_params_fatal))
then 331 do n=1,cs%param_data(i)%num_lines
332 if (.not.cs%param_data(i)%line_used(n))
then 333 num_unused = num_unused + 1
334 if (cs%report_unused) &
335 call mom_error(warning,
"Unused line in "//trim(cs%filename(i))// &
336 " : "//trim(cs%param_data(i)%line(n)))
342 call mom_mesg(
"close_param_file: "// trim(cs%filename(i))// &
343 " has been closed successfully.", 5)
346 cs%NetCDF_file(i) = .false.
347 deallocate (cs%param_data(i)%line)
348 deallocate (cs%param_data(i)%line_used)
351 if (
is_root_pe() .and. (num_unused>0) .and. cs%unused_params_fatal) &
352 call mom_error(fatal,
"Run stopped because of unused parameter lines.")
354 cs%log_open = .false.
360 integer,
intent(in) :: iounit
361 character(len=*),
intent(in) :: filename
364 character(len=INPUT_STR_LENGTH) :: line
366 logical :: inMultiLineComment
372 if (iounit <= 0)
return 380 inmultilinecomment = .false.
382 read(iounit,
'(a)', end=8, err=9) line
384 if (inmultilinecomment)
then 394 call mom_error(fatal,
'MOM_file_parser : A C-style multi-line comment '// &
395 '(/* ... */) was not closed before the end of '//trim(filename))
398 param_data%num_lines = num_lines
403 call broadcast(param_data%num_lines, root_pe())
407 num_lines = param_data%num_lines
408 allocate (param_data%line(num_lines))
409 allocate (param_data%line_used(num_lines))
410 param_data%line(:) =
' ' 411 param_data%line_used(:) = .false.
421 read(iounit,
'(a)', end=18, err=9) line
423 if (inmultilinecomment)
then 429 num_lines = num_lines + 1
430 param_data%line(num_lines) = line
437 if (num_lines /= param_data%num_lines) &
438 call mom_error(fatal,
'MOM_file_parser : Found different number of '// &
439 'valid lines on second reading of '//trim(filename))
449 9
call mom_error(fatal,
"MOM_file_parser : "//&
450 "Error while reading file "//trim(filename))
455 character(len=*),
intent(in) :: string
456 logical :: openMultiLineComment
458 integer :: icom, last
459 openmultilinecomment = .false.
461 icom = index(string(last:),
"/*")
463 openmultilinecomment=.true.
466 icom = index(string(last:),
"*/") ;
if (icom > 0) openmultilinecomment=.false.
470 character(len=*),
intent(in) :: string
471 logical :: closeMultiLineComment
473 closemultilinecomment = .false.
474 if (index(string,
"*/")>0) closemultilinecomment=.true.
478 character(len=*),
intent(in) :: string
479 integer :: lastNonCommentIndex
482 integer :: icom, last
483 last = len_trim(string)
484 icom = index(string(:last),
"!") ;
if (icom > 0) last = icom-1
485 icom = index(string(:last),
"//") ;
if (icom > 0) last = icom-1
486 icom = index(string(:last),
"/*") ;
if (icom > 0) last = icom-1
487 lastnoncommentindex = last
491 character(len=*),
intent(in) :: string
492 integer :: lastNonCommentNonBlank
498 character(len=*),
intent(in) :: string
499 character(len=len(string)) :: replaceTabs
503 if (string(i:i)==achar(9))
then 506 replacetabs(i:i)=string(i:i)
512 character(len=*),
intent(in) :: string
513 character(len=len(string)) :: removeComments
516 removecomments=repeat(
" ",len(string))
518 removecomments(:last)=adjustl(string(:last))
522 character(len=*),
intent(in) :: string
523 character(len=len(string)+16) :: simplifyWhiteSpace
527 logical :: nonBlank = .false., insidestring = .false.
528 character(len=1) :: quoteChar=
" " 529 nonblank = .false.; insidestring = .false.
531 simplifywhitespace=repeat(
" ",len(string)+16)
532 do j=1,len_trim(string)
533 if (insidestring)
then 535 simplifywhitespace(i:i)=string(j:j)
536 if (string(j:j)==quotechar) insidestring=.false.
538 if (string(j:j)==
" " .or. string(j:j)==achar(9))
then 541 simplifywhitespace(i:i)=
" " 544 elseif (string(j:j)==
'"' .or. string(j:j)==
"'")
then 546 simplifywhitespace(i:i)=string(j:j)
548 quotechar=string(j:j)
550 elseif (string(j:j)==
'=')
then 554 simplifywhitespace(i:i)=
" " 557 simplifywhitespace(i-1:i)=string(j:j)//
" " 561 simplifywhitespace(i:i)=string(j:j)
566 if (insidestring)
then 568 "There is a mismatched quote in the parameter file line: "// &
575 character(len=*),
intent(in) :: varname
576 integer,
intent(inout) :: value
577 logical,
optional,
intent(in) :: fail_if_missing
583 character(len=INPUT_STR_LENGTH) :: value_string(1)
584 logical :: found, defined
587 if (found .and. defined .and. (len_trim(value_string(1)) > 0))
then 588 read(value_string(1),*,err = 1001)
value 590 if (
present(fail_if_missing))
then ;
if (fail_if_missing)
then 592 call mom_error(fatal,
'read_param_int: Unable to find variable '//trim(varname)// &
593 ' in any input files.')
595 call mom_error(fatal,
'read_param_int: Variable '//trim(varname)// &
596 ' found but not set in input files.')
601 1001
call mom_error(fatal,
'read_param_int: read error for integer variable '//trim(varname)// &
602 ' parsing "'//trim(value_string(1))//
'"')
607 character(len=*),
intent(in) :: varname
608 integer,
intent(inout) ::
value(:)
609 logical,
optional,
intent(in) :: fail_if_missing
615 character(len=INPUT_STR_LENGTH) :: value_string(1)
616 logical :: found, defined
619 if (found .and. defined .and. (len_trim(value_string(1)) > 0))
then 620 read(value_string(1),*,end=991,err=1002)
value 623 if (
present(fail_if_missing))
then ;
if (fail_if_missing)
then 625 call mom_error(fatal,
'read_param_int_array: Unable to find variable '//trim(varname)// &
626 ' in any input files.')
628 call mom_error(fatal,
'read_param_int_array: Variable '//trim(varname)// &
629 ' found but not set in input files.')
634 1002
call mom_error(fatal,
'read_param_int_array: read error for integer array '//trim(varname)// &
635 ' parsing "'//trim(value_string(1))//
'"')
640 character(len=*),
intent(in) :: varname
641 real,
intent(inout) :: value
642 logical,
optional,
intent(in) :: fail_if_missing
648 character(len=INPUT_STR_LENGTH) :: value_string(1)
649 logical :: found, defined
652 if (found .and. defined .and. (len_trim(value_string(1)) > 0))
then 653 read(value_string(1),*,err=1003)
value 655 if (
present(fail_if_missing))
then ;
if (fail_if_missing)
then 657 call mom_error(fatal,
'read_param_real: Unable to find variable '//trim(varname)// &
658 ' in any input files.')
660 call mom_error(fatal,
'read_param_real: Variable '//trim(varname)// &
661 ' found but not set in input files.')
666 1003
call mom_error(fatal,
'read_param_real: read error for real variable '//trim(varname)// &
667 ' parsing "'//trim(value_string(1))//
'"')
672 character(len=*),
intent(in) :: varname
673 real,
intent(inout) ::
value(:)
674 logical,
optional,
intent(in) :: fail_if_missing
680 character(len=INPUT_STR_LENGTH) :: value_string(1)
681 logical :: found, defined
684 if (found .and. defined .and. (len_trim(value_string(1)) > 0))
then 685 read(value_string(1),*,end=991,err=1004)
value 688 if (
present(fail_if_missing))
then ;
if (fail_if_missing)
then 690 call mom_error(fatal,
'read_param_real_array: Unable to find variable '//trim(varname)// &
691 ' in any input files.')
693 call mom_error(fatal,
'read_param_real_array: Variable '//trim(varname)// &
694 ' found but not set in input files.')
699 1004
call mom_error(fatal,
'read_param_real_array: read error for real array '//trim(varname)// &
700 ' parsing "'//trim(value_string(1))//
'"')
705 character(len=*),
intent(in) :: varname
706 character(len=*),
intent(inout) :: value
707 logical,
optional,
intent(in) :: fail_if_missing
713 character(len=INPUT_STR_LENGTH) :: value_string(1)
714 logical :: found, defined
719 elseif (
present(fail_if_missing))
then ;
if (fail_if_missing)
then 720 call mom_error(fatal,
'Unable to find variable '//trim(varname)// &
721 ' in any input files.')
728 character(len=*),
intent(in) :: varname
729 character(len=*),
intent(inout) ::
value(:)
730 logical,
optional,
intent(in) :: fail_if_missing
736 character(len=INPUT_STR_LENGTH) :: value_string(1), loc_string
737 logical :: found, defined
742 loc_string = trim(value_string(1))
743 i = index(loc_string,
",")
748 loc_string = trim(adjustl(loc_string(i+1:)))
749 i = index(loc_string,
",")
751 if (len_trim(loc_string)>0)
then 755 do i=i_out,
SIZE(
value) ; value(i) =
" " ;
enddo 756 elseif (
present(fail_if_missing))
then ;
if (fail_if_missing)
then 757 call mom_error(fatal,
'Unable to find variable '//trim(varname)// &
758 ' in any input files.')
765 character(len=*),
intent(in) :: varname
766 logical,
intent(inout) :: value
767 logical,
optional,
intent(in) :: fail_if_missing
773 character(len=INPUT_STR_LENGTH) :: value_string(1)
774 logical :: found, defined
776 call get_variable_line(cs, varname, found, defined, value_string, paramislogical=.true.)
779 elseif (
present(fail_if_missing))
then ;
if (fail_if_missing)
then 780 call mom_error(fatal,
'Unable to find variable '//trim(varname)// &
781 ' in any input files.')
786 subroutine read_param_time(CS, varname, value, timeunit, fail_if_missing, date_format)
788 character(len=*),
intent(in) :: varname
789 type(time_type),
intent(inout) :: value
790 real,
optional,
intent(in) :: timeunit
791 logical,
optional,
intent(in) :: fail_if_missing
792 logical,
optional,
intent(out) :: date_format
799 character(len=INPUT_STR_LENGTH) :: value_string(1)
800 character(len=240) :: err_msg
801 logical :: found, defined
802 real :: real_time, time_unit
803 integer :: days, secs, vals(7)
805 if (
present(date_format)) date_format = .false.
808 if (found .and. defined .and. (len_trim(value_string(1)) > 0))
then 811 if ((index(value_string(1),
'-') > 0) .and. &
812 (index(value_string(1),
'-',back=.true.) > index(value_string(1),
'-')))
then 814 value = set_date(value_string(1), err_msg=err_msg)
815 if (len_trim(err_msg) > 0)
call mom_error(fatal,
'read_param_time: '//&
816 trim(err_msg)//
' in integer list read error for time-type variable '//&
817 trim(varname)//
' parsing "'//trim(value_string(1))//
'"')
818 if (
present(date_format)) date_format = .true.
819 elseif (index(value_string(1),
',') > 0)
then 821 vals(:) = (/ -999, -999, -999, 0, 0, 0, 0 /)
822 read(value_string(1),*,end=995,err=1005) vals
824 if ((vals(1) < 0) .or. (vals(2) < 0) .or. (vals(3) < 0)) &
825 call mom_error(fatal,
'read_param_time: integer list read error for time-type variable '//&
826 trim(varname)//
' parsing "'//trim(value_string(1))//
'"')
827 value = set_date(vals(1), vals(2), vals(3), vals(4), vals(5), vals(6), &
828 vals(7), err_msg=err_msg)
829 if (len_trim(err_msg) > 0)
call mom_error(fatal,
'read_param_time: '//&
830 trim(err_msg)//
' in integer list read error for time-type variable '//&
831 trim(varname)//
' parsing "'//trim(value_string(1))//
'"')
832 if (
present(date_format)) date_format = .true.
834 time_unit = 1.0 ;
if (
present(timeunit)) time_unit = timeunit
835 read( value_string(1), *) real_time
836 days = int(real_time*(time_unit/86400.0))
837 secs = int(floor((real_time*(time_unit/86400.0)-days)*86400.0 + 0.5))
838 value = set_time(secs, days)
841 if (
present(fail_if_missing))
then ;
if (fail_if_missing)
then 843 call mom_error(fatal,
'Unable to find variable '//trim(varname)// &
844 ' in any input files.')
846 call mom_error(fatal,
'Variable '//trim(varname)// &
847 ' found but not set in input files.')
852 1005
call mom_error(fatal,
'read_param_time: read error for time-type variable '//&
853 trim(varname)//
' parsing "'//trim(value_string(1))//
'"')
857 character(len=*) :: val_str
858 character(len=INPUT_STR_LENGTH) :: strip_quotes
861 strip_quotes = val_str
862 i = index(strip_quotes,achar(34))
864 if (i > 1)
then ; strip_quotes = strip_quotes(:i-1)//strip_quotes(i+1:)
865 else ; strip_quotes = strip_quotes(2:) ;
endif 866 i = index(strip_quotes,achar(34))
868 i = index(strip_quotes,achar(39))
870 if (i > 1)
then ; strip_quotes = strip_quotes(:i-1)//strip_quotes(i+1:)
871 else ; strip_quotes = strip_quotes(2:) ;
endif 872 i = index(strip_quotes,achar(39))
876 subroutine get_variable_line(CS, varname, found, defined, value_string, paramIsLogical)
878 character(len=*),
intent(in) :: varname
879 logical,
intent(out) :: found, defined
880 character(len=*),
intent(out) :: value_string(:)
881 logical,
optional,
intent(in) :: paramIsLogical
883 character(len=INPUT_STR_LENGTH) :: val_str, lname, origLine
884 character(len=INPUT_STR_LENGTH) :: line, continuationBuffer, blockName
885 character(len=FILENAME_LENGTH) :: filename
886 integer :: is, id, isd, isu, ise, iso, verbose, ipf
887 integer :: last, last1, ival, oval, max_vals, count, contBufSize
888 character(len=52) :: set
889 logical :: found_override, found_equals
890 logical :: found_define, found_undef
891 logical :: force_cycle, defined_in_line, continuedLine
892 logical :: variableKindIsLogical, valueIsSame
893 logical :: inWrongBlock, fullPathParameter
894 logical,
parameter :: requireNamedClose = .false.
895 set =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 900 variablekindislogical=.false.
901 if (
present(paramislogical)) variablekindislogical = paramislogical
908 max_vals =
SIZE(value_string)
909 do is=1,max_vals ; value_string(is) =
" " ;
enddo 911 paramfile_loop:
do ipf = 1, cs%nfiles
912 filename = cs%filename(ipf)
913 continuedline = .false.
917 do count = 1, cs%param_data(ipf)%num_lines
918 line = cs%param_data(ipf)%line(count)
919 last = len_trim(line)
924 if (line(last1:last1) == achar(92).or.line(last1:last1) ==
"&")
then 925 continuationbuffer(contbufsize+1:contbufsize+len_trim(line))=line(:last-1)
926 contbufsize=contbufsize + len_trim(line)-1
927 continuedline = .true.
928 if (count==cs%param_data(ipf)%num_lines .and.
is_root_pe()) &
929 call mom_error(fatal,
"MOM_file_parser : the last line"// &
930 " of the file ends in a continuation character but"// &
931 " there are no more lines to read. "// &
932 " Line: '"//trim(line(:last))//
"'"//&
933 " in file "//trim(filename)//
".")
935 elseif (continuedline)
then 937 continuationbuffer(contbufsize+1:contbufsize+len_trim(line))=line(:last)
938 line = continuationbuffer
941 continuedline = .false.
942 last = len_trim(line)
945 origline = trim(line)
948 found_override = .false.; found_define = .false.; found_undef = .false.
949 iso = index(line(:last),
"#override " )
950 if (iso>1)
call mom_error(fatal,
"MOM_file_parser : #override was found "// &
951 " but was not the first keyword."// &
952 " Line: '"//trim(line(:last))//
"'"//&
953 " in file "//trim(filename)//
".")
955 found_override = .true.
956 if (index(line(:last),
"#override define ")==1) found_define = .true.
957 if (index(line(:last),
"#override undef ")==1) found_undef = .true.
958 line = trim(adjustl(line(iso+10:last))); last = len_trim(line)
962 if (index(line(:last),
'&')==1)
then 963 iso=index(line(:last),
' ')
966 line=trim(adjustl(line(iso:last)))
970 if (len_trim(blockname)>0)
then 971 blockname = trim(blockname) //
'%' //trim(line(2:last))
973 blockname = trim(line(2:last))
981 iso=index(line(:last),
'%')
982 fullpathparameter = .false.
984 if (len_trim(blockname)==0 .and.
is_root_pe())
call mom_error(fatal, &
985 'get_variable_line: An extra close block was encountered. Line="'// &
986 trim(line(:last))//
'"' )
987 if (last>1 .and. trim(blockname)/=trim(line(2:last)) .and.
is_root_pe()) &
988 call mom_error(fatal,
'get_variable_line: A named close for a parameter'// &
989 ' block did not match the open block. Line="'//trim(line(:last))//
'"' )
990 if (last==1 .and. requirenamedclose) &
991 call mom_error(fatal,
'get_variable_line: A named close for a parameter'// &
992 ' block is required but found "%". Block="'//trim(blockname)//
'"' )
995 elseif (iso==last)
then 999 iso=index(line(:last),
'%',.true.)
1001 if (iso>0 .and. trim(cs%blockName%name)==trim(line(:iso-1)))
then 1002 fullpathparameter = .true.
1003 line = trim(line(iso+1:last))
1004 last = len_trim(line)
1009 inwrongblock = .false.
1010 if (len_trim(blockname)>0)
then 1011 if (trim(cs%blockName%name)/=trim(blockname)) inwrongblock = .true.
1013 if (len_trim(cs%blockName%name)>0)
then 1014 if (trim(cs%blockName%name)/=trim(blockname)) inwrongblock = .true.
1018 if (line(last:last)==
'/')
then 1019 if (len_trim(blockname)==0 .and.
is_root_pe())
call mom_error(fatal, &
1020 'get_variable_line: An extra namelist/block end was encountered. Line="'// &
1021 trim(line(:last))//
'"' )
1025 if (inwrongblock .and. .not. fullpathparameter)
then 1026 if (index(
" "//line(:last+1),
" "//trim(varname)//
" ")>0) &
1027 call mom_error(warning,
"MOM_file_parser : "//trim(varname)// &
1028 ' found outside of block '//trim(cs%blockName%name)//
'%. Ignoring.')
1033 if (index(
" "//line(:last)//
" ",
" "//trim(varname)//
" ") == 0) cycle
1036 found_equals = .false.
1037 isd = index(line(:last),
"define" )
1038 isu = index(line(:last),
"undef" )
1039 ise = index(line(:last),
" = " );
if (ise > 1) found_equals = .true.
1040 if (index(line(:last),
"#define ")==1) found_define = .true.
1041 if (index(line(:last),
"#undef ")==1) found_undef = .true.
1045 if (.not. (found_define .or. found_undef .or. found_equals)) &
1046 call mom_error(fatal,
"MOM_file_parser : the parameter name '"// &
1047 trim(varname)//
"' was found without define or undef."// &
1048 " Line: '"//trim(line(:last))//
"'"//&
1049 " in file "//trim(filename)//
".")
1050 if (found_define .and. found_undef)
call mom_error(fatal, &
1051 "MOM_file_parser : Both 'undef' and 'define' occur."// &
1052 " Line: '"//trim(line(:last))//
"'"//&
1053 " in file "//trim(filename)//
".")
1054 if (found_equals .and. (found_define .or. found_undef)) &
1055 call mom_error(fatal, &
1056 "MOM_file_parser : Both 'a=b' and 'undef/define' syntax occur."// &
1057 " Line: '"//trim(line(:last))//
"'"//&
1058 " in file "//trim(filename)//
".")
1059 if (found_override .and. .not. (found_define .or. found_undef .or. found_equals)) &
1060 call mom_error(fatal,
"MOM_file_parser : override was found "// &
1061 " without a define or undef."// &
1062 " Line: '"//trim(line(:last))//
"'"//&
1063 " in file "//trim(filename)//
".")
1067 if (found_define)
then 1069 is = isd + 5 + scan(line(isd+6:last), set)
1071 id = scan(line(is:last),
' ')
1074 lname = trim(line(is:last))
1075 if (trim(lname) /= trim(varname)) cycle
1079 lname = trim(line(is:is+id-1))
1080 if (trim(lname) /= trim(varname)) cycle
1081 val_str = trim(adjustl(line(is+id:last)))
1083 found = .true. ; defined_in_line = .true.
1084 elseif (found_undef)
then 1086 is = isu + 4 + scan(line(isu+5:last), set)
1088 id = scan(line(is:last),
' ')
1089 if (id > 0) last = is + id - 1
1090 lname = trim(line(is:last))
1091 if (trim(lname) /= trim(varname)) cycle
1093 found = .true. ; defined_in_line = .false.
1094 elseif (found_equals)
then 1096 is = scan(line(1:ise), set)
1097 lname = trim(line(is:ise-1))
1098 if (trim(lname) /= trim(varname)) cycle
1099 val_str = trim(adjustl(line(ise+3:last)))
1100 if (variablekindislogical)
then 1101 read(val_str(:len_trim(val_str)),*) defined_in_line
1103 defined_in_line = .true.
1107 call mom_error(fatal,
"MOM_file_parser (non-root PE?): the parameter name '"// &
1108 trim(varname)//
"' was found without an assignment, define or undef."// &
1109 " Line: '"//trim(line(:last))//
"'"//
" in file "//trim(filename)//
".")
1116 force_cycle = .false.
1117 valueissame = (trim(val_str) == trim(value_string(max_vals)))
1118 if (found_override .and. (oval >= max_vals))
then 1120 if ((defined_in_line .neqv. defined) .or. .not. valueissame)
then 1121 call mom_error(fatal,
"MOM_file_parser : "//trim(varname)// &
1122 " found with multiple inconsistent overrides."// &
1123 " Line A: '"//trim(value_string(max_vals))//
"'"//&
1124 " Line B: '"//trim(line(:last))//
"'"//&
1125 " in file "//trim(filename)//
" caused the model failure.")
1127 call mom_error(warning,
"MOM_file_parser : "//trim(varname)// &
1128 " over-ridden more times than is permitted."// &
1129 " Line: '"//trim(line(:last))//
"'"//&
1130 " in file "//trim(filename)//
" is being ignored.")
1133 force_cycle = .true.
1135 if (.not.found_override .and. (oval > 0))
then 1137 call mom_error(warning,
"MOM_file_parser : "//trim(varname)// &
1138 " has already been over-ridden."// &
1139 " Line: '"//trim(line(:last))//
"'"//&
1140 " in file "//trim(filename)//
" is being ignored.")
1141 force_cycle = .true.
1143 if (.not.found_override .and. (ival >= max_vals))
then 1145 if ((defined_in_line .neqv. defined) .or. .not. valueissame)
then 1146 call mom_error(fatal,
"MOM_file_parser : "//trim(varname)// &
1147 " found with multiple inconsistent definitions."// &
1148 " Line A: '"//trim(value_string(max_vals))//
"'"//&
1149 " Line B: '"//trim(line(:last))//
"'"//&
1150 " in file "//trim(filename)//
" caused the model failure.")
1152 call mom_error(warning,
"MOM_file_parser : "//trim(varname)// &
1153 " occurs more times than is permitted."// &
1154 " Line: '"//trim(line(:last))//
"'"//&
1155 " in file "//trim(filename)//
" is being ignored.")
1158 force_cycle = .true.
1160 if (force_cycle) cycle
1163 if (found_override)
then 1165 value_string(oval) = trim(val_str)
1166 defined = defined_in_line
1167 if (verbose > 0 .and. ival > 0 .and.
is_root_pe() .and. &
1169 call mom_error(warning,
"MOM_file_parser : "//trim(varname)// &
1170 " over-ridden. Line: '"//trim(line(:last))//
"'"//&
1171 " in file "//trim(filename)//
".")
1174 value_string(ival) = trim(val_str)
1175 defined = defined_in_line
1177 call mom_error(warning,
"MOM_file_parser : "//trim(varname)// &
1178 " set. Line: '"//trim(line(:last))//
"'"//&
1179 " in file "//trim(filename)//
".")
1184 if (len_trim(blockname)>0 .and.
is_root_pe())
call mom_error(fatal, &
1185 'A namelist/parameter block was not closed. Last open block appears '// &
1186 'to be "'//trim(blockname)//
'".')
1188 enddo paramfile_loop
1193 logical,
dimension(:),
pointer :: line_used
1194 integer,
intent(in) :: count
1195 line_used(count) = .true.
1200 character(len=*),
intent(in) :: varName
1201 logical :: overrideWarningHasBeenIssued
1204 overridewarninghasbeenissued = .false.
1206 do while(
associated(this) )
1207 if (trim(varname) == trim(this%name))
then 1208 overridewarninghasbeenissued = .true.
1214 newlink%name = trim(varname)
1215 newlink%hasIssuedOverrideWarning = .true.
1216 newlink%next => chain
1226 character(len=*),
intent(in) :: modulename
1227 character(len=*),
intent(in) :: version
1228 character(len=*),
optional,
intent(in) :: desc
1230 character(len=240) :: mesg
1232 mesg = trim(modulename)//
": "//trim(version)
1234 if (cs%log_open)
write(cs%stdlog,
'(a)') trim(mesg)
1235 if (cs%log_to_stdout)
write(cs%stdout,
'(a)') trim(mesg)
1238 if (
present(desc))
call doc_module(cs%doc, modulename, desc)
1244 character(len=*),
intent(in) :: modulename
1245 character(len=*),
intent(in) :: version
1247 character(len=240) :: mesg
1249 mesg = trim(modulename)//
": "//trim(version)
1251 write(stdlog(),
'(a)') trim(mesg)
1256 subroutine log_param_int(CS, modulename, varname, value, desc, units, &
1257 default, layoutParam)
1259 character(len=*),
intent(in) :: modulename
1260 character(len=*),
intent(in) :: varname
1261 integer,
intent(in) :: value
1262 character(len=*),
optional,
intent(in) :: desc, units
1263 integer,
optional,
intent(in) :: default
1264 logical,
optional,
intent(in) :: layoutParam
1267 character(len=240) :: mesg, myunits
1269 write(mesg,
'(" ",a," ",a,": ",a)') trim(modulename), trim(varname), trim(left_int(
value))
1271 if (cs%log_open)
write(cs%stdlog,
'(a)') trim(mesg)
1272 if (cs%log_to_stdout)
write(cs%stdout,
'(a)') trim(mesg)
1275 myunits=
" ";
if (
present(units))
write(myunits(1:240),
'(A)') trim(units)
1276 if (
present(desc)) &
1277 call doc_param(cs%doc, varname, desc, myunits,
value, default, &
1278 layoutparam=layoutparam)
1283 units, default, layoutParam)
1285 character(len=*),
intent(in) :: modulename
1286 character(len=*),
intent(in) :: varname
1287 integer,
intent(in) ::
value(:)
1288 character(len=*),
optional,
intent(in) :: desc, units
1289 integer,
optional,
intent(in) :: default
1290 logical,
optional,
intent(in) :: layoutParam
1293 character(len=1320) :: mesg
1294 character(len=240) :: myunits
1296 write(mesg,
'(" ",a," ",a,": ",A)') trim(modulename), trim(varname), trim(left_ints(
value))
1298 if (cs%log_open)
write(cs%stdlog,
'(a)') trim(mesg)
1299 if (cs%log_to_stdout)
write(cs%stdout,
'(a)') trim(mesg)
1302 myunits=
" ";
if (
present(units))
write(myunits(1:240),
'(A)') trim(units)
1303 if (
present(desc)) &
1304 call doc_param(cs%doc, varname, desc, myunits,
value, default, &
1305 layoutparam=layoutparam)
1309 subroutine log_param_real(CS, modulename, varname, value, desc, units, &
1312 character(len=*),
intent(in) :: modulename
1313 character(len=*),
intent(in) :: varname
1314 real,
intent(in) :: value
1315 character(len=*),
optional,
intent(in) :: desc, units
1316 real,
optional,
intent(in) :: default
1319 character(len=240) :: mesg, myunits
1321 write(mesg,
'(" ",a," ",a,": ",a)') &
1322 trim(modulename), trim(varname), trim(
left_real(
value))
1324 if (cs%log_open)
write(cs%stdlog,
'(a)') trim(mesg)
1325 if (cs%log_to_stdout)
write(cs%stdout,
'(a)') trim(mesg)
1328 myunits=
"not defined";
if (
present(units))
write(myunits(1:240),
'(A)') trim(units)
1329 if (
present(desc)) &
1330 call doc_param(cs%doc, varname, desc, myunits,
value, default)
1337 character(len=*),
intent(in) :: modulename
1338 character(len=*),
intent(in) :: varname
1339 real,
intent(in) ::
value(:)
1340 character(len=*),
optional,
intent(in) :: desc, units
1341 real,
optional,
intent(in) :: default
1344 character(len=1320) :: mesg
1345 character(len=240) :: myunits
1350 write(mesg,
'(" ",a," ",a,": ",a)') &
1351 trim(modulename), trim(varname), trim(
left_reals(
value))
1353 if (cs%log_open)
write(cs%stdlog,
'(a)') trim(mesg)
1354 if (cs%log_to_stdout)
write(cs%stdout,
'(a)') trim(mesg)
1357 myunits=
"not defined";
if (
present(units))
write(myunits(1:240),
'(A)') trim(units)
1358 if (
present(desc)) &
1359 call doc_param(cs%doc, varname, desc, myunits,
value, default)
1364 units, default, layoutParam)
1366 character(len=*),
intent(in) :: modulename
1367 character(len=*),
intent(in) :: varname
1368 logical,
intent(in) :: value
1369 character(len=*),
optional,
intent(in) :: desc, units
1370 logical,
optional,
intent(in) :: default
1371 logical,
optional,
intent(in) :: layoutParam
1374 character(len=240) :: mesg, myunits
1377 write(mesg,
'(" ",a," ",a,": True")') trim(modulename), trim(varname)
1379 write(mesg,
'(" ",a," ",a,": False")') trim(modulename), trim(varname)
1382 if (cs%log_open)
write(cs%stdlog,
'(a)') trim(mesg)
1383 if (cs%log_to_stdout)
write(cs%stdout,
'(a)') trim(mesg)
1386 myunits=
"Boolean";
if (
present(units))
write(myunits(1:240),
'(A)') trim(units)
1387 if (
present(desc)) &
1388 call doc_param(cs%doc, varname, desc, myunits,
value, default, &
1389 layoutparam=layoutparam)
1393 subroutine log_param_char(CS, modulename, varname, value, desc, units, &
1394 default, layoutParam)
1396 character(len=*),
intent(in) :: modulename
1397 character(len=*),
intent(in) :: varname
1398 character(len=*),
intent(in) :: value
1399 character(len=*),
optional,
intent(in) :: desc, units
1400 character(len=*),
optional,
intent(in) :: default
1401 logical,
optional,
intent(in) :: layoutParam
1404 character(len=240) :: mesg, myunits
1406 write(mesg,
'(" ",a," ",a,": ",a)') &
1407 trim(modulename), trim(varname), trim(
value)
1409 if (cs%log_open)
write(cs%stdlog,
'(a)') trim(mesg)
1410 if (cs%log_to_stdout)
write(cs%stdout,
'(a)') trim(mesg)
1413 myunits=
" ";
if (
present(units))
write(myunits(1:240),
'(A)') trim(units)
1414 if (
present(desc)) &
1415 call doc_param(cs%doc, varname, desc, myunits,
value, default, &
1416 layoutparam=layoutparam)
1422 subroutine log_param_time(CS, modulename, varname, value, desc, units, &
1423 default, timeunit, layoutParam, log_date)
1425 character(len=*),
intent(in) :: modulename
1426 character(len=*),
intent(in) :: varname
1427 type(time_type),
intent(in) :: value
1428 character(len=*),
optional,
intent(in) :: desc, units
1429 type(time_type),
optional,
intent(in) :: default
1430 real,
optional,
intent(in) :: timeunit
1431 logical,
optional,
intent(in) :: log_date
1432 logical,
optional,
intent(in) :: layoutParam
1434 real :: real_time, real_default
1435 logical :: use_timeunit, date_format
1436 character(len=240) :: mesg, myunits
1437 character(len=80) :: date_string, default_string
1438 integer :: days, secs, ticks, ticks_per_sec
1440 use_timeunit = .false.
1441 date_format = .false. ;
if (
present(log_date)) date_format = log_date
1443 call get_time(
value, secs, days, ticks)
1445 if (ticks == 0)
then 1446 write(mesg,
'(" ",a," ",a," (Time): ",i0,":",i0)') trim(modulename), &
1447 trim(varname), days, secs
1449 write(mesg,
'(" ",a," ",a," (Time): ",i0,":",i0,":",i0)') trim(modulename), &
1450 trim(varname), days, secs, ticks
1453 if (cs%log_open)
write(cs%stdlog,
'(a)') trim(mesg)
1454 if (cs%log_to_stdout)
write(cs%stdout,
'(a)') trim(mesg)
1457 if (
present(desc))
then 1458 if (
present(timeunit)) use_timeunit = (timeunit > 0.0)
1459 if (date_format)
then 1463 if (
present(default))
then 1465 call doc_param(cs%doc, varname, desc, myunits, date_string, &
1466 default=default_string, layoutparam=layoutparam)
1468 call doc_param(cs%doc, varname, desc, myunits, date_string, &
1469 layoutparam=layoutparam)
1471 elseif (use_timeunit)
then 1472 if (
present(units))
then 1473 write(myunits(1:240),
'(A)') trim(units)
1475 if (abs(timeunit-1.0) < 0.01)
then ; myunits =
"seconds" 1476 elseif (abs(timeunit-3600.0) < 1.0)
then ; myunits =
"hours" 1477 elseif (abs(timeunit-86400.0) < 1.0)
then ; myunits =
"days" 1478 elseif (abs(timeunit-3.1e7) < 1.0e6)
then ; myunits =
"years" 1479 else ;
write(myunits,
'(es8.2," sec")') timeunit ;
endif 1481 real_time = (86400.0/timeunit)*days + secs/timeunit
1482 if (ticks > 0) real_time = real_time + &
1483 real(ticks) / (timeunit*get_ticks_per_second())
1484 if (
present(default))
then 1485 call get_time(default, secs, days, ticks)
1486 real_default = (86400.0/timeunit)*days + secs/timeunit
1487 if (ticks > 0) real_default = real_default + &
1488 real(ticks) / (timeunit*get_ticks_per_second())
1489 call doc_param(cs%doc, varname, desc, myunits, real_time, real_default)
1491 call doc_param(cs%doc, varname, desc, myunits, real_time)
1494 myunits=
'not defined';
if (
present(units))
write(myunits(1:240),
'(A)') trim(units)
1495 call doc_param(cs%doc, varname, desc, myunits,
value, default)
1503 type(time_type),
intent(in) :: date
1504 character(len=40) :: date_string
1506 character(len=40) :: sub_string
1508 integer :: yrs, mons, days, hours, mins, secs, ticks, ticks_per_sec
1510 call get_date(date, yrs, mons, days, hours, mins, secs, ticks)
1511 write (date_string,
'(i8.4)') yrs
1512 write (sub_string,
'("-", i2.2, "-", I2.2, " ", i2.2, ":", i2.2, ":")') &
1513 mons, days, hours, mins
1514 date_string = trim(adjustl(date_string)) // trim(sub_string)
1516 ticks_per_sec = get_ticks_per_second()
1517 real_secs = secs + ticks/ticks_per_sec
1518 if (ticks_per_sec <= 100)
then 1519 write (sub_string,
'(F7.3)') real_secs
1521 write (sub_string,
'(F10.6)') real_secs
1524 write (sub_string,
'(i2.2)') secs
1526 date_string = trim(date_string) // trim(adjustl(sub_string))
1530 subroutine get_param_int(CS, modulename, varname, value, desc, units, &
1531 default, fail_if_missing, do_not_read, do_not_log, &
1532 static_value, layoutParam)
1534 character(len=*),
intent(in) :: modulename
1535 character(len=*),
intent(in) :: varname
1536 integer,
intent(inout) :: value
1537 character(len=*),
optional,
intent(in) :: desc, units
1538 integer,
optional,
intent(in) :: default, static_value
1539 logical,
optional,
intent(in) :: fail_if_missing
1540 logical,
optional,
intent(in) :: do_not_read, do_not_log
1541 logical,
optional,
intent(in) :: layoutParam
1544 logical :: do_read, do_log
1546 do_read = .true. ;
if (
present(do_not_read)) do_read = .not.do_not_read
1547 do_log = .true. ;
if (
present(do_not_log)) do_log = .not.do_not_log
1550 if (
present(default))
value = default
1551 if (
present(static_value))
value = static_value
1556 call log_param_int(cs, modulename, varname,
value, desc, units, &
1557 default, layoutparam)
1563 default, fail_if_missing, do_not_read, do_not_log, &
1564 static_value, layoutParam)
1566 character(len=*),
intent(in) :: modulename
1567 character(len=*),
intent(in) :: varname
1568 integer,
intent(inout) ::
value(:)
1569 character(len=*),
optional,
intent(in) :: desc, units
1570 integer,
optional,
intent(in) :: default, static_value
1571 logical,
optional,
intent(in) :: fail_if_missing
1572 logical,
optional,
intent(in) :: do_not_read, do_not_log
1573 logical,
optional,
intent(in) :: layoutParam
1576 logical :: do_read, do_log
1578 do_read = .true. ;
if (
present(do_not_read)) do_read = .not.do_not_read
1579 do_log = .true. ;
if (
present(do_not_log)) do_log = .not.do_not_log
1582 if (
present(default))
then ; value(:) = default ;
endif 1583 if (
present(static_value))
then ; value(:) = static_value ;
endif 1589 units, default, layoutparam)
1594 subroutine get_param_real(CS, modulename, varname, value, desc, units, &
1595 default, fail_if_missing, do_not_read, do_not_log, static_value)
1597 character(len=*),
intent(in) :: modulename
1598 character(len=*),
intent(in) :: varname
1599 real,
intent(inout) :: value
1600 character(len=*),
optional,
intent(in) :: desc, units
1601 real,
optional,
intent(in) :: default, static_value
1602 logical,
optional,
intent(in) :: fail_if_missing
1603 logical,
optional,
intent(in) :: do_not_read, do_not_log
1606 logical :: do_read, do_log
1608 do_read = .true. ;
if (
present(do_not_read)) do_read = .not.do_not_read
1609 do_log = .true. ;
if (
present(do_not_log)) do_log = .not.do_not_log
1612 if (
present(default))
value = default
1613 if (
present(static_value))
value = static_value
1618 call log_param_real(cs, modulename, varname,
value, desc, units, &
1625 default, fail_if_missing, do_not_read, do_not_log, static_value)
1627 character(len=*),
intent(in) :: modulename
1628 character(len=*),
intent(in) :: varname
1629 real,
intent(inout) ::
value(:)
1630 character(len=*),
optional,
intent(in) :: desc, units
1631 real,
optional,
intent(in) :: default, static_value
1632 logical,
optional,
intent(in) :: fail_if_missing
1633 logical,
optional,
intent(in) :: do_not_read, do_not_log
1636 logical :: do_read, do_log
1638 do_read = .true. ;
if (
present(do_not_read)) do_read = .not.do_not_read
1639 do_log = .true. ;
if (
present(do_not_log)) do_log = .not.do_not_log
1642 if (
present(default))
then ; value(:) = default ;
endif 1643 if (
present(static_value))
then ; value(:) = static_value ;
endif 1654 subroutine get_param_char(CS, modulename, varname, value, desc, units, &
1655 default, fail_if_missing, do_not_read, do_not_log, &
1656 static_value, layoutParam)
1658 character(len=*),
intent(in) :: modulename
1659 character(len=*),
intent(in) :: varname
1660 character(len=*),
intent(inout) :: value
1661 character(len=*),
optional,
intent(in) :: desc, units
1662 character(len=*),
optional,
intent(in) :: default, static_value
1663 logical,
optional,
intent(in) :: fail_if_missing
1664 logical,
optional,
intent(in) :: do_not_read, do_not_log
1665 logical,
optional,
intent(in) :: layoutParam
1668 logical :: do_read, do_log
1670 do_read = .true. ;
if (
present(do_not_read)) do_read = .not.do_not_read
1671 do_log = .true. ;
if (
present(do_not_log)) do_log = .not.do_not_log
1674 if (
present(default))
value = default
1675 if (
present(static_value))
value = static_value
1680 call log_param_char(cs, modulename, varname,
value, desc, units, &
1681 default, layoutparam)
1687 default, fail_if_missing, do_not_read, do_not_log, static_value)
1689 character(len=*),
intent(in) :: modulename
1690 character(len=*),
intent(in) :: varname
1691 character(len=*),
intent(inout) ::
value(:)
1692 character(len=*),
optional,
intent(in) :: desc, units
1693 character(len=*),
optional,
intent(in) :: default, static_value
1694 logical,
optional,
intent(in) :: fail_if_missing
1695 logical,
optional,
intent(in) :: do_not_read, do_not_log
1698 logical :: do_read, do_log
1699 integer :: i, len_tot, len_val
1700 character(len=240) :: cat_val
1702 do_read = .true. ;
if (
present(do_not_read)) do_read = .not.do_not_read
1703 do_log = .true. ;
if (
present(do_not_log)) do_log = .not.do_not_log
1706 if (
present(default))
then ; value(:) = default ;
endif 1707 if (
present(static_value))
then ; value(:) = static_value ;
endif 1712 cat_val = trim(value(1)); len_tot = len_trim(value(1))
1714 len_val = len_trim(value(i))
1715 if ((len_val > 0) .and. (len_tot + len_val + 2 < 240))
then 1716 cat_val = trim(cat_val)//achar(34)//
", "//achar(34)//trim(value(i))
1717 len_tot = len_tot + len_val
1727 default, fail_if_missing, do_not_read, do_not_log, &
1728 static_value, layoutParam)
1730 character(len=*),
intent(in) :: modulename
1731 character(len=*),
intent(in) :: varname
1732 logical,
intent(inout) :: value
1733 character(len=*),
optional,
intent(in) :: desc, units
1734 logical,
optional,
intent(in) :: default, static_value
1735 logical,
optional,
intent(in) :: fail_if_missing
1736 logical,
optional,
intent(in) :: do_not_read, do_not_log
1737 logical,
optional,
intent(in) :: layoutParam
1740 logical :: do_read, do_log
1742 do_read = .true. ;
if (
present(do_not_read)) do_read = .not.do_not_read
1743 do_log = .true. ;
if (
present(do_not_log)) do_log = .not.do_not_log
1746 if (
present(default))
value = default
1747 if (
present(static_value))
value = static_value
1753 units, default, layoutparam)
1758 subroutine get_param_time(CS, modulename, varname, value, desc, units, &
1759 default, fail_if_missing, do_not_read, do_not_log, &
1760 timeunit, static_value, layoutParam, log_as_date)
1762 character(len=*),
intent(in) :: modulename
1763 character(len=*),
intent(in) :: varname
1764 type(time_type),
intent(inout) :: value
1765 character(len=*),
optional,
intent(in) :: desc, units
1766 type(time_type),
optional,
intent(in) :: default, static_value
1767 logical,
optional,
intent(in) :: fail_if_missing
1768 logical,
optional,
intent(in) :: do_not_read, do_not_log
1769 real,
optional,
intent(in) :: timeunit
1770 logical,
optional,
intent(in) :: layoutParam
1771 logical,
optional,
intent(in) :: log_as_date
1774 logical :: do_read, do_log, date_format, log_date
1776 do_read = .true. ;
if (
present(do_not_read)) do_read = .not.do_not_read
1777 do_log = .true. ;
if (
present(do_not_log)) do_log = .not.do_not_log
1781 if (
present(default))
value = default
1782 if (
present(static_value))
value = static_value
1783 call read_param_time(cs, varname,
value, timeunit, fail_if_missing, date_format=log_date)
1787 if (
present(log_as_date)) log_date = log_as_date
1788 call log_param_time(cs, modulename, varname,
value, desc, units, default, &
1789 timeunit, layoutparam=layoutparam, log_date=log_date)
1800 if (
associated(cs%blockName))
then 1801 block => cs%blockName
1805 'clearParameterBlock: A clear was attempted before allocation.')
1811 character(len=*),
intent(in) :: blockName
1812 character(len=*),
optional,
intent(in) :: desc
1815 if (
associated(cs%blockName))
then 1816 block => cs%blockName
1821 'openParameterBlock: A push was attempted before allocation.')
1830 if (
associated(cs%blockName))
then 1831 block => cs%blockName
1832 if (
is_root_pe().and.len_trim(block%name)==0)
call mom_error(fatal, &
1833 'closeParameterBlock: A pop was attempted on an empty stack. ("'//&
1834 trim(block%name)//
'")')
1838 'closeParameterBlock: A pop was attempted before allocation.')
1844 character(len=*),
intent(in) :: oldBlockName, newBlockName
1845 character(len=len(oldBlockName)+40) :: pushBlockLevel
1847 if (len_trim(oldblockname)>0)
then 1848 pushblocklevel=trim(oldblockname)//
'%'//trim(newblockname)
1850 pushblocklevel=trim(newblockname)
1855 character(len=*),
intent(in) :: oldBlockName
1856 character(len=len(oldBlockName)+40) :: popBlockLevel
1859 i = index(trim(oldblockname),
'%', .true.)
1861 popblocklevel = trim(oldblockname(1:i-1))
1866 'popBlockLevel: A pop was attempted leaving an empty block name.')
integer, parameter input_str_length
subroutine read_param_real_array(CS, varname, value, fail_if_missing)
subroutine log_param_real_array(CS, modulename, varname, value, desc, units, default)
subroutine get_param_logical(CS, modulename, varname, value, desc, units, default, fail_if_missing, do_not_read, do_not_log, static_value, layoutParam)
subroutine get_variable_line(CS, varname, found, defined, value_string, paramIsLogical)
character(len=40) function convert_date_to_string(date)
This function converts a date into a string, valid with ticks and for dates up to year 99...
character(len=len(string)+16) function simplifywhitespace(string)
subroutine read_param_time(CS, varname, value, timeunit, fail_if_missing, date_format)
subroutine get_param_int(CS, modulename, varname, value, desc, units, default, fail_if_missing, do_not_read, do_not_log, static_value, layoutParam)
subroutine get_param_int_array(CS, modulename, varname, value, desc, units, default, fail_if_missing, do_not_read, do_not_log, static_value, layoutParam)
subroutine get_param_time(CS, modulename, varname, value, desc, units, default, fail_if_missing, do_not_read, do_not_log, timeunit, static_value, layoutParam, log_as_date)
logical, parameter unused_params_fatal_default
subroutine, public doc_end(doc)
logical, parameter complete_doc_default
subroutine log_param_int_array(CS, modulename, varname, value, desc, units, default, layoutParam)
subroutine, public doc_init(docFileBase, doc, minimal, complete)
subroutine log_param_char(CS, modulename, varname, value, desc, units, default, layoutParam)
integer, parameter filename_length
logical, parameter log_to_stdout_default
character(len=len(string)) function replacetabs(string)
subroutine log_param_logical(CS, modulename, varname, value, desc, units, default, layoutParam)
character(len=19) function, public left_int(i)
character(len=32) function, public left_real(val)
subroutine populate_param_data(iounit, filename, param_data)
subroutine, public open_param_file(filename, CS, checkable, component, doc_file_dir)
subroutine read_param_char_array(CS, varname, value, fail_if_missing)
character(len=input_str_length) function strip_quotes(val_str)
subroutine read_param_logical(CS, varname, value, fail_if_missing)
subroutine, public clearparameterblock(CS)
subroutine get_param_char_array(CS, modulename, varname, value, desc, units, default, fail_if_missing, do_not_read, do_not_log, static_value)
subroutine flag_line_as_read(line_used, count)
logical function overridewarninghasbeenissued(chain, varName)
integer, parameter, public max_param_files
character(len=len(dir)+2) function, public slasher(dir)
Returns a directory name that is terminated with a "/" or "./" if the argument is an empty string...
logical function openmultilinecomment(string)
subroutine read_param_int_array(CS, varname, value, fail_if_missing)
subroutine, public doc_closeblock(doc, blockName)
subroutine, public doc_openblock(doc, blockName, desc)
character(len=len(oldblockname)+40) function pushblocklevel(oldblockName, newBlockName)
subroutine, public close_param_file(CS, quiet_close, component)
subroutine, public closeparameterblock(CS)
subroutine read_param_real(CS, varname, value, fail_if_missing)
integer function lastnoncommentindex(string)
subroutine, public openparameterblock(CS, blockName, desc)
subroutine log_version_plain(modulename, version)
Log the version of a module to a log file and/or stdout.
logical function, public is_root_pe()
character(len=len(oldblockname)+40) function popblocklevel(oldblockName)
character(len=1320) function, public left_ints(i)
character(len=len(string)) function removecomments(string)
subroutine get_param_real_array(CS, modulename, varname, value, desc, units, default, fail_if_missing, do_not_read, do_not_log, static_value)
subroutine read_param_int(CS, varname, value, fail_if_missing)
subroutine, public mom_mesg(message, verb, all_print)
subroutine get_param_real(CS, modulename, varname, value, desc, units, default, fail_if_missing, do_not_read, do_not_log, static_value)
subroutine get_param_char(CS, modulename, varname, value, desc, units, default, fail_if_missing, do_not_read, do_not_log, static_value, layoutParam)
subroutine read_param_char(CS, varname, value, fail_if_missing)
logical, parameter report_unused_default
character(len=1320) function, public left_reals(r, sep)
subroutine log_version_cs(CS, modulename, version, desc)
Log the version of a module to a log file and/or stdout, and/or to the parameter documentation file...
subroutine log_param_int(CS, modulename, varname, value, desc, units, default, layoutParam)
subroutine, public mom_error(level, message, all_print)
integer function lastnoncommentnonblank(string)
subroutine log_param_real(CS, modulename, varname, value, desc, units, default)
subroutine log_param_time(CS, modulename, varname, value, desc, units, default, timeunit, layoutParam, log_date)
This subroutine writes the value of a time-type parameter to a log file, along with its name and the ...
logical function closemultilinecomment(string)
subroutine, public doc_module(doc, modname, desc)
logical, parameter minimal_doc_default