Skip to content

Commit

Permalink
Use fms_mod:do_cf_compliance to switch time_bnds axis units
Browse files Browse the repository at this point in the history
To follow CF compliance, the time_bnds axis units must be the same as the time axis.  This modification uses the same time_axis units as the time axis if do_cf_compliance() is true.

Fixes mom-ocean#27
  • Loading branch information
underwoo committed Dec 19, 2016
1 parent 8bea088 commit 938cf5b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions diag_manager/diag_util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ MODULE diag_util_mod
& write_field_meta_data, done_meta_data
USE diag_grid_mod, ONLY: get_local_indexes
USE fms_mod, ONLY: error_mesg, FATAL, WARNING, mpp_pe, mpp_root_pe, lowercase, fms_error_handler,&
& write_version_number
& write_version_number, do_cf_compliance
USE fms_io_mod, ONLY: get_tile_string, return_domain, string, get_instance_filename
USE mpp_domains_mod,ONLY: domain1d, domain2d, mpp_get_compute_domain, null_domain1d, null_domain2d,&
& OPERATOR(.NE.), OPERATOR(.EQ.), mpp_modify_domain, mpp_get_domain_components,&
Expand Down Expand Up @@ -1936,9 +1936,17 @@ SUBROUTINE opening_file(file, time)
& cart_name, dir, edges, Domain, DATA)
CALL get_diag_axis( time_bounds_id(1), timeb_name, timeb_units, timeb_longname,&
& cart_name, dir, edges, Domain, DATA)
files(file)%f_bounds = write_field_meta_data(files(file)%file_unit,&
& TRIM(time_name)//'_bnds', (/time_bounds_id,time_axis_id/),&
& time_units, TRIM(time_name)//' axis boundaries', pack=pack_size)
IF ( do_cf_compliance() ) THEN
! CF Compliance requires the unit on the _bnds axis is the same as 'time'
files(file)%f_bounds = write_field_meta_data(files(file)%file_unit,&
& TRIM(time_name)//'_bnds', (/time_bounds_id,time_axis_id/),&
& TRIM(time_unit_list(files(file)%time_units)),&
& TRIM(time_name)//' axis boundaries', pack=pack_size)
ELSE
files(file)%f_bounds = write_field_meta_data(files(file)%file_unit,&
& TRIM(time_name)//'_bnds', (/time_bounds_id,time_axis_id/),&
& time_units, TRIM(time_name)//' axis boundaries', pack=pack_size)
END IF
END IF
! Let lower levels know that all meta data has been sent
CALL done_meta_data(files(file)%file_unit)
Expand Down

0 comments on commit 938cf5b

Please sign in to comment.