Skip to content
Merged
Show file tree
Hide file tree
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
34 changes: 34 additions & 0 deletions gfsphysics/GFS_layer/GFS_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3910,6 +3910,40 @@ subroutine GFS_externaldiag_populate (ExtDiag, Model, Statein, Stateout, Sfcprop
!rab ExtDiag(idx)%unit = 'kg/kg/s'
!rab ExtDiag(idx)%mod_name = 'gfs_phys'

! Auxiliary 2d arrays to output (for debugging)
do num=1,Model%naux2d
write (xtra,'(I2.2)') num
idx = idx + 1
ExtDiag(idx)%axes = 2
ExtDiag(idx)%name = 'aux2d_'//trim(xtra)
ExtDiag(idx)%desc = 'auxiliary 2d array '//trim(xtra)
ExtDiag(idx)%unit = 'unknown'
ExtDiag(idx)%mod_name = 'gfs_phys'
ExtDiag(idx)%intpl_method = 'bilinear'
ExtDiag(idx)%time_avg = Model%aux2d_time_avg(num)
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var2 => IntDiag(nb)%aux2d(:,num)
enddo
enddo

! Auxiliary 3d arrays to output (for debugging)
do num=1,Model%naux3d
write (xtra,'(I2.2)') num
idx = idx + 1
ExtDiag(idx)%axes = 3
ExtDiag(idx)%name = 'aux3d_'//trim(xtra)
ExtDiag(idx)%desc = 'auxiliary 3d array '//trim(xtra)
ExtDiag(idx)%unit = 'unknown'
ExtDiag(idx)%mod_name = 'gfs_phys'
ExtDiag(idx)%intpl_method = 'bilinear'
ExtDiag(idx)%time_avg = Model%aux3d_time_avg(num)
allocate (ExtDiag(idx)%data(nblks))
do nb = 1,nblks
ExtDiag(idx)%data(nb)%var3 => IntDiag(nb)%aux3d(:,:,num)
enddo
enddo

end subroutine GFS_externaldiag_populate

#ifdef CCPP
Expand Down
61 changes: 60 additions & 1 deletion gfsphysics/GFS_layer/GFS_typedefs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ module GFS_typedefs
private :: levozp, oz_coeff, levh2o, h2o_coeff, ntrcaer
integer :: levozp, oz_coeff, levh2o, h2o_coeff, ntrcaer
#endif
! If these are changed to >99, need to adjust formatting string in GFS_diagnostics.F90 (and names in diag_tables)
integer, parameter :: naux2dmax = 20 !< maximum number of auxiliary 2d arrays in output (for debugging)
integer, parameter :: naux3dmax = 20 !< maximum number of auxiliary 3d arrays in output (for debugging)

!> \section arg_table_GFS_typedefs
!! \htmlinclude GFS_typedefs.html
Expand Down Expand Up @@ -555,6 +558,11 @@ module GFS_typedefs
logical :: flag_for_scnv_generic_tend !< true if GFS_DCNV_generic should calculate tendencies
logical :: flag_for_dcnv_generic_tend !< true if GFS_DCNV_generic should calculate tendencies
logical :: lssav !< logical flag for storing diagnostics
integer :: naux2d !< number of auxiliary 2d arrays to output (for debugging)
integer :: naux3d !< number of auxiliary 3d arrays to output (for debugging)
logical, pointer :: aux2d_time_avg(:) !< flags for time averaging of auxiliary 2d arrays
logical, pointer :: aux3d_time_avg(:) !< flags for time averaging of auxiliary 3d arrays

real(kind=kind_phys) :: fhcyc !< frequency for surface data cycling (hours)
integer :: thermodyn_id !< valid for GFS only for get_prs/phi
integer :: sfcpress_id !< valid for GFS only for get_prs/phi
Expand Down Expand Up @@ -1581,6 +1589,11 @@ module GFS_typedefs
!< for black carbon, organic carbon, and sulfur dioxide ( ug/m**2/s )
real (kind=kind_phys), pointer :: aecm (:,:) => null() !< instantaneous aerosol column mass densities for
!< pm2.5, black carbon, organic carbon, sulfate, dust, sea salt ( g/m**2 )

! Auxiliary output arrays for debugging
real (kind=kind_phys), pointer :: aux2d(:,:) => null() !< auxiliary 2d arrays in output (for debugging)
real (kind=kind_phys), pointer :: aux3d(:,:,:)=> null() !< auxiliary 2d arrays in output (for debugging)

contains
procedure :: create => diag_create
procedure :: rad_zero => diag_rad_zero
Expand Down Expand Up @@ -2739,6 +2752,10 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
logical :: ldiag3d = .false. !< flag for 3d diagnostic fields
logical :: qdiag3d = .false. !< flag for 3d tracer diagnostic fields
logical :: lssav = .false. !< logical flag for storing diagnostics
integer :: naux2d = 0 !< number of auxiliary 2d arrays to output (for debugging)
integer :: naux3d = 0 !< number of auxiliary 3d arrays to output (for debugging)
logical :: aux2d_time_avg(1:naux2dmax) = .false. !< flags for time averaging of auxiliary 2d arrays
logical :: aux3d_time_avg(1:naux3dmax) = .false. !< flags for time averaging of auxiliary 3d arrays

real(kind=kind_phys) :: fhcyc = 0. !< frequency for surface data cycling (hours)
integer :: thermodyn_id = 1 !< valid for GFS only for get_prs/phi
Expand Down Expand Up @@ -3119,7 +3136,8 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &

NAMELIST /gfs_physics_nml/ &
!--- general parameters
fhzero, ldiag3d, qdiag3d, lssav, fhcyc, &
fhzero, ldiag3d, qdiag3d, lssav, naux2d, naux3d, &
aux2d_time_avg, aux3d_time_avg, fhcyc, &
thermodyn_id, sfcpress_id, &
!--- coupling parameters
cplflx, cplwav, cplchm, lsidea, &
Expand Down Expand Up @@ -3329,6 +3347,26 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
Model%do_tofd = do_tofd

Model%lssav = lssav
!
if (naux2d>naux2dmax) then
write(0,*) "Error, number of requested auxiliary 2d arrays exceeds the maximum defined in GFS_typedefs.F90"
stop
endif
if (naux3d>naux3dmax) then
write(0,*) "Error, number of requested auxiliary 3d arrays exceeds the maximum defined in GFS_typedefs.F90"
stop
endif
Model%naux2d = naux2d
Model%naux3d = naux3d
if (Model%naux2d>0) then
allocate(Model%aux2d_time_avg(1:naux2d))
Model%aux2d_time_avg(1:naux2d) = aux2d_time_avg(1:naux2d)
end if
if (Model%naux3d>0) then
allocate(Model%aux3d_time_avg(1:naux3d))
Model%aux3d_time_avg(1:naux3d) = aux3d_time_avg(1:naux3d)
end if
!
Model%fhcyc = fhcyc
Model%thermodyn_id = thermodyn_id
Model%sfcpress_id = sfcpress_id
Expand Down Expand Up @@ -4465,6 +4503,14 @@ subroutine control_print(Model)
print *, ' ldiag3d : ', Model%ldiag3d
print *, ' qdiag3d : ', Model%qdiag3d
print *, ' lssav : ', Model%lssav
print *, ' naux2d : ', Model%naux2d
print *, ' naux3d : ', Model%naux3d
if (Model%naux2d>0) then
print *, ' aux2d_time_avg : ', Model%aux2d_time_avg
endif
if (Model%naux3d>0) then
print *, ' aux3d_time_avg : ', Model%aux3d_time_avg
endif
print *, ' fhcyc : ', Model%fhcyc
print *, ' thermodyn_id : ', Model%thermodyn_id
print *, ' sfcpress_id : ', Model%sfcpress_id
Expand Down Expand Up @@ -5425,6 +5471,16 @@ subroutine diag_create (Diag, IM, Model)
endif
#endif

! Auxiliary arrays in output for debugging
if (Model%naux2d>0) then
allocate (Diag%aux2d(IM,Model%naux2d))
Diag%aux2d = clear_val
endif
if (Model%naux3d>0) then
allocate (Diag%aux3d(IM,Model%levs,Model%naux3d))
Diag%aux3d = clear_val
endif

!--- diagnostics for coupled chemistry
if (Model%cplchm) call Diag%chem_init(IM,Model)

Expand All @@ -5443,6 +5499,7 @@ end subroutine diag_create
subroutine diag_rad_zero(Diag, Model)
class(GFS_diag_type) :: Diag
type(GFS_control_type), intent(in) :: Model
integer :: i

Diag%fluxr = zero
Diag%topfsw%upfxc = zero
Expand All @@ -5465,6 +5522,7 @@ subroutine diag_phys_zero (Diag, Model, linit, iauwindow_center)
logical,optional, intent(in) :: linit, iauwindow_center

logical set_totprcp
integer :: i

!--- In/Out
Diag%srunoff = zero
Expand Down Expand Up @@ -5664,6 +5722,7 @@ subroutine diag_phys_zero (Diag, Model, linit, iauwindow_center)
Diag%totsnw = zero
Diag%totgrp = zero
endif

end subroutine diag_phys_zero

!-----------------------
Expand Down
26 changes: 26 additions & 0 deletions gfsphysics/GFS_layer/GFS_typedefs.meta
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,18 @@
units = flag
dimensions = ()
type = logical
[naux2d]
standard_name = number_of_2d_auxiliary_arrays
long_name = number of 2d auxiliary arrays to output (for debugging)
units = count
dimensions = ()
type = integer
[naux3d]
standard_name = number_of_3d_auxiliary_arrays
long_name = number of 3d auxiliary arrays to output (for debugging)
units = count
dimensions = ()
type = integer
[levs]
standard_name = vertical_dimension
long_name = number of vertical levels
Expand Down Expand Up @@ -5985,6 +5997,20 @@
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
[aux2d]
standard_name = auxiliary_2d_arrays
long_name = auxiliary 2d arrays to output (for debugging)
units = none
dimensions = (horizontal_dimension,number_of_3d_auxiliary_arrays)
type = real
kind = kind_phys
[aux3d]
standard_name = auxiliary_3d_arrays
long_name = auxiliary 3d arrays to output (for debugging)
units = none
dimensions = (horizontal_dimension,vertical_dimension,number_of_3d_auxiliary_arrays)
type = real
kind = kind_phys


########################################################################
Expand Down