From 8a567812866a80d8320ecb8d946c894a91c8047c Mon Sep 17 00:00:00 2001 From: Dusan Jovic <48258889+DusanJovic-NOAA@users.noreply.github.com> Date: Tue, 10 Dec 2019 09:04:10 -0500 Subject: [PATCH] Add support for cmake build system (#20) --- .gitignore | 1 + CMakeLists.txt | 130 +++++++++++++++++ ccpp/driver/CMakeLists.txt | 27 ++++ cpl/CMakeLists.txt | 12 ++ gfsphysics/CMakeLists.txt | 228 ++++++++++++++++++++++++++++++ io/CMakeLists.txt | 33 +++++ ipd/CMakeLists.txt | 26 ++++ namphysics/CMakeLists.txt | 107 ++++++++++++++ stochastic_physics/CMakeLists.txt | 56 ++++++++ 9 files changed, 620 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 ccpp/driver/CMakeLists.txt create mode 100644 cpl/CMakeLists.txt create mode 100644 gfsphysics/CMakeLists.txt create mode 100644 io/CMakeLists.txt create mode 100644 ipd/CMakeLists.txt create mode 100644 namphysics/CMakeLists.txt create mode 100644 stochastic_physics/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 1d3fb332c..ac5fcf245 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o *.mod *.a +*.pyc diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..fdcc5bc49 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,130 @@ +if( NOT DEFINED PHYS) + set(PHYS gfs) +endif() + +if (PHYS MATCHES "nam") + add_definitions(-DNAM_phys) +endif() + +if(CCPP) + add_definitions(-DCCPP) + if(STATIC) + add_definitions(-DSTATIC) + endif() +endif() + +add_subdirectory(cpl) +add_subdirectory(${PHYS}physics) +add_subdirectory(ipd) +add_subdirectory(io) + +# fv3core library + +if(NOT CCPP) +set(FAST_PHYSICS_SRCS_F90 atmos_cubed_sphere/model/fv_cmp.F90) +endif() + +add_library( + fv3core + + atmos_cubed_sphere/model/a2b_edge.F90 + atmos_cubed_sphere/model/multi_gases.F90 + atmos_cubed_sphere/model/boundary.F90 + atmos_cubed_sphere/model/dyn_core.F90 + atmos_cubed_sphere/model/fv_arrays.F90 + ${FAST_PHYSICS_SRCS_F90} + atmos_cubed_sphere/model/fv_control.F90 + atmos_cubed_sphere/model/fv_dynamics.F90 + atmos_cubed_sphere/model/fv_fill.F90 + atmos_cubed_sphere/model/fv_grid_utils.F90 + atmos_cubed_sphere/model/fv_mapz.F90 + atmos_cubed_sphere/model/fv_nesting.F90 + atmos_cubed_sphere/model/fv_regional_bc.F90 + atmos_cubed_sphere/model/fv_sg.F90 + atmos_cubed_sphere/model/fv_tracer2d.F90 + atmos_cubed_sphere/model/fv_update_phys.F90 + atmos_cubed_sphere/model/sw_core.F90 + atmos_cubed_sphere/model/tp_core.F90 + atmos_cubed_sphere/model/nh_core.F90 + atmos_cubed_sphere/model/nh_utils.F90 + atmos_cubed_sphere/tools/external_ic.F90 + atmos_cubed_sphere/tools/external_sst.F90 + atmos_cubed_sphere/tools/fv_diagnostics.F90 + atmos_cubed_sphere/tools/fv_eta.F90 + atmos_cubed_sphere/tools/fv_grid_tools.F90 + atmos_cubed_sphere/tools/fv_io.F90 + atmos_cubed_sphere/tools/fv_mp_mod.F90 + atmos_cubed_sphere/tools/fv_nudge.F90 + atmos_cubed_sphere/tools/fv_treat_da_inc.F90 + atmos_cubed_sphere/tools/fv_iau_mod.F90 + atmos_cubed_sphere/tools/fv_restart.F90 + atmos_cubed_sphere/tools/fv_surf_map.F90 + atmos_cubed_sphere/tools/fv_timing.F90 + atmos_cubed_sphere//tools/init_hydro.F90 + atmos_cubed_sphere/tools/sim_nc_mod.F90 + atmos_cubed_sphere/tools/sorted_index.F90 + atmos_cubed_sphere/tools/test_cases.F90 + atmos_cubed_sphere/driver/fvGFS/DYCORE_typedefs.F90 + atmos_cubed_sphere/driver/fvGFS/fv_nggps_diag.F90 + atmos_cubed_sphere/driver/fvGFS/atmosphere.F90 +) + +set_property(SOURCE atmos_cubed_sphere/model/nh_utils.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "${FAST}") +set_property(SOURCE atmos_cubed_sphere/model/fv_mapz.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "${FAST}") + +target_link_libraries(fv3core PRIVATE fms) +target_link_libraries(fv3core PRIVATE ${PHYS}physics) +target_link_libraries(fv3core PRIVATE ipd) + +target_include_directories(fv3core PRIVATE ${ESMF_MOD}) + +# end of fv3core + +############################################################################### +### ccpp +############################################################################### +if(CCPP) + add_subdirectory(ccpp) + add_subdirectory(ccpp/driver) + add_dependencies(${PHYS}physics ccpp ccppphys) + add_dependencies(ccppdriver ccpp ccppphys) + add_dependencies(ccppphys ccpp) + + target_include_directories(fv3core PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) + target_include_directories(fv3core PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/driver) +endif() + +set_target_properties(fv3core PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(fv3core PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) + +# When specifying an out-of-tree source a binary directory must be explicitly specified. +#add_subdirectory(../stochastic_physics stochastic_physics) +add_subdirectory(stochastic_physics) + +add_library( + fv3cap + + atmos_model.F90 + fv3_cap.F90 + module_fv3_config.F90 + module_fcst_grid_comp.F90 + time_utils.F90 +) + +if(CCPP) +target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver/mod) +endif() +target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/stochastic_physics) +target_compile_definitions(fv3cap PRIVATE -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR}) +target_include_directories(fv3cap PRIVATE ${ESMF_MOD}) + +target_link_libraries(fv3cap PRIVATE fms) +target_link_libraries(fv3cap PRIVATE fv3cpl) +target_link_libraries(fv3cap PRIVATE ${PHYS}physics) +target_link_libraries(fv3cap PRIVATE ipd) +target_link_libraries(fv3cap PRIVATE io) +target_link_libraries(fv3cap PRIVATE fv3core) +target_link_libraries(fv3cap PRIVATE stochastic_physics) + +set_target_properties(fv3cap PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(fv3cap PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) diff --git a/ccpp/driver/CMakeLists.txt b/ccpp/driver/CMakeLists.txt new file mode 100644 index 000000000..d1e36ac34 --- /dev/null +++ b/ccpp/driver/CMakeLists.txt @@ -0,0 +1,27 @@ + +if(NOT DYN32) +remove_definitions(-DOVERLOAD_R8) +remove_definitions(-DOVERLOAD_R4) +endif() + +message ("Force 64 bits in CCPP_layer") +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64 -no-prec-div -no-prec-sqrt" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") +endif() + +add_library( + ccppdriver + + CCPP_driver.F90 +) + +target_link_libraries(ccppdriver ${PHYS}physics) +target_link_libraries(ccppdriver ccpp) +target_link_libraries(ccppdriver ccppphys) + +target_include_directories(ccppdriver PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) + +set_target_properties(ccppdriver PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(ccppdriver PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) diff --git a/cpl/CMakeLists.txt b/cpl/CMakeLists.txt new file mode 100644 index 000000000..c810ed1b3 --- /dev/null +++ b/cpl/CMakeLists.txt @@ -0,0 +1,12 @@ + +add_library( + fv3cpl + + module_cplfields.F90 + module_cap_cpl.F90 +) + +target_include_directories(fv3cpl PRIVATE ${ESMF_MOD}) + +set_target_properties(fv3cpl PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(fv3cpl PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) diff --git a/gfsphysics/CMakeLists.txt b/gfsphysics/CMakeLists.txt new file mode 100644 index 000000000..6c2a23625 --- /dev/null +++ b/gfsphysics/CMakeLists.txt @@ -0,0 +1,228 @@ + +if(32BIT) +remove_definitions(-DOVERLOAD_R4) +remove_definitions(-DOVERLOAD_R8) +message ("Force 64 bits in gfsphysics") +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + if(REPRO) + string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + else() + string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64 -no-prec-div -no-prec-sqrt" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + endif() +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -fdefault-double-8") +endif() +endif() + +set(CCPP_SOURCES + physics/mersenne_twister.f + physics/namelist_soilveg.f + physics/physparam.f + physics/radlw_param.f + physics/radsw_param.f + physics/set_soilveg.f + + physics/noahmp_tables.f90 + + physics/machine.F + + physics/GFDL_parse_tracers.F90 + physics/physcons.F90 + + CCPP_layer/CCPP_typedefs.F90 + CCPP_layer/CCPP_data.F90 + ${CMAKE_BINARY_DIR}/FV3/ccpp/physics/ccpp_static_api.F90 + + GFS_layer/GFS_abstraction_layer.F90 + GFS_layer/GFS_diagnostics.F90 + GFS_layer/GFS_driver.F90 + GFS_layer/GFS_restart.F90 + GFS_layer/GFS_typedefs.F90 +) + +set(IPD_SOURCES + + physics/cnvc90.f + physics/co2hc.f + physics/date_def.f + physics/dcyc2.f + physics/dcyc2.pre.rad.f + physics/efield.f + physics/get_prs.f + physics/gocart_tracer_config_stub.f + physics/gscond.f + physics/gscondp.f + physics/gwdc.f + physics/gwdps.f + physics/ugwp_driver_v0.f + physics/cires_orowam2017.f + physics/h2o_def.f + physics/h2oc.f + physics/h2ohdc.f + physics/h2ophys.f + physics/ideaca.f + physics/idea_co2.f + physics/idea_composition.f + physics/idea_dissipation.f + physics/idea_h2o.f + physics/idea_ion.f + physics/idea_o2_o3.f + physics/idea_phys.f + physics/idea_solar_heating.f + physics/idea_tracer.f + physics/iounitdef.f + physics/lrgsclr.f + physics/mersenne_twister.f + physics/mfpbl.f + physics/mfpblt.f + physics/mfpbltq.f + physics/mfscu.f + physics/mfscuq.f + physics/module_bfmicrophysics.f + physics/moninedmf.f + physics/moninedmf_hafs.f + physics/moninp.f + physics/moninp1.f + physics/moninq.f + physics/moninq1.f + physics/moninshoc.f + physics/mstadb.f + physics/mstadbtn.f + physics/mstadbtn2.f + physics/mstcnv.f + physics/namelist_soilveg.f + physics/ozne_def.f + physics/iccn_def.f + physics/aerclm_def.f + physics/ozphys.f + physics/ozphys_2015.f + physics/physparam.f + physics/precpd.f + physics/precpd_shoc.f + physics/precpdp.f + physics/precpd_shoc.f + physics/progt2.f + physics/progtm_module.f + physics/rad_initialize.f + physics/radiation_aerosols.f + physics/radiation_astronomy.f + physics/radiation_clouds.f + physics/radiation_gases.f + physics/radiation_surface.f + physics/radlw_datatb.f + physics/radlw_main.f + physics/radlw_param.f + physics/radsw_datatb.f + physics/radsw_main.f + physics/radsw_param.f + physics/rascnvv2.f + physics/rayleigh_damp.f + physics/rayleigh_damp_mesopause.f + physics/samfaerosols.f + physics/samfdeepcnv.f + physics/samfshalcnv.f + physics/sascnv.f + physics/sascnvn.f + physics/satmedmfvdif.f + physics/satmedmfvdifq.f + physics/set_soilveg.f + physics/sfc_cice.f + physics/sfc_diag.f + physics/sfc_diff.f + physics/sfc_drv.f + physics/sfc_noahmp_drv.f + physics/sfc_nst.f + physics/sfc_ocean.f + physics/sfc_sice.f + physics/sflx.f + physics/shalcnv.f + physics/shalcv.f + physics/shalcv_1lyr.f + physics/shalcv_fixdp.f + physics/shalcv_opr.f + physics/tracer_const_h.f + physics/tridi2t3.f + + physics/calpreciptype.f90 + physics/funcphys.f90 + physics/gcm_shoc.f90 + physics/get_prs_fv3.f90 + physics/h2ointerp.f90 + physics/module_nst_model.f90 + physics/module_nst_parameters.f90 + physics/module_nst_water_prop.f90 + physics/ozinterp.f90 + physics/module_wrf_utl.f90 + physics/noahmp_tables.f90 + physics/module_sf_noahmplsm.f90 + physics/module_sf_noahmp_glacier.f90 + physics/iccninterp.f90 + physics/aerinterp.f90 + physics/wam_f107_kp_mod.f90 + + physics/aer_cloud.F + physics/cldmacro.F + physics/cldwat2m_micro.F + physics/gfs_phy_tracer_config.F + physics/machine.F + physics/num_parthds.F + physics/sfcsub.F + physics/wv_saturation.F + + physics/GFDL_parse_tracers.F90 + physics/gcycle.F90 + physics/cires_ugwp_initialize.F90 + physics/cires_ugwp_module.F90 + physics/cires_ugwp_utils.F90 + physics/cires_ugwp_triggers.F90 + physics/cires_ugwp_solvers.F90 + physics/cires_vert_lsatdis.F90 + physics/cires_vert_orodis.F90 + physics/cires_vert_wmsdis.F90 + physics/gfdl_cloud_microphys.F90 + physics/micro_mg_utils.F90 + physics/micro_mg2_0.F90 + physics/micro_mg3_0.F90 + physics/m_micro_driver.F90 + physics/cs_conv.F90 + physics/module_mp_radar.F90 + physics/module_mp_thompson_gfs.F90 + physics/module_mp_wsm6_fv3.F90 + physics/physcons.F90 + physics/surface_perturbation.F90 + + GFS_layer/GFS_abstraction_layer.F90 + GFS_layer/GFS_diagnostics.F90 + GFS_layer/GFS_driver.F90 + GFS_layer/GFS_physics_driver.F90 + GFS_layer/GFS_radiation_driver.F90 + GFS_layer/GFS_restart.F90 + GFS_layer/GFS_typedefs.F90 +) + +if(CCPP) + add_definitions(-DCCPP) + if(DYN32) + add_definitions(-DOVERLOAD_R4) + endif() + add_library(gfsphysics ${CCPP_SOURCES}) + target_include_directories(gfsphysics PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) + target_include_directories(gfsphysics PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/physics) +else() + add_library(gfsphysics ${IPD_SOURCES}) +endif() + +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + if(CMAKE_Platform MATCHES "jet") + set_property(SOURCE physics/radiation_aerosols.f APPEND_STRING PROPERTY COMPILE_FLAGS "-axSSE4.2,AVX,CORE-AVX-I") + else() + set_property(SOURCE physics/radiation_aerosols.f APPEND_STRING PROPERTY COMPILE_FLAGS "-xCORE-AVX-I") + endif() +endif() +set_property(SOURCE GFS_layer/GFS_diagnostics.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "-O0") + +target_compile_definitions(gfsphysics PRIVATE -DNEMS_GSM) +target_include_directories(gfsphysics PRIVATE ${NETCDF_INC_DIR}) + +set_target_properties(gfsphysics PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(gfsphysics PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) diff --git a/io/CMakeLists.txt b/io/CMakeLists.txt new file mode 100644 index 000000000..5eecdd9ea --- /dev/null +++ b/io/CMakeLists.txt @@ -0,0 +1,33 @@ +if(INLINE_POST) + set(POST_SRC post_gfs.F90 post_nems_routines.F90) +else() + set(POST_SRC post_gfs_stub.F90) + add_definitions(-DNO_INLINE_POST) +endif() + +add_library( + io + + ffsync.F90 + FV3GFS_io.F90 + module_write_nemsio.F90 + module_write_netcdf.F90 + module_fv3_io_def.F90 + module_write_internal_state.F90 + module_wrt_grid_comp.F90 + ${POST_SRC} +) + +set_source_files_properties(post_gfs.F90 post_nems_routines.F90 + PROPERTIES + COMPILE_FLAGS "-I${POST_INC}") + +target_link_libraries(io fms) +target_link_libraries(io ${PHYS}physics) +target_link_libraries(io ipd) + +target_include_directories(io PRIVATE ${ESMF_MOD}) +target_include_directories(io PRIVATE ${NEMSIO_INC}) + +set_target_properties(io PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(io PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) diff --git a/ipd/CMakeLists.txt b/ipd/CMakeLists.txt new file mode 100644 index 000000000..490ad35f8 --- /dev/null +++ b/ipd/CMakeLists.txt @@ -0,0 +1,26 @@ + +if(32BIT) +remove_definitions(-DOVERLOAD_R4) +remove_definitions(-DOVERLOAD_R8) +message ("Force 64 bits in ipd") +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + if(REPRO) + string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + else() + string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64 -no-prec-div -no-prec-sqrt" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + endif() +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") +endif() +endif() + +add_library( + ipd + + IPD_driver.F90 + IPD_typedefs.F90 +) +target_link_libraries(ipd ${PHYS}physics) + +set_target_properties(ipd PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(ipd PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) diff --git a/namphysics/CMakeLists.txt b/namphysics/CMakeLists.txt new file mode 100644 index 000000000..dd584f891 --- /dev/null +++ b/namphysics/CMakeLists.txt @@ -0,0 +1,107 @@ + +if(32BIT) +remove_definitions(-DOVERLOAD_R4) +remove_definitions(-DOVERLOAD_R8) +message ("Force 64 bits in namphysics") +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + if(REPRO) + string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + else() + string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64 -no-prec-div -no-prec-sqrt" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + endif() +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") +endif() +endif() + +add_library( + namphysics + + physics/grrad_nmmb.f + physics/gscond.f + physics/iounitdef.f + physics/mersenne_twister.f + physics/mfdeepcnv.f + physics/mfpbl.f + physics/mfshalcnv.f + physics/moninedmf.f + physics/moninq.f + physics/namelist_soilveg.f + physics/ozne_def.f + physics/physparam.f + physics/precpd_nmmb.f + physics/rad_initialize_nmmb.f + physics/radiation_aerosols_nmmb.f + physics/radiation_astronomy_nmmb.f + physics/radiation_clouds_nmmb.f + physics/radiation_gases_nmmb.f + physics/radiation_surface_nmmb.f + physics/radlw_datatb.f + physics/radlw_main_nmmb.f + physics/radlw_param.f + physics/radsw_datatb.f + physics/radsw_main_nmmb.f + physics/radsw_param.f + physics/sascnvn.f + physics/h2o_def.f + physics/shalcnv.f + + physics/machine.F + + physics/funcphys.f90 + physics/physcons.f90 + physics/noahmp_tables.f90 + + physics/module_BL_GFSPBL.F90 + physics/module_BL_GFSPBLEDMFHUR.F90 + physics/module_BL_GFSPBLHUR.F90 + physics/module_BL_MYJPBL.F90 + physics/module_CONSTANTS.F90 + physics/module_CONTROL.F90 + physics/module_CONVECTION.F90 + physics/module_CU_BMJ.F90 + physics/module_CU_SAS.F90 + physics/module_CU_SASHUR.F90 + physics/module_CU_SCALE.F90 + physics/module_DIAGNOSE.F90 + physics/module_GWD.F90 + physics/module_KINDS.F90 + physics/module_LS_LISS.F90 + physics/module_LS_NOAHLSM.F90 + physics/module_MICROPHYSICS.F90 + physics/module_MP_ETANEW.F90 + physics/module_MP_FER_HIRES.F90 + physics/module_MP_GFS.F90 + physics/module_MP_WSM6.F90 + physics/module_RADIATION.F90 + physics/module_RA_GFDL.F90 + physics/module_RA_RRTM.F90 + physics/module_SF_GFDL.F90 + physics/module_SF_JSFC.F90 + physics/module_SF_URBAN.F90 + physics/module_TURBULENCE.F90 + physics/module_mp_radar.F90 + physics/module_mp_thompson.F90 + physics/GFDL_parse_tracers.F90 + physics/gfdl_cloud_microphys.F90 + + NAM_layer/module_SOLVER_GRID_COMP.F90 + NAM_layer/NAM_abstraction_layer.F90 + NAM_layer/NAM_diagnostics.F90 + NAM_layer/NAM_driver.F90 + NAM_layer/NAM_radiation_driver.F90 + NAM_layer/NAM_restart.F90 + NAM_layer/NAM_typedefs.F90 +) + +set_property(SOURCE physics/grrad_nmmb.f APPEND_STRING PROPERTY COMPILE_FLAGS "-free -r8") +set_property(SOURCE physics/radiation_astronomy_nmmb.f APPEND_STRING PROPERTY COMPILE_FLAGS "-free -r8") +set_property(SOURCE physics/radiation_clouds_nmmb.f APPEND_STRING PROPERTY COMPILE_FLAGS "-free -r8") +set_property(SOURCE physics/radsw_main_nmmb.f APPEND_STRING PROPERTY COMPILE_FLAGS "-free -r8") + +set_property(SOURCE NAM_layer/NAM_diagnostics.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "-O0") + +target_include_directories(namphysics PRIVATE ${ESMF_MOD}) + +set_target_properties(namphysics PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(namphysics PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) diff --git a/stochastic_physics/CMakeLists.txt b/stochastic_physics/CMakeLists.txt new file mode 100644 index 000000000..5c52ec863 --- /dev/null +++ b/stochastic_physics/CMakeLists.txt @@ -0,0 +1,56 @@ + +if(32BIT) +remove_definitions(-DOVERLOAD_R4) +remove_definitions(-DOVERLOAD_R8) +message ("Force 64 bits in stochastic_physics") +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + if(REPRO) + string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + else() + string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64 -no-prec-div -no-prec-sqrt" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + endif() +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") +endif() +endif() + +add_library( + stochastic_physics + + ../../stochastic_physics/cellular_automata.f90 + ../../stochastic_physics/update_ca.f90 + ../../stochastic_physics/plumes.f90 + + ../../stochastic_physics/stochy_gg_def.f + ../../stochastic_physics/stochy_resol_def.f + ../../stochastic_physics/stochy_layout_lag.f + ../../stochastic_physics/four_to_grid_stochy.F + ../../stochastic_physics/glats_stochy.f + ../../stochastic_physics/sumfln_stochy.f + ../../stochastic_physics/gozrineo_stochy.f + ../../stochastic_physics/num_parthds_stochy.f + ../../stochastic_physics/get_ls_node_stochy.f + ../../stochastic_physics/get_lats_node_a_stochy.f + ../../stochastic_physics/setlats_a_stochy.f + ../../stochastic_physics/setlats_lag_stochy.f + ../../stochastic_physics/epslon_stochy.f + ../../stochastic_physics/getcon_lag_stochy.f + ../../stochastic_physics/pln2eo_stochy.f + ../../stochastic_physics/dozeuv_stochy.f + ../../stochastic_physics/dezouv_stochy.f + + ../../stochastic_physics/spectral_layout.F90 + ../../stochastic_physics/getcon_spectral.F90 + ../../stochastic_physics/stochy_namelist_def.F90 + ../../stochastic_physics/compns_stochy.F90 + ../../stochastic_physics/stochy_internal_state_mod.F90 + ../../stochastic_physics/stochastic_physics.F90 + ../../stochastic_physics/stochy_patterngenerator.F90 + ../../stochastic_physics/stochy_data_mod.F90 + ../../stochastic_physics/get_stochy_pattern.F90 + ../../stochastic_physics/initialize_spectral_mod.F90 +) + +target_link_libraries(stochastic_physics fms) +target_link_libraries(stochastic_physics ${PHYS}physics) +target_link_libraries(stochastic_physics fv3core)