Skip to content

Commit

Permalink
merge in framework-update branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Courtney Peverley committed Mar 6, 2024
2 parents d8c2d6e + d63b1dc commit 36e5dbf
Show file tree
Hide file tree
Showing 15 changed files with 1,502 additions and 42 deletions.
4 changes: 2 additions & 2 deletions Externals_CAM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
local_path = ccpp_framework
protocol = git
repo_url = https://github.com/peverwhee/ccpp-framework
tag = CPF_0.2.050
tag = CPF_0.2.054
required = True

[mpas]
Expand All @@ -17,7 +17,7 @@ required = True
local_path = src/physics/ncar_ccpp
protocol = git
repo_url = https://github.com/ESCOMP/atmospheric_physics
tag = atmos_phys0_01_000
tag = atmos_phys0_02_002
required = True

[externals_description]
Expand Down
8 changes: 6 additions & 2 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ def _setup_mpas(case: Case) -> None:

shutil.copytree(mpas_dycore_src_root, mpas_dycore_bld_root, copy_function=_copy2_as_needed, dirs_exist_ok=True)
shutil.move(os.path.join(mpas_dycore_bld_root, "Makefile"), os.path.join(mpas_dycore_bld_root, "Makefile.CESM"))
_copy2_as_needed(os.path.normpath(os.path.join(mpas_dycore_src_root, os.pardir, os.pardir, "Makefile")), os.path.join(mpas_dycore_bld_root, "Makefile"))
_copy2_as_needed(os.path.normpath(os.path.join(mpas_dycore_src_root, os.pardir, os.pardir, "Makefile.in.CESM")), os.path.join(mpas_dycore_bld_root, "Makefile.in.CESM"))
_copy2_as_needed(os.path.normpath(os.path.join(mpas_dycore_src_root, os.pardir, os.pardir, "driver", "dyn_mpas_subdriver.F90")), os.path.join(mpas_dycore_bld_root, "driver"))
_copy2_as_needed(os.path.normpath(os.path.join(mpas_dycore_src_root, os.pardir, os.pardir, "Makefile")), mpas_dycore_bld_root)
_copy2_as_needed(os.path.normpath(os.path.join(mpas_dycore_src_root, os.pardir, os.pardir, "Makefile.in.CESM")), mpas_dycore_bld_root)

