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. |
|
Returns a left-adjusted string with trailing blanks and commas removed. |
|
Convert the first n elements (3 by default) of an integer array into an underscore delimited 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)
Return a string in which all uppercase letters have been replaced by their lowercase counterparts.
- Parameters:
input_string ::
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_tidal_mixing::tidal_mixing_initmom_tracer_registry::tracer_name_lookup
- function mom_string_functions/uppercase(input_string)
Return a string in which all uppercase letters have been replaced by their lowercase counterparts.
- Parameters:
input_string ::
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_initmom_internal_tides::internal_tides_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)
Returns a character string of a left-formatted integer e.g. “123 “ (assumes 19 digit maximum)
- Parameters:
i ::
i[in] The integer to convert to a string- Return:
undefined :: The output string
- Called from:
- function mom_string_functions/left_ints(i)
Returns a character string of a comma-separated, compact formatted, integers e.g. “1, 2, 3, 4”.
- Parameters:
i ::
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)
Returns a left-justified string with a real formatted like ‘(G)’.
- Parameters:
val ::
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)
Returns a character string of a comma-separated, compact formatted, reals e.g. “1., 2., 5*3., 5.E2”.
- Parameters:
r ::
r[in] The array of real variables to convert to a string, in arbitrary units [A]sep ::
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)
Returns True if the string can be read/parsed to give the exact value of “val”.
- Parameters:
str ::
str[in] The string to parseval ::
val[in] The real value to compare with, in arbitrary units [A]
- Called from:
- function mom_string_functions/extractword(string, n)
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 ::
string[in] The string to scann ::
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)
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 ::
string[in] String to scanseparators ::
separators[in] Characters to use for delineationn ::
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)
Returns the integer corresponding to the nth word in the argument.
- Parameters:
string ::
string[in] String to scanseparators ::
separators[in] Characters to use for delineationn ::
n[in] Number of word to extractmissing_value ::
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)
Returns the real corresponding to the nth word in the argument, in arbitrary units [A].
- Parameters:
string ::
string[in] String to scanseparators ::
separators[in] Characters to use for delineationn ::
n[in] Number of word to extractmissing_value ::
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)
Returns string with all spaces removed.
- Parameters:
string ::
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)
Returns true if a unit test of string_functions fails.
- Parameters:
verbose ::
verbose[in] If true, write results to stdout- Call to:
extract_integerextract_realextract_wordextractwordints_to_stringleft_intleft_intsleft_realleft_realslocaltestilocaltestrlocaltestsremove_spacestrim_trailing_commas- Called from:
- function mom_string_functions/localtests(verbose, str1, str2)
True if str1 does not match str2. False otherwise.
- Parameters:
verbose ::
verbose[in] If true, write results to stdoutstr1 ::
str1[in] Stringstr2 ::
str2[in] String
- Called from:
- function mom_string_functions/localtesti(verbose, i1, i2)
True if i1 is not equal to i2. False otherwise.
- Parameters:
verbose ::
verbose[in] If true, write results to stdouti1 ::
i1[in] Integeri2 ::
i2[in] Integer
- Called from:
- function mom_string_functions/localtestr(verbose, r1, r2)
True if r1 is not equal to r2. False otherwise.
- Parameters:
verbose ::
verbose[in] If true, write results to stdoutr1 ::
r1[in] The first value to compare, in arbitrary units [A]r2 ::
r2[in] The first value to compare, in arbitrary units [A]
- Called from:
- function mom_string_functions/slasher(dir)
Returns a directory name that is terminated with a “/” or “./” if the argument is an empty string.
- Parameters:
dir ::
dir[in] A directory to be terminated with a “/” or changed to “./” if it is blank.- Called from:
mom_diag_mediator::diag_mediator_initmom_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
- function mom_string_functions/trim_trailing_commas(in_str)
Returns a left-adjusted string with trailing blanks and commas removed.
- Parameters:
in_str ::
in_str[in] A string that is to be left adjusted and have its trailing commas and white space removed.- Return:
undefined :: A left-adjusted version of in_str with trailing commas and white space removed
- Called from:
mom_diag_mediator::register_diag_fieldmom_is_diag_mediator::register_mom_is_diag_fieldmom_is_diag_mediator::register_mom_is_static_fieldmom_diag_mediator::register_static_fieldstring_functions_unit_tests
- function mom_string_functions/ints_to_string(a, n)
Convert the first n elements (3 by default) of an integer array into an underscore delimited string.
- Parameters:
a ::
a[in] The array of integers to translaten ::
n[in] The number of elements to translate, by default the lesser of 3 or all of the integers
- Return:
undefined :: The returned underscore delimited string of integers
- Called from:
mom_diag_mediator::define_axes_groupmom_is_diag_mediator::define_axes_groupmom_diag_mediator::define_axes_group_dsampstring_functions_unit_tests