@@ -125,7 +125,7 @@ module MOM_file_parser
125
125
126
126
contains
127
127
128
- ! > Make the contents of a parameter input file availalble in a param_file_type
128
+ ! > Make the contents of a parameter input file available in a param_file_type
129
129
subroutine open_param_file (filename , CS , checkable , component , doc_file_dir , ensemble_num )
130
130
character (len=* ), intent (in ) :: filename ! < An input file name, optionally with the full path
131
131
type (param_file_type), intent (inout ) :: CS ! < The control structure for the file_parser module,
@@ -562,10 +562,10 @@ function removeComments(string)
562
562
removeComments(:last)= adjustl (string (:last)) ! Copy only the non-comment part of string
563
563
end function removeComments
564
564
565
- ! > Constructs a string with all repeated whitespace replaced with single blanks
565
+ ! > Constructs a string with all repeated white space replaced with single blanks
566
566
! ! and insert white space where it helps delineate tokens (e.g. around =)
567
567
function simplifyWhiteSpace (string )
568
- character (len=* ), intent (in ) :: string ! < A string to modify to simpify white space
568
+ character (len=* ), intent (in ) :: string ! < A string to modify to simplify white space
569
569
character (len= len (string)+ 16 ) :: simplifyWhiteSpace
570
570
571
571
! Local variables
@@ -583,7 +583,7 @@ function simplifyWhiteSpace(string)
583
583
if (string (j:j)==quoteChar) insideString= .false. ! End of string
584
584
else ! The following is outside of string delimiters
585
585
if (string (j:j)==" " .or. string (j:j)==achar (9 )) then ! Space or tab
586
- if (nonBlank) then ! Only copy a blank if the preceeding character was non-blank
586
+ if (nonBlank) then ! Only copy a blank if the preceding character was non-blank
587
587
i= i+1
588
588
simplifyWhiteSpace(i:i)= " " ! Not string(j:j) so that tabs are replace by blanks
589
589
nonBlank= .false.
@@ -989,7 +989,7 @@ function max_input_line_length(CS, pf_num) result(max_len)
989
989
end function max_input_line_length
990
990
991
991
! > This subroutine extracts the contents of lines in the param_file_type that refer to
992
- ! ! a named parameter. The value_string that is returned must be interepreted in a way
992
+ ! ! a named parameter. The value_string that is returned must be interpreted in a way
993
993
! ! that depends on the type of this variable.
994
994
subroutine get_variable_line (CS , varname , found , defined , value_string , paramIsLogical )
995
995
type (param_file_type), intent (in ) :: CS ! < The control structure for the file_parser module,
@@ -1391,7 +1391,7 @@ end subroutine log_param_int
1391
1391
1392
1392
! > Log the name and values of an array of integer model parameter in documentation files.
1393
1393
subroutine log_param_int_array (CS , modulename , varname , value , desc , &
1394
- units , default , layoutParam , debuggingParam , like_default )
1394
+ units , default , defaults , layoutParam , debuggingParam , like_default )
1395
1395
type (param_file_type), intent (in ) :: CS ! < The control structure for the file_parser module,
1396
1396
! ! it is also a structure to parse for run-time parameters
1397
1397
character (len=* ), intent (in ) :: modulename ! < The name of the module using this parameter
@@ -1400,7 +1400,8 @@ subroutine log_param_int_array(CS, modulename, varname, value, desc, &
1400
1400
character (len=* ), optional , intent (in ) :: desc ! < A description of this variable; if not
1401
1401
! ! present, this parameter is not written to a doc file
1402
1402
character (len=* ), optional , intent (in ) :: units ! < The units of this parameter
1403
- integer , optional , intent (in ) :: default ! < The default value of the parameter
1403
+ integer , optional , intent (in ) :: default ! < The uniform default value of this parameter
1404
+ integer , optional , intent (in ) :: defaults(:) ! < The element-wise default values of this parameter
1404
1405
logical , optional , intent (in ) :: layoutParam ! < If present and true, this parameter is
1405
1406
! ! logged in the layout parameter file
1406
1407
logical , optional , intent (in ) :: debuggingParam ! < If present and true, this parameter is
@@ -1419,7 +1420,7 @@ subroutine log_param_int_array(CS, modulename, varname, value, desc, &
1419
1420
1420
1421
myunits= " " ; if (present (units)) write (myunits(1 :240 ),' (A)' ) trim (units)
1421
1422
if (present (desc)) &
1422
- call doc_param(CS% doc, varname, desc, myunits, value, default, &
1423
+ call doc_param(CS% doc, varname, desc, myunits, value, default, defaults, &
1423
1424
layoutParam= layoutParam, debuggingParam= debuggingParam, like_default= like_default)
1424
1425
1425
1426
end subroutine log_param_int_array
@@ -1745,7 +1746,7 @@ end subroutine get_param_int
1745
1746
! > This subroutine reads the values of an array of integer model parameters from a parameter file
1746
1747
! ! and logs them in documentation files.
1747
1748
subroutine get_param_int_array (CS , modulename , varname , value , desc , units , &
1748
- default , fail_if_missing , do_not_read , do_not_log , &
1749
+ default , defaults , fail_if_missing , do_not_read , do_not_log , &
1749
1750
layoutParam , debuggingParam )
1750
1751
type (param_file_type), intent (in ) :: CS ! < The control structure for the file_parser module,
1751
1752
! ! it is also a structure to parse for run-time parameters
@@ -1756,7 +1757,8 @@ subroutine get_param_int_array(CS, modulename, varname, value, desc, units, &
1756
1757
character (len=* ), optional , intent (in ) :: desc ! < A description of this variable; if not
1757
1758
! ! present, this parameter is not written to a doc file
1758
1759
character (len=* ), optional , intent (in ) :: units ! < The units of this parameter
1759
- integer , optional , intent (in ) :: default ! < The default value of the parameter
1760
+ integer , optional , intent (in ) :: default ! < The uniform default value of this parameter
1761
+ integer , optional , intent (in ) :: defaults(:) ! < The element-wise default values of this parameter
1760
1762
logical , optional , intent (in ) :: fail_if_missing ! < If present and true, a fatal error occurs
1761
1763
! ! if this variable is not found in the parameter file
1762
1764
logical , optional , intent (in ) :: do_not_read ! < If present and true, do not read a
@@ -1773,14 +1775,22 @@ subroutine get_param_int_array(CS, modulename, varname, value, desc, units, &
1773
1775
do_read = .true. ; if (present (do_not_read)) do_read = .not. do_not_read
1774
1776
do_log = .true. ; if (present (do_not_log)) do_log = .not. do_not_log
1775
1777
1778
+ if (present (defaults)) then
1779
+ if (present (default)) call MOM_error(FATAL, &
1780
+ " get_param_int_array: Only one of default and defaults can be specified at a time." )
1781
+ if (size (defaults) /= size (value)) call MOM_error(FATAL, &
1782
+ " get_param_int_array: The size of defaults and value are not the same." )
1783
+ endif
1784
+
1776
1785
if (do_read) then
1777
1786
if (present (default)) value(:) = default
1787
+ if (present (defaults)) value(:) = defaults(:)
1778
1788
call read_param_int_array(CS, varname, value, fail_if_missing)
1779
1789
endif
1780
1790
1781
1791
if (do_log) then
1782
- call log_param_int_array(CS, modulename, varname, value, desc, &
1783
- units, default , layoutParam, debuggingParam)
1792
+ call log_param_int_array(CS, modulename, varname, value, desc, units, &
1793
+ default, defaults , layoutParam, debuggingParam)
1784
1794
endif
1785
1795
1786
1796
end subroutine get_param_int_array
@@ -1871,7 +1881,7 @@ subroutine get_param_real_array(CS, modulename, varname, value, desc, units, &
1871
1881
if (present (default)) call MOM_error(FATAL, &
1872
1882
" get_param_real_array: Only one of default and defaults can be specified at a time." )
1873
1883
if (size (defaults) /= size (value)) call MOM_error(FATAL, &
1874
- " get_param_real_array: The size of defaults nad value are not the same." )
1884
+ " get_param_real_array: The size of defaults and value are not the same." )
1875
1885
endif
1876
1886
1877
1887
if (do_read) then
0 commit comments