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

String utils module #911

Merged
merged 9 commits into from
Apr 7, 2022
Merged

Conversation

uramirez8707
Copy link
Contributor

@uramirez8707 uramirez8707 commented Feb 15, 2022

Description
Adds a string_utils module that contains the following public routines and added unit tests for each:

  • fms_array_to_pointer : to convert an array of strings to c_pointers
  • fms_pointer_to_array : to convert an array of c_pointers back to an array of strings
  • fms_sort_this: sorts an array of c_pointers in alphabetical order
  • fms_find_my_string: uses a binary search to search for a string in an array of sorted c_pointers
  • fms_find_unique: to find the unique of strings in array

These routines will be implemented in the diag_manager rewrite (i.e when searching the diag_yaml for a field)

To do (in a separate pr):

  • Move other string-related routines to the string_utils_mods (i.e fms_c2f_string, string, str_copy, etc ...) which are currently scattered and duplicated all over FMS

How Has This Been Tested?
make check passes with intel20, gnu 9.3.0, and intel18 on skylake

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

thomas-robinson added a commit to thomas-robinson/FMS that referenced this pull request Feb 28, 2022
@thomas-robinson thomas-robinson mentioned this pull request Feb 28, 2022
8 tasks
@thomas-robinson
Copy link
Member

To do (in a separate pr):

Move other string-related routines to the string_utils_mods (i.e fms_c2f_string, string, str_copy, etc ...) which are currently scattered and duplicated all over FMS

This should be done. You should use a USE statement in fms_mod, and make these routines public through there. Then fms_mod can depend on this instead of the other way around.

