Skip to content

Commit 103c35b

Browse files
committed
Merge branch 'development' into develop/mpas-dycore-bounded-mid-pres
2 parents e83210f + e252454 commit 103c35b

24 files changed

+445
-520
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[submodule "ccpp-framework"]
22
path = ccpp_framework
33
url = https://github.com/NCAR/ccpp-framework
4-
fxtag = 2025-01-06-dev
4+
fxtag = 2025-06-03-dev
55
fxrequired = AlwaysRequired
66
fxDONOTUSEurl = https://github.com/NCAR/ccpp-framework
77
[submodule "history"]
@@ -14,13 +14,13 @@
1414
path = src/dynamics/mpas/dycore
1515
url = https://github.com/MPAS-Dev/MPAS-Model.git
1616
fxsparse = ../.mpas_sparse_checkout
17-
fxtag = v8.2.1
17+
fxtag = v8.3.1
1818
fxrequired = AlwaysRequired
1919
fxDONOTUSEurl = https://github.com/MPAS-Dev/MPAS-Model.git
2020
[submodule "ncar-physics"]
2121
path = src/physics/ncar_ccpp
2222
url = https://github.com/ESCOMP/atmospheric_physics
23-
fxtag = bb7c61028c1d6ead2c09b2c58cfbbfb3c3638a51
23+
fxtag = 2b66267fe263d9268effeaa1d47e3c03e6121d74
2424
fxrequired = AlwaysRequired
2525
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
2626
[submodule "rrtmgp-data"]

ccpp_framework

Submodule ccpp_framework updated 96 files

cime_config/atm_musica_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
MUSICA_CCPP_SCHEME_NAME = "musica_ccpp"
77
MUSICA_CONFIG_DIR_NAME = "musica_configurations"
88
MUSICA_REPO_URL = "https://github.com/NCAR/musica.git"
9-
MUSICA_TAG = "cc39bb00d2220fc81c85b22d3ceea4a39bd2bacf"
9+
MUSICA_TAG = "25fff7ae42d146bf3f83ad5ac18b3caac8701ddd"
1010
CHEMISTRY_DATA_REPO_URL = "https://github.com/NCAR/cam-sima-chemistry-data.git"
1111
CHEMISTRY_DATA_TAG = "71ed143c54b0d5d6e3e70f3d05d413fddcf8d59e"

cime_config/buildlib

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ from CIME.buildlib import parse_input
3232
from CIME.build import get_standard_makefile_args
3333
from CIME.Tools.standard_script_setup import check_minimum_python_version
3434
from CIME.locked_files import lock_file, unlock_file
35+
from CIME.XML.env_build import EnvBuild
3536
#pylint: enable=wrong-import-position
3637

3738
check_minimum_python_version(3, 7) #CAM requires version 3.7 or greater
@@ -180,7 +181,7 @@ def _build_cam():
180181
musica_install_path = _build_musica(caseroot)
181182

182183
cam_linked_libs = case.get_value("CAM_LINKED_LIBS")
183-
musica_libs = "-lmusica-fortran -lmusica -lyaml-cpp"
184+
musica_libs = _get_musica_libs(caseroot)
184185
if not musica_libs in cam_linked_libs:
185186
_set_musica_lib_path(musica_install_path, caseroot)
186187

@@ -249,6 +250,60 @@ def _copy2_as_needed(src: str, dst: str) -> None:
249250
# Example scenario: User added some new source code files.
250251
shutil.copy2(src, dst)
251252

