Skip to content

Commit cf38c6a

Browse files
authored
Merge pull request #1265 from cacraigucar/cam_dme_adj
cam6_4_083: CCPP'ize dme_adjust
2 parents 8860c95 + f8c4f04 commit cf38c6a

7 files changed

Lines changed: 119 additions & 33 deletions

File tree

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
[submodule "atmos_phys"]
3737
path = src/atmos_phys
3838
url = https://github.com/ESCOMP/atmospheric_physics
39-
fxtag = atmos_phys0_10_001
39+
fxtag = atmos_phys0_11_000
4040
fxrequired = AlwaysRequired
4141
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
4242

bld/configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,8 @@ sub write_filepath
21722172
print $fh "$camsrcdir/src/atmos_phys/schemes/tropopause_find\n";
21732173
print $fh "$camsrcdir/src/atmos_phys/schemes/zhang_mcfarlane\n";
21742174
print $fh "$camsrcdir/src/atmos_phys/schemes/dry_adiabatic_adjust\n";
2175-
print $fh "$camsrcdir/src/atmos_phys/schemes/check_energy\n";
2175+
print $fh "$camsrcdir/src/atmos_phys/schemes/conservation_adjust/check_energy\n";
2176+
print $fh "$camsrcdir/src/atmos_phys/schemes/conservation_adjust/dme_adjust\n";
21762177
print $fh "$camsrcdir/src/atmos_phys/schemes/hack_shallow\n";
21772178
print $fh "$camsrcdir/src/atmos_phys/schemes/utilities\n";
21782179

doc/ChangeLog

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,76 @@
1+
2+
===============================================================
3+
4+
Tag name: cam6_4_083
5+
Originator(s): cacraig
6+
Date: April 7, 2025
7+
One-line Summary: CCPP'ize dme_adjust
8+
Github PR URL: https://github.com/ESCOMP/pull/1265
9+
10+
Purpose of changes (include the issue number and title text for each relevant GitHub issue):
11+
- Conversion of physics_dme_adjust to CCPP: https://github.com/ESCOMP/issues/1090
12+
13+
Describe any changes made to build system: N/A
14+
15+
Describe any changes made to the namelist: N/A
16+
17+
List any changes to the defaults for the boundary datasets: N/A
18+
19+
Describe any substantial timing or memory changes: N/A
20+
21+
Code reviewed by: jimmielin
22+
23+
List all files eliminated: N/A
24+
25+
List all files added and what they do: N/A
26+
27+
List all existing files that have been modified, and describe the changes:
28+
M .gitmodules
29+
- Update atmos_phys external to bring in dme_adjust code
30+
31+
M bld/configure
32+
- Introduce conservation_adjust subdirectory and add dme_adjust directory in it
33+
34+
M src/atmos_phys
35+
- update submodule
36+
37+
M src/physics/cam/physics_types.F90
38+
- changes to support calling dme_adjust from CCPP'ized code
39+
40+
M src/physics/cam/physpkg.F90
41+
M src/physics/cam7/physpkg.F90
42+
- add snapshot logic for dme_adjust
43+
44+
45+
If there were any failures reported from running test_driver.sh on any test
46+
platform, and checkin with these failures has been OK'd by the gatekeeper,
47+
then copy the lines from the td.*.status files for the failed tests to the
48+
appropriate machine below. All failed tests must be justified.
49+
50+
derecho/intel/aux_cam: all BFB except:
51+
ERP_Ln9.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s (Overall: FAIL) details:
52+
SMS_Ld1.f09_f09_mg17.FCHIST_GC.derecho_intel.cam-outfrq1d (Overall: DIFF) details:
53+
- pre-existing failures due to HEMCO not having reproducible results (issues #1018 and #856)
54+
55+
SMS_Lh12.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq3h (Overall: DIFF) details:
56+
- pre-existing failures due to HEMCO not having reproducible results (issues #1018 and #856)
57+
This test actually passed this time around, but intermittently does not pass, so keeping in the list
58+
59+
SMS_D_Ln9_P1280x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.derecho_intel.cam-outfrq9s (Overall: FAIL) details:
60+
- pre-existing failures due to build-namelist error requiring CLM/CTSM external update
61+
62+
derecho/nvhpc/aux_cam:
63+
ERS_Ln9.ne30pg3_ne30pg3_mg17.F2000dev.derecho_nvhpc.cam-outfrq9s_gpu_default (Overall: FAIL) details:
64+
FAIL ERS_Ln9.ne30pg3_ne30pg3_mg17.F2000dev.derecho_nvhpc.cam-outfrq9s_gpu_default RUN time=19
65+
- This job fails, but does not appear to be due to changes in the code. Both a run made using
66+
the head of cam_development and a job run using cam6_4_079 failed in the same way.
67+
No issue has been opened yet as we expect this might be a temporary machine problem
68+
69+
izumi/nag/aux_cam: all BFB
70+
71+
izumi/gnu/aux_cam: all BFB
72+
73+
===============================================================
174
===============================================================
275

376
Tag name: cam6_4_082

src/atmos_phys

Submodule atmos_phys updated 27 files

src/physics/cam/physics_types.F90

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,9 +1206,11 @@ end subroutine physics_cnst_limit
12061206

12071207
!===============================================================================
12081208
subroutine physics_dme_adjust(state, tend, qini, liqini, iceini, dt)
1209-
use air_composition, only: dry_air_species_num,thermodynamic_active_species_num
1210-
use air_composition, only: thermodynamic_active_species_idx
1211-
use dycore, only: dycore_is
1209+
use air_composition, only: dry_air_species_num,thermodynamic_active_species_num
1210+
use air_composition, only: thermodynamic_active_species_idx
1211+
use dycore, only: dycore_is
1212+
use dme_adjust, only: dme_adjust_run
1213+
use ccpp_constituent_prop_mod, only: ccpp_const_props
12121214
!-----------------------------------------------------------------------
12131215
!
12141216
! Purpose: Adjust the dry mass in each layer back to the value of physics input state
@@ -1259,6 +1261,12 @@ subroutine physics_dme_adjust(state, tend, qini, liqini, iceini, dt)
12591261

12601262
real(r8),allocatable :: cpairv_loc(:,:)
12611263
integer :: m_cnst
1264+
1265+
logical :: is_dycore_moist
1266+
1267+
character(len=512) :: errmsg
1268+
integer :: errflg
1269+
12621270
!
12631271
!-----------------------------------------------------------------------
12641272

@@ -1269,19 +1277,19 @@ subroutine physics_dme_adjust(state, tend, qini, liqini, iceini, dt)
12691277
lchnk = state%lchnk
12701278
ncol = state%ncol
12711279

1272-
! adjust dry mass in each layer back to input value, while conserving
1273-
! constituents, momentum, and total energy
1274-
state%ps(:ncol) = state%pint(:ncol,1)
1275-
12761280
!
12771281
! original code for backwards compatability with FV
12781282
!
12791283
if (.not.(dycore_is('MPAS') .or. dycore_is('SE'))) then
12801284
do k = 1, pver
1281-
1285+
1286+
! adjust dry mass in each layer back to input value, while conserving
1287+
! constituents, momentum, and total energy
1288+
state%ps(:ncol) = state%pint(:ncol,1)
1289+
12821290
! adjusment factor is just change in water vapor
12831291
fdq(:ncol) = 1._r8 + state%q(:ncol,k,1) - qini(:ncol,k)
1284-
1292+
12851293
! adjust constituents to conserve mass in each layer
12861294
do m = 1, pcnst
12871295
state%q(:ncol,k,m) = state%q(:ncol,k,m) / fdq(:ncol)
@@ -1294,26 +1302,14 @@ subroutine physics_dme_adjust(state, tend, qini, liqini, iceini, dt)
12941302
state%rpdel (:ncol,k ) = 1._r8/ state%pdel(:ncol,k )
12951303
end do
12961304
else
1297-
do k = 1, pver
1298-
tot_water(:ncol,1) = qini(:ncol,k) +liqini(:ncol,k)+iceini(:ncol,k) !initial total H2O
1299-
tot_water(:ncol,2) = 0.0_r8
1300-
do m_cnst=dry_air_species_num+1,thermodynamic_active_species_num
1301-
m = thermodynamic_active_species_idx(m_cnst)
1302-
tot_water(:ncol,2) = tot_water(:ncol,2)+state%q(:ncol,k,m)
1303-
end do
1304-
fdq(:ncol) = 1._r8 + tot_water(:ncol,2) - tot_water(:ncol,1)
1305-
! adjust constituents to conserve mass in each layer
1306-
do m = 1, pcnst
1307-
state%q(:ncol,k,m) = state%q(:ncol,k,m) / fdq(:ncol)
1308-
end do
1309-
! compute new total pressure variables
1310-
state%pdel (:ncol,k ) = state%pdel(:ncol,k ) * fdq(:ncol)
1311-
state%ps(:ncol) = state%ps(:ncol) + state%pdel(:ncol,k)
1312-
state%pint (:ncol,k+1) = state%pint(:ncol,k ) + state%pdel(:ncol,k)
1313-
state%lnpint(:ncol,k+1) = log(state%pint(:ncol,k+1))
1314-
state%rpdel (:ncol,k ) = 1._r8/ state%pdel(:ncol,k )
1315-
!note that mid-level variables (e.g. pmid) are not recomputed
1316-
end do
1305+
is_dycore_moist = .true.
1306+
call dme_adjust_run (state%ncol, pver, pcnst, state%ps(:ncol), state%pint(:ncol,:), state%pdel(:ncol,:), &
1307+
state%lnpint(:ncol,:), state%rpdel(:ncol,:), &
1308+
ccpp_const_props, state%q(:ncol,:,:), qini(:ncol,:), liqini(:ncol,:), iceini(:ncol,:), &
1309+
is_dycore_moist, errmsg, errflg)
1310+
if (errflg /= 0) then
1311+
call endrun('physics_dme_adjust: '//errmsg)
1312+
end if
13171313
endif
13181314
if ( waccmx_is('ionosphere') .or. waccmx_is('neutral') ) then
13191315
zvirv(:,:) = shr_const_rwv / rairv(:,:,state%lchnk) - 1._r8

src/physics/cam/physpkg.F90

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,15 @@ subroutine tphysac (ztodt, cam_in, &
19301930
tmp_trac(:ncol,:pver,:pcnst) = state%q(:ncol,:pver,:pcnst)
19311931
tmp_pdel(:ncol,:pver) = state%pdel(:ncol,:pver)
19321932
tmp_ps(:ncol) = state%ps(:ncol)
1933+
if (trim(cam_take_snapshot_before) == "physics_dme_adjust") then
1934+
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
1935+
fh2o, surfric, obklen, flx_heat)
1936+
end if
19331937
call physics_dme_adjust(state, tend, qini, totliqini, toticeini, ztodt)
1938+
if (trim(cam_take_snapshot_after) == "physics_dme_adjust") then
1939+
call cam_snapshot_all_outfld_tphysac(cam_snapshot_after_num, state, tend, cam_in, cam_out, pbuf,&
1940+
fh2o, surfric, obklen, flx_heat)
1941+
end if
19341942
call tot_energy_phys(state, 'phAM')
19351943
call tot_energy_phys(state, 'dyAM', vc=vc_dycore)
19361944
! Restore pre-"physics_dme_adjust" tracers
@@ -1947,7 +1955,7 @@ subroutine tphysac (ztodt, cam_in, &
19471955
call set_dry_to_wet(state, convert_cnst_type='dry')
19481956

19491957
if (trim(cam_take_snapshot_before) == "physics_dme_adjust") then
1950-
call cam_snapshot_all_outfld_tphysac(cam_snapshot_after_num, state, tend, cam_in, cam_out, pbuf,&
1958+
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
19511959
fh2o, surfric, obklen, flx_heat)
19521960
end if
19531961
call physics_dme_adjust(state, tend, qini, totliqini, toticeini, ztodt)

src/physics/cam7/physpkg.F90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,15 @@ subroutine tphysac (ztodt, cam_in, &
23962396
tmp_trac(:ncol,:pver,:pcnst) = state%q(:ncol,:pver,:pcnst)
23972397
tmp_pdel(:ncol,:pver) = state%pdel(:ncol,:pver)
23982398
tmp_ps(:ncol) = state%ps(:ncol)
2399+
if (trim(cam_take_snapshot_before) == "physics_dme_adjust") then
2400+
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
2401+
fh2o, surfric, obklen, flx_heat, cmfmc, dlf, det_s, det_ice, net_flx)
2402+
end if
23992403
call physics_dme_adjust(state, tend, qini, totliqini, toticeini, ztodt)
2404+
if (trim(cam_take_snapshot_after) == "physics_dme_adjust") then
2405+
call cam_snapshot_all_outfld_tphysac(cam_snapshot_after_num, state, tend, cam_in, cam_out, pbuf,&
2406+
fh2o, surfric, obklen, flx_heat, cmfmc, dlf, det_s, det_ice, net_flx)
2407+
end if
24002408
call tot_energy_phys(state, 'phAM')
24012409
call tot_energy_phys(state, 'dyAM', vc=vc_dycore)
24022410
! Restore pre-"physics_dme_adjust" tracers

0 commit comments

Comments
 (0)