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 dadadj for CCPP framework #91

Merged
merged 28 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
63bab8e
commit initial dadadj mods for SIMA
jtruesdal Mar 27, 2024
9c8ed80
dadadj ccpp mods
jtruesdal Mar 30, 2024
54dc02f
bug fix in loop rewrite
jtruesdal Apr 4, 2024
9da3c51
Merge branch 'ESCOMP:main' into dadadj
jtruesdal Apr 12, 2024
ec51f8c
update main loop in dadadj to get rid of goto statement
jtruesdal Apr 13, 2024
25b52e8
Merge remote-tracking branch 'refs/remotes/jtruesdal/dadadj' into dadadj
jtruesdal Apr 13, 2024
6262dfb
Merge branch 'ESCOMP:main' into dadadj
jtruesdal Apr 30, 2024
8ad3e20
update doc/ChangeLog
jtruesdal May 2, 2024
9fd5230
Update dadadj/dadadj.F90
jtruesdal May 28, 2024
75568fa
Update dadadj/dadadj.F90
jtruesdal May 28, 2024
ff9c000
PR mods
jtruesdal May 28, 2024
ffd527a
rename dadadj dry_adiabatic_adjust
jtruesdal May 28, 2024
d2af285
PR updates
jtruesdal May 28, 2024
6ebbcd6
PR updates
jtruesdal May 28, 2024
e4ccb3e
PR updates - rename dadadj to dry_adiabatic_adjustment
jtruesdal May 30, 2024
eb6c886
Update suite_cam7.xml
jtruesdal May 30, 2024
5c1c3fb
more PR updates
jtruesdal May 30, 2024
3174426
forgot to add test/test_sdfs directory with dry_adiabatic_adjust suite
jtruesdal May 30, 2024
724f30c
PR errmsg update to indicate what column index failed to converge
jtruesdal Jun 4, 2024
4c0f723
PR updates to Changelog
jtruesdal Jun 20, 2024
c98d6ac
fix constituent update - add new update routine until standard one is…
jtruesdal Jul 10, 2024
26591e1
dry adiabatic suite moved to test_sdfs subdirectory, cam7 suite will …
jtruesdal Jul 11, 2024
4a27c3d
ChangeLog update
jtruesdal Jul 12, 2024
4500e60
update to latest atmospheric_physics, generate new NamesNotInDictiona…
jtruesdal Jul 12, 2024
23d7e14
ChangeLog update
jtruesdal Jul 12, 2024
01a0dc2
ChangeLog corr
jtruesdal Jul 12, 2024
9a44dbf
ChangeLog corr
jtruesdal Jul 12, 2024
1e70ee7
minor PR updates to comments, ChangeLog and meta data
jtruesdal Jul 15, 2024
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
2 changes: 1 addition & 1 deletion doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

===============================================================

Tag name: atmos_phys0_02_xxx
Tag name: atmos_phys0_0x_000
Originator(s): jet
Date: May 3, 2024
One-line Summary: dadadj CCPP mods
Expand Down
48 changes: 36 additions & 12 deletions dadadj/dadadj.F90 → dry_adiabatic_adjust/dadadj.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ subroutine dadadj_init(dadadj_nlvdry, dadadj_niter, nz, errmsg, errflg)

if (dadadj_nlvdry >= nz .or. dadadj_nlvdry < 0) then
errflg = 1
write(errmsg,*) 'dadadj_init: dadadj_nlvdry=',dadadj_nlvdry,' but must be less than the number of vertical levels '
write(errmsg,*) 'dadadj_init: dadadj_nlvdry=',dadadj_nlvdry,' but must be less than the number of vertical levels ',&
'(',nz,'), and must be a positive integer.`
nusbaume marked this conversation as resolved.
Show resolved Hide resolved
end if