!> @{
module fms_string_utils_mod
use, intrinsic :: iso_c_binding
use fms_mod, only: fms_c2f_string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move fms_c2f_string here, then have fms_mod use fms_string_utils_mod, only:fms_c2f_string. I think you want the dependency going the other way instead...

thomas-robinson added a commit that referenced this pull request Mar 1, 2022
Pulls in #907 and #911 to dmUpdate branch
Co-authored-by: Uriel Ramirez <[email protected]>
@rem1776 rem1776 merged commit 05ce12c into NOAA-GFDL:main Apr 7, 2022
MinsukJi-NOAA added a commit to NOAA-EMC/FMS that referenced this pull request Apr 15, 2022
* get_unit warning now only prints on root_pe (NOAA-GFDL#872)

Co-authored-by: Eric Stofferahn <[email protected]>

* Update changelog, version numbers and build info (NOAA-GFDL#873)

Co-authored-by: rem1776 <[email protected]>

* chore: Change version number to next development version (NOAA-GFDL#874)

* CI: Update build action for yaml parser (NOAA-GFDL#871)

Update build actions
Change images to organization's repo and fix mixed mode parser test failure

* test(parser): Change real comparison value to double (NOAA-GFDL#886)

Co-authored-by: rem1776 <[email protected]>

* Make 'unsupported kind' error messages more descriptive. Change author of constants4.F90

* Add doxygen comment to valid_types in sat_vapor_pres/sat_vapor_pres_k.F90

* Modify codes for r8-r4 conversion to remove compiler warnings

* Remove OVERLOAD_R8 directives regarding send_data_*d_r8 subroutines

* Add Doxygen comments to constants4.F90

* Updates AM4 regression test suite to run intel 21 only on PW (NOAA-GFDL#893)

* feat: emc changes for mixedmode (NOAA-GFDL#857) (NOAA-GFDL#898)

* Change send_data interface and any necessary routines for mixed real precision support
* Adds an r4 size constants file

BREAKING CHANGE: changes some argument types in diag_manager, tracer_manager, sat_vapor_pres, and time_manager from real to class(*)

Co-authored-by: Minsuk Ji <[email protected]>

* feat: adds option to override (ignore) checksum test when reading restarts (NOAA-GFDL#889)

* update to fms2_io to allow reads to ignore embedded checksums on a fileobj basis
* added fms2_io test cases for the ignore_checksum option to restart reads
tests the domain, domain_wrap, and bc restart options

* docs: add CI information file (NOAA-GFDL#899)

* test: Adds check_nml_error after reading a namelist, so it could crash only as expected (NOAA-GFDL#904)

* Revert "feat: emc changes for mixedmode (NOAA-GFDL#857) (NOAA-GFDL#898)" (NOAA-GFDL#914)

This reverts commit 516a5ef.

* fix: clean up unused/uninitialized variables and other warnings (NOAA-GFDL#859)

Remove unused variables throughout and changes/removals for other warnings such as uninitialized values and implicit casts

* docs: update function style and branch names

* Changes master to main in CONTRIBUTING.md

* Claifies function return documentation in CODE_STYLE.md

* feat: adds support for logical variables in the yaml parser (NOAA-GFDL#907)

* Adds support for logical variables in the yaml parser

* correctly determines if a string is true or false

* fix: add check for affinity to self-initialize and update test program (NOAA-GFDL#917)

* fix: adds casts to class(*) calls to match doubles in C routines (NOAA-GFDL#920)

Co-authored-by: rem1776 <[email protected]>

* build: add intel code coverage build option to autotools (NOAA-GFDL#895)

* refactor: change to inclusive variable names (NOAA-GFDL#926)

* feat: Allow maximum number of restart variables to be set at build time (NOAA-GFDL#909)

* fix: Fixes for linter action and code style (NOAA-GFDL#869)

* test: Test script updates and input tests (NOAA-GFDL#800)

Rewrites test script to use added testing shell functions
Adds previously skipped or removed unit tests and support for testing with input files

Co-authored-by: Seth Underwood <[email protected]>
Co-authored-by: Uriel Ramirez <[email protected]>

* chore: 2022.01 release changes (NOAA-GFDL#941)

* chore: change version number to next development version (NOAA-GFDL#945)

* Add option for position independent code (NOAA-GFDL#930)

* fix: document and change parameter names for grid versions (NOAA-GFDL#918)

* fix: Moving empty and non-existent data table handling inside data_override (NOAA-GFDL#933)

Enables the processing of an empty or non-existent data_table or data_table.yaml from within data_override, so that any routine can call data_override_init without worry

* fix: Removal of internal FMS use of fms_io and mpp_io (NOAA-GFDL#928)

* fix: mpp changes to solve compile issues with serial builds (NOAA-GFDL#949)

* feat: adds build option for compiling with different sets of constants (NOAA-GFDL#929)

* feat: add and aggregate mpp_chksum unit tests (NOAA-GFDL#946)

* feat: add module for string utility routines (NOAA-GFDL#911)

Adds module and accompanying test for common string operations

* revert: reinstated the mpp_io routines and put them at the end for future elimination. (NOAA-GFDL#952)

* fix: add back in small_fac parameter to constants .h files (NOAA-GFDL#954)

* fix: root pe bug with fms2_io::flush_file (NOAA-GFDL#958)

* fix: clean up string routines for fms_string_utils_mod (NOAA-GFDL#953)

* Make changes to lines with more than 120 columns

Co-authored-by: Ryan Mulhall <[email protected]>
Co-authored-by: Eric Stofferahn <[email protected]>
Co-authored-by: rem1776 <[email protected]>
Co-authored-by: Tom Robinson <[email protected]>
Co-authored-by: Rusty Benson <[email protected]>
Co-authored-by: uramirez8707 <[email protected]>
Co-authored-by: Raffaele Montuoro <[email protected]>
Co-authored-by: Seth Underwood <[email protected]>
Co-authored-by: Uriel Ramirez <[email protected]>
Co-authored-by: Matthew Thompson <[email protected]>
Co-authored-by: Eric <[email protected]>
MinsukJi-NOAA added a commit to NOAA-EMC/FMS that referenced this pull request Apr 15, 2022
* get_unit warning now only prints on root_pe (NOAA-GFDL#872)

Co-authored-by: Eric Stofferahn <[email protected]>

* Update changelog, version numbers and build info (NOAA-GFDL#873)

Co-authored-by: rem1776 <[email protected]>

* chore: Change version number to next development version (NOAA-GFDL#874)

* CI: Update build action for yaml parser (NOAA-GFDL#871)

Update build actions
Change images to organization's repo and fix mixed mode parser test failure

* test(parser): Change real comparison value to double (NOAA-GFDL#886)

Co-authored-by: rem1776 <[email protected]>

* Make 'unsupported kind' error messages more descriptive. Change author of constants4.F90

* Add doxygen comment to valid_types in sat_vapor_pres/sat_vapor_pres_k.F90

* Modify codes for r8-r4 conversion to remove compiler warnings

* Remove OVERLOAD_R8 directives regarding send_data_*d_r8 subroutines

* Add Doxygen comments to constants4.F90

* Updates AM4 regression test suite to run intel 21 only on PW (NOAA-GFDL#893)

* feat: emc changes for mixedmode (NOAA-GFDL#857) (NOAA-GFDL#898)

* Change send_data interface and any necessary routines for mixed real precision support
* Adds an r4 size constants file

BREAKING CHANGE: changes some argument types in diag_manager, tracer_manager, sat_vapor_pres, and time_manager from real to class(*)

Co-authored-by: Minsuk Ji <[email protected]>

* feat: adds option to override (ignore) checksum test when reading restarts (NOAA-GFDL#889)

* update to fms2_io to allow reads to ignore embedded checksums on a fileobj basis
* added fms2_io test cases for the ignore_checksum option to restart reads
tests the domain, domain_wrap, and bc restart options

* docs: add CI information file (NOAA-GFDL#899)

* test: Adds check_nml_error after reading a namelist, so it could crash only as expected (NOAA-GFDL#904)

* Revert "feat: emc changes for mixedmode (NOAA-GFDL#857) (NOAA-GFDL#898)" (NOAA-GFDL#914)

This reverts commit 516a5ef.

* fix: clean up unused/uninitialized variables and other warnings (NOAA-GFDL#859)

Remove unused variables throughout and changes/removals for other warnings such as uninitialized values and implicit casts

* docs: update function style and branch names

* Changes master to main in CONTRIBUTING.md

* Claifies function return documentation in CODE_STYLE.md

* feat: adds support for logical variables in the yaml parser (NOAA-GFDL#907)

* Adds support for logical variables in the yaml parser

* correctly determines if a string is true or false

* fix: add check for affinity to self-initialize and update test program (NOAA-GFDL#917)

* fix: adds casts to class(*) calls to match doubles in C routines (NOAA-GFDL#920)

Co-authored-by: rem1776 <[email protected]>

* build: add intel code coverage build option to autotools (NOAA-GFDL#895)

* refactor: change to inclusive variable names (NOAA-GFDL#926)

* feat: Allow maximum number of restart variables to be set at build time (NOAA-GFDL#909)

* fix: Fixes for linter action and code style (NOAA-GFDL#869)

* test: Test script updates and input tests (NOAA-GFDL#800)

Rewrites test script to use added testing shell functions
Adds previously skipped or removed unit tests and support for testing with input files

Co-authored-by: Seth Underwood <[email protected]>
Co-authored-by: Uriel Ramirez <[email protected]>

* chore: 2022.01 release changes (NOAA-GFDL#941)

* chore: change version number to next development version (NOAA-GFDL#945)

* Add option for position independent code (NOAA-GFDL#930)

* fix: document and change parameter names for grid versions (NOAA-GFDL#918)

* fix: Moving empty and non-existent data table handling inside data_override (NOAA-GFDL#933)

Enables the processing of an empty or non-existent data_table or data_table.yaml from within data_override, so that any routine can call data_override_init without worry

* fix: Removal of internal FMS use of fms_io and mpp_io (NOAA-GFDL#928)

* fix: mpp changes to solve compile issues with serial builds (NOAA-GFDL#949)

* feat: adds build option for compiling with different sets of constants (NOAA-GFDL#929)

* feat: add and aggregate mpp_chksum unit tests (NOAA-GFDL#946)

* feat: add module for string utility routines (NOAA-GFDL#911)

Adds module and accompanying test for common string operations

* revert: reinstated the mpp_io routines and put them at the end for future elimination. (NOAA-GFDL#952)

* fix: add back in small_fac parameter to constants .h files (NOAA-GFDL#954)

* fix: root pe bug with fms2_io::flush_file (NOAA-GFDL#958)

* fix: clean up string routines for fms_string_utils_mod (NOAA-GFDL#953)

* chore: update libFMS module with new routines (NOAA-GFDL#912)

* fix: removes fms_c.c and fms_c.h (NOAA-GFDL#961)

* Make changes to lines with more than 120 columns

Co-authored-by: Ryan Mulhall <[email protected]>
Co-authored-by: Eric Stofferahn <[email protected]>
Co-authored-by: rem1776 <[email protected]>
Co-authored-by: Tom Robinson <[email protected]>
Co-authored-by: Rusty Benson <[email protected]>
Co-authored-by: uramirez8707 <[email protected]>
Co-authored-by: Raffaele Montuoro <[email protected]>
Co-authored-by: Seth Underwood <[email protected]>
Co-authored-by: Uriel Ramirez <[email protected]>
Co-authored-by: Matthew Thompson <[email protected]>
Co-authored-by: Eric <[email protected]>
@uramirez8707 uramirez8707 deleted the string_utils_main branch May 18, 2022 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants