Skip to content

Commit

Permalink
Merge pull request #3028 from GEOS-ESM/feature/fixes-#3025
Browse files Browse the repository at this point in the history
Feature/fixes #3025
  • Loading branch information
mathomp4 authored Sep 17, 2024
2 parents 0fe9a5e + cae216f commit 2296a66
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 95 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed


- Added ability to read the attribute with explicit type "string" of a netcdf variable.
- Start implementing changes for vertical regridding in ExtData
- Added ability to read the attribute with explicit type "string" of a netcdf variable.
- Start to implement changes for vertical regridding in ExtData
- Add ability to connect export of the MAPL hierachy to ExtData via CAP.rc file
- Added new driver, CapDriver.x, to excerise the MAPL_Cap with the configuratable component also used by ExtDataDriver.x
- Added Fortran interface to UDUNITS2
Expand Down
216 changes: 123 additions & 93 deletions gridcomps/ExtData2G/ExtDataGridCompNG.F90
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ SUBROUTINE Initialize_ ( GC, IMPORT, EXPORT, CLOCK, rc )
current_base_name => self%derived%import_names%at(i)
num_derived=num_derived+1
allocate(derived_item)
!call config_yaml%fillin_derived(current_base_name,self%derived%item(num_derived),time,clock,_RC)
call config_yaml%fillin_derived(current_base_name,derived_item,time,clock,_RC)
call self%derived%item_vec%push_back(derived_item)
call ESMF_StateGet(Export,current_base_name,field,_RC)
Expand Down Expand Up @@ -612,15 +611,15 @@ SUBROUTINE Run_ ( GC, IMPORT, EXPORT, CLOCK, rc )
call MAPL_TimerOff(MAPLSTATE,"---read-prefetch")
call MAPL_TimerOff(MAPLSTATE,"--PRead")

!bundle_iter = IOBundles%begin()
!do while (bundle_iter /= IOBundles%end())
!io_bundle => bundle_iter%get()
!bracket_side = io_bundle%bracket_side
!entry_num = io_bundle%entry_index
!item => self%primary%item(entry_num)
!call MAPL_ExtDataVerticalInterpolate(self,item,bracket_side,current_time,_RC)
!call bundle_iter%next()
!enddo
bundle_iter = IOBundles%begin()
do while (bundle_iter /= IOBundles%end())
io_bundle => bundle_iter%get()
bracket_side = io_bundle%bracket_side
entry_num = io_bundle%entry_index
item => self%primary%item_vec%at(entry_num)
call MAPL_ExtDataVerticalInterpolate(self,item,bracket_side,current_time,_RC)
call bundle_iter%next()
enddo
call MAPL_ExtDataDestroyCFIO(IOBundles,_RC)

call MAPL_TimerOff(MAPLSTATE,"-Read_Loop")
Expand Down Expand Up @@ -873,62 +872,65 @@ subroutine MAPL_ExtDataInterpField(item,state,time,rc)
_RETURN(ESMF_SUCCESS)
end subroutine MAPL_ExtDataInterpField

!subroutine MAPL_ExtDataVerticalInterpolate(ExtState,item,filec,current_time,rc)
!type(MAPL_ExtData_State), intent(inout) :: ExtState
!type(PrimaryExport), intent(inout) :: item
!integer, intent(in ) :: filec
!type(ESMF_Time), intent(in ) :: current_time
!integer, optional, intent(out ) :: rc

!integer :: status
!integer :: id_ps
!type(ESMF_Field) :: field, newfield,psF

!if (item%do_VertInterp) then
!if (trim(item%importVDir)/=trim(item%fileVDir)) then
!call MAPL_ExtDataFlipVertical(item,filec,_RC)
!end if
!if (item%vartype == MAPL_fieldItem) then
!call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,_RC)
!call MAPL_ExtDataGetBracket(item,filec,Field,_RC)
!id_ps = ExtState%primary%get_item_index("PS",current_time,_RC)
!call MAPL_ExtDataGetBracket(ExtState%primary%item(id_ps),filec,field=psF,_RC)
!call vertInterpolation_pressKappa(field,newfield,psF,item%levs,MAPL_UNDEF,_RC)