def _copy2_as_needed(src: str, dst: str) -> None:
"""
Expand All @@ -199,6 +200,9 @@ def _copy2_as_needed(src: str, dst: str) -> None:
# `src` and `dst` are both files but their modification time or size differ.
# Example scenario: User modified some existing source code files.
shutil.copy2(src, dst)
elif os.path.isdir(dst) and os.path.isfile(os.path.join(dst, os.path.basename(src))):
dst = os.path.join(dst, os.path.basename(src))
_copy2_as_needed(src, dst)
else:
if os.path.isdir(dst) or os.path.isdir(os.path.dirname(dst)):
# `src` is a new file that does not exist at `dst`.
Expand Down
4 changes: 4 additions & 0 deletions cime_config/cam_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ def __init__(self, case, case_log):
# MPAS dynamical core relies on its upstream build infrastructure for compilation instead of CIME to take advantage of future upstream changes automatically.
self.create_config("dyn_src_dirs", dyn_dirs_desc, ["mpas"],
valid_list_type="str")

# Add XML namelist definition file for MPAS dynamical core.
mpas_dyn_nml_path = os.path.normpath(os.path.join(cime_conf_path, os.pardir, "src", "dynamics", "mpas"))
self._add_xml_nml_file(mpas_dyn_nml_path, "namelist_definition_mpas_dycore.xml")
elif dycore == "none":
# Source code directories
self.create_config("dyn_src_dirs", dyn_dirs_desc, ["none"],
Expand Down
3 changes: 2 additions & 1 deletion src/control/cam_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ subroutine cam_register_constituents(cam_runtime_opts)
integer :: errflg
character(len=512) :: errmsg
type(ccpp_constituent_prop_ptr_t), pointer :: const_props(:)
type(ccpp_constituent_properties_t), allocatable, target :: dynamic_constituents(:)
character(len=*), parameter :: subname = 'cam_register_constituents: '

! Initalize error flag and message:
Expand Down Expand Up @@ -614,7 +615,7 @@ subroutine cam_register_constituents(cam_runtime_opts)
!Combine host and physics constituents into a single
!constituents object:
call cam_ccpp_register_constituents(cam_runtime_opts%suite_as_list(), &
host_constituents, errcode=errflg, errmsg=errmsg)
host_constituents, dynamic_constituents, errcode=errflg, errmsg=errmsg)

if (errflg /= 0) then
call endrun(subname//trim(errmsg), file=__FILE__, line=__LINE__)
Expand Down
2 changes: 1 addition & 1 deletion src/data/physconst.meta
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
dimensions = ()
protected = True
[ pref ]
standard_name = reference_pressure
standard_name = surface_reference_pressure
units = Pa
type = real | kind = kind_phys
dimensions = ()
Expand Down
2 changes: 1 addition & 1 deletion src/data/ref_pres.F90
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ subroutine ref_pres_init(pref_edge_in, pref_mid_in, num_pr_lev_in)
! pref_mid_in
call mark_as_initialized("reference_pressure_in_atmosphere_layer")
! pref_mid_norm
call mark_as_initialized("reference_pressure_in_atmosphere_layer_normalized_by_reference_pressure")
call mark_as_initialized("reference_pressure_in_atmosphere_layer_normalized_by_surface_reference_pressure")
! ptop_ref
call mark_as_initialized("air_pressure_at_top_of_atmosphere_model")
! num_pr_lev
Expand Down
2 changes: 1 addition & 1 deletion src/data/ref_pres.meta
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
dimensions = (vertical_layer_dimension)
protected = True
[ pref_mid_norm ]
standard_name = reference_pressure_in_atmosphere_layer_normalized_by_reference_pressure
standard_name = reference_pressure_in_atmosphere_layer_normalized_by_surface_reference_pressure
units = 1
type = real | kind = kind_phys
dimensions = (vertical_layer_dimension)
Expand Down
10 changes: 5 additions & 5 deletions src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
</variable>
<variable local_name="rpdel"
standard_name="reciprocal_of_air_pressure_thickness"
units="Pa" type="real" kind="kind_phys"
units="Pa-1" type="real" kind="kind_phys"
allocatable="pointer">
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
<ic_file_input_names>rpdel state_rpdel</ic_file_input_names>
Expand Down Expand Up @@ -260,7 +260,7 @@
<ic_file_input_names>dvdt tend_dvdt</ic_file_input_names>
</variable>
<variable local_name="lagrangian_vertical"
standard_name="lagrangian_vertical_coordinate"
standard_name="do_lagrangian_vertical_coordinate"
units="flag" type="logical" access="protected">
<long_name>flag indicating if vertical coordinate is lagrangian</long_name>
<initial_value>.false.</initial_value>
Expand Down Expand Up @@ -334,13 +334,13 @@
</variable>
<variable local_name="errcode"
standard_name="ccpp_error_code"
units="flag" type="integer">
units="1" type="integer">
<long_name>ccpp error code</long_name>
<initial_value>0</initial_value>
</variable>
<variable local_name="errmsg"
standard_name="ccpp_error_message"
units="1" type="character" kind="len=512">
units="none" type="character" kind="len=512">
<long_name>ccpp error message</long_name>
<initial_value>''</initial_value>
</variable>
Expand Down Expand Up @@ -379,7 +379,7 @@
</variable>
<variable local_name="zvirv"
standard_name="ratio_of_water_vapor_gas_constant_to_composition_dependent_dry_air_gas_constant_minus_one"
units="J kg-1 K-1" type="real" kind="kind_phys"
units="1" type="real" kind="kind_phys"
allocatable="allocatable">
<long_name>Composition-dependent ratio of water vapor to dry air gas constants minus one</long_name>
<dimensions>horizontal_dimension vertical_layer_dimension</dimensions>
Expand Down
34 changes: 25 additions & 9 deletions src/dynamics/mpas/Makefile.in.CESM
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ endif
#

export CP = cp -afv
export LN = ln -fsv
export MKDIR = mkdir -pv
export RM = rm -frv

Expand Down Expand Up @@ -61,22 +62,29 @@ all:
@echo ' `make libmpas-clean ESM="CESM" LIBROOT="..."`'

.PHONY: libmpas-prepare
libmpas-prepare: libmpas-archiver-script.txt libmpas-no-physics libmpas-preview
libmpas-prepare: libmpas-archiver-script.txt libmpas-no-physics libmpas-prefix-namelist-groups libmpas-preview

# Combine multiple static libraries into `libmpas.a` via archiver/MRI script. This requires GNU or GNU-like archiver (`ar`) program.
libmpas-archiver-script.txt:
@echo "create libmpas.a" > $(@)
@echo "addlib libdycore.a" >> $(@)
@echo "addlib libframework.a" >> $(@)
@echo "addlib libops.a" >> $(@)
@echo "save" >> $(@)
@echo "end" >> $(@)
@echo "create libmpas.a" > $(@)
@echo "addlib libdycore.a" >> $(@)
@echo "addlib libframework.a" >> $(@)
@echo "addlib libops.a" >> $(@)
@echo "addmod dyn_mpas_subdriver.o" >> $(@)
@echo "save" >> $(@)
@echo "end" >> $(@)

# Do not use built-in MPAS/WRF physics.
.PHONY: libmpas-no-physics
libmpas-no-physics:
@sed -E -i -e "s/^ *PHYSICS=.+$$/PHYSICS=/g" core_atmosphere/Makefile

# Prefix `mpas_` to MPAS namelist groups to avoid naming collisions.
.PHONY: libmpas-prefix-namelist-groups
libmpas-prefix-namelist-groups:
@sed -E -i -e "s/(^ *< *nml_record.+name=)\"(mpas_)?(\w+)\"/\1\"mpas_\3\"/g" core_atmosphere/Registry.xml
@sed -E -i -e "s/(^ *< *nml_record.+name=)\"(mpas_)?(\w+)\"/\1\"mpas_\3\"/g" core_atmosphere/diagnostics/Registry_*.xml

.PHONY: libmpas-preview
libmpas-preview:
@echo "Previewing build options for $(LIBROOT)/libmpas.a:"
Expand Down Expand Up @@ -106,13 +114,21 @@ $(LIBROOT)/libmpas.a: libmpas.a
$(MKDIR) $(LIBROOT)
$(CP) $(<) $(@)

libmpas.a: $(AUTOCLEAN_DEPS) dycore externals frame ops
libmpas.a: $(AUTOCLEAN_DEPS) dycore externals frame ops subdrv
$(AR) $(ARFLAGS) < libmpas-archiver-script.txt
@find -P . -name "*.mod" -type f -exec $(LN) "{}" . ";"

.PHONY: libmpas-clean
libmpas-clean: clean
$(RM) $(LIBROOT)/libmpas.a libmpas.a
$(RM) $(LIBROOT)/libmpas.a libmpas.a *.mod *.o

.PHONY: externals
externals: $(AUTOCLEAN_DEPS)
( cd external; $(MAKE) FC="$(FC)" SFC="$(SFC)" CC="$(CC)" SCC="$(SCC)" FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" NETCDF="$(NETCDF)" CORE="$(CORE)" ezxml-lib )

.PHONY: subdrv
subdrv: driver/dyn_mpas_subdriver.o

%.o: %.F90 dycore frame ops
( cd $(<D); $(FC) $(CPPFLAGS) $(FFLAGS) -c $(<F) $(CPPINCLUDES) $(FCINCLUDES) -I../framework -I../operators -I../core_$(CORE) )
$(LN) $(@) .
Loading

0 comments on commit 36e5dbf

Please sign in to comment.