Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-cfe2.0_cleanup #121

Merged
merged 18 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/ngen_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,17 @@ jobs:
rm -rf extern/cfe/cfe/*
mv ${{runner.temp}}/cfe/* extern/cfe/cfe

- name: Run Ngen Test for CFE Couple with PET
- name: PET (checkout master -- remove later)
run: |
git submodule update --remote extern/evapotranspiration/evapotranspiration

- name: Run NGen Test for CFE (cfe1.0) Coupled with PET
run: |
mv ${{ steps.ngen_id1.outputs.build-dir }} ./ngen-build/
inputfile='extern/cfe/cfe/realizations/realization_cfe_pet_surfgiuh.json'
./ngen-build/ngen ./data/catchment_data.geojson "cat-27" ./data/nexus_data.geojson "nex-26" $inputfile

- name: Run Ngen Test for CFE (cfe2.0) Coupled with PET
run: |
inputfile='extern/cfe/cfe/realizations/realization_cfe_pet_surfnash.json'
./ngen-build/ngen ./data/catchment_data.geojson "cat-27" ./data/nexus_data.geojson "nex-26" $inputfile
53 changes: 34 additions & 19 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ make && cd ..
```
### Run
<pre>
Run: <a href="https://github.com/NOAA-OWP/cfe/blob/master/run_cfe.sh">./run_cfe.sh</a> BASE
<a href="https://github.com/NOAA-OWP/cfe/blob/master/run_cfe.sh">./run_cfe.sh</a> BASE
</pre>

## Example 2 (pseudo framework mode)
Expand All @@ -34,7 +34,7 @@ make && cd ..
```
### Run
<pre>
Run: <a href="https://github.com/NOAA-OWP/cfe/blob/master/run_cfe.sh">./run_cfe.sh</a> FORCING
<a href="https://github.com/NOAA-OWP/cfe/blob/master/run_cfe.sh">./run_cfe.sh</a> FORCING
</pre>

## Example 3 (pseudo framework mode)
Expand All @@ -46,7 +46,7 @@ make && cd ..
```
### Run
<pre>
Run: <a href="https://github.com/NOAA-OWP/cfe/blob/master/run_cfe.sh">./run_cfe.sh</a> FORCINGPET
<a href="https://github.com/NOAA-OWP/cfe/blob/master/run_cfe.sh">./run_cfe.sh</a> FORCINGPET
</pre>

## Example 4 (pseudo framework mode)
Expand All @@ -63,35 +63,47 @@ make && cd ..
```
### Run
<pre>
Run: <a href="https://github.com/NOAA-OWP/cfe/blob/master/run_cfe.sh">./run_cfe.sh</a> AETROOTZONE
<a href="https://github.com/NOAA-OWP/cfe/blob/master/run_cfe.sh">./run_cfe.sh</a> AETROOTZONE
</pre>

## Example 5 (nextgen framework mode)
This example couples CFE with PET. Nextgen framework reads the forcing data and passes data to CFE and PET using BMIs. The example uses CAMELS catchment-87 data. (Notation: NGEN)
### Build
See general instructions [here](https://github.com/NOAA-OWP/ngen/wiki/NGen-Tutorial) or [here](https://github.com/NOAA-OWP/SoilFreezeThaw/blob/master/INSTALL.md#build-2) to build and run models in the ngen framework.
**NOTE:** `NGEN_WITH_EXTERN_ALL=ON` builds CFE, SLoTH, and PET models needed for CFE runs. So below some of the steps are optional and only needed if working with unpinned versions; note ngen points to a specific release of each model.

- ### Specific instructions for building nextgen and models needed for the example here
- git clone https://github.com/noaa-owp/ngen && cd ngen
- git submodule update --init --recursive
- #### fortran bmi
- cmake -B extern/iso_c_fortran_bmi/cmake_build -S extern/iso_c_fortran_bmi
- make -C extern/iso_c_fortran_bmi/cmake_build
- #### build ngen
- cmake -B cmake_build -S . -DBMI_C_LIB_ACTIVE=ON -DBMI_FORTRAN_ACTIVE=ON -DNGEN_ACTIVATE_PYTHON=ON
- cmake -B cmake_build -S . -DNGEN_WITH_BMI_C=ON -DNGEN_WITH_BMI_FORTRAN=ON -DNGEN_WITH_EXTERN_ALL=ON
- make -j4 -C cmake_build
- #### CFE

- #### CFE (optional)
- git submodule update --remote extern/cfe/cfe
- cmake -B extern/cfe/cfe/cmake_build -S extern/cfe/cfe/ -DNGEN=ON
- make -C extern/cfe/cfe/cmake_build
- #### SLoTH
SLoTH is also needed to run SFT in the ngen framework. SLoTH is a BMI that is used to set a bmi variable(s) that is not provided by other BMIs but required by the model. So build [SLoTH](https://github.com/NOAA-OWP/SLoTH) using the following instructions

- #### PET (optional)
ajkhattak marked this conversation as resolved.
Show resolved Hide resolved
- git submodule update --remote extern/evapotranspiration/evapotranspiration
- cmake -B extern/evapotranspiration/evapotranspiration/cmake_build -S extern/evapotranspiration/evapotranspiration/
- make -C extern/evapotranspiration/evapotranspiration/cmake_build/

- #### SLoTH (optional)
SLoTH is a BMI that is used to set a bmi variable(s) that is not provided by other BMIs but required by the model. So build [SLoTH](https://github.com/NOAA-OWP/SLoTH) using the following instructions
- cd extern/sloth/ && git checkout latest
- git submodule update --init --recursive
- cd ../..
- cmake -B extern/sloth/cmake_build -S extern/sloth/
- make -C extern/sloth/cmake_build

- #### SMP (Needed only if CFE coupling to SoilMoistureProfiles is needed for AET rootzone based simulations)
- git submodule update --remote extern/SoilMoistureProfiles/SoilMoistureProfiles
- cmake -B extern/SoilMoistureProfiles/SoilMoistureProfiles/cmake_build -S extern/SoilMoistureProfiles/SoilMoistureProfiles -DNGEN=ON
- make -C extern/SoilMoistureProfiles/SoilMoistureProfiles/cmake_build

### Run
The following pre-process step needs to be completed before running the example.
The following pre-process step needs to be completed before running the examples.
#### Pre-process step
```
mkdir cfe && cd cfe
Expand All @@ -103,31 +115,34 @@ The following pre-process step needs to be completed before running the example.
**Note:** Make sure the "library_file" and "init_config" in the BMI blocks in the realization file are pointing to the right files, these paths depend on how you build your models.

```
Run: ../cmake_build/ngen data/catchment_data.geojson cat-27 data/nexus_data.geojson nex-26 realizations/realization_cfe_pet_surfgiuh.json
../cmake_build/ngen data/catchment_data.geojson cat-27 data/nexus_data.geojson nex-26 realizations/realization_cfe_pet_surfgiuh.json
```
```
../cmake_build/ngen data/catchment_data.geojson cat-27 data/nexus_data.geojson nex-26 realizations/realization_cfe_pet_surfnash.json
```

## Alternative: Compiling and Running CFE
### Example 1. Read local forcing file
To compile and run CFE with locally read forcing data, run the following from the command line:

1. `gcc -lm -Iinclude ./src/main.c ./src/cfe.c ./src/bmi_cfe.c ./src/giuh.c ./src/conceptual_reservoir.c -o cfe_base`. This will generate an executable called `cfe_base`.
2. Then run the model with example forcing data: `./cfe_base ./configs/cat_58_bmi_config_cfe.txt`
1. `gcc -lm -Iinclude ./src/main.c ./src/cfe.c ./src/bmi_cfe.c ./src/giuh.c ./src/conceptual_reservoir.c ./src/nash_cascade.c -o cfe_base`. This will generate an executable called `cfe_base`.
2. Then run the model with example forcing data: `./cfe_base ./configs/cfe_config_cat_87.txt`


### Example 2. CFE Model gets forcings passed from BMI

CFE was designed to read its own forcing file, but we have added an option to get forcings passed in through BMI using its `set_value` functionality. To demonstrate this functionality we have included the BMI-enabled AORC forcing read module. Follow the steps below:

1. `gcc -lm -Iinclude ./src/main_pass_forcings.c ./src/cfe.c ./src/bmi_cfe.c ./src/giuh.c ./src/conceptual_reservoir.c . ./extern/aorc_bmi/src/aorc.c ./extern/aorc_bmi/src/bmi_aorc.c -o cfe_forcing`. This generates an executable called `cfe_forcing`.
1. `gcc -lm -Iinclude ./src/main_pass_forcings.c ./src/cfe.c ./src/bmi_cfe.c ./src/giuh.c ./src/conceptual_reservoir.c ./src/nash_cascade.c ./extern/aorc_bmi/src/aorc.c ./extern/aorc_bmi/src/bmi_aorc.c -o cfe_forcing`. This generates an executable called `cfe_forcing`.

2. To run this executable you must pass the path to the corresponding configuration files for **BOTH** CFE and AORC (in that order): `./cfe_forcing ./configs/cat_89_bmi_config_cfe_pass.txt ./configs/cat_89_bmi_config_aorc.txt`
2. To run this executable you must pass the path to the corresponding configuration files for **BOTH** CFE and AORC (in that order): `./cfe_forcing ./configs/cfe_config_cat_87_pass.txt ./extern/aorc_bmi/configs/aorc_config_cat_87.txt`

### Example 3. CFE Model gets forcings AND potential evapotranspiration passed from BMI
CFE can remove mass from the modeled system through evapotranspiration (directly from precipitation and from the soil using the Budyko function). Follow the steps below:

1. `gcc -lm -Iinclude ./src/main_cfe_aorc_pet.c ./extern/evapotranspiration/src/pet.c ./extern/evapotranspiration/src/bmi_pet.c ./src/cfe.c ./src/bmi_cfe.c ./src/giuh.c ./src/conceptual_reservoir.c ./extern/aorc_bmi/src/aorc.c ./extern/aorc_bmi/src/bmi_aorc.c -o cfe_forcingpet`. This generates an executable called `cfe_forcingpet`.
1. `gcc -lm -Iinclude ./src/main_cfe_aorc_pet.c ./extern/evapotranspiration/src/pet.c ./extern/evapotranspiration/src/bmi_pet.c ./src/cfe.c ./src/bmi_cfe.c ./src/giuh.c ./src/conceptual_reservoir.c ./src/nash_cascade.c ./extern/aorc_bmi/src/aorc.c ./extern/aorc_bmi/src/bmi_aorc.c -o cfe_forcingpet`. This generates an executable called `cfe_forcingpet`.

2. To run this executable you must pass the path to the corresponding configuration files for CFE, PET and AORC (in that order): `./cfe_forcingpet ./configs/cat_89_bmi_config_cfe_pass.txt ./configs/cat_89_bmi_config_aorc.txt ./configs/cat_89_bmi_config_pet_pass.txt`
2. To run this executable you must pass the path to the corresponding configuration files for CFE, PET and AORC (in that order): `./cfe_forcingpet ./configs/cfe_config_cat_87_pass.txt ./extern/aorc_bmi/configs/aorc_config_cat_87.txt ./extern/evapotranspiration/configs/pet_config_cat_87_pass.txt`

### Example 4.
CFE rootzone-based example couples C and C++ modules and should be built with cmake, follow the instructions [here](https://github.com/NOAA-OWP/cfe/blob/master/INSTALL.md#example-4-pseudo-framework-mode).
Expand Down
10 changes: 5 additions & 5 deletions configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ Example configuration files are provided in this directory. To build and run the
| gw_storage | *double* | | meters/meters [m/m] | parameter_adjustable | | initial condition for groundwater reservoir - it is the ground water as a decimal fraction of the maximum groundwater storage (max_gw_storage) for the initial timestep |
| alpha_fc | *double* | | | parameter_adjustable | | field capacity |
| soil_storage| *double* | | meters/meters [m/m] | parameter_adjustable | | initial condition for soil reservoir - it is the water in the soil as a decimal fraction of maximum soil water storage (smcmax * depth) for the initial timestep |
| N_nash | *int* | | | parameter_adjustable | | number of Nash lf reservoirs (optional, defaults to 2, ignored if storage values present) |
| K_nash | *double* | | 1/meters [m^-1] | parameter_adjustable | subsurface runoff | Nash Config param for lateral subsurface runoff |
| N_nash_subsurface | *int* | | | parameter_adjustable | | number of Nash lf reservoirs (optional, defaults to 2, ignored if storage values present) |
| K_nash_subsurface | *double* | | 1/meters [m^-1] | parameter_adjustable | subsurface runoff | Nash Config param for lateral subsurface runoff |
| *K_lf | *double* | | | parameter_adjustable | | Nash Config param - primary reservoir |
| nash_storage | *double* | | | parameter_adjustable | | Nash Config param - secondary reservoir |
| nash_storage_subsurface | *double* | | | parameter_adjustable | | Nash Config param - secondary reservoir |
| giuh_ordinates | *double* | | | parameter_adjustable | | Giuh ordinates in dt time steps |
| num_timesteps | *int* | | | time_info | | set to `1` if `forcing_file=BMI` |
| verbosity | *int* | `0`-`3` | | option | | prints various debug and bmi info |
| surface_water_partitioning_scheme | *char* | `Xinanjiang` or `Schaake` | | parameter_adjustable | infiltraton exces | |
| verbosity | *int* | `0`-`3` | | optional | | prints various debug and bmi info (defaults to 0) |
| surface_water_partitioning_scheme | *char* | `Xinanjiang` or `Schaake` | | parameter_adjustable | infiltraton excess | |
| surface_runoff_scheme | *char* | GIUH or NASH_CASCADE | | parameter_adjustable | surface runoff | also supports 1 for GIUH and 2 for NASH_CASCADE; default is GIUH |
| N_nash_surface | *int* | | | parameter_adjustable | surface runoff | number of Nash reservoirs for surface runoff |
| K_nash_surface | *double* | | 1/hour [h^-1] | parameter_adjustable | surface runoff | Nash Config param for surface runoff |
Expand Down
17 changes: 0 additions & 17 deletions configs/cat_58_bmi_config_aorc.txt

This file was deleted.

24 changes: 0 additions & 24 deletions configs/cat_58_bmi_config_cfe.txt

This file was deleted.

23 changes: 0 additions & 23 deletions configs/cat_58_bmi_config_cfe_pass.txt

This file was deleted.

17 changes: 0 additions & 17 deletions configs/cat_87_bmi_config_aorc.txt

This file was deleted.

21 changes: 0 additions & 21 deletions configs/cat_87_bmi_config_pet_pass.txt

This file was deleted.

17 changes: 0 additions & 17 deletions configs/cat_89_bmi_config_aorc.txt

This file was deleted.

23 changes: 0 additions & 23 deletions configs/cat_89_bmi_config_cfe.txt

This file was deleted.

23 changes: 0 additions & 23 deletions configs/cat_89_bmi_config_cfe_pass.txt

This file was deleted.

21 changes: 0 additions & 21 deletions configs/cat_89_bmi_config_pet_pass.txt

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ soil_params.depth=2.0[m]
soil_params.b=4.05[]
soil_params.satdk=0.00000338[m s-1]
soil_params.satpsi=0.355[m]
soil_params.slop=1.0[m/m]
soil_params.slop=0.01[m/m]
soil_params.smcmax=0.439[m/m]
soil_params.wltsmc=0.066[m/m]
soil_params.expon=1.0[]
Expand All @@ -19,6 +19,12 @@ K_lf=0.01[]
nash_storage=0.0,0.0
giuh_ordinates=0.06,0.51,0.28,0.12,0.03
num_timesteps=1
verbosity=2
verbosity=1
surface_runoff_scheme=GIUH
surface_water_partitioning_scheme=Schaake
#surface_water_partitioning_scheme=Xinanjiang
#a_Xinanjiang_inflection_point_parameter=1
#b_Xinanjiang_shape_parameter=1
#x_Xinanjiang_shape_parameter=1
#urban_decimal_fraction=0.0

Loading
Loading