Skip to content

Commit 2f7f432

Browse files
authored
MPAS dycore + Atmosphere Generalization (NOAA-EMC#982)
* Reorganize code for MPAS dycore. Isolate FV3 and MPAS pieces. * Added more build step pieces, up until the MPAS dycore build * MPAS building in UFSATM! Some more reorganization. Initial infrastructure for CCPP. More CMake modifications * Move ccpp/drivers into common directory (revert prioir move) * Move MPAS to ufs-community reporitory * Update CMakeLists in MPAS core.
1 parent c8bb71e commit 2f7f432

40 files changed

Lines changed: 5617 additions & 349 deletions

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
path = upp
1515
url = https://github.com/NOAA-EMC/UPP
1616
branch = develop
17+
[submodule "mpas/MPAS-Model"]
18+
path = mpas/MPAS-Model
19+
url = https://github.com/ufs-community/MPAS-Model.git
20+
branch = feature/mpas-in-ufs

CMakeLists.txt

Lines changed: 108 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ if(BUILD_CI_TESTING)
1818
if (FV3)
1919
project(ufsatm_fv3 VERSION 1.0 LANGUAGES C CXX Fortran)
2020
endif()
21+
if (MPAS)
22+
project(ufsatm_mpas VERSION 1.0 LANGUAGES C CXX Fortran)
23+
endif()
2124
include(ci/CMakeLists.txt)
2225
endif()
2326

2427
# Set variables for all dycore build options in UFSATM.
28+
set(DYCORE_TARGET_MPAS ufsatm_mpas)
2529
set(DYCORE_TARGET_FV3 ufsatm_fv3)
2630

2731
###############################################################################
@@ -56,14 +60,38 @@ if(BUILD_CI_TESTING)
5660
add_subdirectory(tests)
5761
endif()
5862

63+
# Not used yet by MPAS in UFSATM, but needed by ufsatm_cap.F90 to work.
64+
list(APPEND coupling_srcs
65+
cpl/module_block_data.F90
66+
cpl/module_cplfields.F90
67+
cpl/module_cap_cpl.F90
68+
cpl/module_cplscalars.F90)
69+
70+
list(APPEND io_srcs
71+
io/module_write_netcdf.F90
72+
io/module_write_restart_netcdf.F90
73+
io/module_fv3_io_def.F90
74+
io/module_write_internal_state.F90
75+
io/module_wrt_grid_comp.F90)
76+
77+
# Eventually these could be shared by MPAS, and merged with {io_srcs} list.
78+
list(APPEND fv3_io_srcs
79+
io/fv3atm_common_io.F90
80+
io/fv3atm_clm_lake_io.F90
81+
io/fv3atm_rrfs_sd_io.F90
82+
io/fv3atm_sfc_io.F90
83+
io/fv3atm_oro_io.F90
84+
io/fv3atm_history_io.F90
85+
io/fv3atm_restart_io.F90)
86+
5987
###############################################################################
6088
### UFSATM with FV3 dynamical core
6189
###############################################################################
6290
if (FV3)
91+
add_definitions(-DFV3)
6392
set(DYCORE_TARGET ${DYCORE_TARGET_FV3}
6493
CACHE INTERNAL "DYCORE_TARGET Options: fv3atm")
65-
set(DYCORE_TARGET_CAP_MOD fv3atm_cap_mod PARENT_SCOPE)
66-
94+
set(DYCORE_TARGET_CAP_MOD ufsatm_cap_mod PARENT_SCOPE)
6795

6896
# These ifdefs need to be turned ON in the dycore.
6997
set(use_WRTCOMP ON)
@@ -83,7 +111,7 @@ if (FV3)
83111
if(INLINE_POST)
84112
set(BUILD_POSTEXEC OFF)
85113
add_subdirectory(upp)
86-
set(POST_SRC fv3/io/post_nems_routines.F90 fv3/io/post_fv3.F90)
114+
set(POST_SRC io/post_nems_routines.F90 io/post_fv3.F90)
87115
list(APPEND _ufsatm_defs_private INLINE_POST)
88116
endif()
89117

@@ -130,27 +158,15 @@ if (FV3)
130158

131159
# FV3 drivers and dependencies
132160
add_library(${DYCORE_TARGET}
161+
ufsatm_cap.F90
162+
ufsatm_util.F90
133163
fv3/atmos_model.F90
134-
fv3/fv3_cap.F90
135164
fv3/module_fv3_config.F90
136165
fv3/module_fcst_grid_comp.F90
137166
fv3/stochastic_physics/stochastic_physics_wrapper.F90
138-
cpl/module_block_data.F90
139-
cpl/module_cplfields.F90
140-
cpl/module_cap_cpl.F90
141-
cpl/module_cplscalars.F90
142-
fv3/io/fv3atm_common_io.F90
143-
fv3/io/fv3atm_clm_lake_io.F90
144-
fv3/io/fv3atm_rrfs_sd_io.F90
145-
fv3/io/fv3atm_sfc_io.F90
146-
fv3/io/fv3atm_oro_io.F90
147-
fv3/io/fv3atm_history_io.F90
148-
fv3/io/fv3atm_restart_io.F90
149-
fv3/io/module_write_netcdf.F90
150-
fv3/io/module_write_restart_netcdf.F90
151-
fv3/io/module_fv3_io_def.F90
152-
fv3/io/module_write_internal_state.F90
153-
fv3/io/module_wrt_grid_comp.F90
167+
${coupling_srcs}
168+
${fv3_io_srcs}
169+
${io_srcs}
154170
${moving_nest_srcs}
155171
${POST_SRC}
156172
)
@@ -159,8 +175,75 @@ if (FV3)
159175
list(APPEND _ufsatm_defs_private GFS_PHYS
160176
INTERNAL_FILE_NML
161177
use_WRTCOMP)
178+
else()
179+
remove_definitions(-DFV3)
162180
endif()
163181

182+
###############################################################################
183+
### UFSATM with MPAS dynamical core.
184+
###############################################################################
185+
if (MPAS)
186+
add_definitions(-DMPAS)
187+
set(DYCORE_TARGET ${DYCORE_TARGET_MPAS})
188+
189+
# Include MPAS Cmake tools.
190+
include(${CMAKE_CURRENT_SOURCE_DIR}/mpas/MPAS-Model/cmake/Functions/MPAS_Functions.cmake)
191+
192+
# Set any pre-processor directive needed in MPAS dycore.
193+
get_mpas_version(MPAS_VERSION)
194+
set(MPAS_ALL_CORES atmosphere)
195+
set(MPAS_CORES atmosphere CACHE STRING "MPAS cores to build. Options: ${MPAS_ALL_CORES}")
196+
if(MPAS_CORES MATCHES " ") #Convert strings separated with spaces to CMake list separated with ';'
197+
string(REPLACE " " ";" MPAS_CORES ${MPAS_CORES})
198+
set(MPAS_CORES ${MPAS_CORES} CACHE STRING "MPAS cores to build. Options: ${MPAS_ALL_CORES}" FORCE)
199+
endif()
200+
set(MPAS_CAM_DYCORE TRUE)
201+
set(MPAS_USE_PIO TRUE)
202+
add_definitions(-DMPAS_USE_MPI_F08)
203+
add_definitions(-DMPAS_PIO_SUPPORT)
204+
add_definitions(-DMPAS_CAM_DYCORE)
205+
add_definitions(-DMPAS_UFS_DYCORE)
206+
add_definitions(-DSINGLE_PRECISION)
207+
208+
# Source files for MPAS dynamical core drivers.
209+
set(MPAS_MAIN_SRC ${CMAKE_CURRENT_SOURCE_DIR}/mpas/MPAS-Model/src/driver/mpas.F)
210+
set(MPAS_SUBDRIVER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/mpas/MPAS-Model/src/driver/mpas_subdriver.F)
211+
212+
# MPAS dynamical core
213+
add_subdirectory(mpas)
214+
215+
# MPAS drivers and dependencies
216+
add_library(${DYCORE_TARGET}
217+
ufsatm_cap.F90
218+
ufsatm_util.F90
219+
mpas/atmos_model.F90
220+
mpas/module_mpas_config.F90
221+
mpas/module_fcst_grid_comp.F90
222+
mpas/atmos_coupling.F90
223+
mpas/ufs_mpas_subdriver.F90
224+
${coupling_srcs}
225+
${io_srcs}
226+
ccpp/data/MPAS_typedefs.F90
227+
ccpp/driver/MPAS_init.F90
228+
)
229+
add_dependencies(${DYCORE_TARGET} mpas mpasccpp)
230+
231+
if(NOT MPAS_GIT_VERSION)
232+
find_package(Git QUIET)
233+
if(GIT_FOUND)
234+
execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty
235+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/mpas/MPAS-Model"
236+
OUTPUT_VARIABLE _mpas_git_version
237+
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
238+
else()
239+
set(_mpas_git_version "Unknown")
240+
endif()
241+
set(MPAS_GIT_VERSION ${_mpas_git_version} CACHE STRING "MPAS-Model git version")
242+
message(STATUS "Setting MPAS_GIT_VERSION ${_mpas_git_version}")
243+
endif()
244+
else()
245+
remove_definitions(-DMPAS)
246+
endif()
164247

165248
###############################################################################
166249
### Link libraries
@@ -183,7 +266,11 @@ if (FV3)
183266
endif()
184267
endif()
185268

186-
269+
if (MPAS)
270+
target_link_libraries(${DYCORE_TARGET} PUBLIC mpas
271+
mpasccpp
272+
fms)
273+
endif()
187274

188275
# Always include EMC libraries in dycore install
189276
target_link_libraries(${DYCORE_TARGET} PUBLIC w3emc::w3emc_d

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11

2-
# fv3atm
2+
# ufsatm
33

44
This repository contains a driver and key subcomponents of the
55
atmospheric component of the NOAA's [Unified Forecast System
66
(UFS)](https://ufscommunity.org/) weather model.
77

88
The subcomponents include:
99

10-
- The Finite-Volume Cubed-Sphere (FV3) dynamical core, originally
11-
from the [Geophysical Fluid Dynamics
12-
Laboratory](https://www.gfdl.noaa.gov/).
13-
- The Common Community Physics Package (CCPP) supported by the
10+
- The Finite-Volume Cubed-Sphere (FV3) dynamical core, originally
11+
from the [Geophysical Fluid Dynamics Laboratory](https://www.gfdl.noaa.gov/).
12+
13+
- The Model for Prediction Across Scales - Atmosphere (MPAS-A) dynamical
14+
core developed by [NSF-NCAR Mesoscale and Micrometeorology Laboratory (MMM)](https://www.mmm.ucar.edu).
15+
- [MPAS Model](https://github.com/ufs-community/MPAS-Model)
16+
- [MPAS documentation](https://www.mmm.ucar.edu/models/mpas)
17+
18+
- The Common Community Physics Package (CCPP) supported by the
1419
[Developmental Testbed Center
1520
(DTC)](https://dtcenter.org/community-code/common-community-physics-package-ccpp),
1621
including:
1722
- [CCPP Framework](https://github.com/NCAR/ccpp-framework).
1823
- [CCPP Physics](https://github.com/NCAR/ccpp-physics)
19-
- wrapper code to call [UFS stochastic
24+
25+
- wrapper code to call [UFS stochastic
2026
physics](https://stochastic-physics.readthedocs.io/en/latest/)
21-
- The io code handles netCDF I/O.
22-
- The cpl coupler code connects the different components and allows
27+
28+
- The io code handles netCDF I/O.
29+
30+
- The cpl coupler code connects the different components and allows
2331
them to communicate.
2432

2533
## Prerequisites
@@ -41,13 +49,13 @@ This package also requires the following external packages:
4149
- [ESMF](https://github.com/esmf-org/esmf)
4250
- [GFDL's Flexible Modeling System](https://github.com/NOAA-GFDL/FMS)
4351

44-
## Obtaining fv3atm
52+
## Obtaining ufsatm
4553

46-
To obtain fv3atm, clone the git repository, and update the submodules:
54+
To obtain ufsatm, clone the git repository, and update the submodules:
4755

4856
```
49-
git clone https://github.com/NOAA-EMC/fv3atm.git
50-
cd fv3atm
57+
git clone https://github.com/NOAA-EMC/ufsatm.git
58+
cd ufsatm
5159
git submodule update --init --recursive
5260
```
5361

0 commit comments

Comments
 (0)