From f52b712bfc5868a018323a12ea7bce24db0ddecb Mon Sep 17 00:00:00 2001 From: Kuan-Chih Wang Date: Fri, 29 Dec 2023 15:36:46 -0700 Subject: [PATCH 1/5] Sparse checkout MPAS code from upstream repository --- Externals_CAM.cfg | 8 ++++++++ src/dynamics/mpas/.mpas_sparse_checkout | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 src/dynamics/mpas/.mpas_sparse_checkout diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 60154f2b..f179217c 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -5,6 +5,14 @@ repo_url = https://github.com/peverwhee/ccpp-framework tag = CPF_0.2.050 required = True +[mpas] +local_path = src/dynamics/mpas/dycore +protocol = git +repo_url = https://github.com/MPAS-Dev/MPAS-Model.git +sparse = ../.mpas_sparse_checkout +tag = v8.0.1 +required = True + [ncar-physics] local_path = src/physics/ncar_ccpp protocol = git diff --git a/src/dynamics/mpas/.mpas_sparse_checkout b/src/dynamics/mpas/.mpas_sparse_checkout new file mode 100644 index 00000000..e9e22096 --- /dev/null +++ b/src/dynamics/mpas/.mpas_sparse_checkout @@ -0,0 +1,7 @@ +/src/core_atmosphere +/src/driver +/src/external +/src/framework +/src/operators +/src/tools +/src/Makefile From 07942101cd95784a2adcc55e78e6d73cd689d276 Mon Sep 17 00:00:00 2001 From: Kuan-Chih Wang Date: Fri, 29 Dec 2023 15:41:06 -0700 Subject: [PATCH 2/5] Update .gitignore to ignore MPAS code from upstream repository --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d88504dd..c9d328de 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ share libraries components manage_externals.log +src/dynamics/mpas/dycore src/physics/carma/base src/physics/clubb src/physics/cosp2/src From 1a0fc315770cd87f63bded8c9df5582ad6445b50 Mon Sep 17 00:00:00 2001 From: Kuan-Chih Wang Date: Fri, 29 Dec 2023 16:17:54 -0700 Subject: [PATCH 3/5] Sort entries in .gitignore --- .gitignore | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c9d328de..a3997f2a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,10 @@ ccpp_framework ccs_config chem_proc cime -share -libraries components +libraries manage_externals.log +share src/dynamics/mpas/dycore src/physics/carma/base src/physics/clubb @@ -15,18 +15,17 @@ src/physics/ncar_ccpp src/physics/silhs src/utils/history_output - # Ignore compiled python -buildnmlc *.pyc +buildnmlc # Ignore test output -test/unit/tmp test/include/*.mod test/include/*.o +test/unit/tmp # Ignore editor temporaries and backups +*.swp *~ .#* \#*# -*.swp From 13a466daa7d4c3dfb03215f9165c0ae49798063a Mon Sep 17 00:00:00 2001 From: Kuan-Chih Wang Date: Fri, 29 Dec 2023 16:56:08 -0700 Subject: [PATCH 4/5] Add stub interface for MPAS dynamical core The APIs between CAM-SIMA control and dynamical core have changed from CAM. This stub interface currently does nothing, but it provides a fresh start from scratch for actual functionalities to be incrementally implemented later. --- src/dynamics/mpas/dyn_comp.F90 | 42 +++++++++++++++++++++++ src/dynamics/mpas/dyn_grid.F90 | 13 +++++++ src/dynamics/mpas/stepon.F90 | 62 ++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 src/dynamics/mpas/dyn_comp.F90 create mode 100644 src/dynamics/mpas/dyn_grid.F90 create mode 100644 src/dynamics/mpas/stepon.F90 diff --git a/src/dynamics/mpas/dyn_comp.F90 b/src/dynamics/mpas/dyn_comp.F90 new file mode 100644 index 00000000..b9443d9a --- /dev/null +++ b/src/dynamics/mpas/dyn_comp.F90 @@ -0,0 +1,42 @@ +module dyn_comp + use runtime_obj, only: runtime_options + + implicit none + + private + ! Provide APIs required by CAM Control. + public :: dyn_import_t + public :: dyn_export_t + public :: dyn_readnl + public :: dyn_init + ! public :: dyn_run + ! public :: dyn_final + + type dyn_import_t + end type dyn_import_t + + type dyn_export_t + end type dyn_export_t +contains + +! Called by `read_namelist` in `src/control/runtime_opts.F90`. +subroutine dyn_readnl(namelist_path) + character(*), intent(in) :: namelist_path +end subroutine dyn_readnl + +! Called by `cam_init` in `src/control/cam_comp.F90`. +subroutine dyn_init(cam_runtime_opts, dyn_in, dyn_out) + type(runtime_options), intent(in) :: cam_runtime_opts + type(dyn_import_t), intent(out) :: dyn_in + type(dyn_export_t), intent(out) :: dyn_out +end subroutine dyn_init + +! Not used for now. Intended to be called by `stepon_run*` in `src/dynamics/mpas/stepon.F90`. +! subroutine dyn_run() +! end subroutine dyn_run + +! Not used for now. Intended to be called by `stepon_final` in `src/dynamics/mpas/stepon.F90`. +! subroutine dyn_final() +! end subroutine dyn_final + +end module dyn_comp diff --git a/src/dynamics/mpas/dyn_grid.F90 b/src/dynamics/mpas/dyn_grid.F90 new file mode 100644 index 00000000..5b2c77bc --- /dev/null +++ b/src/dynamics/mpas/dyn_grid.F90 @@ -0,0 +1,13 @@ +module dyn_grid + implicit none + + private + ! Provide APIs required by CAM Control. + public :: model_grid_init +contains + +! Called by `cam_init` in `src/control/cam_comp.F90`. +subroutine model_grid_init() +end subroutine model_grid_init + +end module dyn_grid diff --git a/src/dynamics/mpas/stepon.F90 b/src/dynamics/mpas/stepon.F90 new file mode 100644 index 00000000..49784c5e --- /dev/null +++ b/src/dynamics/mpas/stepon.F90 @@ -0,0 +1,62 @@ +module stepon + use camsrfexch, only: cam_out_t + use dyn_comp, only: dyn_import_t, dyn_export_t + use physics_types, only: physics_state, physics_tend + use runtime_obj, only: runtime_options + use shr_kind_mod, only: r8 => shr_kind_r8 + + implicit none + + private + ! Provide APIs required by CAM Control. + public :: stepon_init + public :: stepon_run1 + public :: stepon_run2 + public :: stepon_run3 + public :: stepon_final +contains + +! Called by `cam_init` in `src/control/cam_comp.F90`. +subroutine stepon_init(cam_runtime_opts, dyn_in, dyn_out) + type(runtime_options), intent(in) :: cam_runtime_opts + type(dyn_import_t), intent(in) :: dyn_in + type(dyn_export_t), intent(in) :: dyn_out +end subroutine stepon_init + +! Called by `cam_run1` in `src/control/cam_comp.F90`. +subroutine stepon_run1(dtime_phys, cam_runtime_opts, phys_state, phys_tend, dyn_in, dyn_out) + real(r8), intent(out) :: dtime_phys + type(runtime_options), intent(in) :: cam_runtime_opts + type(physics_state), intent(inout) :: phys_state + type(physics_tend), intent(inout) :: phys_tend + type(dyn_import_t), intent(inout) :: dyn_in + type(dyn_export_t), intent(inout) :: dyn_out +end subroutine stepon_run1 + +! Called by `cam_run2` in `src/control/cam_comp.F90`. +subroutine stepon_run2(cam_runtime_opts, phys_state, phys_tend, dyn_in, dyn_out) + type(runtime_options), intent(in) :: cam_runtime_opts + type(physics_state), intent(inout) :: phys_state + type(physics_tend), intent(inout) :: phys_tend + type(dyn_import_t), intent(inout) :: dyn_in + type(dyn_export_t), intent(inout) :: dyn_out +end subroutine stepon_run2 + +! Called by `cam_run3` in `src/control/cam_comp.F90`. +subroutine stepon_run3(dtime_phys, cam_runtime_opts, cam_out, phys_state, dyn_in, dyn_out) + real(r8), intent(in) :: dtime_phys + type(runtime_options), intent(in) :: cam_runtime_opts + type(cam_out_t), intent(inout) :: cam_out + type(physics_state), intent(inout) :: phys_state + type(dyn_import_t), intent(inout) :: dyn_in + type(dyn_export_t), intent(inout) :: dyn_out +end subroutine stepon_run3 + +! Called by `cam_final` in `src/control/cam_comp.F90`. +subroutine stepon_final(cam_runtime_opts, dyn_in, dyn_out) + type(runtime_options), intent(in) :: cam_runtime_opts + type(dyn_import_t), intent(inout) :: dyn_in + type(dyn_export_t), intent(inout) :: dyn_out +end subroutine stepon_final + +end module stepon From 5e1343f1c16ab6cc250448acf33f26ad5113306f Mon Sep 17 00:00:00 2001 From: Kuan-Chih Wang Date: Fri, 29 Dec 2023 18:21:15 -0700 Subject: [PATCH 5/5] Include path to stub interface for building Also correct typos. --- cime_config/cam_config.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cime_config/cam_config.py b/cime_config/cam_config.py index 8b35faa8..2e2458f1 100644 --- a/cime_config/cam_config.py +++ b/cime_config/cam_config.py @@ -310,7 +310,7 @@ def __init__(self, case, case_log): "src/dynamics, with a slash ('/') indicating directory hierarchy."] - #Determine dynmaical core and grid-matching regex to use for validation: + #Determine dynamical core and grid-matching regex to use for validation: dycore, grid_regex = get_atm_hgrid(atm_grid) #Add dynamical core to config object: @@ -370,6 +370,11 @@ def __init__(self, case, case_log): self.create_config("trm", trm_desc, 1, (1, None)) self.create_config("trn", trn_desc, 1, (1, None)) self.create_config("trk", trk_desc, 1, (1, None)) + elif dycore == "mpas": + # This only includes the driver and interface code between CAM-SIMA and MPAS dynamical core. + # 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") elif dycore == "none": # Source code directories self.create_config("dyn_src_dirs", dyn_dirs_desc, ["none"], @@ -865,7 +870,7 @@ def generate_cam_src(self, gen_fort_indent): capgen_db, ic_names) #Add registry path to config object: - init_dir_desc = "Location of auto-generated physics initilazation code." + init_dir_desc = "Location of auto-generated physics initialization code." self.create_config("init_dir", init_dir_desc, init_dir) #--------------------------------------------------------------