Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bena-nasa committed Dec 3, 2024
1 parent 8ce9c6a commit d1b0f0d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
1 change: 1 addition & 0 deletions base/MAPL_LatLonGridFactory.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 12 additions & 21 deletions griddedio/FieldBundleRead.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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(:,:,:)
Expand All @@ -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(:,:,:)
Expand All @@ -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(:,:)
Expand All @@ -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)
Expand Down

0 comments on commit d1b0f0d

Please sign in to comment.