GCN10 is a high-resolution, open-source global Curve Number (CN) dataset generator. It combines ESA WorldCover land cover data and HYSOGs250m soil data to create CN rasters suitable for hydrologic modeling and runoff estimation.
- GCN10: Global Curve Number 10m
- Acknowledgments
src/: C MPI Program for parallelized CN generation.landcover/: ESA WorldCover 2021 land cover virtual raster.hsg/: HYSOGs250m hydrologic soil group raster.blocks/: Block shapefile defining spatial extents for processing.lookups/: Lookup tables mapping land cover and HSG to CN values.archive/python/: Python scripts for serial and parallel CN raster generation.hybrid/: Hybrid MPI/OpenMP C program for CN computation.gee/: Google Earth Engine script for dynamic CN raster generation.arcs/: Quarto reports and reproducible documentation for Antecedent Runoff Condition.
Clone the repository:
# ~/usr/local/src or wherever you want to compile
[ -d ~/usr/local/src ] || mkdir -p ~/usr/local/src
cd ~/usr/local/src
git clone https://github.com/clawrim/gcn10
# or if you have SSH enabled
git clone git@github.com:clawrim/gcn10.git
cd gcn10/Make sure the following directories contain the required input files:
landcover/esa_worldcover_2021.vrthsg/HYSOGs250m.tifblocks/esa_extent_blocks.shplookups/default_lookup_*.csv
- MPI: Required for parallel processing (MS-MPI on Windows).
- GDAL/OGR: Required for geospatial raster and vector operations.
- CMake: Required for building the project (version 3.12+).
- C Compiler: gcc (Linux) or MSVC (Visual Studio 2022 on windows).
(
cd src
[ -d build ] && rm -rf build
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/usr/local && cmake --build . -v &&
cmake --install .
)Ensure development packages for GDAL, MPI (e.g., MPICH/OpenMPI), and OpenMP are installed.
- Download: https://visualstudio.microsoft.com/vs/
- Install the "Desktop development with C++" workload.
Install both the SDK and the Runtime:
-
MPI SDK Download: https://www.microsoft.com/en-us/download/details.aspx?id=100593 File:
msmpisdk.msi -
MPI Runtime Download: https://www.microsoft.com/en-us/download/details.aspx?id=100593
File:msmpisetup.exe
After installation:
- MPI SDK path:
C:\Program Files (x86)\Microsoft SDKs\MPI - MPI Runtime path:
C:\Program Files\Microsoft MPI\Bin
Add to your system PATH:
C:\Program Files\Microsoft MPI\Bin
- Download the OSGeo4W installer: https://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe
- Choose Advanced Install.
- Select and install the following packages:
gdal(runtime)gdal-dev(headers andgdal_i.lib)
After installation:
- GDAL include:
C:\OSGeo4W\include - GDAL lib:
C:\OSGeo4W\lib\gdal_i.lib
Add to your PATH:
C:\OSGeo4W\bin
Download from CMake and install
Either open x64 Native Tools Command Prompt for VS 2022, or run manually:
"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvars64.bat"Replace USERNAME with your user.
cd C:\USERNAME\gcn10\src
mkdir build
cd buildcmake .. -G "Visual Studio 17 2022" -A x64 ^
-DGDAL_INCLUDE_DIR="C:\OSGeo4W\include" ^
-DGDAL_LIBRARY="C:\OSGeo4W\lib\gdal_i.lib" ^
-DMPIEXEC_EXECUTABLE="C:\Program Files\Microsoft MPI\Bin\mpiexec.exe"Use ^ for line continuation in CMD.
cmake --build . --config ReleaseOutput will be located at:
build\Release\gcn10.exe
Your config.txt and input paths are relative to test, so copy the executable:
copy build\Release\gcn10.exe ..\Now your executable is located at:
C:\USERNAME\gcn10\src\gcn10.exe
Before compiling, load the required toolchain modules.
Versions may vary by the cluster, check module spider or module avail
for the correct ones.
On the New Mexico State Discovery cluster, the setup is;
module purge
module load spack/2023a
module load gcc/12.2.0-2023a-gcc_8.5.0-e643dqu
module load cmake/3.24.3-2023a-gcc_12.2.0-l6ogg2k
module load openmpi/4.1.4-2023a-gcc_12.2.0-slurm-pmix_v4-vv2mnh6
module load gdal/3.6.2-2023a-gcc_12.2.0-cuda-phafc4iCheck that the compilers and the libraries are visible
which mpicc mpicxx gdal-config cmake
mpicc -show
gdal-config --version- Assuming the source code is cloned (e.g.,
~/usr/local/src/gcn10by following Section 2.1)
(
cd src
[ -d build ] && rm -rf build
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/usr/local && cmake --build . -v &&
cmake --install .
)The executable (gcn10) will be installed in <CMAKE_INSTALL_PREFIX>/bin (e.g., ~/usr/local/bin following this Section).
This repository ships a standard conda recipe under conda/recipe/. The expected recipe files are:
conda/recipe/meta.yaml
conda/recipe/build.sh
conda/recipe/bld.bat
conda/recipe/conda_build_config.yaml
The build is driven by conda-build, with CMake invoked from the platform-specific recipe script. The commands below assume you start from the repository root.
The Unix-like build path is fully self-contained once Conda is installed. You do not need to drive CMake manually; conda-build creates the isolated build environment, resolves the recipe dependencies, and runs build.sh.
-
Ensure Conda is installed and initialized for your shell, then verify it is available:
conda --version
-
Install conda-build into the base environment:
conda activate base conda install -n base -c conda-forge conda-build
-
Clone the repository and enter it:
git clone https://github.com/mabdazzam/gcn10 cd gcn10 -
Build the package from the recipe:
conda activate base conda build conda/recipe -c conda-forge --override-channels
-
If you want to see the exact output filename and path without performing the full build, run:
conda build conda/recipe --output
-
Install the locally built package into a clean test environment:
conda create -y -n gcn10test conda activate gcn10test conda install -y -c local -c conda-forge gcn10 -
Verify the installation:
which gcn10 gcn10 --help gcn10 --version
-
Run a basic MPI launch from any directory containing a valid config.txt and blocks.txt:
mpiexec -n 4 gcn10 -c config.txt -l blocks.txt
The built package is written into Conda's local build cache under a platform directory such as conda-bld/linux-64/, conda-bld/osx-64/, or conda-bld/osx-arm64/. For a clean rebuild, remove old artifacts with:
conda build purge
conda build purge-allThe Windows build uses MSVC through the Visual Studio developer command prompt. Do not start from a plain cmd.exe session and do not try to drive the build outside the MSVC environment. Open the Visual Studio prompt first, activate Conda inside it, and then run conda-build.
-
Install Conda if it is not already installed.
-
Install Visual Studio Community Edition. During installation, make sure the following components are selected:
- MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
- Windows 11 SDK (10.0.26100.0)
-
From the Start menu, open:
x64 Native Tools Command Prompt for VS 2022 -
Inside that MSVC prompt, activate your Conda installation. Typical examples are:
CALL %USERPROFILE%\miniconda3\condabin\conda.bat activate base
or, for a system-wide install:
CALL C:\ProgramData\miniconda3\condabin\conda.bat activate baseIf you installed Anaconda instead of Miniconda, replace miniconda3 with anaconda3.
-
Confirm that the toolchain is available in the current session:
conda --version cl cmake --version
-
Install conda-build into base if needed:
conda install -n base -c conda-forge conda-build
-
Clone the repository and enter it:
git clone https://github.com/mabdazzam/gcn10 cd gcn10 -
Build the package from the recipe:
conda build conda\recipe -c conda-forge --override-channels
-
To print the exact output filename and path without performing the full build, run:
conda build conda\recipe --output
-
Install the locally built package into a clean test environment:
conda create -y -n gcn10test
conda activate gcn10test
conda install -y -c local -c conda-forge gcn10- Verify the installation:
where gcn10
gcn10 --help
gcn10 --version- Run a basic MPI launch from any directory containing a valid config.txt and blocks.txt:
mpiexec -n 4 gcn10 -c config.txt -l blocks.txtThe built Windows package is written into Conda's local build cache under conda-bld\win-64. For a clean rebuild, remove old artifacts with:
conda build purge
conda build purge-allA few practical checks are usually enough to diagnose failures quickly. If conda is not recognized, you did not activate Conda inside the MSVC prompt. If cl is not recognized, you are not in the Visual Studio developer prompt or the C++ tools were not installed. If the build succeeds but gcn10 is not found afterward, activate the test environment again and reinstall from -c local.
For testing the installation of the program on any OS:
cd test/
chmod a+x run_test.py && ./run_test.py
# or
python3 run_test.py
# this will run the test with 8 processes by default.If you want to change the number of processes;
./run_test.py n
# where n can be [1-8] e.g;
./run_test.py 4This will create progress log in logs/ subdirectory and output rasters in
cn_raster_drained and cn_raster_undrained subdirectories in the
gcn10/src/test/ directory.
NOTE: Running more that 8 blocks will not have any additional advantages because blocks.txt contains only 8 blocks
# use your CMAKE_INSTALL_PREFIX if it's different from $HOME/usr/local
# e.g., export PATH="<CMAKE_INSTALL_PREFIX>/bin:$PATH"
export PATH="$HOME/usr/local/bin:$PATH"
# serial
# start generating global CN rasters for all blocks
gcn10 -c config.txt
# serial with blocks list and overwrite
gcn10 -c config.txt -l blocks.txt -o
# parallel
# mpi (openmpi or mpich)
mpirun -n 4 gcn10 -c config.txt -o
# or (some setups)
mpiexec -n 4 gcn10 -c config.txt -oFrom the src\test\ directory:
:: serial
gcn10.exe -c config.txt
:: serial with block list + overwrite
gcn10.exe -c config.txt -l blocks.txt -o
:: mpi (ms-mpi)
mpiexec -n 4 gcn10.exe -c config.txt -o| Task | Command / Action |
|---|---|
| Install MSVC | Visual Studio 2022 + Desktop C++ workload |
| Install MPI | Install SDK + Runtime, add Runtime to PATH |
| Install GDAL | Use OSGeo4W: install gdal, gdal-dev, add bin to PATH |
| Configure with CMake | cmake .. -G ... -DGDAL_INCLUDE_DIR=... -DGDAL_LIBRARY=... |
| Build | cmake --build . --config Release |
| Copy executable | copy build\Release\gcn10.exe ..\ |
| Run | gcn10.exe -c config.txt [-l blocks.txt] [-o] |
-
If gcn10 crashes, check:
- Paths in config.txt are valid
- Input rasters and shapefiles exist
- You're in the correct working directory
-
If mpiexec fails:
- Ensure MPI Runtime is installed
- Ensure mpiexec.exe is in your system PATH
-
Read the log files in written rankwise in the logs/ subdir for other errors.
- 18 Cloud Optimized GeoTIFFs per block (9 drained, 9 undrained)
- Output directories:
cn_rasters_drained/cn_rasters_undrained/
- File naming:
cn_{hc}_{arc}_{block_id}.tif
We acknowledge the New Mexico Water Resources Research Institute (NM WRRI) and the New Mexico State Legislature for their support and resources, which were essential for this project. This work is funded by the NM WRRI and the New Mexico State Legislature under the grant number NMWRRI-SG-FALL2024.