From 87695c350c009923ada53e8fb55e72ab6a464750 Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Thu, 21 Nov 2024 15:03:18 -0500 Subject: [PATCH 1/7] updates --- base/MAPL_LatLonGridFactory.F90 | 99 +++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 12 deletions(-) diff --git a/base/MAPL_LatLonGridFactory.F90 b/base/MAPL_LatLonGridFactory.F90 index fbbbfe3a41e7..0e2f59db9a32 100644 --- a/base/MAPL_LatLonGridFactory.F90 +++ b/base/MAPL_LatLonGridFactory.F90 @@ -218,10 +218,16 @@ function create_basic_grid(this, unusable, rc) result(grid) integer, optional, intent(out) :: rc integer :: status + type(ESMF_PoleKind_Flag) :: polekindflag(2) _UNUSED_DUMMY(unusable) if (this%periodic) then + if (this%pole == "XY") then + polekindflag = ESMF_POLEKIND_NONE + else + polekindflag = ESMF_POLEKIND_BIPOLE + end if grid = ESMF_GridCreate1PeriDim( & & name = this%grid_name, & & countsPerDEDim1=this%ims, & @@ -232,6 +238,7 @@ function create_basic_grid(this, unusable, rc) result(grid) & coordDep1=[1,2], & & coordDep2=[1,2], & & coordSys=ESMF_COORDSYS_SPH_RAD, & + & polekindflag=polekindflag, & & rc=status) _VERIFY(status) else @@ -673,7 +680,7 @@ subroutine initialize_from_file_metadata(this, file_metadata, unusable, force_fi integer :: i_min, i_max real(kind=REAL64) :: d_lat, d_lat_temp, extrap_lat - logical :: is_valid, use_file_coords, compute_lons, compute_lats + logical :: is_valid, use_file_coords, compute_lons, compute_lats, has_bnds _UNUSED_DUMMY(unusable) @@ -759,6 +766,10 @@ subroutine initialize_from_file_metadata(this, file_metadata, unusable, force_fi where(this%lon_centers > 180) this%lon_centers=this%lon_centers-360 end if + has_bnds = coordinate_has_bounds(file_metadata, lon_name, _RC) + if (has_bnds) then + this%lon_corners = get_coordinate_bounds(file_metadata, lon_name, _RC) + end if v => file_metadata%get_coordinate_variable(lat_name, rc=status) _VERIFY(status) @@ -773,6 +784,11 @@ subroutine initialize_from_file_metadata(this, file_metadata, unusable, force_fi _FAIL('unsupported type of data; must be REAL32 or REAL64') end select + has_bnds = coordinate_has_bounds(file_metadata, lat_name, _RC) + if (has_bnds) then + this%lat_corners = get_coordinate_bounds(file_metadata, lat_name, _RC) + end if + ! Check: is this a "mis-specified" pole-centered grid? if (size(this%lat_centers) >= 4) then @@ -804,14 +820,14 @@ subroutine initialize_from_file_metadata(this, file_metadata, unusable, force_fi end if end if - ! Corners are the midpoints of centers (and extrapolated at the ! poles for lats.) - allocate(this%lon_corners(im+1), this%lat_corners(jm+1)) - - this%lon_corners(1) = (this%lon_centers(im) + this%lon_centers(1))/2 - 180 - this%lon_corners(2:im) = (this%lon_centers(1:im-1) + this%lon_centers(2:im))/2 - this%lon_corners(im+1) = (this%lon_centers(im) + this%lon_centers(1))/2 + 180 + if (.not. allocated(this%lon_corners)) then + allocate(this%lon_corners(im+1)) + this%lon_corners(1) = (this%lon_centers(im) + this%lon_centers(1))/2 - 180 + this%lon_corners(2:im) = (this%lon_centers(1:im-1) + this%lon_centers(2:im))/2 + this%lon_corners(im+1) = (this%lon_centers(im) + this%lon_centers(1))/2 + 180 + end if ! This section about pole/dateline is probably not needed in file data case. if (abs(this%lon_centers(1) + 180) < 1000*epsilon(1.0)) then @@ -826,10 +842,13 @@ subroutine initialize_from_file_metadata(this, file_metadata, unusable, force_fi this%dateline = 'XY' this%lon_range = RealMinMax(this%lon_centers(1), this%lon_centers(jm)) end if - - this%lat_corners(1) = this%lat_centers(1) - (this%lat_centers(2)-this%lat_centers(1))/2 - this%lat_corners(2:jm) = (this%lat_centers(1:jm-1) + this%lat_centers(2:jm))/2 - this%lat_corners(jm+1) = this%lat_centers(jm) - (this%lat_centers(jm-1)-this%lat_centers(jm))/2 + + if (.not. allocated(this%lat_corners)) then + allocate(this%lat_corners(jm+1)) + this%lat_corners(1) = this%lat_centers(1) - (this%lat_centers(2)-this%lat_centers(1))/2 + this%lat_corners(2:jm) = (this%lat_centers(1:jm-1) + this%lat_centers(2:jm))/2 + this%lat_corners(jm+1) = this%lat_centers(jm) - (this%lat_centers(jm-1)-this%lat_centers(jm))/2 + end if if (abs(this%lat_centers(1) + 90) < 1000*epsilon(1.0)) then this%pole = 'PC' @@ -1139,7 +1158,6 @@ subroutine check_and_fill_consistency(this, unusable, rc) ! Check regional vs global if (this%pole == 'XY') then ! regional - this%periodic = .false. _ASSERT(this%lat_range%min /= MAPL_UNDEFINED_REAL, 'uninitialized min for lat_range') _ASSERT(this%lat_range%max /= MAPL_UNDEFINED_REAL, 'uninitialized min for lat_range') else ! global @@ -1928,5 +1946,62 @@ function generate_file_reference3D(this,fpointer,metaData) result(ref) _UNUSED_DUMMY(metaData) end function generate_file_reference3D + function coordinate_has_bounds(metadata, coord_name, rc) result(has_bounds) + logical :: has_bounds + type(FileMetadata), intent(in) :: metadata + character(len=*), intent(in) :: coord_name + integer, optional, intent(out) :: rc + + type(Variable), pointer :: var + integer :: status + + var => metadata%get_variable(coord_name, _RC) + has_bounds = var%is_attribute_present("bounds") + + _RETURN(_SUCCESS) + end function + + function get_coordinate_bounds(metadata, coord_name, rc) result(coord_bounds) + real(kind=REAL64), allocatable :: coord_bounds(:) + type(FileMetadata), intent(in) :: metadata + character(len=*), intent(in) :: coord_name + integer, optional, intent(out) :: rc + + type(Variable), pointer :: var + type(Attribute), pointer :: attr + integer :: status, im, i + class(*), pointer :: attr_val + character(len=:), allocatable :: bnds_name, source_file + real(kind=REAL64), allocatable :: file_bounds(:,:) + type(NetCDF4_FileFormatter) :: file_formatter + + + var => metadata%get_variable(coord_name, _RC) + attr => var%get_attribute("bounds", _RC) + attr_val => attr%get_value() + select type(attr_val) + type is(character(*)) + bnds_name = attr_val + class default + _FAIL('coordinate bounds must be a string') + end select + im = metadata%get_dimension(coord_name, _RC) + allocate(coord_bounds(im+1), _STAT) + allocate(file_bounds(im,2), _STAT) + source_file = metadata%get_source_file() + + call file_formatter%open(source_file, PFIO_READ, _RC) + call file_formatter%get_var(coord_name, file_bounds, _RC) + call file_formatter%close(_RC) + do i=1,im-1 + _ASSERT(file_bounds(i,2)==file_bounds(i+1,1), "Bounds are not contiguous in file") + enddo + do i=1,im + coord_bounds(i) = file_bounds(i,1) + coord_bounds(i+1) = file_bounds(i,2) + enddo + + _RETURN(_SUCCESS) + end function end module MAPL_LatLonGridFactoryMod From 9153589986bc53a1fafb4f91b6e4406cb777783f Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Fri, 22 Nov 2024 10:36:23 -0500 Subject: [PATCH 2/7] more updates --- base/MAPL_LatLonGridFactory.F90 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/base/MAPL_LatLonGridFactory.F90 b/base/MAPL_LatLonGridFactory.F90 index 0e2f59db9a32..260ebc6afd87 100644 --- a/base/MAPL_LatLonGridFactory.F90 +++ b/base/MAPL_LatLonGridFactory.F90 @@ -851,10 +851,13 @@ subroutine initialize_from_file_metadata(this, file_metadata, unusable, force_fi end if if (abs(this%lat_centers(1) + 90) < 1000*epsilon(1.0)) then + write(*,*)'bmaa here 1' this%pole = 'PC' else if (abs(this%lat_corners(1) + 90) < 1000*epsilon(1.0)) then + write(*,*)'bmaa here 2' this%pole = 'PE' else ! assume XY + write(*,*)'bmaa here 3' this%pole = 'XY' this%lat_range = RealMinMax(this%lat_centers(1), this%lat_centers(jm)) end if @@ -1987,18 +1990,18 @@ function get_coordinate_bounds(metadata, coord_name, rc) result(coord_bounds) end select im = metadata%get_dimension(coord_name, _RC) allocate(coord_bounds(im+1), _STAT) - allocate(file_bounds(im,2), _STAT) + allocate(file_bounds(2,im), _STAT) source_file = metadata%get_source_file() - + call file_formatter%open(source_file, PFIO_READ, _RC) - call file_formatter%get_var(coord_name, file_bounds, _RC) + call file_formatter%get_var(bnds_name, file_bounds, _RC) call file_formatter%close(_RC) do i=1,im-1 - _ASSERT(file_bounds(i,2)==file_bounds(i+1,1), "Bounds are not contiguous in file") + _ASSERT(file_bounds(2,i)==file_bounds(1,i+1), "Bounds are not contiguous in file") enddo do i=1,im - coord_bounds(i) = file_bounds(i,1) - coord_bounds(i+1) = file_bounds(i,2) + coord_bounds(i) = file_bounds(1,i) + coord_bounds(i+1) = file_bounds(2,i) enddo _RETURN(_SUCCESS) From ded9a8f8811c7995a4bad6d9e7c59e4fd8c2c105 Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Fri, 22 Nov 2024 16:34:53 -0500 Subject: [PATCH 3/7] more updates --- base/MAPL_LatLonGridFactory.F90 | 42 +++++++++++++++++++++++++++++---- griddedio/FieldBundleRead.F90 | 2 +- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/base/MAPL_LatLonGridFactory.F90 b/base/MAPL_LatLonGridFactory.F90 index 260ebc6afd87..7d7adf040f67 100644 --- a/base/MAPL_LatLonGridFactory.F90 +++ b/base/MAPL_LatLonGridFactory.F90 @@ -56,6 +56,8 @@ module MAPL_LatLonGridFactoryMod integer :: px, py logical :: is_halo_initialized = .false. logical :: periodic = .true. + character(len=:), allocatable :: lon_bounds_name + character(len=:), allocatable :: lat_bounds_name contains procedure :: make_new_grid procedure :: create_basic_grid @@ -226,7 +228,7 @@ function create_basic_grid(this, unusable, rc) result(grid) if (this%pole == "XY") then polekindflag = ESMF_POLEKIND_NONE else - polekindflag = ESMF_POLEKIND_BIPOLE + polekindflag = ESMF_POLEKIND_MONOPOLE end if grid = ESMF_GridCreate1PeriDim( & & name = this%grid_name, & @@ -768,6 +770,7 @@ subroutine initialize_from_file_metadata(this, file_metadata, unusable, force_fi has_bnds = coordinate_has_bounds(file_metadata, lon_name, _RC) if (has_bnds) then + this%lon_bounds_name = get_coordinate_bounds_name(file_metadata, lon_name, _RC) this%lon_corners = get_coordinate_bounds(file_metadata, lon_name, _RC) end if @@ -786,6 +789,7 @@ subroutine initialize_from_file_metadata(this, file_metadata, unusable, force_fi has_bnds = coordinate_has_bounds(file_metadata, lat_name, _RC) if (has_bnds) then + this%lat_bounds_name = get_coordinate_bounds_name(file_metadata, lat_name, _RC) this%lat_corners = get_coordinate_bounds(file_metadata, lat_name, _RC) end if @@ -851,13 +855,10 @@ subroutine initialize_from_file_metadata(this, file_metadata, unusable, force_fi end if if (abs(this%lat_centers(1) + 90) < 1000*epsilon(1.0)) then - write(*,*)'bmaa here 1' this%pole = 'PC' else if (abs(this%lat_corners(1) + 90) < 1000*epsilon(1.0)) then - write(*,*)'bmaa here 2' this%pole = 'PE' else ! assume XY - write(*,*)'bmaa here 3' this%pole = 'XY' this%lat_range = RealMinMax(this%lat_centers(1), this%lat_centers(jm)) end if @@ -1872,7 +1873,15 @@ function get_file_format_vars(this) result(vars) character(len=:), allocatable :: vars _UNUSED_DUMMY(this) - vars = 'lon,lat' + if (allocated(this%lon_bounds_name) .and. allocated(this%lat_bounds_name)) then + vars = 'lon,lat,'//this%lon_bounds_name//','//this%lat_bounds_name + else if (allocated(this%lon_bounds_name) .and. (.not. allocated(this%lat_bounds_name))) then + vars = 'lon,lat,'//this%lon_bounds_name + else if (allocated(this%lat_bounds_name) .and. (.not. allocated(this%lon_bounds_name))) then + vars = 'lon,lat,'//this%lat_bounds_name + else if ((.not.allocated(this%lat_bounds_name)) .and. (.not. allocated(this%lon_bounds_name))) then + vars = 'lon,lat' + end if end function get_file_format_vars @@ -1964,6 +1973,29 @@ function coordinate_has_bounds(metadata, coord_name, rc) result(has_bounds) _RETURN(_SUCCESS) end function + function get_coordinate_bounds_name(metadata, coord_name, rc) result(coord_bounds_name) + character(len=:), allocatable :: coord_bounds_name + type(FileMetadata), intent(in) :: metadata + character(len=*), intent(in) :: coord_name + integer, optional, intent(out) :: rc + + type(Variable), pointer :: var + type(Attribute), pointer :: attr + integer :: status + class(*), pointer :: attr_val + + var => metadata%get_variable(coord_name, _RC) + attr => var%get_attribute("bounds", _RC) + attr_val => attr%get_value() + select type(attr_val) + type is(character(*)) + coord_bounds_name = attr_val + class default + _FAIL('coordinate bounds must be a string') + end select + _RETURN(_SUCCESS) + end function + function get_coordinate_bounds(metadata, coord_name, rc) result(coord_bounds) real(kind=REAL64), allocatable :: coord_bounds(:) type(FileMetadata), intent(in) :: metadata diff --git a/griddedio/FieldBundleRead.F90 b/griddedio/FieldBundleRead.F90 index 6f0bd2b09c65..b8da3d92e091 100644 --- a/griddedio/FieldBundleRead.F90 +++ b/griddedio/FieldBundleRead.F90 @@ -71,7 +71,7 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_ factory => get_factory(file_grid,rc=status) _VERIFY(status) grid_vars = factory%get_file_format_vars() - exclude_vars = grid_vars//",lev,time,lons,lats" + exclude_vars = grid_vars//",lev,time,lons,lats,time_bnds" if (has_vertical_level) lev_size = metadata%get_dimension(trim(lev_name)) variables => metadata%get_variables() From 935a4b8ed847f42a4d6e7664bd42b9ee9ee0ec9e Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Fri, 22 Nov 2024 16:37:25 -0500 Subject: [PATCH 4/7] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd4571e4279e..a3599eb08549 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Allow update offsets of ±timestep in ExtData2G - Minor revision (and generalization) of grid-def for GSI purposes - Trajectory sampler: fix a bug when group_name does not exist in netCDF file and a bug that omitted the first time point +- Allow lat-lon grid factory to detect and use CF compliant lat-lon bounds in a file when making a grid ### Changed @@ -39,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed issue of some Baselibs builds appearing to support zstandard. This is not possible due to Baselibs building HDF5 and netCDF as static libraries +- Fixed a bug where the periodicity around the earth of the lat-lon grid was not being set properly when grid did not span from pole to pole ### Removed From 8ce9c6a8757594f1d480f62ac7b91c8c1509d5cd Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Mon, 25 Nov 2024 13:35:45 -0500 Subject: [PATCH 5/7] comments --- griddedio/FieldBundleRead.F90 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/griddedio/FieldBundleRead.F90 b/griddedio/FieldBundleRead.F90 index b8da3d92e091..a16ab0597285 100644 --- a/griddedio/FieldBundleRead.F90 +++ b/griddedio/FieldBundleRead.F90 @@ -91,6 +91,15 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_ enddo end if + write(*,*)'bmaa exclude ',','//trim(exclude_vars)//',' + write(*,*)'bmaa var_name ',trim(var_name) + write(*,*)'bmaa index(exclude_var,var_name) ',index(','//trim(exclude_vars)//',',','//trim(var_name)//',') + write(*,*)'bmaa hardcode string index comma vs no ',index(',lon,lat,lon_bnds,lat_bnds,lev,time,lons,lats,time_bnds,',",lat_bnds,"),index(',lon,lat,lon_bnds,lat_bnds,lev,time,lons,lats,time_bnds,',"lat_bnds") + write(*,*)'bmaa allocatable string index comma vs no ',index(exclude_vars,",lat_bnds,"),index(exclude_vars,"lat_bnds") + write(*,*)'bmaa allocatable string index comma vs no ',index(exclude_vars,",time_bnds,"),index(exclude_vars,"time_bnds") + write(*,*)'bmaa allocatable string index comma vs no ',index(exclude_vars,",time,"),index(exclude_vars,"time") + write(*,*)'bmaa allocatable string index comma vs no ',index(exclude_vars,",lat,"),index(exclude_vars,"lat") + if (index(','//trim(exclude_vars)//',',','//trim(var_name)//',') > 0) then call var_iter%next() cycle @@ -137,6 +146,7 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_ _VERIFY(status) call ESMF_AttributeSet(field,name='VLOCATION',value=location,rc=status) _VERIFY(status) + write(*,*)"bmaa getting units for ",trim(var_name) units = metadata%get_var_attr_string(var_name,'units',_RC) long_name = metadata%get_var_attr_string(var_name,'long_name',_RC) call ESMF_AttributeSet(field,name='UNITS',value=units,rc=status) From d1b0f0d5c7086836929ac9a59a39e21f6c56575d Mon Sep 17 00:00:00 2001 From: Benjamin Auer Date: Tue, 3 Dec 2024 12:16:48 -0500 Subject: [PATCH 6/7] more updates --- base/MAPL_LatLonGridFactory.F90 | 1 + griddedio/FieldBundleRead.F90 | 33 ++++++++++++--------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/base/MAPL_LatLonGridFactory.F90 b/base/MAPL_LatLonGridFactory.F90 index 7d7adf040f67..8d4de3ada406 100644 --- a/base/MAPL_LatLonGridFactory.F90 +++ b/base/MAPL_LatLonGridFactory.F90 @@ -1871,6 +1871,7 @@ function get_file_format_vars(this) result(vars) class (LatLonGridFactory), intent(inout) :: this character(len=:), allocatable :: vars + integer :: i _UNUSED_DUMMY(this) if (allocated(this%lon_bounds_name) .and. allocated(this%lat_bounds_name)) then diff --git a/griddedio/FieldBundleRead.F90 b/griddedio/FieldBundleRead.F90 index a16ab0597285..352dd414c330 100644 --- a/griddedio/FieldBundleRead.F90 +++ b/griddedio/FieldBundleRead.F90 @@ -48,8 +48,8 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_ type(StringVariableMap), pointer :: variables type(Variable), pointer :: this_variable type(StringVariableMapIterator) :: var_iter - character(len=:), pointer :: var_name,dim_name - character(len=:), allocatable :: lev_name + character(len=:), pointer :: var_name_ptr,dim_name + character(len=:), allocatable :: lev_name,var_name type(ESMF_Field) :: field type (StringVector), pointer :: dimensions type (StringVectorIterator) :: dim_iter @@ -71,14 +71,15 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_ factory => get_factory(file_grid,rc=status) _VERIFY(status) grid_vars = factory%get_file_format_vars() - exclude_vars = grid_vars//",lev,time,lons,lats,time_bnds" + exclude_vars = ","//grid_vars//",lev,time,time_bnds," if (has_vertical_level) lev_size = metadata%get_dimension(trim(lev_name)) variables => metadata%get_variables() var_iter = variables%begin() do while (var_iter /= variables%end()) var_has_levels = .false. - var_name => var_iter%key() + var_name_ptr => var_iter%key() + var_name = ","//var_name_ptr//"," this_variable => var_iter%value() if (has_vertical_level) then @@ -91,29 +92,20 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_ enddo end if - write(*,*)'bmaa exclude ',','//trim(exclude_vars)//',' - write(*,*)'bmaa var_name ',trim(var_name) - write(*,*)'bmaa index(exclude_var,var_name) ',index(','//trim(exclude_vars)//',',','//trim(var_name)//',') - write(*,*)'bmaa hardcode string index comma vs no ',index(',lon,lat,lon_bnds,lat_bnds,lev,time,lons,lats,time_bnds,',",lat_bnds,"),index(',lon,lat,lon_bnds,lat_bnds,lev,time,lons,lats,time_bnds,',"lat_bnds") - write(*,*)'bmaa allocatable string index comma vs no ',index(exclude_vars,",lat_bnds,"),index(exclude_vars,"lat_bnds") - write(*,*)'bmaa allocatable string index comma vs no ',index(exclude_vars,",time_bnds,"),index(exclude_vars,"time_bnds") - write(*,*)'bmaa allocatable string index comma vs no ',index(exclude_vars,",time,"),index(exclude_vars,"time") - write(*,*)'bmaa allocatable string index comma vs no ',index(exclude_vars,",lat,"),index(exclude_vars,"lat") - - if (index(','//trim(exclude_vars)//',',','//trim(var_name)//',') > 0) then + if (index(trim(exclude_vars),trim(var_name)) > 0) then call var_iter%next() cycle end if create_variable = .true. if (present(only_vars)) then - if (index(','//trim(only_vars)//',',','//trim(var_name)//',') < 1) create_variable = .false. + if (index(','//trim(only_vars)//',',trim(var_name)) < 1) create_variable = .false. end if if (create_variable) then if(var_has_levels) then if (grid_size(3) == lev_size) then location=MAPL_VLocationCenter dims = MAPL_DimsHorzVert - field= ESMF_FieldCreate(grid,name=trim(var_name),typekind=ESMF_TYPEKIND_R4, & + field= ESMF_FieldCreate(grid,name=trim(var_name_ptr),typekind=ESMF_TYPEKIND_R4, & ungriddedUbound=[grid_size(3)],ungriddedLBound=[1], rc=status) block real, pointer :: ptr3d(:,:,:) @@ -123,7 +115,7 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_ else if (grid_size(3)+1 == lev_size) then location=MAPL_VLocationEdge dims = MAPL_DimsHorzVert - field= ESMF_FieldCreate(grid,name=trim(var_name),typekind=ESMF_TYPEKIND_R4, & + field= ESMF_FieldCreate(grid,name=trim(var_name_ptr),typekind=ESMF_TYPEKIND_R4, & ungriddedUbound=[grid_size(3)],ungriddedLBound=[0], rc=status) block real, pointer :: ptr3d(:,:,:) @@ -134,7 +126,7 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_ else location=MAPL_VLocationNone dims = MAPL_DimsHorzOnly - field= ESMF_FieldCreate(grid,name=trim(var_name),typekind=ESMF_TYPEKIND_R4, & + field= ESMF_FieldCreate(grid,name=trim(var_name_ptr),typekind=ESMF_TYPEKIND_R4, & rc=status) block real, pointer :: ptr2d(:,:) @@ -146,9 +138,8 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_ _VERIFY(status) call ESMF_AttributeSet(field,name='VLOCATION',value=location,rc=status) _VERIFY(status) - write(*,*)"bmaa getting units for ",trim(var_name) - units = metadata%get_var_attr_string(var_name,'units',_RC) - long_name = metadata%get_var_attr_string(var_name,'long_name',_RC) + units = metadata%get_var_attr_string(var_name_ptr,'units',_RC) + long_name = metadata%get_var_attr_string(var_name_ptr,'long_name',_RC) call ESMF_AttributeSet(field,name='UNITS',value=units,rc=status) _VERIFY(status) call ESMF_AttributeSet(field,name='LONG_NAME',value=long_name,rc=status) From 9a2fee5d61489747b7799d0a8f07282d2b531034 Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Wed, 4 Dec 2024 16:01:19 -0500 Subject: [PATCH 7/7] Update base/MAPL_LatLonGridFactory.F90 --- base/MAPL_LatLonGridFactory.F90 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/base/MAPL_LatLonGridFactory.F90 b/base/MAPL_LatLonGridFactory.F90 index 8d4de3ada406..b7d076e5a2a3 100644 --- a/base/MAPL_LatLonGridFactory.F90 +++ b/base/MAPL_LatLonGridFactory.F90 @@ -1874,14 +1874,12 @@ function get_file_format_vars(this) result(vars) integer :: i _UNUSED_DUMMY(this) - if (allocated(this%lon_bounds_name) .and. allocated(this%lat_bounds_name)) then - vars = 'lon,lat,'//this%lon_bounds_name//','//this%lat_bounds_name - else if (allocated(this%lon_bounds_name) .and. (.not. allocated(this%lat_bounds_name))) then - vars = 'lon,lat,'//this%lon_bounds_name - else if (allocated(this%lat_bounds_name) .and. (.not. allocated(this%lon_bounds_name))) then - vars = 'lon,lat,'//this%lat_bounds_name - else if ((.not.allocated(this%lat_bounds_name)) .and. (.not. allocated(this%lon_bounds_name))) then - vars = 'lon,lat' + vars = 'lon,lat' + if (allocated(this%lon_bounds_name)) then + vars = vars // ',' // this%lon_bounds_name + end if + if (allocated(this%lat_bounds_name)) then + vars = vars // ',' // this%lat_bounds_name end if end function get_file_format_vars