Skip to content

Commit

Permalink
Updated CMake for separate builds. Fixes #441
Browse files Browse the repository at this point in the history
  • Loading branch information
bschroeter committed Nov 26, 2024
1 parent 9ffee33 commit fdd0d75
Show file tree
Hide file tree
Showing 2 changed files with 240 additions and 144 deletions.
383 changes: 239 additions & 144 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,152 +37,247 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
)
endif()

add_library(
cable_science
STATIC
src/science/albedo/cbl_albedo.F90
src/science/albedo/cbl_snow_albedo.F90
src/science/albedo/cbl_soilColour_albedo.F90
src/science/canopy/cable_canopy.F90
src/science/canopy/cbl_dryLeaf.F90
src/science/canopy/cbl_friction_vel.F90
src/science/canopy/cbl_fwsoil.F90
src/science/canopy/cbl_init_wetfac_mod.F90
src/science/canopy/cbl_latent_heat.F90
src/science/canopy/cbl_photosynthesis.F90
src/science/canopy/cbl_pot_evap_snow.F90
src/science/canopy/cbl_qsat.F90
src/science/canopy/cbl_SurfaceWetness.F90
src/science/canopy/cbl_wetleaf.F90
src/science/canopy/cbl_within_canopy.F90
src/science/canopy/cbl_zetar.F90
src/science/casa-cnp/bgcdriver.F90
src/science/casa-cnp/biogeochem_casa.F90
src/science/casa-cnp/casa_cnp.F90
src/science/casa-cnp/casa_dimension.F90
src/science/casa-cnp/casa_feedback.F90
src/science/casa-cnp/casa_inout.F90
src/science/casa-cnp/casa_param.F90
src/science/casa-cnp/casa_phenology.F90
src/science/casa-cnp/casa_readbiome.F90
src/science/casa-cnp/casa_rplant.F90
src/science/casa-cnp/casa_sumcflux.F90
src/science/casa-cnp/casa_variable.F90
src/science/gw_hydro/cable_gw_hydro.F90
src/science/gw_hydro/cable_psm.F90
src/science/landuse/landuse3.F90
src/science/landuse/landuse_constant.F90
src/science/misc/cable_air.F90
src/science/misc/cable_carbon.F90
src/science/misc/cable_climate.F90
src/science/pop/pop_constants.F90
src/science/pop/pop_def.F90
src/science/pop/POP.F90
src/science/pop/pop_io.F90
src/science/pop/POPLUC.F90
src/science/pop/pop_types.F90
src/science/radiation/cbl_init_radiation.F90
src/science/radiation/cbl_radiation.F90
src/science/radiation/cbl_rhoch.F90
src/science/radiation/cbl_sinbet.F90
src/science/radiation/cbl_spitter.F90
src/science/roughness/cable_roughness.F90
src/science/roughness/roughnessHGT_effLAI_cbl.F90
src/science/sli/cable_sli_main.F90
src/science/sli/cable_sli_numbers.F90
src/science/sli/cable_sli_roots.F90
src/science/sli/cable_sli_solve.F90
src/science/sli/cable_sli_utils.F90
src/science/soilsnow/cbl_conductivity.F90
src/science/soilsnow/cbl_GW.F90
src/science/soilsnow/cbl_hyd_redistrib.F90
src/science/soilsnow/cbl_Oldconductivity.F90
src/science/soilsnow/cbl_remove_trans.F90
src/science/soilsnow/cbl_smoisturev.F90
src/science/soilsnow/cbl_snowAccum.F90
src/science/soilsnow/cbl_snow_aging.F90
src/science/soilsnow/cbl_snowCheck.F90
src/science/soilsnow/cbl_snowDensity.F90
src/science/soilsnow/cbl_snowl_adjust.F90
src/science/soilsnow/cbl_snowMelt.F90
src/science/soilsnow/cbl_soilfreeze.F90
src/science/soilsnow/cbl_soilsnow_data.F90
src/science/soilsnow/cbl_soilsnow_init_special.F90
src/science/soilsnow/cbl_soilsnow_main.F90
src/science/soilsnow/cbl_stempv.F90
src/science/soilsnow/cbl_surfbv.F90
src/science/soilsnow/cbl_thermal.F90
src/science/soilsnow/cbl_trimb.F90
src/params/cable_phys_constants_mod.F90
src/params/grid_constants_cbl.F90
src/params/cable_photo_constants_mod.F90
src/params/cable_other_constants_mod.F90
src/params/cable_maths_constants_mod.F90
src/util/cable_runtime_opts_mod.F90
src/util/cable_common.F90
src/coupled/esm16/casa_offline_inout.F90
src/coupled/esm16/casa_ncdf.F90
src/coupled/esm16/cable_iovars.F90
src/coupled/esm16/cable_surface_types.F90
src/coupled/esm16/cable_define_types.F90
src/coupled/esm16/cable_phenology.F90
src/coupled/esm16/cable_LUC_EXPT.F90
)