253+
###############################################################################
254+
def _cmake_default_args(caseroot):
255+
###############################################################################
256+
# Returns a dictionary of CMake variables based on the Macros.cmake file for
257+
# the build.
258+
259+
build = EnvBuild(case_root=caseroot)
260+
with Case(caseroot) as case:
261+
macro_path = os.path.abspath(os.path.join(caseroot, "cmake_macros", ""))
262+
args = "-DCONVERT_TO_MAKE=ON "
263+
args += f"-DCASEROOT={caseroot} "
264+
args += f"-DCOMPILER={build.get_value('COMPILER')} "
265+
args += f"-DOS={build.get_value('OS')} "
266+
args += f"-DMACH={case.get_value('MACH')} "
267+
args += "-DCMAKE_C_COMPILER_WORKS=1 "
268+
args += "-DCMAKE_Fortran_COMPILER_WORKS=1 "
269+
args += "-DCMAKE_CXX_COMPILER_WORKS=1 "
270+
args += f"-DDEBUG={build.get_value('DEBUG')} "
271+
cmd = f"cmake {args} ."
272+
rc, out, err = run_cmd(cmd, combine_output=True, from_dir=macro_path)
273+
expect(rc == 0, "Command {} failed with rc={} out={} err={}".format(cmd, rc, out, err))
274+
275+
arg_dict = {}
276+
for line in out.splitlines():
277+
if ":=" in line:
278+
key, val = line.split(":=")
279+
arg_dict[key.replace('CIME_SET_MAKEFILE_VAR','').strip()] = val.strip()
280+
281+
return arg_dict
282+
283+
###############################################################################
284+
def _get_musica_libs(caseroot: str) -> str:
285+
###############################################################################
286+
"""
287+
Returns the MUSICA libraries to be linked to CAM.
288+
289+
Args:
290+
caseroot: CASEROOT where the xmlchange command is located
291+
292+
Raises:
293+
Exception: If the subprocess for the xmlquery command fails,
294+
an exception is raised with the error message.
295+
296+
Returns:
297+
musica_libs: MUSICA libraries to be linked to CAM
298+
"""
299+
build = EnvBuild(case_root=caseroot)
300+
if build.get_value("DEBUG"):
301+
musica_libs = "-lmusica-fortran -lmusica -lmechanism_configuration -lyaml-cppd -lstdc++"
302+
else:
303+
musica_libs = "-lmusica-fortran -lmusica -lmechanism_configuration -lyaml-cpp -lstdc++"
304+
305+
return musica_libs
306+
252307
###############################################################################
253308
def _build_musica(clone_dest: str) -> str:
254309
###############################################################################
@@ -266,19 +321,29 @@ def _build_musica(clone_dest: str) -> str:
266321
musica_install_path: path to the MUSICA installation directory
267322
"""
268323
_clone_and_checkout(MUSICA_REPO_URL, MUSICA_TAG, clone_dest)
324+
build = EnvBuild(case_root=clone_dest)
325+
arg_dict = _cmake_default_args(clone_dest)
269326

270327
bld_path = os.path.join(clone_dest, "musica", "build")
271328
if os.path.exists(bld_path):
272329
shutil.rmtree(bld_path)
273330
os.makedirs(bld_path)
274-
275331
install_dir = "install"
332+
333+
with Case(clone_dest) as case:
334+
if build.get_value("DEBUG"):
335+
cmake_build_type = "Debug"
336+
else:
337+
cmake_build_type = "Release"
338+
276339
command = [
277340
"cmake",
278341
f"-D CMAKE_INSTALL_PREFIX={install_dir}",
279-
"-D CMAKE_BUILD_TYPE=Release",
342+
f"-D CMAKE_BUILD_TYPE={cmake_build_type}",
343+
f"-D CMAKE_Fotran_FLAGS={arg_dict['FFLAGS']}",
280344
"-D MUSICA_ENABLE_TESTS=OFF",
281345
"-D MUSICA_BUILD_FORTRAN_INTERFACE=ON",
346+
"-D MUSICA_SET_MICM_DEFAULT_VECTOR_SIZE=128",
282347
".."
283348
]
284349
try:
@@ -365,14 +430,14 @@ def _set_musica_lib_path(musica_install_path: str, caseroot: str) -> None:
365430
an exception is raised with the error message.
366431
"""
367432

368-
unlock_file("env_build.xml", caseroot)
433+
musica_libs = _get_musica_libs(caseroot)
369434