!else if (item%vartype == MAPL_VectorField) then

!id_ps = ExtState%primary%get_item_index("PS",current_time,_RC)
!call MAPL_ExtDataGetBracket(ExtState%primary%item(id_ps),filec,field=psF,_RC)
!call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,vcomp=1,_RC)
!call MAPL_ExtDataGetBracket(item,filec,Field,vcomp=1,_RC)
!call vertInterpolation_pressKappa(field,newfield,psF,item%levs,MAPL_UNDEF,_RC)
!call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,vcomp=2,_RC)
!call MAPL_ExtDataGetBracket(item,filec,Field,vcomp=2,_RC)
!call vertInterpolation_pressKappa(field,newfield,psF,item%levs,MAPL_UNDEF,_RC)

!end if

!else if (item%do_Fill) then
!if (item%vartype == MAPL_fieldItem) then
!call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,_RC)
!call MAPL_ExtDataGetBracket(item,filec,Field,_RC)
!call MAPL_ExtDataFillField(item,field,newfield,_RC)
!else if (item%vartype == MAPL_VectorField) then
!call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,vcomp=1,_RC)
!call MAPL_ExtDataGetBracket(item,filec,Field,vcomp=1,_RC)
!call MAPL_ExtDataFillField(item,field,newfield,_RC)
!call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,vcomp=2,_RC)
!call MAPL_ExtDataGetBracket(item,filec,Field,vcomp=2,_RC)
!call MAPL_ExtDataFillField(item,field,newfield,_RC)
!end if
!else
!if (trim(item%importVDir)/=trim(item%fileVDir)) then
!call MAPL_ExtDataFlipVertical(item,filec,_RC)
!end if
!end if

!_RETURN(ESMF_SUCCESS)
!end subroutine MAPL_ExtDataVerticalInterpolate
subroutine MAPL_ExtDataVerticalInterpolate(ExtState,item,filec,current_time,rc)
type(MAPL_ExtData_State), intent(inout) :: ExtState
type(PrimaryExport), intent(inout) :: item
integer, intent(in ) :: filec
type(ESMF_Time), intent(in ) :: current_time
integer, optional, intent(out ) :: rc

integer :: status
integer :: id_ps
type(ESMF_Field) :: field, newfield,psF
type(PrimaryExport), pointer :: ps_item

if (item%do_VertInterp) then
if (trim(item%importVDir)/=trim(item%fileVDir)) then
call MAPL_ExtDataFlipVertical(item,filec,_RC)
end if
if (item%vartype == MAPL_fieldItem) then
call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,_RC)
call MAPL_ExtDataGetBracket(item,filec,Field,_RC)
id_ps = ExtState%primary%get_item_index("PS",current_time,_RC)
ps_item => ExtState%primary%item_vec%at(id_ps)
call MAPL_ExtDataGetBracket(ps_item,filec,field=psF,_RC)
call vertInterpolation_pressKappa(field,newfield,psF,item%levs,MAPL_UNDEF,_RC)

else if (item%vartype == MAPL_VectorField) then

id_ps = ExtState%primary%get_item_index("PS",current_time,_RC)
ps_item => ExtState%primary%item_vec%at(id_ps)
call MAPL_ExtDataGetBracket(ps_item,filec,field=psF,_RC)
call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,vcomp=1,_RC)
call MAPL_ExtDataGetBracket(item,filec,Field,vcomp=1,_RC)
call vertInterpolation_pressKappa(field,newfield,psF,item%levs,MAPL_UNDEF,_RC)
call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,vcomp=2,_RC)
call MAPL_ExtDataGetBracket(item,filec,Field,vcomp=2,_RC)
call vertInterpolation_pressKappa(field,newfield,psF,item%levs,MAPL_UNDEF,_RC)

end if

