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

GWD interstitial reorganization #342

Merged
merged 8 commits into from
Nov 15, 2019
64 changes: 57 additions & 7 deletions physics/GFS_GWD_generic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ module GFS_GWD_generic_pre

contains

!> \section arg_table_GFS_GWD_generic_pre_init Argument Table
!!
subroutine GFS_GWD_generic_pre_init()
end subroutine GFS_GWD_generic_pre_init

Expand Down Expand Up @@ -105,12 +103,64 @@ subroutine GFS_GWD_generic_pre_run( &
end subroutine GFS_GWD_generic_pre_run
!> @}

! \ingroup GFS_ogwd
! \brief Brief description of the subroutine
!
!> \section arg_table_GFS_GWD_generic_pre_finalize Argument Table
!!
subroutine GFS_GWD_generic_pre_finalize()
end subroutine GFS_GWD_generic_pre_finalize

end module GFS_GWD_generic_pre

!> This module contains the CCPP-compliant orographic gravity wave drag post
!! interstitial codes.
module GFS_GWD_generic_post

contains


subroutine GFS_GWD_generic_post_init()
end subroutine GFS_GWD_generic_post_init

!! \section arg_table_GFS_GWD_generic_post_run Argument Table
!! \htmlinclude GFS_GWD_generic_post_run.html
!!
!! \section general General Algorithm
!! \section detailed Detailed Algorithm
!! @{
subroutine GFS_GWD_generic_post_run(lssav, ldiag3d, dtf, dusfcg, dvsfcg, dudt, dvdt, dtdt, &
& dugwd, dvgwd, du3dt, dv3dt, dt3dt, errmsg, errflg)

use machine, only : kind_phys
implicit none

logical, intent(in) :: lssav, ldiag3d

real(kind=kind_phys), intent(in) :: dusfcg(:), dvsfcg(:)
real(kind=kind_phys), intent(in) :: dudt(:,:), dvdt(:,:), dtdt(:,:)
real(kind=kind_phys), intent(in) :: dtf

real(kind=kind_phys), intent(inout) :: dugwd(:), dvgwd(:)
real(kind=kind_phys), intent(inout) :: du3dt(:,:), dv3dt(:,:), dt3dt(:,:)

character(len=*), intent(out) :: errmsg
integer, intent(out) :: errflg

! Initialize CCPP error handling variables
errmsg = ''
errflg = 0

if (lssav) then
dugwd(:) = dugwd(:) + dusfcg(:)*dtf
dvgwd(:) = dvgwd(:) + dvsfcg(:)*dtf

if (ldiag3d) then
du3dt(:,:) = du3dt(:,:) + dudt(:,:) * dtf
dv3dt(:,:) = dv3dt(:,:) + dvdt(:,:) * dtf
dt3dt(:,:) = dt3dt(:,:) + dtdt(:,:) * dtf
endif
endif

end subroutine GFS_GWD_generic_post_run
!> @}

subroutine GFS_GWD_generic_post_finalize()
end subroutine GFS_GWD_generic_post_finalize

end module GFS_GWD_generic_post
137 changes: 137 additions & 0 deletions physics/GFS_GWD_generic.meta
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,140 @@
[ccpp-arg-table]
name = GFS_GWD_generic_pre_finalize
type = scheme