370435
command = [
371436
"./xmlchange",
372437
"--append",
373438
# The libraries must be on the same line because CIME flags an
374439
# error for multi-character arguments preceded by a single dash
375-
f"CAM_LINKED_LIBS=-L{os.path.join(musica_install_path, 'lib64')} -lmusica-fortran -lmusica -lyaml-cpp"
440+
f"CAM_LINKED_LIBS=-L{os.path.join(musica_install_path, 'lib64')} {musica_libs}"
376441
]
377442
try:
378443
subprocess.run(command, cwd=caseroot, stdout=subprocess.PIPE,
@@ -385,8 +450,6 @@ def _set_musica_lib_path(musica_install_path: str, caseroot: str) -> None:
385450
except OSError as e:
386451
raise OSError("An error occurred while executing the 'xmlchange' command.") from e
387452

388-
lock_file("env_build.xml", caseroot)
389-
390453
###############################################################################
391454
def _clone_and_checkout(repo_url: str, tag_name: str, clone_dest: str) -> None:
392455
###############################################################################

cime_config/testdefs/testlist_cam.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
</machines>
5050
<options>
5151
<option name="wallclock">00:10:00</option>
52-
<option name="comment">Test for Zhang McFarlane physics</option>
52+
<option name="comment">Test for Zhang McFarlane deep convection scheme</option>
5353
</options>
5454
</test>
5555
<test compset="FPHYStest" grid="ne3pg3_ne3pg3_mg37" name="SMS_Ln2" testmods="cam/outfrq_hack_shallow_derecho">
@@ -70,7 +70,15 @@
7070
<option name="comment">Test for dme_adjust scheme</option>
7171
</options>
7272
</test>
73-
73+
<test compset="FPHYStest" grid="ne3pg3_ne3pg3_mg37" name="SMS_Ln2" testmods="cam/outfrq_rk_stratiform_derecho">
74+
<machines>
75+
<machine name="derecho" compiler="gnu" category="aux_sima"/>
76+
</machines>
77+
<options>
78+
<option name="wallclock">00:10:00</option>
79+
<option name="comment">Test for Rasch-Kristjansson microphysics scheme</option>
80+
</options>
81+
</test>
7482

7583
<!-- Derecho dycore tests -->
7684
<test compset="FKESSLER" grid="mpasa480_mpasa480" name="SMS_Ln9" testmods="cam/outfrq_kessler_mpas_derecho">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./xmlchange CAM_CONFIG_OPTS="--dyn none --physics-suites rasch_kristjansson"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
! these are QPC4 snapshots and require custom physical constant definitions.
2+
ncdata = '/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_rasch_kristjansson_rk_stratiform_snapshot_derecho_gnu_before_c20250328.nc'
3+
ncdata_check = '/glade/campaign/cesm/community/amwg/sima_baselines/cam_sima_test_snapshots/cam_ne3pg3_rasch_kristjansson_rk_stratiform_snapshot_derecho_gnu_after_c20250328.nc'
4+
5+
! tolerances for testing
6+
ncdata_check_err = .true.
7+
min_difference = 2e-15
8+
9+
! qpc4
10+
pver = 26
11+
user_defined_cpwv = 1.846e3
12+
user_defined_gravit = 9.79764
13+
user_defined_mwdry = 28.96623324623746
14+
user_defined_mwh2o = 18.01618112892741
15+
user_defined_rearth = 6.37100e6
16+
user_defined_sday = 86164.10063718943
17+
18+
! rk
19+
cldfrc_dp1 = 0.10D0
20+
cldfrc_dp2 = 500.0D0
21+
cldfrc_freeze_dry = .true.
22+
cldfrc_ice = .false.
23+
cldfrc_icecrit = 0.95D0
24+
cldfrc_iceopt = 1
25+
cldfrc_premib = 750.0D2
26+
cldfrc_premit = 75000.0D0
27+
cldfrc_rhminh = 0.800D0
28+
cldfrc_rhminl = 0.910D0
29+
cldfrc_rhminl_adj_land = 0.100D0
30+
cldfrc_sh1 = 0.04D0
31+
cldfrc_sh2 = 500.0D0
32+
33+
! sima only:
34+
cldfrc_inversion_cld_off = .false.
35+
36+
cldsed_ice_stokes_fac = 1.0D0
37+
38+
rk_strat_conke = 5.0e-6
39+
rk_strat_icritc = 18.0e-6
40+
rk_strat_icritw = 2.0e-4
41+
rk_strat_r3lcrit = 10.0e-6
42+
! sima only:
43+
rk_strat_polstrat_dorhmin = .false.
44+
45+
hist_output_frequency;h1: 1*nsteps
46+
hist_max_frames;h1: 1
47+
hist_add_inst_fields;h1:DQSED,DISED,DLSED,HSED,PRECSED,SNOWSED,RAINSED
48+
hist_add_inst_fields;h1:SH_CLD,DP_CLD,CONCLD,AST
49+
hist_add_inst_fields;h1:FICE,REPARTICE,REPARTLIQ,HREPART
50+
hist_add_inst_fields;h1:FWAUT,FSAUT,FRACW,FSACW,FSACI,PCSNOW,CME,CMEICE,CMELIQ
51+
hist_add_inst_fields;h1:ICE2PR,LIQ2PR,HPROGCLD,HEVAP,HMELT,HCME,HFREEZ
52+
hist_add_inst_fields;h1:PRODPREC,EVAPPREC,EVAPSNOW,LS_FLXPRC,LS_FLXSNW,PRACWO,PSACWO,PSACIO
53+
hist_add_inst_fields;h1:CLDLIQSTR,CLDICESTR,CLDLIQCON,CLDICECON
54+
hist_add_inst_fields;h1:IWC,LWC,ICIMR,ICWMR,REI,REL
55+
hist_precision;h1: REAL64

src/control/cam_comp.F90

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &
8686

8787
use cam_initfiles, only: cam_initfiles_open
8888
use dyn_grid, only: model_grid_init
89-
use phys_comp, only: phys_init
89+
use phys_comp, only: phys_init, phys_suite_name
9090
use phys_comp, only: phys_register
9191
use dyn_comp, only: dyn_init
9292
! use cam_restart, only: cam_read_restart
@@ -100,7 +100,6 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &
100100
use air_composition, only: air_composition_init
101101
use cam_ccpp_cap, only: cam_ccpp_initialize_constituents
102102
use cam_ccpp_cap, only: cam_model_const_properties
103-
use cam_ccpp_cap, only: cam_constituents_array
104103
use physics_grid, only: columns_on_task
105104
use vert_coord, only: pver
106105
use phys_vars_init_check, only: mark_as_initialized
@@ -156,7 +155,6 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &
156155
character(len=cx) :: errmsg
157156

158157
type(ccpp_constituent_prop_ptr_t), pointer :: constituent_properties(:)
159-
real(kind_phys), pointer :: constituents_array(:,:,:)
160158
!-----------------------------------------------------------------------
161159

162160
call init_pio_subsystem()
@@ -255,17 +253,14 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &
255253
! Read tropopause climatology
256254
call tropopause_climo_read_file()
257255

258-
! Temporary: Prescribe realistic but inaccurate physical quantities
256+
! TEMPORARY: Prescribe realistic but inaccurate physical quantities
259257
! necessary for MUSICA that are currently unavailable in CAM-SIMA.
260-
! It also initializes the MUSICA constituent values until the file
261-
! I/O object is implemented.
262258
!
263259
! Remove this when MUSICA input data are available from CAM-SIMA or
264260
! other physics schemes.
265261
constituent_properties => cam_model_const_properties()
266-
constituents_array => cam_constituents_array()
267262
call musica_ccpp_dependencies_init(columns_on_task, pver, &
268-
constituent_properties, constituents_array)
263+
constituent_properties, phys_suite_name)
269264

