Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto GitFlow - main β†’ develop #1272

Merged
merged 10 commits into from
Jan 6, 2022
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions base/MAPL_CubedSphereGridFactory.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions base/MAPL_LatLonGridFactory.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
22 changes: 22 additions & 0 deletions gridcomps/History/MAPL_HistoryCollection.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module MAPL_HistoryCollectionMod
use MAPL_VerticalDataMod
use MAPL_TimeDataMod
use HistoryTrajectoryMod
use gFTL_StringStringMap
implicit none

private
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions gridcomps/History/MAPL_HistoryGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
!------
Expand Down Expand Up @@ -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)
Expand Down
25 changes: 22 additions & 3 deletions griddedio/GriddedIO.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down