Skip to content

Commit

Permalink
feat: Merge dmUpdate branch into main (#1505)
Browse files Browse the repository at this point in the history
  • Loading branch information
rem1776 authored May 3, 2024
2 parents 648cbcf + 00f8e36 commit b67a685
Show file tree
Hide file tree
Showing 72 changed files with 20,344 additions and 512 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,20 @@ list(APPEND fms_fortran_src_files
diag_manager/diag_output.F90
diag_manager/diag_table.F90
diag_manager/diag_util.F90
diag_manager/fms_diag_time_utils.F90
diag_manager/fms_diag_object.F90
diag_manager/fms_diag_yaml.F90
diag_manager/fms_diag_file_object.F90
diag_manager/fms_diag_field_object.F90
diag_manager/fms_diag_axis_object.F90
diag_manager/fms_diag_output_buffer.F90
diag_manager/fms_diag_input_buffer.F90
diag_manager/fms_diag_time_reduction.F90
diag_manager/fms_diag_outfield.F90
diag_manager/fms_diag_elem_weight_procs.F90
diag_manager/fms_diag_fieldbuff_update.F90
diag_manager/fms_diag_bbox.F90
diag_manager/fms_diag_reduction_methods.F90
drifters/cloud_interpolator.F90
drifters/drifters.F90
drifters/drifters_comm.F90
Expand Down
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SUBDIRS = \
mosaic2 \
fms \
parser \
string_utils \
affinity \
mosaic \
time_manager \
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ if test $with_yaml = yes; then
#If the test pass, define use_yaml macro
AC_DEFINE([use_yaml], [1], [This is required to use yaml parser])

AM_CONDITIONAL([SKIP_PARSER_TESTS], false )
AM_CONDITIONAL([USING_YAML], true)
else
AM_CONDITIONAL([SKIP_PARSER_TESTS], true )
AM_CONDITIONAL([USING_YAML], false)
fi

# Require netCDF
Expand Down
79 changes: 64 additions & 15 deletions diag_manager/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,68 @@ libdiag_manager_la_SOURCES = \
diag_output.F90 \
diag_table.F90 \
diag_util.F90 \
fms_diag_time_utils.F90 \
fms_diag_file_object.F90 \
fms_diag_field_object.F90 \
fms_diag_yaml.F90 \
fms_diag_object.F90 \
fms_diag_axis_object.F90 \
fms_diag_output_buffer.F90 \
fms_diag_input_buffer.F90 \
fms_diag_time_reduction.F90 \
fms_diag_outfield.F90 \
fms_diag_elem_weight_procs.F90 \
fms_diag_fieldbuff_update.F90 \
fms_diag_bbox.F90 \
fms_diag_reduction_methods.F90 \
include/fms_diag_fieldbuff_update.inc \
include/fms_diag_fieldbuff_update.fh
include/fms_diag_fieldbuff_update.fh \
include/fms_diag_reduction_methods.inc \
include/fms_diag_reduction_methods_r4.fh \
include/fms_diag_reduction_methods_r8.fh \
include/fms_diag_input_buffer.inc \
include/fms_diag_input_buffer_r4.fh \
include/fms_diag_input_buffer_r8.fh

# Some mods are dependant on other mods in this dir.
diag_data_mod.$(FC_MODEXT): fms_diag_bbox_mod.$(FC_MODEXT)
diag_axis_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
diag_axis_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_object_mod.$(FC_MODEXT)
diag_output_mod.$(FC_MODEXT): diag_axis_mod.$(FC_MODEXT) diag_data_mod.$(FC_MODEXT)
diag_util_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_axis_mod.$(FC_MODEXT) diag_output_mod.$(FC_MODEXT) \
diag_grid_mod.$(FC_MODEXT) fms_diag_bbox_mod.$(FC_MODEXT)
diag_grid_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT) fms_diag_bbox_mod.$(FC_MODEXT)
fms_diag_time_utils_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
diag_table_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_util_mod.$(FC_MODEXT)
fms_diag_axis_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT)
fms_diag_time_reduction_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
fms_diag_yaml_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
fms_diag_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_file_object_mod.$(FC_MODEXT) fms_diag_field_object_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) \
fms_diag_time_utils_mod.$(FC_MODEXT) \
fms_diag_output_buffer_mod.$(FC_MODEXT) \
fms_diag_reduction_methods_mod.$(FC_MODEXT) \
fms_diag_bbox_mod.$(FC_MODEXT) \
fms_diag_input_buffer_mod.$(FC_MODEXT)
fms_diag_input_buffer_mod.$(FC_MODEXT): fms_diag_axis_object_mod.$(FC_MODEXT)
fms_diag_field_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT) \
fms_diag_axis_object_mod.$(FC_MODEXT) fms_diag_input_buffer_mod.$(FC_MODEXT)
fms_diag_file_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) fms_diag_field_object_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT) \
fms_diag_axis_object_mod.$(FC_MODEXT) fms_diag_output_buffer_mod.$(FC_MODEXT)
fms_diag_axis_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) \
diag_grid_mod.$(FC_MODEXT)
fms_diag_time_reduction_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_bbox_mod.$(FC_MODEXT)
fms_diag_elem_weight_procs_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
fms_diag_outfield_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_elem_weight_procs_mod.$(FC_MODEXT)
fms_diag_fieldbuff_update_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_util_mod.$(FC_MODEXT) \
fms_diag_outfield_mod.$(FC_MODEXT) fms_diag_elem_weight_procs_mod.$(FC_MODEXT) \
fms_diag_bbox_mod.$(FC_MODEXT)
fms_diag_outfield_mod.$(FC_MODEXT) fms_diag_elem_weight_procs_mod.$(FC_MODEXT) \
fms_diag_bbox_mod.$(FC_MODEXT)
diag_manager_mod.$(FC_MODEXT): diag_axis_mod.$(FC_MODEXT) diag_data_mod.$(FC_MODEXT) diag_util_mod.$(FC_MODEXT) \
diag_output_mod.$(FC_MODEXT) diag_grid_mod.$(FC_MODEXT) diag_table_mod.$(FC_MODEXT) \
fms_diag_time_reduction_mod.$(FC_MODEXT) fms_diag_outfield_mod.$(FC_MODEXT) \
fms_diag_fieldbuff_update_mod.$(FC_MODEXT)