nlvdry = dadadj_nlvdry
Expand All @@ -63,8 +64,8 @@ subroutine dadadj_run( &
real(kind_phys), intent(in) :: cappa(:,:) ! variable Kappa
real(kind_phys), intent(in) :: state_t(:,:) ! temperature (K)
real(kind_phys), intent(in) :: state_q(:,:) ! specific humidity
real(kind_phys), intent(out), TARGET :: t_tend(:,:) ! temperature tendency
real(kind_phys), intent(out), TARGET :: q_tend(:,:) ! specific humidity tendency
real(kind_phys), intent(out), target :: t_tend(:,:) ! temperature tendency
real(kind_phys), intent(out), target :: q_tend(:,:) ! specific humidity tendency
real(kind_phys), intent(out) :: dadpdf(:,:) ! PDF of where adjustments happened

character(len=64), intent(out) :: scheme_name
Expand Down Expand Up @@ -102,7 +103,30 @@ subroutine dadadj_run( &
errflg = 0
scheme_name = 'DADADJ'

allocate(c1dad(nlvdry), c2dad(nlvdry), c3dad(nlvdry), c4dad(nlvdry))
allocate(c1dad(nlvdry), stat=ierr)
if (ierr /= 0) then
errcode = ierr
errmsg = trim(scheme_name)//': Allocate of c1dad(nlvdry) failed'
return
end if
allocate(c2dad(nlvdry), stat=ierr)
if (ierr /= 0) then
errcode = ierr
errmsg = trim(scheme_name)//': Allocate of c2dad(nlvdry) failed'
return
end if
allocate(c3dad(nlvdry), stat=ierr)
if (ierr /= 0) then
errcode = ierr
errmsg = trim(scheme_name)//': Allocate of c3dad(nlvdry) failed'
return
end if
allocate(c4dad(nlvdry), stat=ierr)
if (ierr /= 0) then
errcode = ierr
errmsg = trim(scheme_name)//': Allocate of c4dad(nlvdry) failed'
return
end if

! t_tend< and tend_dtdq used as workspace until needed to calculate tendencies
t => t_tend
Expand All @@ -117,7 +141,7 @@ subroutine dadadj_run( &
cappaint = 0.5_kind_phys*(cappa(i,2) + cappa(i,1))
gammad = cappaint*0.5_kind_phys*(t(i,2) + t(i,1))/pint(i,2)
dtdp = (t(i,2) - t(i,1))/(pmid(i,2) - pmid(i,1))
dodad(i) = (dtdp + zeps) .gt. gammad
dodad(i) = (dtdp + zeps) > gammad
end do

dadpdf(:ncol,:) = 0._kind_phys
Expand All @@ -126,8 +150,8 @@ subroutine dadadj_run( &
cappaint = 0.5_kind_phys*(cappa(i,k+1) + cappa(i,k))
gammad = cappaint*0.5_kind_phys*(t(i,k+1) + t(i,k))/pint(i,k+1)
dtdp = (t(i,k+1) - t(i,k))/(pmid(i,k+1) - pmid(i,k))
dodad(i) = dodad(i) .or. (dtdp + zeps).gt.gammad
if ((dtdp + zeps).gt.gammad) then
dodad(i) = dodad(i) .or. (dtdp + zeps) > gammad
if ((dtdp + zeps) > gammad) then
dadpdf(i,k) = 1._kind_phys
end if
end do
Expand All @@ -152,26 +176,25 @@ subroutine dadadj_run( &
end do

ilconv = .false.

DBLZEP: do while (.not. ilconv)

do jiter = 1, niter
ilconv = .true.

do k = 1, nlvdry
zepsdp = zeps*(pmid(i,k+1) - pmid(i,k))
zgamma = c1dad(k)*(t(i,k) + t(i,k+1))

if ((t(i,k+1)-t(i,k)) >= (zgamma+zepsdp)) then
write(6,*)'adjusting t and q at i,k=',i,k
ilconv = .false.
t(i,k+1) = t(i,k)*c3dad(k) + t(i,k+1)*c4dad(k)
t(i,k) = c2dad(k)*t(i,k+1)
qave = (pdel(i,k+1)*q(i,k+1) + pdel(i,k)*q(i,k))/(pdel(i,k+1)+ pdel(i,k))
q(i,k+1) = qave
q(i,k) = qave
end if

end do

if (ilconv) cycle COL ! convergence => next longitude
Expand All @@ -181,6 +204,7 @@ subroutine dadadj_run( &
zeps = zeps + zeps
if (zeps > 1.e-4_kind_phys) then
errflg = i
errmsg = trim(scheme_name)//': Convergence failure, zeps > 1.e-4'
return ! error return
end if
end do DBLZEP
Expand Down
26 changes: 13 additions & 13 deletions dadadj/dadadj.meta → dry_adiabatic_adjust/dadadj.meta
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
dimensions = ()
intent = out
[ errflg ]
standard_name = ccpp_error_flag
long_name = Error flag for error handling in CCPP
units = flag
standard_name = ccpp_error_code
long_name = Error code for error handling in CCPP
units = 1
type = integer
dimensions = ()
intent = out
Expand Down Expand Up @@ -78,10 +78,10 @@
standard_name = air_temperature
type = real | kind = kind_phys
units = K
dimensions = (horizontal_dimension, vertical_layer_dimension)
dimensions = (horizontal_loop_extent, vertical_layer_dimension)
intent = in
[ state_q ]
standard_name = water_vapor_mixing_ratio_wrt_dry_air
standard_name = water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water
long_name = mass mixing ratio of water vapor / dry air
advected = True
units = kg kg-1
Expand All @@ -97,20 +97,20 @@
[ t_tend ]
standard_name = tendency_of_air_temperature
units = K s-1
dimensions = (horizontal_dimension, vertical_layer_dimension)
dimensions = (horizontal_loop_extent, vertical_layer_dimension)
type = real | kind = kind_phys
intent = out
[ q_tend ]
standard_name = tendency_of_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water
units = kg kg-1 s-1
type = real | kind = kind_phys
dimensions = (horizontal_dimension, vertical_layer_dimension)
dimensions = (horizontal_loop_extent, vertical_layer_dimension)
intent = out
[ dadpdf ]
standard_name = indicator_for_dry_adiabatic_adjusted_grid_cell
units = 1
standard_name = binary_indicator_for_dry_adiabatic_adjusted_grid_cell
units = fraction
type = real | kind = kind_phys
dimensions = (horizontal_dimension, vertical_layer_dimension)
dimensions = (horizontal_loop_extent, vertical_layer_dimension)
intent = out
[ scheme_name ]
standard_name = scheme_name
Expand All @@ -126,9 +126,9 @@
dimensions = ()
intent = out
[ errflg ]
standard_name = ccpp_error_flag
long_name = Error flag for error handling in CCPP
units = flag
standard_name = ccpp_error_code
long_name = Error code for error handling in CCPP
units = 1
nusbaume marked this conversation as resolved.
Show resolved Hide resolved
type = integer
dimensions = ()
intent = out
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<standard_name>number_of_vertical_levels_from_model_top_where_dry_adiabatic_adjustment_occurs</standard_name>
<units>count</units>
<desc>
Number of layers from the top of the model over which to do dry convective adjustment.
Number of layers from the top of the model over which to do dry adiabatic adjustment.
Must be less than plev (the number of vertical levels).
</desc>
<values>
Expand All @@ -99,7 +99,7 @@
<units>count</units>
<desc>
The maximum number of iterations to achieve convergence in dry adiabatic adjustment.
For WACCM-X it can be advantageous to use a number which is much higher than the CAM
For WACCM-X it can be advantageous to use a number which is much higher than the default CAM value.
</desc>
<values>
<value>15</value>
Expand Down
10 changes: 10 additions & 0 deletions suite_cam7.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="dadadj" version="1.0">
jtruesdal marked this conversation as resolved.
Show resolved Hide resolved
<group name="physics_before_coupler">
<scheme>dadadj</scheme>
nusbaume marked this conversation as resolved.
Show resolved Hide resolved
<scheme>apply_tendency_of_air_temperature</scheme>
<scheme>qneg</scheme>
<scheme>geopotential_temp</scheme>
</group>
</suite>
10 changes: 10 additions & 0 deletions test/test_sdfs/suite_dadadj.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<suite name="dadadj" version="1.0">
<group name="physics_before_coupler">
<scheme>dadadj</scheme>
<scheme>apply_tendency_of_air_temperature</scheme>
<scheme>qneg</scheme>
<scheme>geopotential_temp</scheme>
</group>
</suite>