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

Refactor NRL h2o photochemical physics scheme #213

Closed
Show file tree
Hide file tree
Changes from 3 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
4 changes: 1 addition & 3 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ physics/SFC_Models/SeaIce/CICE/sfc_cice.* @wd
physics/SFC_Models/SeaIce/CICE/sfc_sice.* @wd20xw @grantfirl @Qingfu-Liu @dustinswales
physics/hooks/machine.* @grantfirl @Qingfu-Liu @dustinswales
physics/hooks/physcons.F90 @grantfirl @Qingfu-Liu @dustinswales
physics/photochem/h2o_def.* @grantfirl @Qingfu-Liu @dustinswales
physics/photochem/h2ointerp.f90 @grantfirl @Qingfu-Liu @dustinswales
physics/photochem/h2ophys.* @Qingfu-Liu @grantfirl @Qingfu-Liu @dustinswales
physics/photochem/module_h2ophys.* @Qingfu-Liu @grantfirl @Qingfu-Liu @dustinswales
physics/photochem/module_ozphys.* @dustinswales @grantfirl @Qingfu-Liu @dustinswales
physics/smoke_dust/* @haiqinli @grantfirl @Qingfu-Liu @dustinswales
physics/tools/funcphys.f90 @grantfirl @Qingfu-Liu @dustinswales
Expand Down
76 changes: 76 additions & 0 deletions physics/Interstitials/UFS_SCM_NEPTUNE/GFS_photochemistry.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
! #########################################################################################
!> \file GFS_photochemistry.f90
!!
! #########################################################################################
module GFS_photochemistry
use machine, only: kind_phys
use module_ozphys, only: ty_ozphys
use module_h2ophys, only: ty_h2ophys
implicit none
contains
! #########################################################################################
!> \section arg_table_GFS_photochemistry_run Argument Table
!! \htmlinclude GFS_photochemistry_run.html
!!
! #########################################################################################
subroutine GFS_photochemistry_run (dtp, ozphys, oz_phys_2015, oz_phys_2006, con_1ovg, &
prsl, dp, ozpl, h2o_phys, h2ophys, h2opl, h2o0, oz0, gt0, do3_dt_prd, do3_dt_ozmx, &
do3_dt_temp, do3_dt_ohoz, errmsg, errflg)

! Inputs
real(kind=kind_phys), intent(in ) :: &
dtp, & ! Model timestep
con_1ovg ! Physical constant (1./gravity)
real(kind=kind_phys), intent(in ), dimension(:,:) :: &
prsl, & ! Air pressure (Pa)
dp ! Pressure thickness (Pa)
real(kind=kind_phys), intent(in ), dimension(:,:,:) :: &
ozpl, & ! Ozone data for current model timestep
h2opl ! h2o data for curent model timestep
logical, intent(in) :: &
oz_phys_2015, & ! Do ozone photochemistry? (2015)
oz_phys_2006, & ! Do ozone photochemistry? (2006)
h2o_phys ! Do h2o photochemistry?
type(ty_ozphys), intent(in) :: &
dustinswales marked this conversation as resolved.
Show resolved Hide resolved
ozphys ! DDT with ozone photochemistry scheme.
type(ty_h2ophys), intent(in) :: &
h2ophys ! DDT with h2o photochemistry scheme.

! Outputs (optional)
real(kind=kind_phys), intent(inout), dimension(:,:), optional :: &
do3_dt_prd, & ! Physics tendency: production and loss effect
do3_dt_ozmx, & ! Physics tendency: ozone mixing ratio effect
do3_dt_temp, & ! Physics tendency: temperature effect
do3_dt_ohoz ! Physics tendency: overhead ozone effect

! Outputs
real(kind=kind_phys), intent(out), dimension(:,:) :: &
oz0, & ! Update ozone concentration.
h2o0 ! Updated h2o concentration.
real(kind=kind_phys), intent(inout), dimension(:,:) :: &
gt0 ! Updated temperature

character(len=*), intent(out) :: &
errmsg ! CCPP Error message.
integer, intent(out) :: &
errflg ! CCPP Error flag.

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

if (oz_phys_2015) then
call ozphys%run_o3prog_2015(con_1ovg, dtp, prsl, gt0, dp, ozpl, oz0, do3_dt_prd, &
do3_dt_ozmx, do3_dt_temp, do3_dt_ohoz)
endif
if (oz_phys_2006) then
call ozphys%run_o3prog_2006(con_1ovg, dtp, prsl, gt0, dp, ozpl, oz0, do3_dt_prd, &
do3_dt_ozmx, do3_dt_temp, do3_dt_ohoz)
endif
if (h2o_phys) then
call h2ophys%run(dtp, prsl, h2opl, h2o0)
endif

end subroutine GFS_photochemistry_run

end module GFS_photochemistry
161 changes: 161 additions & 0 deletions physics/Interstitials/UFS_SCM_NEPTUNE/GFS_photochemistry.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
########################################################################
[ccpp-table-properties]
name = GFS_photochemistry
type = scheme
dependencies = ../../hooks/machine.F,../../photochem/module_ozphys.F90
dependencies = ../../photochem/module_h2ophys.F90

########################################################################
[ccpp-arg-table]
name = GFS_photochemistry
type = scheme
[dtp]
standard_name = timestep_for_physics
long_name = physics timestep
units = s
dimensions = ()
type = real
kind = kind_phys
intent = in
[ozphys]
standard_name = dataset_for_ozone_physics
long_name = dataset for NRL ozone physics
units = mixed
dimensions = ()
type = ty_ozphys
intent = in
[oz_phys_2015]
standard_name = flag_for_nrl_2015_ozone_scheme
long_name = flag for new (2015) ozone physics
units = flag
dimensions = ()
type = logical
intent = in
[oz_phys_2006]
standard_name = flag_for_nrl_2006_ozone_scheme
long_name = flag for new (2006) ozone physics
units = flag
dimensions = ()
type = logical
intent = in
[prsl]
standard_name = air_pressure
long_name = mid-layer pressure
units = Pa
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
intent = in
[dp]
standard_name = air_pressure_difference_between_midlayers
long_name = difference between mid-layer pressures
units = Pa
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
intent = in
[ozpl]
standard_name = ozone_forcing
long_name = ozone forcing data
units = mixed
dimensions = (horizontal_loop_extent,vertical_dimension_of_ozone_forcing_data,number_of_coefficients_in_ozone_data)
type = real
kind = kind_phys
intent = in
[h2o_phys]
standard_name = flag_for_stratospheric_water_vapor_physics
long_name = flag for stratospheric water vapor physics
units = flag
dimensions = ()
type = logical
intent = in
[h2ophys]
standard_name = dataset_for_h2o_photochemistry_physics
long_name = dataset for NRL h2o photochemistry physics
units = mixed
dimensions = ()
type = ty_h2ophys
intent = in
[h2opl]
standard_name = stratospheric_water_vapor_forcing
long_name = water forcing data
units = mixed
dimensions = (horizontal_loop_extent,vertical_dimension_of_h2o_forcing_data,number_of_coefficients_in_h2o_forcing_data)
type = real
kind = kind_phys
intent = in
[h2o0]
standard_name = specific_humidity_of_new_state
long_name = water vapor specific humidity updated by physics
units = kg kg-1
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
intent = out
[oz0]
standard_name = ozone_concentration_of_new_state
long_name = ozone concentration updated by physics
units = kg kg-1
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
intent = out
[gt0]
standard_name = air_temperature_of_new_state
long_name = temperature updated by physics
units = K
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
[do3_dt_prd]
standard_name = ozone_tendency_due_to_production_and_loss_rate
long_name = ozone tendency due to production and loss rate
units = kg kg-1 s-1
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
optional = True
[do3_dt_ozmx]
standard_name = ozone_tendency_due_to_ozone_mixing_ratio
long_name = ozone tendency due to ozone mixing ratio
units = kg kg-1 s-1
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
optional = True
[do3_dt_temp]
standard_name = ozone_tendency_due_to_temperature
long_name = ozone tendency due to temperature
units = kg kg-1 s-1
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
optional = True
[do3_dt_ohoz]
standard_name = ozone_tendency_due_to_overhead_ozone_column
long_name = ozone tendency due to overhead ozone column
units = kg kg-1 s-1
dimensions = (horizontal_loop_extent,vertical_layer_dimension)
type = real
kind = kind_phys
intent = inout
optional = True
[errmsg]
standard_name = ccpp_error_message
long_name = error message for error handling in CCPP
units = none
dimensions = ()
type = character
kind = len=*
intent = out
[errflg]
standard_name = ccpp_error_code
long_name = error code for error handling in CCPP
units = 1
dimensions = ()
type = integer
intent = out
dustinswales marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ module GFS_phys_time_vary
use mersenne_twister, only: random_setseed, random_number

use module_ozphys, only: ty_ozphys

use h2o_def, only : levh2o, h2o_coeff, h2o_lat, h2o_pres, h2o_time, h2oplin
use h2ointerp, only : read_h2odata, setindxh2o, h2ointerpol
use module_h2ophys, only: ty_h2ophys

use aerclm_def, only : aerin, aer_pres, ntrcaer, ntrcaerm, iamin, iamax, jamin, jamax
use aerinterp, only : read_aerdata, setindxaer, aerinterpol, read_aerdataf
Expand Down Expand Up @@ -97,7 +95,7 @@ subroutine GFS_phys_time_vary_init (
smcwtdxy, deeprechxy, rechxy, snowxy, snicexy, snliqxy, tsnoxy , smoiseq, zsnsoxy, &
slc, smc, stc, tsfcl, snowd, canopy, tg3, stype, con_t0c, lsm_cold_start, nthrds, &
lkm, use_lake_model, lakefrac, lakedepth, iopt_lake, iopt_lake_clm, iopt_lake_flake, &
lakefrac_threshold, lakedepth_threshold, ozphys, errmsg, errflg)
lakefrac_threshold, lakedepth_threshold, ozphys, h2ophys, errmsg, errflg)

implicit none

Expand Down Expand Up @@ -133,6 +131,7 @@ subroutine GFS_phys_time_vary_init (
real(kind_phys), intent(in) :: landfrac(:)
real(kind_phys), intent(inout) :: weasd(:)
type(ty_ozphys), intent(in) :: ozphys
type(ty_h2ophys), intent(in) :: h2ophys

! NoahMP - only allocated when NoahMP is used
integer, intent(in) :: lsoil, lsnow_lsm_lbound, lsnow_lsm_ubound
Expand Down Expand Up @@ -222,29 +221,6 @@ subroutine GFS_phys_time_vary_init (
jamin=999
jamax=-999

!> - Call read_h2odata() to read stratospheric water vapor data
need_h2odata: if(h2o_phys) then
call read_h2odata (h2o_phys, me, master)

! Consistency check that the hardcoded values for levh2o and
! h2o_coeff in GFS_typedefs.F90 match what is set by read_h2odata
! in GFS_typedefs.F90: allocate (Tbd%h2opl (IM,levh2o,h2o_coeff))
if (size(h2opl, dim=2).ne.levh2o) then
write(myerrmsg,'(2a,i0,a,i0)') "Value error in GFS_phys_time_vary_init: ", &
"levh2o from read_h2odata does not match value in GFS_typedefs.F90: ", &
levh2o, " /= ", size(h2opl, dim=2)
myerrflg = 1
call copy_error(myerrmsg, myerrflg, errmsg, errflg)
end if
if (size(h2opl, dim=3).ne.h2o_coeff) then
write(myerrmsg,'(2a,i0,a,i0)') "Value error in GFS_phys_time_vary_init: ", &
"h2o_coeff from read_h2odata does not match value in GFS_typedefs.F90: ", &
h2o_coeff, " /= ", size(h2opl, dim=3)
myerrflg = 1
call copy_error(myerrmsg, myerrflg, errmsg, errflg)
end if
endif need_h2odata

!> - Call read_aerdata() to read aerosol climatology, Anning added coupled
!> added coupled gocart and radiation option to initializing aer_nm
if (iaerclm) then
Expand Down Expand Up @@ -305,7 +281,7 @@ subroutine GFS_phys_time_vary_init (

!> - Call setindxh2o() to initialize stratospheric water vapor data
if (h2o_phys) then
call setindxh2o (im, xlat_d, jindx1_h, jindx2_h, ddy_h)
call h2ophys%setup(xlat_d, jindx1_h, jindx2_h, ddy_h)
endif

!> - Call setindxaer() to initialize aerosols data
Expand Down Expand Up @@ -734,7 +710,7 @@ subroutine GFS_phys_time_vary_timestep_init (
lakefrac, min_seaice, min_lakeice, smc, slc, stc, smois, sh2o, tslb, tiice, tg3, tref, &
tsfc, tsfco, tisfc, hice, fice, facsf, facwf, alvsf, alvwf, alnsf, alnwf, zorli, zorll, &
zorlo, weasd, slope, snoalb, canopy, vfrac, vtype, stype,scolor, shdmin, shdmax, snowd, &
cv, cvb, cvt, oro, oro_uf, xlat_d, xlon_d, slmsk, landfrac, ozphys, &
cv, cvb, cvt, oro, oro_uf, xlat_d, xlon_d, slmsk, landfrac, ozphys, h2ophys, &
do_ugwp_v1, jindx1_tau, jindx2_tau, ddy_j1tau, ddy_j2tau, tau_amf, errmsg, errflg)

implicit none
Expand Down Expand Up @@ -765,6 +741,7 @@ subroutine GFS_phys_time_vary_timestep_init (
real(kind_phys), intent(in), optional :: ddy_j1tau(:), ddy_j2tau(:)
real(kind_phys), intent(inout) :: tau_amf(:)
type(ty_ozphys), intent(in) :: ozphys
type(ty_h2ophys), intent(in) :: h2ophys

! For gcycle only
integer, intent(in) :: nthrds, nx, ny, nsst, tile_num, nlunit, lsoil
Expand Down Expand Up @@ -812,7 +789,7 @@ subroutine GFS_phys_time_vary_timestep_init (
!$OMP shared(ozpl,ddy_o3,h2o_phys,jindx1_h,jindx2_h,h2opl,ddy_h,iaerclm,master) &
!$OMP shared(levs,prsl,iccn,jindx1_ci,jindx2_ci,ddy_ci,iindx1_ci,iindx2_ci) &
!$OMP shared(ddx_ci,in_nm,ccn_nm,do_ugwp_v1,jindx1_tau,jindx2_tau,ddy_j1tau) &
!$OMP shared(ddy_j2tau,tau_amf,iflip,ozphys,rjday,n1,n2,idat,jdat,rinc) &
!$OMP shared(ddy_j2tau,tau_amf,iflip,ozphys,h2ophys,rjday,n1,n2,idat,jdat,rinc) &
!$OMP shared(w3kindreal,w3kindint,jdow,jdoy,jday) &
!$OMP private(iseed,iskip,i,j,k)

Expand Down Expand Up @@ -895,12 +872,9 @@ subroutine GFS_phys_time_vary_timestep_init (
call ozphys%update_o3prog(jindx1_o3, jindx2_o3, ddy_o3, rjday, n1, n2, ozpl)
endif

!$OMP section
!> - Call h2ointerpol() to make stratospheric water vapor data interpolation
!> - Update stratospheric h2o concentration.
if (h2o_phys) then
call h2ointerpol (me, im, idate, fhour, &
jindx1_h, jindx2_h, &
h2opl, ddy_h)
call h2ophys%update(jindx1_h, jindx2_h, ddy_h, rjday, n1, n2, h2opl)
endif

!$OMP section
Expand Down Expand Up @@ -992,12 +966,6 @@ subroutine GFS_phys_time_vary_finalize(errmsg, errflg)

if (.not.is_initialized) return

! Deallocate h2o arrays
if (allocated(h2o_lat) ) deallocate(h2o_lat)
if (allocated(h2o_pres)) deallocate(h2o_pres)
if (allocated(h2o_time)) deallocate(h2o_time)
if (allocated(h2oplin) ) deallocate(h2oplin)

! Deallocate aerosol arrays
if (allocated(aerin) ) deallocate(aerin)
if (allocated(aer_pres)) deallocate(aer_pres)
Expand Down
Loading
Loading