else if (item%do_Fill) then
if (item%vartype == MAPL_fieldItem) then
call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,_RC)
call MAPL_ExtDataGetBracket(item,filec,Field,_RC)
call MAPL_ExtDataFillField(item,field,newfield,_RC)
else if (item%vartype == MAPL_VectorField) then
call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,vcomp=1,_RC)
call MAPL_ExtDataGetBracket(item,filec,Field,vcomp=1,_RC)
call MAPL_ExtDataFillField(item,field,newfield,_RC)
call MAPL_ExtDataGetBracket(item,filec,newField,getRL=.true.,vcomp=2,_RC)
call MAPL_ExtDataGetBracket(item,filec,Field,vcomp=2,_RC)
call MAPL_ExtDataFillField(item,field,newfield,_RC)
end if
else
if (trim(item%importVDir)/=trim(item%fileVDir)) then
call MAPL_ExtDataFlipVertical(item,filec,_RC)
end if
end if

_RETURN(ESMF_SUCCESS)
end subroutine MAPL_ExtDataVerticalInterpolate

function MAPL_ExtDataGridChangeLev(Grid,CF,lm,rc) result(NewGrid)

Expand Down Expand Up @@ -996,7 +998,6 @@ function MAPL_ExtDataGridChangeLev(Grid,CF,lm,rc) result(NewGrid)
end function MAPL_ExtDataGridChangeLev

subroutine MAPL_ExtDataGetBracket(item,Bside,field,bundle,getRL,vcomp,rc)

type(PrimaryExport), intent(inout) :: item
integer, intent(in ) :: bside
type(ESMF_Field), optional, intent(inout) :: field
Expand All @@ -1020,17 +1021,37 @@ subroutine MAPL_ExtDataGetBracket(item,Bside,field,bundle,getRL,vcomp,rc)
if (present(field)) then

if (Bside == MAPL_ExtDataLeft .and. vcomp == 1) then
call item%modelGridFields%comp1%get_parameters('L',field=field,_RC)
_RETURN(ESMF_SUCCESS)
if (getRL_) then
call item%modelGridFields%auxiliary1%get_parameters('L',field=field,_RC)
_RETURN(ESMF_SUCCESS)
else
call item%modelGridFields%comp1%get_parameters('L',field=field,_RC)
_RETURN(ESMF_SUCCESS)
end if
else if (Bside == MAPL_ExtDataLeft .and. vcomp == 2) then
call item%modelGridFields%comp2%get_parameters('L',field=field,_RC)
_RETURN(ESMF_SUCCESS)
if (getRL_) then
call item%modelGridFields%auxiliary2%get_parameters('L',field=field,_RC)
_RETURN(ESMF_SUCCESS)
else
call item%modelGridFields%comp2%get_parameters('L',field=field,_RC)
_RETURN(ESMF_SUCCESS)
end if
else if (Bside == MAPL_ExtDataRight .and. vcomp == 1) then
call item%modelGridFields%comp1%get_parameters('R',field=field,_RC)
_RETURN(ESMF_SUCCESS)
if (getRL_) then
call item%modelGridFields%auxiliary1%get_parameters('R',field=field,_RC)
_RETURN(ESMF_SUCCESS)
else
call item%modelGridFields%comp1%get_parameters('R',field=field,_RC)
_RETURN(ESMF_SUCCESS)
end if
else if (Bside == MAPL_ExtDataRight .and. vcomp == 2) then
call item%modelGridFields%comp2%get_parameters('R',field=field,_RC)
_RETURN(ESMF_SUCCESS)
if (getRL_) then
call item%modelGridFields%auxiliary2%get_parameters('R',field=field,_RC)
_RETURN(ESMF_SUCCESS)
else
call item%modelGridFields%comp2%get_parameters('R',field=field,_RC)
_RETURN(ESMF_SUCCESS)
end if
end if

else if (present(bundle)) then
Expand All @@ -1041,11 +1062,21 @@ subroutine MAPL_ExtDataGetBracket(item,Bside,field,bundle,getRL,vcomp,rc)

