mom_string_functions module reference

Handy functions for manipulating strings.

More…

Functions/Subroutines

lowercase()

Return a string in which all uppercase letters have been replaced by their lowercase counterparts.

uppercase()

Return a string in which all uppercase letters have been replaced by their lowercase counterparts.

left_int()

Returns a character string of a left-formatted integer e.g.

left_ints()

Returns a character string of a comma-separated, compact formatted, integers e.g.

left_real()

Returns a left-justified string with a real formatted like ‘(G)’.

left_reals()

Returns a character string of a comma-separated, compact formatted, reals e.g.

isformattedfloatequalto()

Returns True if the string can be read/parsed to give the exact value of “val”.

extractword()

Returns the string corresponding to the nth word in the argument or “” if the string is not long enough.

extract_word()

Returns the string corresponding to the nth word in the argument or “” if the string is not long enough.

extract_integer()

Returns the integer corresponding to the nth word in the argument.

extract_real()

Returns the real corresponding to the nth word in the argument.

remove_spaces()

Returns string with all spaces removed.

string_functions_unit_tests()

Returns true if a unit test of string_functions fails.

localtests()

True if str1 does not match str2.

localtesti()

True if i1 is not equal to i2.

localtestr()

True if r1 is not equal to r2.

slasher()

Returns a directory name that is terminated with a “/” or “./” if the argument is an empty string.

append_substring()

append a string (substring) to another string (string_in) and return the concatenated string (string_out)

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_topography mom_io::cmor_long_std mom_io::create_file mom_diag_remap::diag_remap_configure_axes mom_io::get_varid mom_oda_driver_mod::init_oda mom_state_initialization::mom_initialize_state mom_tracer_registry::register_tracer_diagnostics mom_restart::restore_state separate_idamp_for_uv mom_is_diag_mediator::set_is_axes_info mom_tidal_mixing::tidal_mixing_init mom_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

mom_continuity::continuity_init regrid_consts::coordinatemode mom_coriolisadv::coriolisadv_init mom_energetic_pbl::energetic_pbl_init mom_eos::eos_init regrid_interp::interpolation_scheme mom_is_diag_mediator::mom_is_diag_mediator_init mom_main ocean_model_mod::ocean_model_init mom_opacity::opacity_init mom_shared_initialization::read_face_length_list mom_tidal_mixing::read_tidal_energy mom_shared_initialization::reset_face_lengths_list mom_remapping::setreconstructiontype mom_surface_forcing_gfdl::surface_forcing_init mom_tidal_mixing::tidal_mixing_init mom_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

left_ints left_reals string_functions_unit_tests

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

left_int

Called from

string_functions_unit_tests

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

Return

undefined :: The output string

Call to

isformattedfloatequalto

Called from

left_reals mom_file_parser::log_param_real string_functions_unit_tests

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

  • sep :: [in] The separator between successive values, by default it is ‘, ‘.

Return

undefined :: The output string

Call to

left_int left_real

Called from

mom_file_parser::log_param_real_array string_functions_unit_tests

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

Called from

left_real

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

extract_word

Called from

mom_diag_remap::diag_remap_init mom_regridding::initialize_regridding string_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_integer extract_real extractword mom_open_boundary::parse_segment_data_str mom_open_boundary::parse_segment_manifest_str mom_open_boundary::parse_segment_param_real mom_open_boundary::parse_segment_str string_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

extract_word

Called from

mom_regridding::initialize_regridding string_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.

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

extract_word

Called from

mom_regridding::initialize_regridding string_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_config string_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_integer extract_real extract_word extractword left_int left_ints left_real left_reals localtesti localtestr localtests remove_spaces

Called from

mom_unit_tests::unit_tests

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

string_functions_unit_tests

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

string_functions_unit_tests

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] Float

  • r2 :: [in] Float

Called from

string_functions_unit_tests

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_domains::mom_domains_init mom_is_diag_mediator::mom_is_diag_mediator_init mom_coord_initialization::set_coord_from_file mom_coord_initialization::set_coord_from_ts_profile

function mom_string_functions/append_substring(string_in, substring) [character(len=1024)]

append a string (substring) to another string (string_in) and return the concatenated string (string_out)

Parameters
  • string_in :: [in] input string

  • substring :: [in] string to append string_in