Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add additional helper functions to utilities_mod #645

Open
johnsonbk opened this issue Feb 28, 2024 · 0 comments
Open

Feature request: Add additional helper functions to utilities_mod #645

johnsonbk opened this issue Feb 28, 2024 · 0 comments

Comments

@johnsonbk
Copy link
Collaborator

johnsonbk commented Feb 28, 2024

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'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):

  1. A string '0000' in a block input file
  2. Converts to an integer 0
  3. The integer is incremented to 1
  4. Which converts and is padded to a string '0001' in a filter input file
  5. filter is run
  6. The string '0001' in a filter output file
  7. Converts to an integer 1
  8. Decrements to an integer 0
  9. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant