From f916b3194635953009cc060d03fd95e97d16b4ed Mon Sep 17 00:00:00 2001 From: Uriel Ramirez Date: Tue, 28 Nov 2023 11:12:33 -0500 Subject: [PATCH 1/2] implement the multi file data override in yaml and update the documentation --- data_override/README.MD | 7 +++++++ data_override/include/data_override.inc | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/data_override/README.MD b/data_override/README.MD index 8790d94bbf..64ecd05bb5 100644 --- a/data_override/README.MD +++ b/data_override/README.MD @@ -24,6 +24,13 @@ If it is desired to interpolate the data to a region of the model grid. The foll - **lat_start:** The starting longitude in the same units as the grid data in the file - **lon_end:** The ending longitude in the same units as the grid data in the file +If it is desired to use multiple(3) input netcf files instead of 1. The following **optional** keys are available. +- **is_multi_file:** Set to `True` is using the multi-file feature +- **prev_file_name:** The name of the first file in the set +- **next_file_name:** The name of the third file in the set + +Note that **file_name** must be the second file in the set. **prev_file_name** and **next_file_name** are required if **is_multi_file** is set to `True` + #### 2. How to use it? In order to use the yaml data format, [libyaml](https://github.com/yaml/libyaml) needs to be installed and linked with FMS. Additionally, FMS must be compiled with -Duse_yaml macro. If using autotools, you can add `--with-yaml`, which will add the macro for you and check that libyaml is linked correctly. ``` diff --git a/data_override/include/data_override.inc b/data_override/include/data_override.inc index f1276a13e3..91e43372eb 100644 --- a/data_override/include/data_override.inc +++ b/data_override/include/data_override.inc @@ -576,6 +576,23 @@ subroutine read_table_yaml(data_table) call get_value_from_key(file_id, entry_id(i), "fieldname_file", data_table(i)%fieldname_file, & & is_optional=.true.) + data_table(i)%multifile = .false. + call get_value_from_key(file_id, entry_id(i), "is_multi_file", data_table(i)%multifile, & + & is_optional=.true.) + + if (data_table(i)%multifile) then + data_table(i)%prev_file_name = "" + data_table(i)%next_file_name = "" + call get_value_from_key(file_id, entry_id(i), "prev_file_name", data_table(i)%prev_file_name, & + & is_optional=.true.) + call get_value_from_key(file_id, entry_id(i), "next_file_name", data_table(i)%next_file_name, & + & is_optional=.true.) + if (trim(data_table(i)%prev_file_name) .eq. "" .or. trim(data_table(i)%next_file_name) .eq. "") & + call mpp_error(FATAL, "The prev_file_name and next_file_name must be present if is_multi_file. "//& + "Check your data_table.yaml entry for field:"//trim(data_table(i)%gridname)//":"//& + trim(data_table(i)%fieldname_code)) + endif + data_table(i)%file_name = "" call get_value_from_key(file_id, entry_id(i), "file_name", data_table(i)%file_name, & & is_optional=.true.) From 4c19eb38c920aa5d0596679ce14c321a0e5f5875 Mon Sep 17 00:00:00 2001 From: Uriel Ramirez Date: Tue, 28 Nov 2023 12:28:09 -0500 Subject: [PATCH 2/2] allow for two and/or three files --- data_override/README.MD | 4 ++-- data_override/include/data_override.inc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data_override/README.MD b/data_override/README.MD index 64ecd05bb5..f9e19464aa 100644 --- a/data_override/README.MD +++ b/data_override/README.MD @@ -24,12 +24,12 @@ If it is desired to interpolate the data to a region of the model grid. The foll - **lat_start:** The starting longitude in the same units as the grid data in the file - **lon_end:** The ending longitude in the same units as the grid data in the file -If it is desired to use multiple(3) input netcf files instead of 1. The following **optional** keys are available. +If it is desired to use multiple(3) input netcdf files instead of 1. The following **optional** keys are available. - **is_multi_file:** Set to `True` is using the multi-file feature - **prev_file_name:** The name of the first file in the set - **next_file_name:** The name of the third file in the set -Note that **file_name** must be the second file in the set. **prev_file_name** and **next_file_name** are required if **is_multi_file** is set to `True` +Note that **file_name** must be the second file in the set. **prev_file_name** and/or **next_file_name** are required if **is_multi_file** is set to `True` #### 2. How to use it? In order to use the yaml data format, [libyaml](https://github.com/yaml/libyaml) needs to be installed and linked with FMS. Additionally, FMS must be compiled with -Duse_yaml macro. If using autotools, you can add `--with-yaml`, which will add the macro for you and check that libyaml is linked correctly. diff --git a/data_override/include/data_override.inc b/data_override/include/data_override.inc index 91e43372eb..7a5999d6ff 100644 --- a/data_override/include/data_override.inc +++ b/data_override/include/data_override.inc @@ -587,7 +587,7 @@ subroutine read_table_yaml(data_table) & is_optional=.true.) call get_value_from_key(file_id, entry_id(i), "next_file_name", data_table(i)%next_file_name, & & is_optional=.true.) - if (trim(data_table(i)%prev_file_name) .eq. "" .or. trim(data_table(i)%next_file_name) .eq. "") & + if (trim(data_table(i)%prev_file_name) .eq. "" .and. trim(data_table(i)%next_file_name) .eq. "") & call mpp_error(FATAL, "The prev_file_name and next_file_name must be present if is_multi_file. "//& "Check your data_table.yaml entry for field:"//trim(data_table(i)%gridname)//":"//& trim(data_table(i)%fieldname_code))