Skip to content

Commit

Permalink
Merge pull request #3 from uramirez8707/multi_file_yaml
Browse files Browse the repository at this point in the history
multi file data override yaml
  • Loading branch information
nikizadehgfdl authored Nov 30, 2023
2 parents 0063c64 + 4c19eb3 commit e35629e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions data_override/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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 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/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.
```
Expand Down
17 changes: 17 additions & 0 deletions data_override/include/data_override.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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. "" .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))
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.)
Expand Down

0 comments on commit e35629e

Please sign in to comment.