add_library(
cable_common
STATIC
src/offline/CASAONLY_LUC.F90
src/offline/cable_abort.F90
src/offline/cable_checks.F90
src/offline/cable_cru_TRENDY.F90
src/offline/cable_driver_init.F90
src/offline/cable_initialise.F90
src/offline/cable_input.F90
src/offline/cable_metutils.F90
src/offline/cable_mpi.F90
src/offline/cable_namelist_input.F90
src/offline/cable_output.F90
src/offline/cable_parameters.F90
src/offline/cable_pft_params.F90
src/offline/cable_plume_mip.F90
src/offline/cable_read.F90
src/offline/cable_site.F90
src/offline/cable_serial.F90
src/offline/cable_soil_params.F90
src/offline/cable_weathergenerator.F90
src/offline/cable_write.F90
src/offline/casa_cable.F90
src/offline/cbl_model_driver_offline.F90
src/offline/landuse_inout.F90
src/offline/spincasacnp.F90
src/util/cable_climate_type_mod.F90
src/util/masks_cbl.F90
)
target_link_libraries(cable_common PRIVATE PkgConfig::NETCDF cable_science)
if(CABLE_MPI)
target_compile_definitions(cable_common PRIVATE __MPI__)
target_link_libraries(cable_common PRIVATE MPI::MPI_Fortran cable_science)
endif()
if(CABLE_LIBRARY)