270265
! Initialize orbital data
271266
call orbital_data_init(columns_on_task)
@@ -295,10 +290,15 @@ subroutine cam_timestep_init()
295290
!
296291
!-----------------------------------------------------------------------
297292

298-
use phys_comp, only: phys_timestep_init
299-
use physics_grid, only: lat_rad, lon_rad
300-
use orbital_data, only: orbital_data_advance
301-
use stepon, only: stepon_timestep_init
293+
use phys_comp, only: phys_timestep_init
294+
use physics_grid, only: lat_rad, lon_rad
295+
use orbital_data, only: orbital_data_advance
296+
use stepon, only: stepon_timestep_init
297+
use cam_ccpp_cap, only: cam_constituents_array
298+
use ccpp_kinds, only: kind_phys
299+
use musica_ccpp_dependencies, only: set_initial_musica_concentrations
300+
301+
real(kind_phys), pointer :: constituents_array(:,:,:)
302302

303303
! Update current fractional calendar day. Needs to be updated at every timestep.
304304
calday = get_curr_calday()
@@ -319,6 +319,21 @@ subroutine cam_timestep_init()
319319
call stepon_timestep_init(dtime_phys, cam_runtime_opts, phys_state, phys_tend, &
320320
dyn_in, dyn_out)
321321
call t_stopf('stepon_timestep_init')
322+
323+
!----------------------------------------------------------
324+
! TEMPORARY: Set initial MUSICA constituent values
325+
!
326+
! This is a temporary workaround to initialize
327+
! MUSICA constituent values until the file I/O
328+
! capability is implemented.
329+
! Remove this when MUSICA species are initialized
330+
! by CAM-SIMA.
331+
!----------------------------------------------------------
332+
if (is_first_timestep) then
333+
constituents_array => cam_constituents_array()
334+
call set_initial_musica_concentrations(constituents_array)
335+
end if
336+
322337
!
323338
!----------------------------------------------------------
324339
! PHYS_TIMESTEP_INIT Call the Physics package

src/control/cam_initfiles.F90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ subroutine cam_initfiles_open()
224224
! Open initial dataset
225225

226226
if (initial_run) then
227+
if (trim(ncdata) == 'ncdata' .or. trim(ncdata) == trim(unset_path_str)) then
228+
call endrun(subname//': ERROR: Missing initial dataset. '// &
229+
'Please set "ncdata" in the CAM namelist')
230+
end if
227231
call cam_get_file(ncdata, ncdata_loc)
228232
allocate(fh_ini, stat=iret)
229233
if (iret /= 0) then

0 commit comments

Comments
 (0)