########################################################################
[ccpp-arg-table]
name = GFS_GWD_generic_post_run
type = scheme
[lssav]
standard_name = flag_diagnostics
long_name = flag for calculating diagnostic fields
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[ldiag3d]
standard_name = flag_diagnostics_3D
long_name = flag for calculating 3-D diagnostic fields
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[dtf]
standard_name = time_step_for_dynamics
long_name = dynamics time step
units = s
dimensions = ()
type = real
kind = kind_phys
intent = in
optional = F
[dusfcg]
standard_name = instantaneous_x_stress_due_to_gravity_wave_drag
long_name = zonal surface stress due to orographic gravity wave drag
units = Pa
dimensions = (horizontal_dimension)
type = real
kind = kind_phys
intent = in
optional = F
[dvsfcg]
standard_name = instantaneous_y_stress_due_to_gravity_wave_drag
long_name = meridional surface stress due to orographic gravity wave drag
units = Pa
dimensions = (horizontal_dimension)
type = real
kind = kind_phys
intent = in
optional = F
[dudt]
standard_name = tendency_of_x_wind_due_to_model_physics
long_name = zonal wind tendency due to model physics
units = m s-2
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = in
optional = F
[dvdt]
standard_name = tendency_of_y_wind_due_to_model_physics
long_name = meridional wind tendency due to model physics
units = m s-2
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = in
optional = F
[dtdt]
standard_name = tendency_of_air_temperature_due_to_model_physics
long_name = air temperature tendency due to model physics
units = K s-1
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = in
optional = F
[dugwd]
standard_name = time_integral_of_x_stress_due_to_gravity_wave_drag
long_name = integral over time of zonal stress due to gravity wave drag
units = Pa s
dimensions = (horizontal_dimension)
type = real
kind = kind_phys
intent = inout
optional = F
[dvgwd]
standard_name = time_integral_of_y_stress_due_to_gravity_wave_drag
long_name = integral over time of meridional stress due to gravity wave drag
units = Pa s
dimensions = (horizontal_dimension)
type = real
kind = kind_phys
intent = inout
optional = F
[du3dt]
standard_name = cumulative_change_in_x_wind_due_to_orographic_gravity_wave_drag
long_name = cumulative change in zonal wind due to orographic gravity wave drag
units = m s-1
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = inout
optional = F
[dv3dt]
standard_name = cumulative_change_in_y_wind_due_to_orographic_gravity_wave_drag
long_name = cumulative change in meridional wind due to orographic gravity wave drag
units = m s-1
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = inout
optional = F
[dt3dt]
standard_name = cumulative_change_in_temperature_due_to_orographic_gravity_wave_drag
long_name = cumulative change in temperature due to orographic gravity wave drag
units = K
dimensions = (horizontal_dimension,vertical_dimension)
type = real
kind = kind_phys
intent = inout
optional = F
[errmsg]
standard_name = ccpp_error_message
long_name = error message for error handling in CCPP
units = none
dimensions = ()
type = character
kind = len=*
intent = out
optional = F
[errflg]
standard_name = ccpp_error_flag
long_name = error flag for error handling in CCPP
units = flag
dimensions = ()
type = integer
intent = out
optional = F
9 changes: 5 additions & 4 deletions physics/cires_ugwp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ module cires_ugwp
!!
! -----------------------------------------------------------------------
!
subroutine cires_ugwp_init (me, master, nlunit, logunit, fn_nml2, &
lonr, latr, levs, ak, bk, dtp, cdmbgwd, cgwf, &
subroutine cires_ugwp_init (me, master, nlunit, input_nml_file, logunit, &
fn_nml2, lonr, latr, levs, ak, bk, dtp, cdmbgwd, cgwf, &
pa_rf_in, tau_rf_in, con_p0, do_ugwp, errmsg, errflg)

!---- initialization of cires_ugwp
Expand All @@ -47,6 +47,7 @@ subroutine cires_ugwp_init (me, master, nlunit, logunit, fn_nml2, &
integer, intent (in) :: me
integer, intent (in) :: master
integer, intent (in) :: nlunit
character(len=*), intent (in) :: input_nml_file(:)
integer, intent (in) :: logunit
integer, intent (in) :: lonr
integer, intent (in) :: levs
Expand Down Expand Up @@ -76,8 +77,8 @@ subroutine cires_ugwp_init (me, master, nlunit, logunit, fn_nml2, &
if (is_initialized) return

if (do_ugwp .or. cdmbgwd(3) > 0.0) then
call cires_ugwp_mod_init (me, master, nlunit, logunit, fn_nml2, &
lonr, latr, levs, ak, bk, con_p0, dtp, &
call cires_ugwp_mod_init (me, master, nlunit, input_nml_file, logunit, &
fn_nml2, lonr, latr, levs, ak, bk, con_p0, dtp, &
cdmbgwd(1:2), cgwf, pa_rf_in, tau_rf_in)
else
write(errmsg,'(*(a))') "Logic error: cires_ugwp_init called but do_ugwp is false and cdmbgwd(3) <= 0"
Expand Down
9 changes: 9 additions & 0 deletions physics/cires_ugwp.meta
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
type = integer
intent = in
optional = F
[input_nml_file]
standard_name = namelist_filename_for_internal_file_reads
long_name = character string to store full namelist contents
units = none
dimensions = (number_of_lines_of_namelist_filename_for_internal_file_reads)
type = character
kind = len=*
intent = in
optional = F
[logunit]
standard_name = iounit_log
long_name = fortran unit number for writing logfile
Expand Down
48 changes: 26 additions & 22 deletions physics/cires_ugwp_module.F90
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ module cires_ugwp_module
! init of cires_ugwp (_init) called from GFS_driver.F90
!
! -----------------------------------------------------------------------
subroutine cires_ugwp_mod_init (me, master, nlunit, logunit, fn_nml2, &
lonr, latr, levs, ak, bk, pref, dtp, cdmvgwd, cgwf, &
subroutine cires_ugwp_mod_init (me, master, nlunit, input_nml_file, logunit, &
fn_nml, lonr, latr, levs, ak, bk, pref, dtp, cdmvgwd, cgwf, &
pa_rf_in, tau_rf_in)
!
! input_nml_file ='input.nml'=fn_nml
!

use ugwp_oro_init, only : init_oro_gws
use ugwp_conv_init, only : init_conv_gws
use ugwp_fjet_init, only : init_fjet_gws
Expand All @@ -120,31 +118,33 @@ subroutine cires_ugwp_mod_init (me, master, nlunit, logunit, fn_nml2, &
use ugwp_lsatdis_init, only : initsolv_lsatdis
implicit none

integer, intent (in) :: me
integer, intent (in) :: master
integer, intent (in) :: nlunit
integer, intent (in) :: logunit
integer, intent (in) :: lonr
integer, intent (in) :: levs
integer, intent (in) :: latr
real, intent (in) :: ak(levs+1), bk(levs+1), pref
real, intent (in) :: dtp
real, intent (in) :: cdmvgwd(2), cgwf(2) ! "scaling" controls for "old" GFS-GW schemes
real, intent (in) :: pa_rf_in, tau_rf_in

character(len=64), intent (in) :: fn_nml2
character(len=64), parameter :: fn_nml='input.nml'
integer, intent (in) :: me
integer, intent (in) :: master
integer, intent (in) :: nlunit
character (len = *), intent (in) :: input_nml_file(:)
integer, intent (in) :: logunit
character(len=64), intent (in) :: fn_nml
integer, intent (in) :: lonr
integer, intent (in) :: levs
integer, intent (in) :: latr
real, intent (in) :: ak(levs+1), bk(levs+1), pref
real, intent (in) :: dtp
real, intent (in) :: cdmvgwd(2), cgwf(2) ! "scaling" controls for "old" GFS-GW schemes
real, intent (in) :: pa_rf_in, tau_rf_in

! character, intent (in) :: input_nml_file
! integer, parameter :: logunit = 6
integer :: ios
logical :: exists
real :: dxsg
integer :: k
!

#ifdef INTERNAL_FILE_NML
read (input_nml_file, nml = cires_ugwp_nml)
#else
if (me == master) print *, trim (fn_nml), ' GW-namelist file '

inquire (file =trim (fn_nml) , exist = exists)
!

if (.not. exists) then
if (me == master) &
write (6, *) 'separate ugwp :: namelist file: ', trim (fn_nml), ' does not exist'
Expand All @@ -154,6 +154,10 @@ subroutine cires_ugwp_mod_init (me, master, nlunit, logunit, fn_nml2, &
rewind (nlunit)
read (nlunit, nml = cires_ugwp_nml)
close (nlunit)
#endif



!
ilaunch = launch_level
pa_rf = pa_rf_in
Expand Down
22 changes: 2 additions & 20 deletions physics/cires_ugwp_post.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ subroutine cires_ugwp_post_run (ldiag_ugwp, dtf, im, levs, &
tot_zmtb, tot_zlwb, tot_zogw, &
tot_tofd, tot_mtb, tot_ogw, tot_ngw, &
du3dt_mtb,du3dt_ogw, du3dt_tms, du3dt_ngw, dv3dt_ngw, &
dtdt, dudt, dvdt, lssav, ldiag3d, dusfcg, dvsfcg, dugwd, &
dvgwd, du3dt, dv3dt, dt3dt, errmsg, errflg)
dtdt, dudt, dvdt, &
errmsg, errflg)

use machine, only: kind_phys

Expand All @@ -45,12 +45,6 @@ subroutine cires_ugwp_post_run (ldiag_ugwp, dtf, im, levs, &
real(kind=kind_phys), intent(inout), dimension(:,:) :: du3dt_mtb, du3dt_ogw, du3dt_tms, du3dt_ngw, dv3dt_ngw
real(kind=kind_phys), intent(inout), dimension(:,:) :: dtdt, dudt, dvdt

! For if (lssav) block, originally in gwdps_post_run
logical, intent(in) :: lssav, ldiag3d
real(kind=kind_phys), intent(in), dimension(:) :: dusfcg, dvsfcg
real(kind=kind_phys), intent(inout), dimension(:) :: dugwd, dvgwd
real(kind=kind_phys), intent(inout), dimension(:,:) :: du3dt, dv3dt, dt3dt

character(len=*), intent(out) :: errmsg
integer, intent(out) :: errflg

Expand Down Expand Up @@ -79,18 +73,6 @@ subroutine cires_ugwp_post_run (ldiag_ugwp, dtf, im, levs, &
dudt = dudt + gw_dudt
dvdt = dvdt + gw_dvdt

! Originally in gwdps_post_run
if (lssav) then
dugwd(:) = dugwd(:) + dusfcg(:)*dtf
dvgwd(:) = dvgwd(:) + dvsfcg(:)*dtf

if (ldiag3d) then
du3dt(:,:) = du3dt(:,:) + dudt(:,:) * dtf
dv3dt(:,:) = dv3dt(:,:) + dvdt(:,:) * dtf
dt3dt(:,:) = dt3dt(:,:) + dtdt(:,:) * dtf
endif
endif

end subroutine cires_ugwp_post_run

!> \section arg_table_cires_ugwp_post_finalize Argument Table
Expand Down
Loading