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

Hotfix: Fix attributes to match FP #1366

Merged
merged 4 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Deprecated

## [2.17.2] - 2022-02-16

- Fixes for Global Attributes to match FP 5.27
- Changed `lev` variable `standard_name` to `model_layers`
- Changed global attribute `Convention` to `Conventions`
- Fill `Source` with a string "<EXPSRC> experiment_id: <EXPID>" where EXPSRC and EXPID are from the `EXPSRC:` and `EXPID:` lines in HISTORY.rc

## [2.17.1] - 2022-02-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.17.1
VERSION 2.17.2
LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF

# Set the default build type to release
Expand Down
2 changes: 1 addition & 1 deletion Tests/pfio_MAPL_demo.F90
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ program main
rc = status)

! Set File attributes
call fmd%add_attribute('Convention', 'COARDS')
call fmd%add_attribute('Conventions', 'COARDS')
call fmd%add_attribute('Source', 'GMAO')
call fmd%add_attribute('Title', 'Sample code to test PFIO')
call fmd%add_attribute('HISTORY', 'File writtem by PFIO vx.x.x')
Expand Down
40 changes: 20 additions & 20 deletions base/MAPL_VerticalMethods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module MAPL_VerticalDataMod
use, intrinsic :: ISO_C_BINDING
use, intrinsic :: iso_fortran_env, only: REAL64
implicit none

private

public :: VERTICAL_METHOD_NONE
Expand Down Expand Up @@ -56,7 +56,7 @@ module MAPL_VerticalDataMod
end interface

contains

function newVerticalData(levels,vcoord,vscale,vunit,positive,rc) result(vdata)
type(VerticalData) :: vData
real, pointer, intent(in), optional :: levels(:)
Expand All @@ -65,14 +65,14 @@ function newVerticalData(levels,vcoord,vscale,vunit,positive,rc) result(vdata)
character(len=*), optional, intent(in) :: vunit
character(len=*), optional, intent(in) :: positive
integer, optional, intent(Out) :: rc


