From b3bae44333888a08d3dfd906b642e7ec8f44203e Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Wed, 5 Jan 2022 13:25:22 -0500 Subject: [PATCH 1/6] fixes #1269 --- CHANGELOG.md | 2 ++ base/MAPL_LatLonGridFactory.F90 | 4 +-- gridcomps/History/MAPL_HistoryCollection.F90 | 31 ++++++++++++++++++++ gridcomps/History/MAPL_HistoryGridComp.F90 | 7 +++-- griddedio/GriddedIO.F90 | 25 ++++++++++++++-- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 915cebbb2d60..db8444e1fb53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Add back attributes at the variable level and global level in History output that were accidentally eliminated when Hisotyr moved from CFIO to PFIO. Also revert the coordinate variables in the lat-lon output to double precision + ### Added ### Changed diff --git a/base/MAPL_LatLonGridFactory.F90 b/base/MAPL_LatLonGridFactory.F90 index 41a5133bdd6d..de1c6df15f79 100644 --- a/base/MAPL_LatLonGridFactory.F90 +++ b/base/MAPL_LatLonGridFactory.F90 @@ -1761,13 +1761,13 @@ subroutine append_metadata(this, metadata) call metadata%add_dimension('lat', this%jm_world) ! Coordinate variables - v = Variable(type=PFIO_REAL32, dimensions='lon') + v = Variable(type=PFIO_REAL64, dimensions='lon') call v%add_attribute('long_name', 'longitude') call v%add_attribute('units', 'degrees_east') call v%add_const_value(UnlimitedEntity(MAPL_RADIANS_TO_DEGREES*this%get_longitudes())) call metadata%add_variable('lon', v) - v = Variable(type=PFIO_REAL32, dimensions='lat') + v = Variable(type=PFIO_REAL64, dimensions='lat') call v%add_attribute('long_name', 'latitude') call v%add_attribute('units', 'degrees_north') call v%add_const_value(UnlimitedEntity(MAPL_RADIANS_TO_DEGREES*this%get_latitudes())) diff --git a/gridcomps/History/MAPL_HistoryCollection.F90 b/gridcomps/History/MAPL_HistoryCollection.F90 index d5d6b9b0c57d..35886bd77abc 100644 --- a/gridcomps/History/MAPL_HistoryCollection.F90 +++ b/gridcomps/History/MAPL_HistoryCollection.F90 @@ -9,6 +9,7 @@ module MAPL_HistoryCollectionMod use MAPL_VerticalDataMod use MAPL_TimeDataMod use HistoryTrajectoryMod + use gFTL_StringStringMap implicit none private @@ -91,10 +92,40 @@ module MAPL_HistoryCollectionMod character(len=ESMF_MAXSTR) :: positive contains procedure :: AddGrid + procedure :: define_collection_attributes end type HistoryCollection contains + function define_collection_attributes(this,rc) result(global_attributes) + class(HistoryCollection), intent(inout) :: this + integer, optional, intent(out) :: rc + + type(StringStringMap) :: global_attributes + integer :: status + + ! title + call global_attributes%insert("Title",trim(this%descr)) + ! History + call global_attributes%insert("History","File written by MAPL_PFIO") + ! Source + call global_attributes%insert("Source","unknown") + ! Contact + call global_attributes%insert("Contact","http://gmao.gsfc.nasa.gov") + ! Convention + call global_attributes%insert("Convention","CF") + ! Institution + call global_attributes%insert("Institution","NASA Global Modeling and Assimilation Office") + ! References + call global_attributes%insert("References","see MAPL documentation") + ! filename + call global_attributes%insert("Filename",trim(this%filename)) + ! comment + call global_attributes%insert("Comment","NetCDF-4") + + _RETURN(_SUCCESS) + end function define_collection_attributes + subroutine AddGrid(this,output_grids,resolution,rc) use MAPL_GridManagerMod use MAPL_AbstractGridFactoryMod diff --git a/gridcomps/History/MAPL_HistoryGridComp.F90 b/gridcomps/History/MAPL_HistoryGridComp.F90 index 92a4a6606179..ebd53a6b152b 100644 --- a/gridcomps/History/MAPL_HistoryGridComp.F90 +++ b/gridcomps/History/MAPL_HistoryGridComp.F90 @@ -44,6 +44,7 @@ module MAPL_HistoryGridCompMod use MAPL_StringTemplate use regex_module use MAPL_TimeUtilsMod, only: is_valid_time, is_valid_date + use gFTL_StringStringMap !use ESMF_CFIOMOD implicit none @@ -408,6 +409,7 @@ subroutine Initialize ( gc, import, dumexport, clock, rc ) logical, allocatable :: needSplit(:) type(ESMF_Field), allocatable :: fldList(:) character(len=ESMF_MAXSTR), allocatable :: regexList(:) + type(StringStringMap) :: global_attributes ! Begin !------ @@ -2432,12 +2434,13 @@ subroutine Initialize ( gc, import, dumexport, clock, rc ) call list(n)%trajectory%initialize(list(n)%items,list(n)%bundle,list(n)%timeInfo,vdata=list(n)%vdata,recycle_track=list(n)%recycle_track,rc=status) _VERIFY(status) else + global_attributes = list(n)%define_collection_attributes(_RC) if (trim(list(n)%output_grid_label)/='') then pgrid => IntState%output_grids%at(trim(list(n)%output_grid_label)) - call list(n)%mGriddedIO%CreateFileMetaData(list(n)%items,list(n)%bundle,list(n)%timeInfo,ogrid=pgrid,vdata=list(n)%vdata,rc=status) + call list(n)%mGriddedIO%CreateFileMetaData(list(n)%items,list(n)%bundle,list(n)%timeInfo,ogrid=pgrid,vdata=list(n)%vdata,global_attributes=global_attributes,rc=status) _VERIFY(status) else - call list(n)%mGriddedIO%CreateFileMetaData(list(n)%items,list(n)%bundle,list(n)%timeInfo,vdata=list(n)%vdata,rc=status) + call list(n)%mGriddedIO%CreateFileMetaData(list(n)%items,list(n)%bundle,list(n)%timeInfo,vdata=list(n)%vdata,global_attributes=global_attributes,rc=status) _VERIFY(status) end if collection_id = o_Clients%add_hist_collection(list(n)%mGriddedIO%metadata) diff --git a/griddedio/GriddedIO.F90 b/griddedio/GriddedIO.F90 index 2937392d5a4c..03f6a3fa6af3 100644 --- a/griddedio/GriddedIO.F90 +++ b/griddedio/GriddedIO.F90 @@ -20,6 +20,7 @@ module MAPL_GriddedIOMod use MAPL_DataCollectionMod use MAPL_DataCollectionManagerMod use gFTL_StringVector + use gFTL_StringStringMap use MAPL_FileMetadataUtilsMod use, intrinsic :: ISO_C_BINDING use, intrinsic :: iso_fortran_env, only: REAL64 @@ -99,13 +100,14 @@ function new_MAPL_GriddedIO(metadata,input_bundle,output_bundle,write_collection _RETURN(ESMF_SUCCESS) end function new_MAPL_GriddedIO - subroutine CreateFileMetaData(this,items,bundle,timeInfo,vdata,ogrid,rc) + subroutine CreateFileMetaData(this,items,bundle,timeInfo,vdata,ogrid,global_attributes,rc) class (MAPL_GriddedIO), intent(inout) :: this type(GriddedIOitemVector), target, intent(inout) :: items type(ESMF_FieldBundle), intent(inout) :: bundle type(TimeData), intent(inout) :: timeInfo type(VerticalData), intent(inout), optional :: vdata type (ESMF_Grid), intent(inout), pointer, optional :: ogrid + type(StringStringMap), intent(in), optional :: global_attributes integer, intent(out), optional :: rc type(ESMF_Grid) :: input_grid @@ -115,7 +117,8 @@ subroutine CreateFileMetaData(this,items,bundle,timeInfo,vdata,ogrid,rc) type(GriddedIOitem), pointer :: item type(stringVector) :: order integer :: metadataVarsSize - + type(StringStringMapIterator) :: s_iter + character(len=:), pointer :: attr_name, attr_val integer :: status this%items = items @@ -182,7 +185,17 @@ subroutine CreateFileMetaData(this,items,bundle,timeInfo,vdata,ogrid,rc) call this%alphabatize_variables(metadataVarsSize,rc=status) _VERIFY(status) end if - + + if (present(global_attributes)) then + s_iter = global_attributes%begin() + do while(s_iter /= global_attributes%end()) + attr_name => s_iter%key() + attr_val => s_iter%value() + call this%metadata%add_attribute(attr_name,attr_val,_RC) + call s_iter%next() + enddo + end if + end subroutine CreateFileMetaData subroutine set_param(this,deflation,chunking,nbits,regrid_method,itemOrder,write_collection_id,rc) @@ -290,7 +303,13 @@ subroutine CreateVariable(this,itemName,rc) v = Variable(type=PFIO_REAL32,dimensions=vdims,chunksizes=this%chunking,deflation=this%deflateLevel) call v%add_attribute('units',trim(units)) call v%add_attribute('long_name',trim(longName)) + call v%add_attribute('standard_name',trim(longName)) call v%add_attribute('missing_value',MAPL_UNDEF) + call v%add_attribute('fmissing_value',MAPL_UNDEF) + call v%add_attribute('vmax',MAPL_UNDEF) + call v%add_attribute('vmin',-MAPL_UNDEF) + call v%add_attribute('scale_factor',1.0) + call v%add_attribute('add_offset',0.0) call v%add_attribute('_FillValue',MAPL_UNDEF) call v%add_attribute('valid_range',(/-MAPL_UNDEF,MAPL_UNDEF/)) call factory%append_variable_metadata(v) From 1770eb1535957776aa148122e22f88d47cb51357 Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Wed, 5 Jan 2022 13:31:23 -0500 Subject: [PATCH 2/6] remove comments --- gridcomps/History/MAPL_HistoryCollection.F90 | 9 --------- 1 file changed, 9 deletions(-) diff --git a/gridcomps/History/MAPL_HistoryCollection.F90 b/gridcomps/History/MAPL_HistoryCollection.F90 index 35886bd77abc..427c55eed2e6 100644 --- a/gridcomps/History/MAPL_HistoryCollection.F90 +++ b/gridcomps/History/MAPL_HistoryCollection.F90 @@ -104,23 +104,14 @@ function define_collection_attributes(this,rc) result(global_attributes) type(StringStringMap) :: global_attributes integer :: status - ! title call global_attributes%insert("Title",trim(this%descr)) - ! History call global_attributes%insert("History","File written by MAPL_PFIO") - ! Source call global_attributes%insert("Source","unknown") - ! Contact call global_attributes%insert("Contact","http://gmao.gsfc.nasa.gov") - ! Convention call global_attributes%insert("Convention","CF") - ! Institution call global_attributes%insert("Institution","NASA Global Modeling and Assimilation Office") - ! References call global_attributes%insert("References","see MAPL documentation") - ! filename call global_attributes%insert("Filename",trim(this%filename)) - ! comment call global_attributes%insert("Comment","NetCDF-4") _RETURN(_SUCCESS) From 089c74f78a48307ee92158732848b6d3150ba6f1 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 5 Jan 2022 15:57:11 -0500 Subject: [PATCH 3/6] Make changelog consistent with 2.8.0.1 --- CHANGELOG.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db8444e1fb53..0577ce883c0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,12 +9,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Add back attributes at the variable level and global level in History output that were accidentally eliminated when Hisotyr moved from CFIO to PFIO. Also revert the coordinate variables in the lat-lon output to double precision - ### Added ### Changed +- Changes to make MAPL 2 History output match GEOS FP file spec + - Coordinate Variables + - `lon` and `lat` are now 64-bit (double) in lat-lon History files rather than 32-bit (single) + - `lons`, `lats`, `corner_lons`, and `corner_lats` are now 64-bit (double) in History files rather than 32-bit (single) + - `time` is now an integer *if* the History is output at a frequency that is not a fraction of the time unit + - Variable Metadata + - Added `fmissing_value` (equal to `_FillValue` aka `MAPL_UNDEF`) + - Added `missing_value` (equal to `_FillValue` aka `MAPL_UNDEF`) + - Added `vmin` (equal to `-MAPL_UNDEF`) + - Added `vmax` (equal to `+MAPL_UNDEF`) + - Added `add_offset` (equal to 0.0) + - Added `scale_factor` (equal to 1.0) + - Added `standard_name` (equal to `long_name`) + - Global Metadata + - Added `Title`, `History`, `Source`, `Contact`, `Convention`, `Institution`, `References`, `Filename`, `Comment` + - These currently have hardcoded values roughly equivalent to the GEOS FP 5.27 output + ### Removed ### Deprecated From f5dd5aab3d79362e8073c4b1a4a2e1c880d27521 Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Wed, 5 Jan 2022 15:59:12 -0500 Subject: [PATCH 4/6] make 2d coordinates in cubedspherefactory double precision --- base/MAPL_CubedSphereGridFactory.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/MAPL_CubedSphereGridFactory.F90 b/base/MAPL_CubedSphereGridFactory.F90 index 88e90fbfd25a..8550a1bdb786 100644 --- a/base/MAPL_CubedSphereGridFactory.F90 +++ b/base/MAPL_CubedSphereGridFactory.F90 @@ -1038,27 +1038,27 @@ subroutine append_metadata(this, metadata)!, unusable, rc) call metadata%add_variable('anchor', v) call Metadata%add_attribute('grid_mapping_name', 'gnomonic cubed-sphere') - call Metadata%add_attribute('file_format_version', '2.91') + call Metadata%add_attribute('file_format_version', '2.92') call Metadata%add_attribute('additional_vars', 'contacts,orientation,anchor') write(gridspec_file_name,'("C",i0,"_gridspec.nc4")') this%im_world call Metadata%add_attribute('gridspec_file', trim(gridspec_file_name)) - v = Variable(type=PFIO_REAL32, dimensions='Xdim,Ydim,nf') + v = Variable(type=PFIO_REAL64, dimensions='Xdim,Ydim,nf') call v%add_attribute('long_name','longitude') call v%add_attribute('units','degrees_east') call metadata%add_variable('lons',v) - v = Variable(type=PFIO_REAL32, dimensions='Xdim,Ydim,nf') + v = Variable(type=PFIO_REAL64, dimensions='Xdim,Ydim,nf') call v%add_attribute('long_name','latitude') call v%add_attribute('units','degrees_north') call metadata%add_variable('lats',v) - v = Variable(type=PFIO_REAL32, dimensions='XCdim,YCdim,nf') + v = Variable(type=PFIO_REAL64, dimensions='XCdim,YCdim,nf') call v%add_attribute('long_name','longitude') call v%add_attribute('units','degrees_east') call metadata%add_variable('corner_lons',v) - v = Variable(type=PFIO_REAL32, dimensions='XCdim,YCdim,nf') + v = Variable(type=PFIO_REAL64, dimensions='XCdim,YCdim,nf') call v%add_attribute('long_name','latitude') call v%add_attribute('units','degrees_north') call metadata%add_variable('corner_lats',v) From 0b9029d62306b2127a046e69996d3999dc75e721 Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Wed, 5 Jan 2022 16:36:44 -0500 Subject: [PATCH 5/6] updated changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0577ce883c0e..38ad53b033ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Coordinate Variables - `lon` and `lat` are now 64-bit (double) in lat-lon History files rather than 32-bit (single) - `lons`, `lats`, `corner_lons`, and `corner_lats` are now 64-bit (double) in History files rather than 32-bit (single) - - `time` is now an integer *if* the History is output at a frequency that is not a fraction of the time unit - Variable Metadata - Added `fmissing_value` (equal to `_FillValue` aka `MAPL_UNDEF`) - Added `missing_value` (equal to `_FillValue` aka `MAPL_UNDEF`) From 1c7719c574a6e3b140d403201daf3c3a11a3ca72 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 5 Jan 2022 19:09:48 -0500 Subject: [PATCH 6/6] Prepare for 2.15.1 release --- CHANGELOG.md | 12 ++++++++---- CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38ad53b033ad..319103f8791c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +### Removed + +### Deprecated + +## [2.15.1] - 2022-01-06 + +### Changed + - Changes to make MAPL 2 History output match GEOS FP file spec - Coordinate Variables - `lon` and `lat` are now 64-bit (double) in lat-lon History files rather than 32-bit (single) @@ -29,10 +37,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `Title`, `History`, `Source`, `Contact`, `Convention`, `Institution`, `References`, `Filename`, `Comment` - These currently have hardcoded values roughly equivalent to the GEOS FP 5.27 output -### Removed - -### Deprecated - ## [2.15.0] - 2022-01-04 ### Fixed diff --git a/CMakeLists.txt b/CMakeLists.txt index bf2a89eb0439..6200225e826d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_policy (SET CMP0054 NEW) project ( MAPL - VERSION 2.15.0 + VERSION 2.15.1 LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF # Set the default build type to release