Skip to content

Commit ee9db83

Browse files
Add support for cmake build system. (#11)
1 parent bc4aeab commit ee9db83

File tree

9 files changed

+620
-0
lines changed

9 files changed

+620
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.o
22
*.mod
33
*.a
4+
*.pyc

CMakeLists.txt

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
if( NOT DEFINED PHYS)
2+
set(PHYS gfs)
3+
endif()
4+
5+
if (PHYS MATCHES "nam")
6+
add_definitions(-DNAM_phys)
7+
endif()
8+
9+
if(CCPP)
10+
add_definitions(-DCCPP)
11+
if(STATIC)
12+
add_definitions(-DSTATIC)
13+
endif()
14+
endif()
15+
16+
add_subdirectory(cpl)
17+
add_subdirectory(${PHYS}physics)
18+
add_subdirectory(ipd)
19+
add_subdirectory(io)
20+
21+
# fv3core library
22+
23+
if(NOT CCPP)
24+
set(FAST_PHYSICS_SRCS_F90 atmos_cubed_sphere/model/fv_cmp.F90)
25+
endif()
26+
27+
add_library(
28+
fv3core
29+
30+
atmos_cubed_sphere/model/a2b_edge.F90
31+
atmos_cubed_sphere/model/multi_gases.F90
32+
atmos_cubed_sphere/model/boundary.F90
33+
atmos_cubed_sphere/model/dyn_core.F90
34+
atmos_cubed_sphere/model/fv_arrays.F90
35+
${FAST_PHYSICS_SRCS_F90}
36+
atmos_cubed_sphere/model/fv_control.F90
37+
atmos_cubed_sphere/model/fv_dynamics.F90
38+
atmos_cubed_sphere/model/fv_fill.F90
39+
atmos_cubed_sphere/model/fv_grid_utils.F90
40+
atmos_cubed_sphere/model/fv_mapz.F90
41+
atmos_cubed_sphere/model/fv_nesting.F90
42+
atmos_cubed_sphere/model/fv_regional_bc.F90
43+
atmos_cubed_sphere/model/fv_sg.F90
44+
atmos_cubed_sphere/model/fv_tracer2d.F90
45+
atmos_cubed_sphere/model/fv_update_phys.F90
46+
atmos_cubed_sphere/model/sw_core.F90
47+
atmos_cubed_sphere/model/tp_core.F90
48+
atmos_cubed_sphere/model/nh_core.F90
49+
atmos_cubed_sphere/model/nh_utils.F90
50+
atmos_cubed_sphere/tools/external_ic.F90
51+
atmos_cubed_sphere/tools/external_sst.F90
52+
atmos_cubed_sphere/tools/fv_diagnostics.F90
53+
atmos_cubed_sphere/tools/fv_eta.F90
54+
atmos_cubed_sphere/tools/fv_grid_tools.F90
55+
atmos_cubed_sphere/tools/fv_io.F90
56+
atmos_cubed_sphere/tools/fv_mp_mod.F90
57+
atmos_cubed_sphere/tools/fv_nudge.F90
58+
atmos_cubed_sphere/tools/fv_treat_da_inc.F90
59+
atmos_cubed_sphere/tools/fv_iau_mod.F90
60+
atmos_cubed_sphere/tools/fv_restart.F90
61+
atmos_cubed_sphere/tools/fv_surf_map.F90
62+
atmos_cubed_sphere/tools/fv_timing.F90
63+
atmos_cubed_sphere//tools/init_hydro.F90
64+
atmos_cubed_sphere/tools/sim_nc_mod.F90
65+
atmos_cubed_sphere/tools/sorted_index.F90
66+
atmos_cubed_sphere/tools/test_cases.F90
67+
atmos_cubed_sphere/driver/fvGFS/DYCORE_typedefs.F90
68+
atmos_cubed_sphere/driver/fvGFS/fv_nggps_diag.F90
69+
atmos_cubed_sphere/driver/fvGFS/atmosphere.F90
70+
)
71+
72+
set_property(SOURCE atmos_cubed_sphere/model/nh_utils.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "${FAST}")
73+
set_property(SOURCE atmos_cubed_sphere/model/fv_mapz.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "${FAST}")
74+
75+
target_link_libraries(fv3core PRIVATE fms)
76+
target_link_libraries(fv3core PRIVATE ${PHYS}physics)
77+
target_link_libraries(fv3core PRIVATE ipd)
78+
79+
target_include_directories(fv3core PRIVATE ${ESMF_MOD})
80+
81+
# end of fv3core
82+
83+
###############################################################################
84+
### ccpp
85+
###############################################################################
86+
if(CCPP)
87+
add_subdirectory(ccpp)
88+
add_subdirectory(ccpp/driver)
89+
add_dependencies(${PHYS}physics ccpp ccppphys)
90+
add_dependencies(ccppdriver ccpp ccppphys)
91+
add_dependencies(ccppphys ccpp)
92+
93+
target_include_directories(fv3core PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src)
94+
target_include_directories(fv3core PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/driver)
95+
endif()
96+
97+
set_target_properties(fv3core PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
98+
target_include_directories(fv3core PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod)
99+
100+
# When specifying an out-of-tree source a binary directory must be explicitly specified.
101+
#add_subdirectory(../stochastic_physics stochastic_physics)
102+
add_subdirectory(stochastic_physics)
103+
104+
add_library(
105+
fv3cap
106+
107+
atmos_model.F90
108+
fv3_cap.F90
109+
module_fv3_config.F90
110+
module_fcst_grid_comp.F90
111+
time_utils.F90
112+
)
113+
114+
if(CCPP)
115+
target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver/mod)
116+
endif()
117+
target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/stochastic_physics)
118+
target_compile_definitions(fv3cap PRIVATE -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR})
119+
target_include_directories(fv3cap PRIVATE ${ESMF_MOD})
120+
121+
target_link_libraries(fv3cap PRIVATE fms)
122+
target_link_libraries(fv3cap PRIVATE fv3cpl)
123+
target_link_libraries(fv3cap PRIVATE ${PHYS}physics)
124+
target_link_libraries(fv3cap PRIVATE ipd)
125+
target_link_libraries(fv3cap PRIVATE io)
126+
target_link_libraries(fv3cap PRIVATE fv3core)
127+
target_link_libraries(fv3cap PRIVATE stochastic_physics)
128+
129+
set_target_properties(fv3cap PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
130+
target_include_directories(fv3cap PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod)

ccpp/driver/CMakeLists.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
if(NOT DYN32)
3+
remove_definitions(-DOVERLOAD_R8)
4+
remove_definitions(-DOVERLOAD_R4)
5+
endif()
6+
7+
message ("Force 64 bits in CCPP_layer")
8+
if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
9+
string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64 -no-prec-div -no-prec-sqrt" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
10+
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
11+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8")
12+
endif()
13+
14+
add_library(
15+
ccppdriver
16+
17+
CCPP_driver.F90
18+
)
19+
20+
target_link_libraries(ccppdriver ${PHYS}physics)
21+
target_link_libraries(ccppdriver ccpp)
22+
target_link_libraries(ccppdriver ccppphys)
23+
24+
target_include_directories(ccppdriver PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src)
25+
26+
set_target_properties(ccppdriver PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
27+
target_include_directories(ccppdriver PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod)

cpl/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
add_library(
3+
fv3cpl
4+
5+
module_cplfields.F90
6+
module_cap_cpl.F90
7+
)
8+
9+
target_include_directories(fv3cpl PRIVATE ${ESMF_MOD})
10+
11+
set_target_properties(fv3cpl PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
12+
target_include_directories(fv3cpl PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod)

0 commit comments

Comments
 (0)