if (present(positive)) then
_ASSERT(trim(positive)=='up'.or.trim(positive)=='down',trim(positive)//" not allowed for positive argument")
vdata%positive=trim(positive)
else
vdata%positive='down'
end if
end if

if (.not.present(levels)) then
if (trim(vdata%positive)=='down') then
Expand Down Expand Up @@ -109,7 +109,7 @@ function newVerticalData(levels,vcoord,vscale,vunit,positive,rc) result(vdata)
else
vdata%interp_levels = vdata%scaled_levels
endif
else
else
vdata%regrid_type = VERTICAL_METHOD_SELECT
end if
end function newVerticalData
Expand Down Expand Up @@ -166,7 +166,7 @@ subroutine setup_eta_to_pressure(this,regrid_handle,output_grid,rc)
this%pl3d = ( 0.5*(ptr3(:,:,1:)+ptr3(:,:,0:ubound(ptr3,3)-1)) )
end if
orig_surface_level = ptr3(:,:,ubound(ptr3,3))
this%ascending = (ptr3(1,1,0)<ptr3(1,1,1))
this%ascending = (ptr3(1,1,0)<ptr3(1,1,1))
else

! the ptr3 interpolating variable is a (1-lm) mid-layer variable
Expand Down Expand Up @@ -201,7 +201,7 @@ subroutine setup_eta_to_pressure(this,regrid_handle,output_grid,rc)
_ASSERT(present(regrid_handle),"Must provide regridding handle")
call MAPL_GridGet(output_grid,localCellCountPerDim=counts,rc=status)
_VERIFY(status)
if (.not.allocated(this%surface_level)) then
if (.not.allocated(this%surface_level)) then
allocate(this%surface_level(counts(1),counts(2)),stat=status)
_VERIFY(status)
end if
Expand Down Expand Up @@ -241,15 +241,15 @@ subroutine flip_levels(this,ptrin,ptrout,rc)
integer :: km

_ASSERT(all(shape(ptrin)==shape(ptrout)),"array must match shape to flip")

km = size(ptrin,3)

ptrout(:,:,1:km)=ptrin(:,:,km:1:-1)
_RETURN(_SUCCESS)

end subroutine flip_levels

subroutine correct_topo(this,field,rc)
subroutine correct_topo(this,field,rc)
class(verticalData), intent(inout) :: this
type(ESMF_Field), intent(inout) :: field
integer, optional, intent(out) :: rc
Expand Down Expand Up @@ -286,7 +286,7 @@ subroutine regrid_select_level(this,ptrIn,PtrOut,rc)
integer :: i

do i=1,size(this%levs)
ptrOut(:,:,i)=ptrIn(:,:,nint(this%levs(i)))
ptrOut(:,:,i)=ptrIn(:,:,nint(this%levs(i)))
enddo
_RETURN(ESMF_SUCCESS)

Expand Down Expand Up @@ -316,16 +316,16 @@ subroutine append_vertical_metadata(this,metadata,bundle,rc)
type(ESMF_Field) :: field
real, pointer :: ptr3d(:,:,:)
logical :: haveVert

logical, allocatable :: HasUngrid(:)
character(len=ESMF_MAXSTR), allocatable :: ungridded_units(:)
character(len=ESMF_MAXSTR), allocatable :: ungridded_names(:)
character(len=ESMF_MAXSTR), allocatable :: ungridded_names(:)
character(len=ESMF_MAXSTR) :: ungridded_unit, ungridded_name
integer :: ungrdsize
real, allocatable :: ungridded_coord(:)
real, allocatable :: ungridded_coords(:,:)
logical :: unGrdNameCheck, unGrdUnitCheck, unGrdCoordCheck, have_ungrd, found_mixed_ce

integer :: status
type(Variable) :: v
logical :: isPresent
Expand Down Expand Up @@ -425,7 +425,7 @@ subroutine append_vertical_metadata(this,metadata,bundle,rc)
vlb = 0
else
vlb = 1
end if
end if
end if

if (this%regrid_type == VERTICAL_METHOD_ETA2LEV) then
Expand All @@ -443,7 +443,7 @@ subroutine append_vertical_metadata(this,metadata,bundle,rc)
if (this%regrid_type == VERTICAL_METHOD_NONE) then
_ASSERT(.not.(found_mixed_ce),'have mixed level/edge')
end if


if (haveVert) then
this%lm=lm
Expand All @@ -458,7 +458,7 @@ subroutine append_vertical_metadata(this,metadata,bundle,rc)
if (allocated(ungridded_coord)) then
this%levs=ungridded_coord
end if

call metadata%add_dimension('lev', lm, rc=status)
v = Variable(type=PFIO_REAL64, dimensions='lev')
call v%add_attribute('units',ungridded_unit)
Expand All @@ -467,14 +467,14 @@ subroutine append_vertical_metadata(this,metadata,bundle,rc)
call v%add_const_value(UnlimitedEntity(this%levs))
call metadata%add_variable('lev',v,rc=status)
_VERIFY(status)
else
else
call metadata%add_dimension('lev', lm, rc=status)
v = Variable(type=PFIO_REAL64, dimensions='lev')
call v%add_attribute('long_name','vertical level')
call v%add_attribute('units','layer')
call v%add_attribute('positive',trim(this%positive))
call v%add_attribute('coordinate','eta')
call v%add_attribute('standard_name','model_layer')
call v%add_attribute('standard_name','model_layers')
call v%add_const_value(UnlimitedEntity(this%levs))
call metadata%add_variable('lev',v,rc=status)
_VERIFY(status)
Expand Down Expand Up @@ -503,7 +503,7 @@ subroutine append_vertical_metadata(this,metadata,bundle,rc)
call v%add_attribute('units','layer')
call v%add_attribute('positive','down')
call v%add_attribute('coordinate','eta')
call v%add_attribute('standard_name','model_layer')
call v%add_attribute('standard_name','model_layers')
call v%add_const_value(UnlimitedEntity(this%levs))
call metadata%add_variable('lev',v,rc=status)
_VERIFY(status)
Expand Down
29 changes: 15 additions & 14 deletions gridcomps/History/MAPL_HistoryCollection.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module MAPL_HistoryCollectionMod
use HistoryTrajectoryMod
use gFTL_StringStringMap
implicit none

private

type, public :: FieldSet
Expand All @@ -26,6 +26,7 @@ module MAPL_HistoryCollectionMod
character(len=ESMF_MAXSTR) :: format
character(len=ESMF_MAXSTR) :: mode
character(len=ESMF_MAXSTR) :: descr
character(len=ESMF_MAXSTR) :: source
integer :: frequency
integer :: acc_interval
integer :: ref_date
Expand Down Expand Up @@ -61,7 +62,7 @@ module MAPL_HistoryCollectionMod
integer :: conservative
integer :: voting
integer :: nbits
integer :: deflate
integer :: deflate
integer :: slices
integer :: Root
integer :: Psize
Expand Down Expand Up @@ -89,7 +90,7 @@ module MAPL_HistoryCollectionMod
logical :: timeseries_output = .false.
logical :: recycle_track = .false.
type(HistoryTrajectory) :: trajectory
character(len=ESMF_MAXSTR) :: positive
character(len=ESMF_MAXSTR) :: positive
contains
procedure :: AddGrid
procedure :: define_collection_attributes
Expand All @@ -106,9 +107,9 @@ function define_collection_attributes(this,rc) result(global_attributes)

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("Source",trim(this%source))
call global_attributes%insert("Contact","http://gmao.gsfc.nasa.gov")
call global_attributes%insert("Convention","CF")
call global_attributes%insert("Conventions","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))
Expand All @@ -117,7 +118,7 @@ function define_collection_attributes(this,rc) result(global_attributes)
_RETURN(_SUCCESS)
end function define_collection_attributes

subroutine AddGrid(this,output_grids,resolution,rc)
subroutine AddGrid(this,output_grids,resolution,rc)
use MAPL_GridManagerMod
use MAPL_AbstractGridFactoryMod
use MAPL_ConfigMod
Expand All @@ -130,7 +131,7 @@ subroutine AddGrid(this,output_grids,resolution,rc)
integer, intent(inout), optional :: rc

integer :: status
character(len=ESMF_MAXSTR), parameter :: Iam = "AddGrid"
character(len=ESMF_MAXSTR), parameter :: Iam = "AddGrid"
type(ESMF_Config) :: cfg
integer :: nx,ny,im_world,jm_world
character(len=ESMF_MAXSTR) :: tlabel
Expand All @@ -155,7 +156,7 @@ subroutine AddGrid(this,output_grids,resolution,rc)
_VERIFY(status)
call MAPL_ConfigSetAttribute(cfg,value=ny, label=trim(tlabel)//".NY:",rc=status)
_VERIFY(status)

if (resolution(2)==resolution(1)*6) then
call MAPL_ConfigSetAttribute(cfg,value="Cubed-Sphere", label=trim(tlabel)//".GRID_TYPE:",rc=status)
_VERIFY(status)
Expand All @@ -177,20 +178,20 @@ subroutine AddGrid(this,output_grids,resolution,rc)
end if
output_grid = grid_manager%make_grid(cfg,prefix=trim(tlabel)//'.',rc=status)
_VERIFY(status)

factory => grid_manager%get_factory(output_grid,rc=status)
_VERIFY(status)
this%output_grid_label = factory%generate_grid_name()
lgrid => output_grids%at(trim(this%output_grid_label))
if (.not.associated(lgrid)) call output_grids%insert(this%output_grid_label,output_grid)
if (.not.associated(lgrid)) call output_grids%insert(this%output_grid_label,output_grid)

end subroutine AddGrid

end module MAPL_HistoryCollectionMod

module MAPL_HistoryCollectionVectorMod
use MAPL_HistoryCollectionMod

#define _type type (HistoryCollection)
#define _vector HistoryCollectionVector
#define _iterator HistoryCollectionVectorIterator
Expand All @@ -200,7 +201,7 @@ module MAPL_HistoryCollectionVectorMod
#undef _iterator
#undef _vector
#undef _type

end module MAPL_HistoryCollectionVectorMod

module MAPL_StringFieldSetMapMod
Expand All @@ -218,5 +219,5 @@ module MAPL_StringFieldSetMapMod
#undef _map
#undef _value
#undef _key

end module MAPL_StringFieldSetMapMod
1 change: 1 addition & 0 deletions gridcomps/History/MAPL_HistoryGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ subroutine Initialize ( gc, import, dumexport, clock, rc )
list(n)%monthly = .false.
list(n)%splitField = .false.
list(n)%regex = .false.
list(n)%source = trim(INTSTATE%expsrc) // ' experiment_id: ' // trim(INTSTATE%expid)

cfg = ESMF_ConfigCreate(rc=STATUS)
_VERIFY(STATUS)
Expand Down