Skip to content

Commit

Permalink
mmanyin found bug with vector regridding of winds in the ctm. Hotfix …
Browse files Browse the repository at this point in the history
…to get correct logic here
  • Loading branch information
bena-nasa committed Dec 9, 2019
1 parent 22a130f commit 8f52ee2
Showing 1 changed file with 38 additions and 10 deletions.
48 changes: 38 additions & 10 deletions MAPL_Base/MAPL_CFIO.F90
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ module MAPL_CFIOMod
integer, pointer :: VarType(:)=>null()
integer, pointer :: needVar(:)=>null()
integer, pointer :: pairList(:)=>null()
logical :: doRotate
character(len=ESMF_MAXSTR), &
pointer :: vectorList(:,:)=>null()
logical :: Vinterp=.false.
Expand Down Expand Up @@ -5317,6 +5318,8 @@ subroutine MAPL_CFIOCreateFromFile(MCFIO,bundlein,RegridMethod,hw,only_vars,rc)
character(len=ESMF_MAXSTR) :: vectorlist(2)
logical :: found
integer :: j
integer :: rotation,gridstagger,rotation1,rotation2,gridStagger1,gridStagger2
type(ESMF_Field) :: field1,field2
allocate(mCFIO%needVar(size(mCFIO%varname)),stat=status)
VERIFY_(status)
mCFIO%needVar=0
Expand Down Expand Up @@ -5346,6 +5349,39 @@ subroutine MAPL_CFIOCreateFromFile(MCFIO,bundlein,RegridMethod,hw,only_vars,rc)
mCFIO%needvar(i)=-j
end if
end do

call ESMF_FieldBundleGet(MCFIO%BUNDLE, trim(vectorList(1)), field=FIELD1,RC=STATUS)
VERIFY_(STATUS)
call ESMF_FieldBundleGet(MCFIO%BUNDLE, trim(vectorList(2)), field=FIELD2,RC=STATUS)
VERIFY_(STATUS)
mCFIO%doRotate=.false.
call ESMF_AttributeGet(field1,name='ROTATION',value=rotation1,rc=status)
call ESMF_AttributeGet(field1,name='STAGGERING',value=gridStagger1,rc=status)
call ESMF_AttributeGet(field2,name='ROTATION',value=rotation2,rc=status)
call ESMF_AttributeGet(field2,name='STAGGERING',value=gridStagger2,rc=status)
ASSERT_(rotation1==rotation2)
ASSERT_(gridStagger1==gridStagger2)
rotation=rotation1
gridStagger=gridStagger1
if (gridStagger == MAPL_AGrid) then
if (rotation == MAPL_RotateLL) then
mCFIO%doRotate = .false.
else if (rotation == MAPL_RotateCube) then
mCFIO%doRotate = .true.
end if
else if (gridStagger == MAPL_DGrid) then
if (rotation /= MAPL_RotateCube) then
ASSERT_(.false.)
else
mCFIO%doRotate = .false.
end if
else if (gridStagger == MAPL_CGrid) then
if (rotation /= MAPL_RotateCube) then
ASSERT_(.false.)
else
mCFIO%doRotate = .false.
end if
end if
end if
end block
!@ call ESMF_CFIOVarInfoDestroy(vars, __RC__)
Expand Down Expand Up @@ -5384,8 +5420,7 @@ subroutine MAPL_CFIOReadBundleRead(MCFIO,tindex,hw,rc)
type(Ptr2Arr) :: PtrTypeOut(2)
integer, allocatable :: varids(:)
logical, allocatable :: transDone(:)
integer :: status1,status2,rotation
logical :: doRotate
integer :: status1,status2,rotation,gridStagger
integer :: alloc_ra

if (present(hw)) then
Expand Down Expand Up @@ -5451,13 +5486,6 @@ subroutine MAPL_CFIOReadBundleRead(MCFIO,tindex,hw,rc)

end if CREATE_REQ

doRotate=.false.
call ESMF_AttributeGet(field,name='ROTATION',value=rotation,rc=status)
if (status==ESMF_SUCCESS) then
if (rotation==MAPL_RotateCube) doRotate=.true.
end if


end do VARS1

nn = 0
Expand Down Expand Up @@ -5657,7 +5685,7 @@ subroutine TransAndSave(ptrin,ptrout,req,doTrans,idxOut)
call C_F_pointer (cptr, vout,[im,jm,1])

call mCFIO%regridder%set_undef_value(MAPL_undef)
call mCFIO%regridder%regrid(uin, vin, uout, vout, rotate=doRotate, rc=status)
call mCFIO%regridder%regrid(uin, vin, uout, vout, rotate=mCFIO%doRotate, rc=status)
VERIFY_(status)

end if
Expand Down

0 comments on commit 8f52ee2

Please sign in to comment.