mom_string_functions module reference¶
Handy functions for manipulating strings.
Functions/Subroutines¶
Return a string in which all uppercase letters have been replaced by their lowercase counterparts. |
|
Return a string in which all uppercase letters have been replaced by their lowercase counterparts. |
|
Returns a character string of a left-formatted integer e.g. |
|
Returns a character string of a comma-separated, compact formatted, integers e.g. |
|
Returns a left-justified string with a real formatted like ‘(G)’. |
|
Returns a character string of a comma-separated, compact formatted, reals e.g. |
|
Returns True if the string can be read/parsed to give the exact value of “val”. |
|
Returns the string corresponding to the nth word in the argument or “” if the string is not long enough. |
|
Returns the string corresponding to the nth word in the argument or “” if the string is not long enough. |
|
Returns the integer corresponding to the nth word in the argument. |
|
Returns the real corresponding to the nth word in the argument, in arbitrary units [A]. |
|
Returns string with all spaces removed. |
|
Returns true if a unit test of string_functions fails. |
|
True if str1 does not match str2. |
|
True if i1 is not equal to i2. |
|
True if r1 is not equal to r2. |
|
Returns a directory name that is terminated with a “/” or “./” if the argument is an empty string. |
Detailed Description¶
By Alistair Adcroft and Robert Hallberg, last updated Sept. 2013.
The functions here perform a set of useful manipulations of character strings. Although they are a part of MOM6, the do not require any other MOM software to be useful.
Function/Subroutine Documentation¶
-
function
mom_string_functions/lowercase(input_string) [character(len=len(input_string))]¶ Return a string in which all uppercase letters have been replaced by their lowercase counterparts.
- Parameters:
input_string :: [in] The string to modify
- Return:
undefined :: The modified output string
- Called from:
basin_builder::basin_builder_topographymom_io::cmor_long_stdmom_io::create_mom_filemom_diag_remap::diag_remap_configure_axesmom_io::get_varidmom_oda_driver_mod::init_odamom_meke::meke_initmom_state_initialization::mom_initialize_obcsmom_tracer_registry::register_tracermom_tracer_registry::register_tracer_diagnosticsmom_restart::restore_statemom_self_attr_load::sal_initmom_is_diag_mediator::set_is_axes_infomom_tidal_mixing::tidal_mixing_initmom_tracer_registry::tracer_name_lookup
-
function
mom_string_functions/uppercase(input_string) [character(len=len(input_string))]¶ Return a string in which all uppercase letters have been replaced by their lowercase counterparts.
- Parameters:
input_string :: [in] The string to modify
- Return:
undefined :: The modified output string
- Called from:
regrid_consts::coordinatemodemom_coriolisadv::coriolisadv_initmom_energetic_pbl::energetic_pbl_initregrid_interp::interpolation_schememom6mom_is_diag_mediator::mom_is_diag_mediator_initocean_model_mod::ocean_model_initmom_opacity::opacity_initmom_shared_initialization::read_face_length_listmom_tidal_mixing::read_tidal_energymom_shared_initialization::reset_face_lengths_listmom_open_boundary::scale_factor_from_namemom_remapping::setreconstructiontypemom_surface_forcing_gfdl::surface_forcing_initmom_tidal_mixing::tidal_mixing_initmom_surface_forcing::wind_forcing_from_file
-
function
mom_string_functions/left_int(i) [character(len=19)]¶ Returns a character string of a left-formatted integer e.g. “123 ” (assumes 19 digit maximum)
- Parameters:
i :: [in] The integer to convert to a string
- Return:
undefined :: The output string
- Called from:
-
function
mom_string_functions/left_ints(i) [character(len=1320)]¶ Returns a character string of a comma-separated, compact formatted, integers e.g. “1, 2, 3, 4”.
- Parameters:
i :: [in] The array of integers to convert to a string
- Return:
undefined :: The output string
- Call to:
- Called from:
-
function
mom_string_functions/left_real(val) [character(len=32)]¶ Returns a left-justified string with a real formatted like ‘(G)’.
- Parameters:
val :: [in] The real variable to convert to a string, in arbitrary units [A]
- Return:
undefined :: The output string
- Call to:
- Called from:
-
function
mom_string_functions/left_reals(r, sep) [character(len=:)]¶ Returns a character string of a comma-separated, compact formatted, reals e.g. “1., 2., 5*3., 5.E2”.
- Parameters:
r :: [in] The array of real variables to convert to a string, in arbitrary units [A]
sep :: [in] The separator between successive values, by default it is ‘, ‘.
- Return:
undefined :: The output string
- Call to:
- Called from:
-
function
mom_string_functions/isformattedfloatequalto(str, val) [logical]¶ Returns True if the string can be read/parsed to give the exact value of “val”.
- Parameters:
str :: [in] The string to parse
val :: [in] The real value to compare with, in arbitrary units [A]
- Called from:
-
function
mom_string_functions/extractword(string, n) [character(len=120)]¶ Returns the string corresponding to the nth word in the argument or “” if the string is not long enough. Both spaces and commas are interpreted as separators.
- Parameters:
string :: [in] The string to scan
n :: [in] Number of word to extract
- Call to:
- Called from:
mom_diag_remap::diag_remap_initmom_regridding::initialize_regriddingmom_int_tide_input::int_tide_input_initstring_functions_unit_tests
-
function
mom_string_functions/extract_word(string, separators, n) [character(len=120)]¶ Returns the string corresponding to the nth word in the argument or “” if the string is not long enough. Words are delineated by the mandatory separators argument.
- Parameters:
string :: [in] String to scan
separators :: [in] Characters to use for delineation
n :: [in] Number of word to extract
- Called from:
extract_integerextract_realextractwordmom_open_boundary::parse_segment_data_strmom_open_boundary::parse_segment_manifest_strmom_open_boundary::parse_segment_strstring_functions_unit_tests
-
function
mom_string_functions/extract_integer(string, separators, n, missing_value) [integer]¶ Returns the integer corresponding to the nth word in the argument.
- Parameters:
string :: [in] String to scan
separators :: [in] Characters to use for delineation
n :: [in] Number of word to extract
missing_value :: [in] Value to assign if word is missing
- Call to:
- Called from:
mom_regridding::initialize_regriddingstring_functions_unit_tests
-
function
mom_string_functions/extract_real(string, separators, n, missing_value) [real]¶ Returns the real corresponding to the nth word in the argument, in arbitrary units [A].
- Parameters:
string :: [in] String to scan
separators :: [in] Characters to use for delineation
n :: [in] Number of word to extract
missing_value :: [in] Value to assign if word is missing, in arbitrary units [A]
- Call to:
- Called from:
mom_regridding::initialize_regriddingmom_internal_tides::internal_tides_initstring_functions_unit_tests
-
function
mom_string_functions/remove_spaces(string) [character(len=120)]¶ Returns string with all spaces removed.
- Parameters:
string :: [in] String to scan
- Called from:
mom_open_boundary::open_boundary_configstring_functions_unit_tests
-
function
mom_string_functions/string_functions_unit_tests(verbose) [logical]¶ Returns true if a unit test of string_functions fails.
- Parameters:
verbose :: [in] If true, write results to stdout
- Call to:
extract_integerextract_realextract_wordextractwordleft_intleft_intsleft_realleft_realslocaltestilocaltestrlocaltestsremove_spaces- Called from:
-
function
mom_string_functions/localtests(verbose, str1, str2) [logical]¶ True if str1 does not match str2. False otherwise.
- Parameters:
verbose :: [in] If true, write results to stdout
str1 :: [in] String
str2 :: [in] String
- Called from:
-
function
mom_string_functions/localtesti(verbose, i1, i2) [logical]¶ True if i1 is not equal to i2. False otherwise.
- Parameters:
verbose :: [in] If true, write results to stdout
i1 :: [in] Integer
i2 :: [in] Integer
- Called from:
-
function
mom_string_functions/localtestr(verbose, r1, r2) [logical]¶ True if r1 is not equal to r2. False otherwise.
- Parameters:
verbose :: [in] If true, write results to stdout
r1 :: [in] The first value to compare, in arbitrary units [A]
r2 :: [in] The first value to compare, in arbitrary units [A]
- Called from:
-
function
mom_string_functions/slasher(dir) [character(len=len(dir)+2)]¶ Returns a directory name that is terminated with a “/” or “./” if the argument is an empty string.
- Parameters:
dir :: [in] A directory to be terminated with a “/” or changed to “./” if it is blank.
- Called from:
mom_hybgen_regrid::init_hybgen_regridmom_domains::mom_domains_initmom_is_diag_mediator::mom_is_diag_mediator_initmom_coord_initialization::set_coord_from_filemom_coord_initialization::set_coord_from_ts_profile