From 58308e4f6b42df7ed735c9287f31d9699739e53d Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Wed, 7 Aug 2024 17:17:04 -0600 Subject: [PATCH 1/2] Fix for "none" units edge case (#583) Tiny bugfix for unit conversion edge case that was trying to convert "None" to "none" ## Description Convert "none" units to lowercase before comparing. User interface changes?: No Fixes: closes #567 Testing: - Updated var_compatability_test to include a "None" to "none" comparison Co-authored-by: Courtney Peverley --- scripts/var_props.py | 7 +++++++ test/var_compatibility_test/test_host.meta | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/var_props.py b/scripts/var_props.py index 9a2fd7d0..53f39f5c 100755 --- a/scripts/var_props.py +++ b/scripts/var_props.py @@ -936,6 +936,13 @@ def __init__(self, var1_stdname, var1_type, var1_kind, var1_units, # end if # end if if self.__compat: + # Only "none" units are case-insensitive + if var1_units.lower() == 'none': + var1_units = 'none' + # end if + if var2_units.lower() == 'none': + var2_units = 'none' + # end if # Check units argument if var1_units != var2_units: self.__equiv = False diff --git a/test/var_compatibility_test/test_host.meta b/test/var_compatibility_test/test_host.meta index 5d861764..da71b182 100644 --- a/test/var_compatibility_test/test_host.meta +++ b/test/var_compatibility_test/test_host.meta @@ -26,7 +26,7 @@ [ errmsg ] standard_name = ccpp_error_message long_name = Error message for error handling in CCPP - units = none + units = None dimensions = () type = character kind = len=512 From af90b948b85b88649547b49d28ba98fd5cb8c4b1 Mon Sep 17 00:00:00 2001 From: Michael Kavulich Date: Thu, 15 Aug 2024 14:16:18 -0600 Subject: [PATCH 2/2] Fix for ccpp_track_variables.py: Need "recursive=True" for glob on .meta files (#581) Because of the change in directory structure for CCPP physics (https://github.com/ufs-community/ccpp-physics/pull/99), there are now `.meta` files at different levels in the directory tree. The `ccpp_track_variables.py` script needs the location of these `.meta` files as an input argument to the script, but the call to `glob.glob` in the script does not use the `recursive=True` argument, so even if the user passes in the argument `-m './physics/physics/**/'` (which should include all subdirectories), the call to `glob.glob` only searches one level. Our simple test case only has `.meta` files at a single directory level, so we never caught this issue. Simply adding the `recursive=True` argument fixes this issue. --- scripts/ccpp_track_variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ccpp_track_variables.py b/scripts/ccpp_track_variables.py index 60d31c1e..64dfc518 100755 --- a/scripts/ccpp_track_variables.py +++ b/scripts/ccpp_track_variables.py @@ -69,7 +69,7 @@ def create_metadata_filename_dict(metapath): with that scheme""" metadata_dict = {} - scheme_filenames = glob.glob(os.path.join(metapath, "*.meta")) + scheme_filenames = glob.glob(os.path.join(metapath, "*.meta"), recursive=True) if not scheme_filenames: raise Exception(f'No files found in {metapath} with ".meta" extension')