diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..cd1cf3b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.14) + +project(ecoslim LANGUAGES Fortran) + +find_package(OpenMP) + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(DEBUG_FLAGS "-ffpe-trap=zero,overflow,underflow -fbacktrace -fbounds-check") +endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(DEBUG_FLAGS "-check bounds") +endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI") + set(DEBUG_FLAGS "-C") +endif() + +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${DEBUG_FLAGS}") + +set(SOURCE ran1.mod.f90 EcoSLIM.f90 pfb_read.f90 vtk_write.f90 vtk_write_points.f90) + +add_executable(EcoSLIM.exe ${SOURCE}) + +if(OpenMP_Fortran_FOUND) + target_link_libraries(EcoSLIM.exe PUBLIC OpenMP::OpenMP_Fortran) +endif() diff --git a/Makefile b/Makefile.orig similarity index 100% rename from Makefile rename to Makefile.orig diff --git a/README.md b/README.md index 1f6b667..d6deb6f 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,21 @@ For more details on the model and if you use EcoSLIM in published work please ci Building and Running -------------------- -To build *EcoSLIM* simply type `make` in the directory with the main directory where `EcoSLIM.f90` sits. +To build *EcoSLIM* first use CMake to configure the build. EcoSLIM will build with OpenMP if it is found by CMake. + +``` +mkdir build +cd build +cmake .. +``` + +The next step is to build *EcoSLIM* + +``` +make +``` + +If this is successful there should be an `EcoSLIM.exe` executable in the build directory. To set the number of parallel threads use either `export OMP_NUM_THREADS=16` for bash or @@ -23,9 +37,9 @@ To set the number of parallel threads use either To run you will need to have a completed *ParFlow* simulation and an *EcoSLIM* input file that must be named `slimin.txt` and follow the format described below. Note that the slim input file does not need to be co-located -with the ParFlow simulation. +with the ParFlow simulation. -To run simply execute `EcoSLIM.exe` from the directory that contains the +To run simply execute the `EcoSLIM.exe` binary in the directory that contains the `slimin.txt` input file. Refer to the *Examples* directory described below for example workflows @@ -216,3 +230,22 @@ is provided here. For more details on how to run the examples refer to the readme files in that directory. Note that the *testing* folder contains tests that were used for development purposes and which are not necessarily maintained with updated versions. User should refer only to the *Examples* folder. 1. **ParFlow_SteadyFlux**: A hillslope domain with constant recharge and ET applied at the top and bottom of the hill respectively. Example is setup to run *EcoSLIM* on transient *ParFlow* outputs without *CLM*. The documentation for this example includes all the steps for running *ParFlow* and *EcoSLIM* 2. **Hillslope_Simulations/paper_cases**:Hillslope Cases Run in [Maxwell et al. Ecohydrology](https://doi.org/10.1002/eco.2042), see readme file for more details + + +FAQ +--------------- + +If you wish to build *EcoSLIM* with debugging enabled, use the +standard method of setting the CMake build type to debug: + +``` +cmake -DCMAKE_BUILD_TYPE=debug .. +``` + +Explicitly controlling the Fortran compiler used is done by setting +the FC environment variable for the CMake configure, here we use the +Intel Fortran compiler: + +``` +FC=ifort cmake .. +```