Skip to content

Commit

Permalink
Merge branch 'fire_updates' into active_crown_Scott_2001
Browse files Browse the repository at this point in the history
  • Loading branch information
adrifoster committed Nov 3, 2023
2 parents 97860ba + adde527 commit 2168641
Show file tree
Hide file tree
Showing 22 changed files with 2,339 additions and 1,301 deletions.
91 changes: 91 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
cmake_minimum_required(VERSION 3.4)

list(APPEND CMAKE_MODULE_PATH ${CIME_CMAKE_MODULE_DIRECTORY})
include(CIME_initial_setup)

project(FATES_tests Fortran C)

include(CIME_utils)

set(HLM_ROOT "../../")

# Add source directories from other share code (csm_share, etc.)
add_subdirectory(${HLM_ROOT}/share/src csm_share)
add_subdirectory(${HLM_ROOT}/share/unit_test_stubs/util csm_share_stubs)

# Add FATES source directories
add_subdirectory(${HLM_ROOT}/src/fates/main fates_main)
add_subdirectory(${HLM_ROOT}/src/fates/biogeochem fates_biogeochem)
add_subdirectory(${HLM_ROOT}/src/fates/biogeophys fates_biogeophys)
add_subdirectory(${HLM_ROOT}/src/fates/parteh fates_parteh)
add_subdirectory(${HLM_ROOT}/src/fates/fire fates_fire)

# Add general unit test directories
add_subdirectory(${HLM_ROOT}/src/fates/unit_test_shr)

# Remove shr_mpi_mod from share_sources.
# This is needed because we want to use the mock shr_mpi_mod in place of the real one
#
# TODO: this should be moved into a general-purpose function in Sourcelist_utils.
# Then this block of code could be replaced with a single call, like:
# remove_source_file(${share_sources} "shr_mpi_mod.F90")
foreach (sourcefile ${share_sources})
string(REGEX MATCH "shr_mpi_mod.F90" match_found ${sourcefile})
if(match_found)
list(REMOVE_ITEM share_sources ${sourcefile})
endif()
endforeach()

# Remove shr_cal_mod from share_sources.
#
# shr_cal_mod depends on ESMF (or the lightweight esmf wrf timemgr, at
# least). Since CTSM doesn't currently use shr_cal_mod, we're avoiding
# the extra overhead of including esmf_wrf_timemgr sources in this
# build.
#
# TODO: like above, this should be moved into a general-purpose function
# in Sourcelist_utils. Then this block of code could be replaced with a
# single call, like: remove_source_file(${share_sources}
# "shr_cal_mod.F90")
foreach (sourcefile ${share_sources})
string(REGEX MATCH "shr_cal_mod.F90" match_found ${sourcefile})
if(match_found)
list(REMOVE_ITEM share_sources ${sourcefile})
endif()
endforeach()

# Build libraries containing stuff needed for the unit tests.
# Eventually, these add_library calls should probably be distributed into the correct location, rather than being in this top-level CMakeLists.txt file.
add_library(csm_share ${share_sources})
declare_generated_dependencies(csm_share "${share_genf90_sources}")
add_library(fates ${fates_sources})
add_dependencies(fates csm_share)

# We need to look for header files here, in order to pick up shr_assert.h
include_directories(${HLM_ROOT}/share/include)

# This needs to be something we add dynamically
# via some calls using cime
set(NETCDF_C_DIR "/usr/local/Cellar/netcdf/4.9.2_1")
set(NETCDF_FORTRAN_DIR "/usr/local/Cellar/netcdf-fortran/4.6.1")

FIND_PATH(NETCDFC_FOUND libnetcdf.a ${NETCDF_C_DIR}/lib)
FIND_PATH(NETCDFF_FOUND libnetcdff.a ${NETCDF_FORTRAN_DIR}/lib)
MESSAGE(" NETCDFC_FOUND = ${NETCDFC_FOUND}")
MESSAGE(" NETCDFF_FOUND = ${NETCDFF_FOUND}")

include_directories(${NETCDF_C_DIR}/include
${NETCDF_FORTRAN_DIR}/include)
link_directories(${NETCDF_C_DIR}/lib
${NETCDF_FORTRAN_DIR}/lib)

# Tell cmake to look for libraries & mod files here, because this is where we built libraries
include_directories(${CMAKE_CURRENT_BINARY_DIR})
link_directories(${CMAKE_CURRENT_BINARY_DIR})

# Add the test directories
# Note: it's possible that these could be added by each source directory that
# has tests in it. However, it appears that the order needs to be done
# carefully: for example, include_directories and link_directories needs to be
# done before adding the tests themselves.
add_subdirectory(${HLM_ROOT}/src/fates/fire/test fates_fire_test)
8 changes: 8 additions & 0 deletions biogeochem/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
list(APPEND fates_sources
FatesLitterMod.F90
FatesCohortMod.F90
FatesAllometryMod.F90
DamageMainMod.F90
FatesPatchMod.F90)

sourcelist_to_parent(fates_sources)
4 changes: 4 additions & 0 deletions biogeophys/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
list(APPEND fates_sources
FatesHydroWTFMod.F90)

sourcelist_to_parent(fates_sources)
8 changes: 8 additions & 0 deletions fire/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
list(APPEND fates_sources
SFMainMod.F90
SFParamsMod.F90
SFFireWeatherMod.F90
SFNesterovMod.F90
)

sourcelist_to_parent(fates_sources)
25 changes: 25 additions & 0 deletions fire/SFFireWeatherMod.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module SFFireWeatherMod

use FatesConstantsMod, only : r8 => fates_r8

implicit none
private

type, abstract, public :: fire_weather
real(r8) :: fire_weather_index ! fire weather index
contains
procedure(calc_fire_weather), public, deferred :: Calculate
end type fire_weather

abstract interface
subroutine calc_fire_weather(this, temp_C, precip, rh)
use FatesConstantsMod, only : r8 => fates_r8
import :: fire_weather
class(fire_weather), intent(inout) :: this
real(r8), intent(in) :: temp_C
real(r8), intent(in) :: precip
real(r8), intent(in) :: rh
end subroutine calc_fire_weather
end interface

end module SFFireWeatherMod
Loading

0 comments on commit 2168641

Please sign in to comment.