From 92519b5980245180050d343393be845e612ed2e5 Mon Sep 17 00:00:00 2001 From: Lawrence Takacs Date: Tue, 23 Aug 2022 12:07:30 -0400 Subject: [PATCH 1/2] Updates for lowest-model-level forcing Collections. Also, some quickplot fixes --- DynCore_GridCompMod.F90 | 96 +++++++++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 23 deletions(-) diff --git a/DynCore_GridCompMod.F90 b/DynCore_GridCompMod.F90 index 7ab22b2..7b5057c 100644 --- a/DynCore_GridCompMod.F90 +++ b/DynCore_GridCompMod.F90 @@ -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', & @@ -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 (:,:,:) @@ -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 ! ------- @@ -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) @@ -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 ! ------- @@ -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) @@ -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 @@ -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 @@ -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(:,:,:) @@ -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) ) @@ -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 ) From e13a1bf7ec04ef111b4e946fe5c8a24ecaf561dc Mon Sep 17 00:00:00 2001 From: Scott Rabenhorst Date: Thu, 29 Sep 2022 11:48:44 -0400 Subject: [PATCH 2/2] Fix incorrect pressure weighted accumulated mass flux units --- DynCore_GridCompMod.F90 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DynCore_GridCompMod.F90 b/DynCore_GridCompMod.F90 index 7ab22b2..6d626f0 100644 --- a/DynCore_GridCompMod.F90 +++ b/DynCore_GridCompMod.F90 @@ -993,17 +993,17 @@ 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) @@ -1011,7 +1011,7 @@ Subroutine SetServices ( gc, rc ) 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 ) @@ -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 )