NCAR / DART

Data Assimilation Research Testbed
https://dart.ucar.edu/
Apache License 2.0
192 stars 143 forks source link

Feature request: Add additional helper functions to utilities_mod #645

Open johnsonbk opened 7 months ago

johnsonbk commented 7 months ago

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:

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.