While writing the model_to_dart code for the aether cube_sphere interface I found that it would be useful if there were a few additional functions DART's utilities_mod to make the model_to_dart code simpler.
Is your feature request related to a problem?
Yes. DART typically uses one-based indexing for ensemble members, whereas some models (such as aether) and languages (such as python) use zero-based indexing.
If so, give a clear and concise description of what the problem is.
For the model_to_dart code for aether, for example, the code takes blocks from the zeroth ensemble member to create the analogous DART filter input file (the DART filter input file could be denoted by '0000' but that isn't the typical DART convention):
A string '0000' in a block input file
Converts to an integer 0
The integer is incremented to 1
Which converts and is padded to a string '0001' in a filter input file
filter is run
The string '0001' in a filter output file
Converts to an integer 1
Decrements to an integer 0
Which converts and is padded to a string '0000' in a block output file
Describe your preferred solution
Add three additional functions to the utilities_mod:
integer_to_string This function compliments the already existing string_to_integer function. It takes an integer and converts it to a string analog of the integer.
pad_left: this function takes a string and pads it to the left with a specified character
zero_fill: this function takes a string and pads it to the left with zeros
zero_fill will be implemented as a specific use case of pad_left but it is included because python users are typically familiar the use of the zfill function included in the standard libraries of that language.
Describe any alternatives you have considered
These functions could just be included in a specific model directory, but that encourages code redundancy. For example, the RTTOV forward operators:
./observations/forward_operators/obs_def_rttov_mod.f90
./observations/forward_operators/obs_def_rttov13_mod.f90
contain their own stray version of a str2int function, which replicates the functionality of the string_to_integer function in utilities_mod.
Use case
While writing the
model_to_dart
code for the aether cube_sphere interface I found that it would be useful if there were a few additional functions DART'sutilities_mod
to make themodel_to_dart
code simpler.Is your feature request related to a problem?
Yes. DART typically uses one-based indexing for ensemble members, whereas some models (such as aether) and languages (such as python) use zero-based indexing.
If so, give a clear and concise description of what the problem is.
For the model_to_dart code for aether, for example, the code takes blocks from the zeroth ensemble member to create the analogous DART filter input file (the DART filter input file could be denoted by '0000' but that isn't the typical DART convention):
Describe your preferred solution
Add three additional functions to the
utilities_mod
:integer_to_string
This function compliments the already existingstring_to_integer
function. It takes an integer and converts it to a string analog of the integer.pad_left
: this function takes a string and pads it to the left with a specified characterzero_fill
: this function takes a string and pads it to the left with zeroszero_fill
will be implemented as a specific use case ofpad_left
but it is included because python users are typically familiar the use of thezfill
function included in the standard libraries of that language.Describe any alternatives you have considered
These functions could just be included in a specific model directory, but that encourages code redundancy. For example, the RTTOV forward operators: ./observations/forward_operators/obs_def_rttov_mod.f90 ./observations/forward_operators/obs_def_rttov13_mod.f90 contain their own stray version of a
str2int
function, which replicates the functionality of thestring_to_integer
function inutilities_mod
.