diff --git a/CHANGELOG.md b/CHANGELOG.md index c1b3669db898..ccb1d53fbca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/gridcomps/ExtData2G/ExtDataGridCompNG.F90 b/gridcomps/ExtData2G/ExtDataGridCompNG.F90 index 542199a2edc9..2561c0dd855a 100644 --- a/gridcomps/ExtData2G/ExtDataGridCompNG.F90 +++ b/gridcomps/ExtData2G/ExtDataGridCompNG.F90 @@ -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) @@ -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") @@ -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) @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/gridcomps/ExtData2G/ExtDataTypeDef.F90 b/gridcomps/ExtData2G/ExtDataTypeDef.F90 index 295f979b7a9b..e34d9c1a2907 100644 --- a/gridcomps/ExtData2G/ExtDataTypeDef.F90 +++ b/gridcomps/ExtData2G/ExtDataTypeDef.F90 @@ -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 @@ -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