diff --git a/MAPL_Base/MAPL_CFIO.F90 b/MAPL_Base/MAPL_CFIO.F90 index 50cf53448473..078d7407819d 100644 --- a/MAPL_Base/MAPL_CFIO.F90 +++ b/MAPL_Base/MAPL_CFIO.F90 @@ -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. @@ -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 @@ -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__) @@ -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 integer :: alloc_ra if (present(hw)) then @@ -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 @@ -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