diag_output_mod.$(FC_MODEXT) diag_grid_mod.$(FC_MODEXT) diag_table_mod.$(FC_MODEXT) \
fms_diag_object_mod.$(FC_MODEXT) fms_diag_file_object_mod.$(FC_MODEXT) \
fms_diag_yaml_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT) \
fms_diag_axis_object_mod.$(FC_MODEXT) \
fms_diag_time_reduction_mod.$(FC_MODEXT) fms_diag_outfield_mod.$(FC_MODEXT) \
fms_diag_fieldbuff_update_mod.$(FC_MODEXT)
fms_diag_output_buffer_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) \
fms_diag_reduction_methods_mod.$(FC_MODEXT) fms_diag_time_utils_mod.$(FC_MODEXT)
fms_diag_reduction_methods_mod.$(FC_MODEXT): fms_diag_bbox_mod.$(FC_MODEXT) fms_diag_output_buffer_mod.$(FC_MODEXT) \
diag_data_mod.$(FC_MODEXT)

# Mod files are built and then installed as headers.
MODFILES = \
Expand All @@ -73,17 +108,31 @@ MODFILES = \
diag_grid_mod.$(FC_MODEXT) \
diag_output_mod.$(FC_MODEXT) \
diag_util_mod.$(FC_MODEXT) \
fms_diag_time_utils_mod.$(FC_MODEXT) \
diag_table_mod.$(FC_MODEXT) \
fms_diag_yaml_mod.$(FC_MODEXT) \
fms_diag_file_object_mod.$(FC_MODEXT) \
fms_diag_field_object_mod.$(FC_MODEXT) \
fms_diag_object_mod.$(FC_MODEXT) \
fms_diag_axis_object_mod.$(FC_MODEXT) \
fms_diag_output_buffer_mod.$(FC_MODEXT) \
fms_diag_input_buffer_mod.$(FC_MODEXT) \
diag_manager_mod.$(FC_MODEXT) \
fms_diag_time_reduction_mod.$(FC_MODEXT) \
fms_diag_outfield_mod.$(FC_MODEXT) \
fms_diag_bbox_mod.$(FC_MODEXT) \
fms_diag_bbox_mod.$(FC_MODEXT) \
fms_diag_elem_weight_procs_mod.$(FC_MODEXT) \
fms_diag_fieldbuff_update_mod.$(FC_MODEXT) \
diag_manager_mod.$(FC_MODEXT) \
fms_diag_reduction_methods_mod.$(FC_MODEXT) \
include/fms_diag_fieldbuff_update.inc \
include/fms_diag_fieldbuff_update.fh
include/fms_diag_fieldbuff_update.fh \
include/fms_diag_reduction_methods_r4.fh \
include/fms_diag_reduction_methods_r8.fh \
include/fms_diag_input_buffer.inc \
include/fms_diag_input_buffer_r4.fh \
include/fms_diag_input_buffer_r8.fh

nodist_include_HEADERS = $(MODFILES)
nodist_include_HEADERS = $(MODFILES)
BUILT_SOURCES = $(MODFILES)

include $(top_srcdir)/mkmods.mk
113 changes: 113 additions & 0 deletions diag_manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
The purpose of this document is to document the differences between the old diag manager and the new (modern) diag manager.

