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

Regrid_Util.x and file weights #2848

Merged
merged 1 commit into from
May 28, 2024
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
8 changes: 6 additions & 2 deletions Apps/Regrid_Util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module regrid_util_support_mod
integer :: deflate, shave
integer :: quantize_algorithm
integer :: quantize_level
logical :: use_weights
contains
procedure :: create_grid
procedure :: process_command_line
Expand Down Expand Up @@ -97,6 +98,7 @@ subroutine process_command_line(this,rc)
this%deflate=0
this%quantize_algorithm=1
this%quantize_level=0
this%use_weights = .false.
nargs = command_argument_count()
do i=1,nargs
call get_command_argument(i,str)
Expand Down Expand Up @@ -159,6 +161,8 @@ subroutine process_command_line(this,rc)
case('-quantize_level')
call get_command_argument(i+1,astr)
read(astr,*)this%quantize_level
case('-file_weights')
this%use_weights = .true.
case('--help')
if (mapl_am_I_root()) then

Expand Down Expand Up @@ -413,9 +417,9 @@ subroutine main()
if (mapl_am_i_root()) write(*,*)'processing timestep from '//trim(filename)
time = tSeries(i)
if (support%onlyvars) then
call MAPL_Read_bundle(bundle,trim(filename),time=time,regrid_method=support%regridMethod,only_vars=support%vars,_RC)
call MAPL_Read_bundle(bundle,trim(filename),time=time,regrid_method=support%regridMethod,only_vars=support%vars,file_weights=support%use_weights, _RC)
else
call MAPL_Read_bundle(bundle,trim(filename),time=time,regrid_method=support%regridMethod,_RC)
call MAPL_Read_bundle(bundle,trim(filename),time=time,regrid_method=support%regridMethod,file_weights=support%use_weights, _RC)
end if
call t_prof%stop("Read")

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add new option to Regrid_Util.x to write and re-use ESMF pregenerated weights
- If file path length exceeds ESMF_MAXSTR, add _FAIL in subroutine fglob
- Add GNU UFS-like CI test

Expand Down
15 changes: 12 additions & 3 deletions griddedio/FieldBundleRead.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module MAPL_ESMFFieldBundleRead
use MAPL_SimpleAlarm
use MAPL_StringTemplate
use gFTL_StringVector
use MAPL_RegridMethods
use, intrinsic :: iso_fortran_env, only: REAL32
implicit none
private
Expand Down Expand Up @@ -152,18 +153,19 @@ subroutine MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_

end subroutine MAPL_create_bundle_from_metdata_id

subroutine MAPL_read_bundle(bundle,file_tmpl,time,only_vars,regrid_method,noread,file_override,rc)
subroutine MAPL_read_bundle(bundle,file_tmpl,time,only_vars,regrid_method,noread,file_override,file_weights,rc)
type(ESMF_FieldBundle), intent(inout) :: bundle
character(len=*), intent(in) :: file_tmpl
type(ESMF_Time), intent(in) :: time
character(len=*), optional, intent(in) :: only_vars
integer, optional, intent(in) :: regrid_method
logical, optional, intent(in) :: noread
character(len=*), optional, intent(in) :: file_override
logical, optional, intent(in) :: file_weights
integer, optional, intent(out) :: rc

integer :: status
integer :: num_fields, metadata_id, collection_id, time_index, i
integer :: num_fields, metadata_id, collection_id, time_index, i, regrid_hints
type(MAPL_GriddedIO) :: cfio
character(len=ESMF_MAXPATHLEN) :: file_name
type(MAPLDataCollection), pointer :: collection => null()
Expand All @@ -181,7 +183,7 @@ subroutine MAPL_read_bundle(bundle,file_tmpl,time,only_vars,regrid_method,noread
metadata_id = MAPL_DataAddCollection(trim(file_tmpl))
collection => DataCollections%at(metadata_id)
if (present(file_override)) file_name = file_override

metadata => collection%find(trim(file_name), _RC)
call metadata%get_time_info(timeVector=time_series,rc=status)
_VERIFY(status)
Expand Down Expand Up @@ -221,6 +223,13 @@ subroutine MAPL_read_bundle(bundle,file_tmpl,time,only_vars,regrid_method,noread

cfio=MAPL_GriddedIO(output_bundle=bundle,metadata_collection_id=metadata_id,read_collection_id=collection_id,items=items)
call cfio%set_param(regrid_method=regrid_method)
if (present(file_weights)) then
if (file_weights) then
regrid_hints = 0
regrid_hints = IOR(regrid_hints,REGRID_HINT_FILE_WEIGHTS)
call cfio%set_param(regrid_hints=regrid_hints)
end if
end if
call cfio%request_data_from_file(trim(file_name),timeindex=time_index,rc=status)
_VERIFY(status)
call i_clients%done_collective_prefetch()
Expand Down