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

Merge in changes from feature/sdrabenh/r21c_updates #189

Draft
wants to merge 4 commits into
base: feature/sdrabenh/merge_v10.25.0_MSTRF
Choose a base branch
from
Draft
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
108 changes: 79 additions & 29 deletions DynCore_GridCompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -993,25 +993,25 @@ Subroutine SetServices ( gc, rc )
VERIFY_(STATUS)

call MAPL_AddExportSpec ( gc, &
SHORT_NAME = 'MX', &
SHORT_NAME = 'MX', &
LONG_NAME = 'pressure_weighted_accumulated_eastward_mass_flux', &
UNITS = 'Pa m+2 s-1', &
UNITS = 'Pa m+2', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddExportSpec ( gc, &
SHORT_NAME = 'MY', &
SHORT_NAME = 'MY', &
LONG_NAME = 'pressure_weighted_accumulated_northward_mass_flux', &
UNITS = 'Pa m+2 s-1', &
UNITS = 'Pa m+2', &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddExportSpec ( gc, &
SHORT_NAME = 'MFX', &
LONG_NAME = 'pressure_weighted_accumulated_eastward_mass_flux', &
UNITS = 'Pa m+2 s-1', &
UNITS = 'Pa m+2', &
PRECISION = ESMF_KIND_R8, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, RC=STATUS )
Expand All @@ -1020,7 +1020,7 @@ Subroutine SetServices ( gc, rc )
call MAPL_AddExportSpec ( gc, &
SHORT_NAME = 'MFY', &
LONG_NAME = 'pressure_weighted_accumulated_northward_mass_flux', &
UNITS = 'Pa m+2 s-1', &
UNITS = 'Pa m+2', &
PRECISION = ESMF_KIND_R8, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, RC=STATUS )
Expand Down Expand Up @@ -1067,6 +1067,24 @@ Subroutine SetServices ( gc, rc )
VLOCATION = MAPL_VLocationCenter, RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddExportSpec ( gc, &
SHORT_NAME = 'DUDTPHY', &
LONG_NAME = 'tendency_of_eastward_wind_due_to_physics', &
UNITS = 'm/s/s', &
DIMS = MAPL_DimsHorzVert, &
FIELD_TYPE = MAPL_VectorField, &
VLOCATION = MAPL_VLocationCenter, RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddExportSpec ( gc, &
SHORT_NAME = 'DVDTPHY', &
LONG_NAME = 'tendency_of_northward_wind_due_to_physics', &
UNITS = 'm/s/s', &
DIMS = MAPL_DimsHorzVert, &
FIELD_TYPE = MAPL_VectorField, &
VLOCATION = MAPL_VLocationCenter, RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddExportSpec ( gc, &
SHORT_NAME = 'DUDTANA', &
LONG_NAME = 'tendency_of_eastward_wind_due_to_analysis', &
Expand Down Expand Up @@ -2809,8 +2827,6 @@ subroutine Run(gc, import, export, clock, rc)
real(r8), allocatable :: trsum1(:) ! Global Sum of Tracers before Add_Incs
real(r8), allocatable :: trsum2(:) ! Global Sum of Tracers after Add_Incs

real(kind=4), pointer :: dudtana(:,:,:)
real(kind=4), pointer :: dvdtana(:,:,:)
real(kind=4), pointer :: dtdtana(:,:,:)
real(kind=4), pointer :: ddpdtana(:,:,:)
real(kind=4), pointer :: qctmp (:,:,:)
Expand Down Expand Up @@ -3503,15 +3519,11 @@ subroutine Run(gc, import, export, clock, rc)

! DUDTANA
! -------
call MAPL_GetPointer ( export, dudtana, 'DUDTANA', rc=status )
VERIFY_(STATUS)
if( associated(dudtana) ) dudtana = ua
! Note: Calculation of DUDTANA moved to ADD_INCS to account for AtoD & DtoA transformations

! DVDTANA
! -------
call MAPL_GetPointer ( export, dvdtana, 'DVDTANA', rc=status )
VERIFY_(STATUS)
if( associated(dvdtana) ) dvdtana = va
! Note: Calculation of DVDTANA moved to ADD_INCS to account for AtoD & DtoA transformations

! DTDTANA
! -------
Expand Down Expand Up @@ -3634,7 +3646,7 @@ subroutine Run(gc, import, export, clock, rc)
! -----------------------
delpold = delp ! Old Pressure Thickness

call ADD_INCS ( STATE,IMPORT,DT,IS_WEIGHTED=IS_WEIGHTED )
call ADD_INCS ( STATE,IMPORT,EXPORT,DT,'ANA ADD_INCS',IS_WEIGHTED=IS_WEIGHTED )

if (DYN_DEBUG) call DEBUG_FV_STATE('ANA ADD_INCS',STATE)

Expand Down Expand Up @@ -3798,21 +3810,11 @@ subroutine Run(gc, import, export, clock, rc)

! DUDTANA
! -------
call MAPL_GetPointer ( export, dudtana, 'DUDTANA', rc=status )
VERIFY_(STATUS)
if( associated(dudtana) ) then
dummy = ua
dudtana = (dummy-dudtana)/dt
endif
! Note: Calculation of DUDTANA moved to ADD_INCS to account for AtoD & DtoA transformations

! DVDTANA
! -------
call MAPL_GetPointer ( export, dvdtana, 'DVDTANA', rc=status )
VERIFY_(STATUS)
if( associated(dvdtana) ) then
dummy = va
dvdtana = (dummy-dvdtana)/dt
endif
! Note: Calculation of DVDTANA moved to ADD_INCS to account for AtoD & DtoA transformations

! DTDTANA
! -------
Expand Down Expand Up @@ -6278,7 +6280,7 @@ subroutine RunAddIncs(gc, import, export, clock, rc)

! Add Diabatic Forcing to State Variables
! ---------------------------------------
call ADD_INCS ( STATE,IMPORT,DT )
call ADD_INCS ( STATE,IMPORT,EXPORT,DT,'PHYSICS ADD_INCS' )

if (DYN_DEBUG) call DEBUG_FV_STATE('PHYSICS ADD_INCS',STATE)

Expand Down Expand Up @@ -6750,7 +6752,7 @@ subroutine RunAddIncs(gc, import, export, clock, rc)
end subroutine RunAddIncs

!-----------------------------------------------------------------------
subroutine ADD_INCS ( STATE,IMPORT,DT,IS_WEIGHTED,RC )
subroutine ADD_INCS ( STATE,IMPORT,EXPORT,DT,STRING,IS_WEIGHTED,RC )

use fms_mod, only: set_domain, nullify_domain
use fv_diagnostics_mod, only: prt_maxmin
Expand All @@ -6761,7 +6763,9 @@ subroutine ADD_INCS ( STATE,IMPORT,DT,IS_WEIGHTED,RC )

type(DynState), pointer :: STATE
type(ESMF_State), intent(INOUT) :: IMPORT
type(ESMF_State), intent(INOUT) :: EXPORT
real(FVPRC), intent(IN ) :: DT
character(len=*), intent(IN ) :: STRING
integer, optional, intent(OUT ) :: RC
logical, optional, intent(IN ) :: is_weighted

Expand All @@ -6780,6 +6784,7 @@ subroutine ADD_INCS ( STATE,IMPORT,DT,IS_WEIGHTED,RC )
real(r4), allocatable :: fvQOLD(:,:,:), QTEND(:,:,:)
real(r8), allocatable :: DPNEW(:,:,:),DPOLD(:,:,:)

real(REAL8), allocatable :: ua(:,:,:), va(:,:,:)
real(REAL8), allocatable :: tend_ua(:,:,:), tend_va(:,:,:)
real(REAL8), allocatable :: tend_un(:,:,:), tend_vn(:,:,:)

Expand Down Expand Up @@ -6956,6 +6961,8 @@ subroutine ADD_INCS ( STATE,IMPORT,DT,IS_WEIGHTED,RC )
! **** while IMPORT Tendencies are on the A-Grid ****
! **********************************************************************

ALLOCATE( ua(is:ie ,js:je ,km) )
ALLOCATE( va(is:ie ,js:je ,km) )
ALLOCATE( tend_ua(is:ie ,js:je ,km) )
ALLOCATE( tend_va(is:ie ,js:je ,km) )
ALLOCATE( tend_un(is:ie ,js:je+1,km) )
Expand All @@ -6980,12 +6987,55 @@ subroutine ADD_INCS ( STATE,IMPORT,DT,IS_WEIGHTED,RC )
! Put the wind tendencies on the Native Dynamics grid
! ---------------------------------------------------
call Agrid_To_Native( tend_ua, tend_va, tend_un, tend_vn )
call getAgridWinds( STATE%VARS%U, STATE%VARS%V, ua, va, rotate=.true.)

if( trim(STRING) == 'ANA ADD_INCS' ) then
call ESMFL_StateGetPointerToData ( EXPORT,TEND,'DUDTANA',RC=STATUS )
VERIFY_(STATUS)
if( associated(TEND) ) tend = ua(is:ie,js:je,1:km)
call ESMFL_StateGetPointerToData ( EXPORT,TEND,'DVDTANA',RC=STATUS )
VERIFY_(STATUS)
if( associated(TEND) ) tend = va(is:ie,js:je,1:km)
endif

if( trim(STRING) == 'PHYSICS ADD_INCS' ) then
call ESMFL_StateGetPointerToData ( EXPORT,TEND,'DUDTPHY',RC=STATUS )
VERIFY_(STATUS)
if( associated(TEND) ) tend = ua(is:ie,js:je,1:km)
call ESMFL_StateGetPointerToData ( EXPORT,TEND,'DVDTPHY',RC=STATUS )
VERIFY_(STATUS)
if( associated(TEND) ) tend = va(is:ie,js:je,1:km)
endif

! Add the wind tendencies to the control variables
! ------------------------------------------------
STATE%VARS%U = STATE%VARS%U + DT*TEND_UN(is:ie,js:je,1:km)
STATE%VARS%V = STATE%VARS%V + DT*TEND_VN(is:ie,js:je,1:km)

! Put the wind tendencies back on A-Grid (for consistency with wind output)
! -------------------------------------------------------------------------
call getAgridWinds( STATE%VARS%U, STATE%VARS%V, ua, va, rotate=.true.)

if( trim(STRING) == 'ANA ADD_INCS' ) then
call ESMFL_StateGetPointerToData ( EXPORT,TEND,'DUDTANA',RC=STATUS )
VERIFY_(STATUS)
if( associated(TEND) ) tend = ( ua(is:ie,js:je,1:km)-tend )/DT
call ESMFL_StateGetPointerToData ( EXPORT,TEND,'DVDTANA',RC=STATUS )
VERIFY_(STATUS)
if( associated(TEND) ) tend = ( va(is:ie,js:je,1:km)-tend )/DT
endif

if( trim(STRING) == 'PHYSICS ADD_INCS' ) then
call ESMFL_StateGetPointerToData ( EXPORT,TEND,'DUDTPHY',RC=STATUS )
VERIFY_(STATUS)
if( associated(TEND) ) tend = ( ua(is:ie,js:je,1:km)-tend )/DT
call ESMFL_StateGetPointerToData ( EXPORT,TEND,'DVDTPHY',RC=STATUS )
VERIFY_(STATUS)
if( associated(TEND) ) tend = ( va(is:ie,js:je,1:km)-tend )/DT
endif

DEALLOCATE( ua )
DEALLOCATE( va )
DEALLOCATE( tend_ua )
DEALLOCATE( tend_va )
DEALLOCATE( tend_un )
Expand Down