## Contents
- [1. Diag Table Format](README.md#1-diag-table-format)
- [2. Scalar Axis](README.md#2-scalar-axis)
- [3. Average Time Variables](README.md#3-average-time-variables)
- [4. Subregional Files](README.md#4-subregional-files)
- [5. Global attributes](README.md#5-global-attributes)
- [6. Real attributes from diag_field_add_attribute calls](README.md#6-real-attributes-from-diag_field_add_attribute-calls)
- [7. History files data output "changes"](README.md#7-history-files-data-output-changes)

### 1. Diag Table Format
The modern diag manager uses a YAML format instead of the legacy ascii table. A description of the YAML diag table can be found [here](diag_yaml_format.md).

### 2. Scalar Axis
The old diag manager was adding a `scalar_axis` dimension of size 1 for scalar variables

```
dimensions:
scalar_axis = 1 ;
variables:
double p700(scalar_axis) ;
p700:_FillValue = 1.e+20 ;
p700:missing_value = 1.e+20 ;
```
The new diag manager will no longer have a dummy scalar axis dimension.

### 3. Average Time Variables
The old diag manager includes time bounds metadata in a non-standard convention (i.e. `average_T1`, `average_T2`, and `average_DT`)
1. `average_T1` is the start time for the averaging period (in the same time units as time)
2. `average_T2` is the end time for the averaging period
3. `average_DT` is the length of the averaging period, in days

```
double average_T1(time) ;
average_T1:_FillValue = 1.e+20 ;
average_T1:missing_value = 1.e+20 ;
average_T1:units = "days since 1979-01-01 00:00:00" ;
average_T1:long_name = "Start time for average period" ;
double average_T2(time) ;
average_T2:_FillValue = 1.e+20 ;
average_T2:missing_value = 1.e+20 ;
average_T2:units = "days since 1979-01-01 00:00:00" ;
average_T2:long_name = "End time for average period" ;
double average_DT(time) ;
average_DT:_FillValue = 1.e+20 ;
average_DT:missing_value = 1.e+20 ;
average_DT:units = "days" ;
average_DT:long_name = "Length of average period" ;
```
These 3 variables are referenced as a variable attribute in each diagnostic. e.g.
```
dis_liq:time_avg_info = "average_T1,average_T2,average_DT" ;
```

The new diag manager will not be using these non standard variables. Instead the time bounds information will be specified in CF standards. One time_bounds variable, with an extra nv dimension, that species both average_T1 and average_T2. The average_DT information can be obtained from the time_bnds variable.

```
double nv(nv) ;
nv:long_name = "vertex number" ;
double time_bnds(time, nv) ;
time_bnds:units = "days since 1979-01-01 00:00:00" ;
time_bnds:long_name = "time axis boundaries" ;
```
This time_bounds variable is refernced as a variable attribute of time:
```
time:bounds = "time_bnds" ;
```

### 4. Subregional Files

#### A. `is_subregional` global attribute:
Subregional files will have a global NetCDF attribute `is_subregional = True` set for non-global history files. This attribute will be used in PP tools.

#### B. Subregional dimension names:
In some cases, the old diag manager was adding `sub0X` to the dimension names where X is a number greater than 1. This was causing problems in PP tools that were expecting the dimension to have `sub01` in the name. The new diag manager will not have this problem.

#### C. Corner and center diagnostics:
In the old diag manager, if mixing variables that are corner variables, such as velocities={uo,vo,umo,vmo} and center variables, such as tracers={thetao,so,volcello} you sometimes ended up with a different number of variables per file. The extra files had duplicate data for the corner velocities because the two PEs shared the point at the edge. This happened with some grid/layouts/masks/subregion combinations and it caused problems with the combiner. The new diag manager will not have this problem.

### 5. Global attributes
#### A. Grid type and grid tile:
The old diag manager was adding the global attributes grid_type = "regular" and grid_tile = "N/A" for all files regardless of what the grid_type and the grid_title actually were. The new diag manager will no longer be doing this as they are not correct and don’t seem to be used.

#### B. Associated_files global attribute:
We were unable to reproduce the exact order of the associated_files global attribute, so users may see differences like

```
lake_area: 19790101.land_static.nc soil_area: 19790101.land_static.nc land_area: 19790101.land_static.nc <> land_area: 19790101.land_static.nc soil_area: 19790101.land_static.nc lake_area: 19790101.land_static.nc
```

### 6. Real attributes from diag_field_add_attribute calls
When real attributes were added to the file via a diag_field_add_attribute call, the old diag manager is always saving it as NF90_FLOAT regardless of the precision the data was [passed in](https://github.com/NOAA-GFDL/FMS/blob/ebb32649efa395ea14598f74c8d49e74d1408579/diag_manager/diag_manager.F90#L4532-L4543)

The new diag manager is going to write the attribute as it is passed in. This will cause differences when the model component was compiled with r8 as it will write the attribute as r8 instead of r4.

### 7. History files data output "changes"
When the model run time is less than then the output frequency (i.e if the module run time is 2 days and you are writing monthly diagnostics), the old diag manager was writing 9.96921e+36. The new diag manager is not going to write anything for this cases, so if you ncdump the output from the new diag manager, you will get:

```
wa =
_, _, _, _, _, _, ...
```

Similarly, when a variable was registered, but send_data was never called, the old diag manager was outputting the warning like

```
WARNING from PE 0: diag_manager_mod::closing_file: module/output_field soil/soil_fgw, skip one time level, maybe send_data never called
```

And writing out `9.96921e+36` for the variable. The new diag manager will also be outputting the warning, but it will not write out anything.


Loading

0 comments on commit b67a685

Please sign in to comment.