diff --git a/CHANGELOG.md b/CHANGELOG.md index 915cebbb2d60..319103f8791c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 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) + - `lons`, `lats`, `corner_lons`, and `corner_lats` are now 64-bit (double) in History files rather than 32-bit (single) + - 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 + ## [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 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) 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..427c55eed2e6 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,31 @@ 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 + + call global_attributes%insert("Title",trim(this%descr)) + call global_attributes%insert("History","File written by MAPL_PFIO") + call global_attributes%insert("Source","unknown") + call global_attributes%insert("Contact","http://gmao.gsfc.nasa.gov") + call global_attributes%insert("Convention","CF") + call global_attributes%insert("Institution","NASA Global Modeling and Assimilation Office") + call global_attributes%insert("References","see MAPL documentation") + call global_attributes%insert("Filename",trim(this%filename)) + 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)