NCAR / DART

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

Add integer_to_string, pad_left, zero_fill functions to utilities_mod #646

Closed johnsonbk closed 4 months ago

johnsonbk commented 4 months ago

Description:

Adds three functions to utilities_mod: zero_fill, pad_left and integer_to_string

Fixes issue

645

Types of changes

Documentation changes needed?

Tests

I used all three functions in a test version of the lorenz_96 model_mod to ensure they work properly, testing edge cases such as passing the zero_fill and pad_left functions desired_length = 0 or passing an inputstring equal to the value of desired_length.

Checklist for merging

Checklist for release

Testing Datasets

hkershaw-brown commented 4 months ago

Hi Ben,

I'm going to close this pull request. The Fortran format statement can be used when writing integers to strings (e.g. I4.4) so I don't think this code is needed.

Cheers, Helen

johnsonbk commented 4 months ago

Hi Helen, can we discuss this further before the pull request is closed? I brought this up at software stand up on Tuesday. There was general consensus that since there are helper functions already in utilities mod such as string_to_integer (which yes, uses a format statement) it would be helpful to DART developers if there were complimentary functions such as integer_to_string and padding functions that users who are familiar with other languages such as python and MATLAB are accustomed to. Providing such functions in an obvious module such as the utilities_mod can encourage less code duplication, such as the str2int functions in the RTTOV forward operator code.