if (present(field)) then
if (Bside == MAPL_ExtDataLeft) then
call item%modelGridFields%comp1%get_parameters('L',field=field,_RC)
_RETURN(ESMF_SUCCESS)
if (getRL_) then
call item%modelGridFields%auxiliary1%get_parameters('L',field=field,_RC)
_RETURN(ESMF_SUCCESS)
else
call item%modelGridFields%comp1%get_parameters('L',field=field,_RC)
_RETURN(ESMF_SUCCESS)
end if
else if (Bside == MAPL_ExtDataRight) then
call item%modelGridFields%comp1%get_parameters('R',field=field,_RC)
_RETURN(ESMF_SUCCESS)
if (getRL_) then
call item%modelGridFields%auxiliary1%get_parameters('R',field=field,_RC)
_RETURN(ESMF_SUCCESS)
else
call item%modelGridFields%comp1%get_parameters('R',field=field,_RC)
_RETURN(ESMF_SUCCESS)
end if
end if
else if (present(bundle)) then
!if (Bside == MAPL_ExtDataLeft) then
Expand Down Expand Up @@ -1285,20 +1316,19 @@ subroutine createFileLevBracket(item,cf,rc)
type (ESMF_Grid) :: grid, newgrid
type(ESMF_Field) :: field,new_field

_FAIL('you be bad')
!call item%modelGridFields%comp1%get_parameters('L',field=field,_RC)
!newGrid = MAPL_ExtDataGridChangeLev(grid,cf,item%lm,_RC)
!new_field = MAPL_FieldCreate(field,newGrid,lm=item%lm,newName=trim(item%fcomp1),_RC)
!call item%modelGridFields%auxiliary1%set_parameters(left_field=new_field,_RC)
!new_field = MAPL_FieldCreate(field,newGrid,lm=item%lm,newName=trim(item%fcomp1),_RC)
!call item%modelGridFields%auxiliary1%set_parameters(right_field=new_field,_RC)
!if (item%vartype==MAPL_VectorField) then
!new_field = MAPL_FieldCreate(field,newGrid,lm=item%lm,newName=trim(item%fcomp2),_RC)
!call item%modelGridFields%auxiliary2%set_parameters(left_field=new_field,_RC)
!new_field = MAPL_FieldCreate(field,newGrid,lm=item%lm,newName=trim(item%fcomp2),_RC)
!call item%modelGridFields%auxiliary2%set_parameters(right_field=new_field,_RC)
!end if
!_RETURN(_SUCCESS)
call item%modelGridFields%comp1%get_parameters('L',field=field,_RC)
newGrid = MAPL_ExtDataGridChangeLev(grid,cf,item%lm,_RC)
new_field = MAPL_FieldCreate(field,newGrid,lm=item%lm,newName=trim(item%fcomp1),_RC)
call item%modelGridFields%auxiliary1%set_parameters(left_field=new_field,_RC)
new_field = MAPL_FieldCreate(field,newGrid,lm=item%lm,newName=trim(item%fcomp1),_RC)
call item%modelGridFields%auxiliary1%set_parameters(right_field=new_field,_RC)
if (item%vartype==MAPL_VectorField) then
new_field = MAPL_FieldCreate(field,newGrid,lm=item%lm,newName=trim(item%fcomp2),_RC)
call item%modelGridFields%auxiliary2%set_parameters(left_field=new_field,_RC)
new_field = MAPL_FieldCreate(field,newGrid,lm=item%lm,newName=trim(item%fcomp2),_RC)
call item%modelGridFields%auxiliary2%set_parameters(right_field=new_field,_RC)
end if
_RETURN(_SUCCESS)

end subroutine createFileLevBracket

Expand Down
4 changes: 4 additions & 0 deletions gridcomps/ExtData2G/ExtDataTypeDef.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module MAPL_ExtDataTypeDef
! fields to store endpoints for interpolation of a vector pair
type(ExtDataBracket) :: comp1
type(ExtDataBracket) :: comp2
! if vertically interpolating vector fields
type(ExtDataBracket) :: auxiliary1
type(ExtDataBracket) :: auxiliary2
logical :: initialized = .false.
end type BracketingFields

Expand All @@ -37,6 +40,7 @@ module MAPL_ExtDataTypeDef
class(ExtDataAbstractFileHandler), allocatable :: filestream

! if primary export represents a pair of vector fields
logical :: isVector
type(BracketingFields) :: modelGridFields

! names of the two vector components in the gridded component where import is declared
Expand Down

0 comments on commit 2296a66

Please sign in to comment.