if(CABLE_MPI)
add_executable(
cable-mpi
src/offline/cable_mpicommon.F90
src/offline/cable_mpimaster.F90
src/offline/cable_mpiworker.F90
src/science/pop/pop_mpi.F90
src/offline/cable_offline_driver.F90
add_library(
cable_science
STATIC
src/science/albedo/cbl_albedo.F90
src/science/albedo/cbl_snow_albedo.F90
src/science/albedo/cbl_soilColour_albedo.F90
src/science/canopy/cable_canopy.F90
src/science/canopy/cbl_dryLeaf.F90
src/science/canopy/cbl_friction_vel.F90
src/science/canopy/cbl_fwsoil.F90
src/science/canopy/cbl_init_wetfac_mod.F90
src/science/canopy/cbl_latent_heat.F90
src/science/canopy/cbl_photosynthesis.F90
src/science/canopy/cbl_pot_evap_snow.F90
src/science/canopy/cbl_qsat.F90
src/science/canopy/cbl_SurfaceWetness.F90
src/science/canopy/cbl_wetleaf.F90
src/science/canopy/cbl_within_canopy.F90
src/science/canopy/cbl_zetar.F90
src/science/casa-cnp/bgcdriver.F90
src/science/casa-cnp/biogeochem_casa.F90
src/science/casa-cnp/casa_cnp.F90
src/science/casa-cnp/casa_dimension.F90
src/science/casa-cnp/casa_feedback.F90
src/science/casa-cnp/casa_inout.F90
src/science/casa-cnp/casa_param.F90
src/science/casa-cnp/casa_phenology.F90
src/science/casa-cnp/casa_readbiome.F90
src/science/casa-cnp/casa_rplant.F90
src/science/casa-cnp/casa_sumcflux.F90
src/science/casa-cnp/casa_variable.F90
src/science/gw_hydro/cable_gw_hydro.F90
src/science/gw_hydro/cable_psm.F90
src/science/landuse/landuse3.F90
src/science/landuse/landuse_constant.F90
src/science/misc/cable_air.F90
src/science/misc/cable_carbon.F90
src/science/misc/cable_climate.F90
src/science/pop/pop_constants.F90
src/science/pop/pop_def.F90
src/science/pop/POP.F90
src/science/pop/pop_io.F90
src/science/pop/POPLUC.F90
src/science/pop/pop_types.F90
src/science/radiation/cbl_init_radiation.F90
src/science/radiation/cbl_radiation.F90
src/science/radiation/cbl_rhoch.F90
src/science/radiation/cbl_sinbet.F90
src/science/radiation/cbl_spitter.F90
src/science/roughness/cable_roughness.F90
src/science/roughness/roughnessHGT_effLAI_cbl.F90
src/science/sli/cable_sli_main.F90
src/science/sli/cable_sli_numbers.F90
src/science/sli/cable_sli_roots.F90
src/science/sli/cable_sli_solve.F90
src/science/sli/cable_sli_utils.F90
src/science/soilsnow/cbl_conductivity.F90
src/science/soilsnow/cbl_GW.F90
src/science/soilsnow/cbl_hyd_redistrib.F90
src/science/soilsnow/cbl_Oldconductivity.F90
src/science/soilsnow/cbl_remove_trans.F90
src/science/soilsnow/cbl_smoisturev.F90
src/science/soilsnow/cbl_snowAccum.F90
src/science/soilsnow/cbl_snow_aging.F90
src/science/soilsnow/cbl_snowCheck.F90
src/science/soilsnow/cbl_snowDensity.F90
src/science/soilsnow/cbl_snowl_adjust.F90
src/science/soilsnow/cbl_snowMelt.F90
src/science/soilsnow/cbl_soilfreeze.F90
src/science/soilsnow/cbl_soilsnow_data.F90
src/science/soilsnow/cbl_soilsnow_init_special.F90
src/science/soilsnow/cbl_soilsnow_main.F90
src/science/soilsnow/cbl_stempv.F90
src/science/soilsnow/cbl_surfbv.F90
src/science/soilsnow/cbl_thermal.F90
src/science/soilsnow/cbl_trimb.F90
src/params/cable_phys_constants_mod.F90
src/params/grid_constants_cbl.F90
src/params/cable_photo_constants_mod.F90
src/params/cable_other_constants_mod.F90
src/params/cable_maths_constants_mod.F90
src/util/cable_runtime_opts_mod.F90
src/util/cable_common.F90
src/coupled/esm16/casa_offline_inout.F90
src/coupled/esm16/casa_ncdf.F90
src/coupled/esm16/cable_iovars.F90
src/coupled/esm16/cable_surface_types.F90
src/coupled/esm16/cable_define_types.F90
src/coupled/esm16/cable_phenology.F90
src/coupled/esm16/cable_LUC_EXPT.F90
)
target_link_libraries(cable-mpi PRIVATE cable_common MPI::MPI_Fortran cable_science)
install(TARGETS cable-mpi RUNTIME)

else()
add_executable(
cable
src/offline/cable_mpimaster_stub.F90
src/offline/cable_mpiworker_stub.F90
src/offline/cable_offline_driver.F90

add_library(
cable_common
STATIC
src/science/albedo/cbl_albedo.F90
src/science/albedo/cbl_snow_albedo.F90
src/science/albedo/cbl_soilColour_albedo.F90
src/science/canopy/cable_canopy.F90
src/science/canopy/cbl_dryLeaf.F90
src/science/canopy/cbl_friction_vel.F90
src/science/canopy/cbl_fwsoil.F90
src/science/canopy/cbl_init_wetfac_mod.F90
src/science/canopy/cbl_latent_heat.F90
src/science/canopy/cbl_photosynthesis.F90
src/science/canopy/cbl_pot_evap_snow.F90
src/science/canopy/cbl_qsat.F90
src/science/canopy/cbl_SurfaceWetness.F90
src/science/canopy/cbl_wetleaf.F90
src/science/canopy/cbl_within_canopy.F90
src/science/canopy/cbl_zetar.F90
src/science/casa-cnp/bgcdriver.F90
src/science/casa-cnp/biogeochem_casa.F90
src/science/casa-cnp/casa_cnp.F90
src/science/casa-cnp/casa_dimension.F90
src/science/casa-cnp/casa_feedback.F90
src/science/casa-cnp/casa_inout.F90
src/science/casa-cnp/casa_param.F90
src/science/casa-cnp/casa_phenology.F90
src/science/casa-cnp/casa_readbiome.F90
src/science/casa-cnp/casa_rplant.F90
src/science/casa-cnp/casa_sumcflux.F90
src/science/casa-cnp/casa_variable.F90
src/science/gw_hydro/cable_gw_hydro.F90
src/science/gw_hydro/cable_psm.F90
src/science/landuse/landuse3.F90
src/science/landuse/landuse_constant.F90
src/science/misc/cable_air.F90
src/science/misc/cable_carbon.F90
src/science/misc/cable_climate.F90
src/science/pop/pop_constants.F90
src/science/pop/pop_def.F90
src/science/pop/POP.F90
src/science/pop/pop_io.F90
src/science/pop/POPLUC.F90
src/science/pop/pop_types.F90
src/science/radiation/cbl_init_radiation.F90
src/science/radiation/cbl_radiation.F90
src/science/radiation/cbl_rhoch.F90
src/science/radiation/cbl_sinbet.F90
src/science/radiation/cbl_spitter.F90
src/science/roughness/cable_roughness.F90
src/science/roughness/roughnessHGT_effLAI_cbl.F90
src/science/sli/cable_sli_main.F90
src/science/sli/cable_sli_numbers.F90
src/science/sli/cable_sli_roots.F90
src/science/sli/cable_sli_solve.F90
src/science/sli/cable_sli_utils.F90
src/science/soilsnow/cbl_conductivity.F90
src/science/soilsnow/cbl_GW.F90
src/science/soilsnow/cbl_hyd_redistrib.F90
src/science/soilsnow/cbl_Oldconductivity.F90
src/science/soilsnow/cbl_remove_trans.F90
src/science/soilsnow/cbl_smoisturev.F90
src/science/soilsnow/cbl_snowAccum.F90
src/science/soilsnow/cbl_snow_aging.F90
src/science/soilsnow/cbl_snowCheck.F90
src/science/soilsnow/cbl_snowDensity.F90
src/science/soilsnow/cbl_snowl_adjust.F90
src/science/soilsnow/cbl_snowMelt.F90
src/science/soilsnow/cbl_soilfreeze.F90
src/science/soilsnow/cbl_soilsnow_data.F90
src/science/soilsnow/cbl_soilsnow_init_special.F90
src/science/soilsnow/cbl_soilsnow_main.F90
src/science/soilsnow/cbl_stempv.F90
src/science/soilsnow/cbl_surfbv.F90
src/science/soilsnow/cbl_thermal.F90
src/science/soilsnow/cbl_trimb.F90
src/params/cable_phys_constants_mod.F90
src/params/grid_constants_cbl.F90
src/params/cable_photo_constants_mod.F90
src/params/cable_other_constants_mod.F90
src/params/cable_maths_constants_mod.F90
src/util/cable_runtime_opts_mod.F90
src/util/cable_common.F90
src/offline/casa_offline_inout.F90
src/offline/casa_ncdf.F90
src/offline/cable_iovars.F90
src/offline/cable_surface_types.F90
src/offline/cable_define_types.F90
src/offline/cable_phenology.F90
src/offline/cable_LUC_EXPT.F90
src/offline/CASAONLY_LUC.F90
src/offline/cable_abort.F90
src/offline/cable_checks.F90
src/offline/cable_cru_TRENDY.F90
src/offline/cable_driver_init.F90
src/offline/cable_initialise.F90
src/offline/cable_input.F90
src/offline/cable_metutils.F90
src/offline/cable_mpi.F90
src/offline/cable_namelist_input.F90
src/offline/cable_output.F90
src/offline/cable_parameters.F90
src/offline/cable_pft_params.F90
src/offline/cable_plume_mip.F90
src/offline/cable_read.F90
src/offline/cable_site.F90
src/offline/cable_serial.F90
src/offline/cable_soil_params.F90
src/offline/cable_weathergenerator.F90
src/offline/cable_write.F90
src/offline/casa_cable.F90
src/offline/cbl_model_driver_offline.F90
src/offline/landuse_inout.F90
src/offline/spincasacnp.F90
src/util/cable_climate_type_mod.F90
src/util/masks_cbl.F90
)
target_link_libraries(cable PRIVATE cable_common cable_science)
install(TARGETS cable RUNTIME)

target_link_libraries(cable_common PRIVATE PkgConfig::NETCDF)

if(CABLE_MPI)
target_compile_definitions(cable_common PRIVATE __MPI__)
target_link_libraries(cable_common PRIVATE MPI::MPI_Fortran)
endif()

if(CABLE_MPI)
add_executable(
cable-mpi
src/offline/cable_mpicommon.F90
src/offline/cable_mpimaster.F90
src/offline/cable_mpiworker.F90
src/science/pop/pop_mpi.F90
src/offline/cable_offline_driver.F90
)
target_link_libraries(cable-mpi PRIVATE cable_common MPI::MPI_Fortran)
install(TARGETS cable-mpi RUNTIME)
else()
add_executable(
cable
src/offline/cable_mpimaster_stub.F90
src/offline/cable_mpiworker_stub.F90
src/offline/cable_offline_driver.F90
)
target_link_libraries(cable PRIVATE cable_common)
install(TARGETS cable RUNTIME)
endif()

endif()
Loading

0 comments on commit fdd0d75

Please sign in to comment.