3 Downloading and compiling TRIGRS
3.1 Download the source code
Download the official 2.1.0 release from the USGS GitLab: https://code.usgs.gov/usgs/landslides-trigrs/-/releases/v2.1.0
Extract the .zip into a working folder, for example C:\TRIGRS\landslides-trigrs-2.1.0\. The src\ folder contains four programs:
| Program | Purpose |
|---|---|
TRIGRS |
Main model: transient infiltration + factor of safety |
TopoIndex |
Topographic preprocessor: runoff routing and array sizing |
GridMatch |
Checks whether the input grids are congruent with each other |
UnitConvert |
Unit conversion of the grids |
3.2 Compile
Open PowerShell in the src\ folder of the extracted source code and run the four blocks below. The order of the files matters (modules first) — copy and paste them exactly:
# TopoIndex
gfortran -O2 -w -static -o topoindex.exe TopoIndex\ssizgrd.f95 TopoIndex\tpindx.f90 `
TopoIndex\nxtcel.f90 TopoIndex\isvgrd.f TopoIndex\mpfldr.f TopoIndex\rdflodir.f `
TopoIndex\sindex.f TopoIndex\slofac.f TopoIndex\srdgrd1.f# TRIGRS (serial version — handles small and medium watersheds in seconds)
gfortran -O2 -w -static -o trigrs.exe TRIGRS\grids.f95 TRIGRS\input_file_defs.f95 `
TRIGRS\input_vars.f95 TRIGRS\model_vars.f95 TRIGRS\dsimps.f95 TRIGRS\iverson.f95 `
TRIGRS\pstpi.f95 TRIGRS\satfin.f95 TRIGRS\savage.f95 TRIGRS\steady.f95 TRIGRS\trini.f95 `
TRIGRS\unsinf.f95 TRIGRS\ivestp.f95 TRIGRS\pstpf.f95 TRIGRS\rnoff.f95 TRIGRS\satinf.f95 `
TRIGRS\smallt.f95 TRIGRS\svgstp.f95 TRIGRS\unsfin.f95 TRIGRS\unsth.f95 TRIGRS\ssizgrd.f95 `
TRIGRS\svlist.f95 TRIGRS\trigrs.f90 TRIGRS\flux.f90 TRIGRS\prpijz.f90 TRIGRS\svxmdv.f90 `
TRIGRS\svijz.f90 TRIGRS\dzero_brac.f90 TRIGRS\calerf.f TRIGRS\dbsct.f TRIGRS\derfc.f `
TRIGRS\irdgrd.f TRIGRS\irdswm.f TRIGRS\isvgrd.f TRIGRS\roots.f TRIGRS\srdgrd.f `
TRIGRS\srdswm.f TRIGRS\ssvgrd.f# GridMatch
gfortran -O2 -w -static -o gridmatch.exe GridMatch\ssizgrd.f95 GridMatch\gridmatch.f90 `
GridMatch\srdgrd.f GridMatch\ssvgrd.f# UnitConvert (this one needs the -fdec flag because of a legacy Fortran format in the code)
gfortran -O2 -w -static -fdec -o unitconvert.exe UnitConvert\unitconvert.f90 `
UnitConvert\srdgrd.f UnitConvert\ssvgrd.fAt the end, the src\ folder will contain topoindex.exe, trigrs.exe, gridmatch.exe, and unitconvert.exe. Keep them in a bin\ folder — they will be copied into the folder of each project/run.
The Makefile that comes with the code uses mpif90 (MPI) and also compiles a parallel version (trigrs_p), useful for very large areas. It is not needed for this short course — the serial version above is sufficient.
3.3 What the compiler options mean
| Option | Effect |
|---|---|
-O2 |
Optimization (faster code) |
-w |
Suppresses style warnings from the legacy code (harmless) |
-static |
Embeds the libraries in the executable — this is what avoids the DLL problem |
-fdec |
Accepts legacy DEC extensions (needed only for UnitConvert) |