General Lake Model (GLM) - Setup and Configuration
What is GLM?
GLM is a 1D hydrodynamic model that simulates vertical temperature, salinity, and density profiles in lakes and reservoirs. It solves energy and mass balance equations layer-by-layer.
Prerequisites
glm binary installed (check with which glm)
- Configuration file
glm3.nml in working directory
- Meteorological forcing CSV (
bcs/meteo.csv)
- Inflow/outflow CSVs
- Output directory must exist (
mkdir -p output)
Configuration File Structure (glm3.nml)
The file uses Fortran namelist format with §ion ... / blocks:
| Section |
Key Parameters |
Notes |
&glm_setup |
max_layers, layer thickness |
Layer resolution |
&light |
Kw (extinction coeff) |
Controls light penetration depth |
&mixing |
coef_mix_hyp, coef_mix_conv, etc. |
Vertical mixing strengths |
&morphometry |
H, A arrays |
Lake bathymetry (elevation-area) |
&time |
start, stop, dt |
Simulation period and timestep |
&output |
out_dir, out_fn, nsave |
NetCDF output control |
&init_profiles |
the_depths, the_temps |
Initial conditions |
&meteorology |
wind_factor, lw_factor, ch, cd, ce, sw_factor |
Met scaling and bulk transfer |
&inflow/&outflow |
inflow_fl, outflow_fl |
Hydrological boundary conditions |
&sediment |
sed_temp_mean, sed_heat_Ksoil |
Bottom boundary condition |
Running GLM
cd /path/to/config/dir
mkdir -p output
glm # reads glm3.nml, writes output/output.nc
GLM exits silently on success. Check for output/output.nc existence.
Output Structure (NetCDF)
temp[time, z] - water temperature (°C)
z[time, z] - height from lake bottom (m) - NOT depth from surface
time - time coordinate with units attribute for num2date conversion
Converting height to depth
surface_height = np.max(z[time_idx, :])
depth_from_surface = surface_height - z[time_idx, :]
Parameter Sensitivity for Lake Mendota
From calibration experiments:
- Kw (0.1-0.5): Most impactful. Higher values reduce deep heating, improve thermocline.
- wind_factor (0.7-1.3): Controls wind-driven mixing intensity. Lower = stronger stratification.
- lw_factor (0.7-1.3): Scales longwave radiation. Values < 1 cool the lake.
- coef_mix_hyp (0.3-0.7): Hypolimnetic mixing. Moderate values (0.4-0.5) balance deep temperature.
- ch (0.0005-0.002): Sensible heat transfer. Lower = less surface heat exchange.
Common Pitfalls
- Forgetting to create output directory before running
- Not preserving the exact nml format when editing (Fortran is picky)
- Confusing z (height from bottom) with depth from surface
- The
ch parameter regex can match catchrain if not careful - use \bch\s*= or match line context
1---2name: run2-glm-lake-modeling3description: Complete guide to setting up, running, and configuring the General Lake Model (GLM) for 1D lake temperature simulation.4metadata:5 source: https://skillmd.com/skills/cxcscmu/run2-glm-lake-modeling6---78# General Lake Model (GLM) - Setup and Configuration910## What is GLM?11GLM is a 1D hydrodynamic model that simulates vertical temperature, salinity, and density profiles in lakes and reservoirs. It solves energy and mass balance equations layer-by-layer.1213## Prerequisites14- `glm` binary installed (check with `which glm`)15- Configuration file `glm3.nml` in working directory16- Meteorological forcing CSV (`bcs/meteo.csv`)17- Inflow/outflow CSVs18- Output directory must exist (`mkdir -p output`)1920## Configuration File Structure (glm3.nml)21The file uses Fortran namelist format with `§ion ... /` blocks:2223| Section | Key Parameters | Notes |24|---------|---------------|-------|25| `&glm_setup` | max_layers, layer thickness | Layer resolution |26| `&light` | **Kw** (extinction coeff) | Controls light penetration depth |27| `&mixing` | **coef_mix_hyp**, coef_mix_conv, etc. | Vertical mixing strengths |28| `&morphometry` | H, A arrays | Lake bathymetry (elevation-area) |29| `&time` | start, stop, dt | Simulation period and timestep |30| `&output` | out_dir, out_fn, nsave | NetCDF output control |31| `&init_profiles` | the_depths, the_temps | Initial conditions |32| `&meteorology` | **wind_factor**, **lw_factor**, **ch**, cd, ce, sw_factor | Met scaling and bulk transfer |33| `&inflow`/`&outflow` | inflow_fl, outflow_fl | Hydrological boundary conditions |34| `&sediment` | sed_temp_mean, sed_heat_Ksoil | Bottom boundary condition |3536## Running GLM37```bash38cd /path/to/config/dir39mkdir -p output40glm # reads glm3.nml, writes output/output.nc41```42GLM exits silently on success. Check for `output/output.nc` existence.4344## Output Structure (NetCDF)45- `temp[time, z]` - water temperature (°C)46- `z[time, z]` - height from lake bottom (m) - NOT depth from surface47- `time` - time coordinate with units attribute for `num2date` conversion4849### Converting height to depth50```python51surface_height = np.max(z[time_idx, :])52depth_from_surface = surface_height - z[time_idx, :]53```5455## Parameter Sensitivity for Lake Mendota56From calibration experiments:571. **Kw** (0.1-0.5): Most impactful. Higher values reduce deep heating, improve thermocline.582. **wind_factor** (0.7-1.3): Controls wind-driven mixing intensity. Lower = stronger stratification.593. **lw_factor** (0.7-1.3): Scales longwave radiation. Values < 1 cool the lake.604. **coef_mix_hyp** (0.3-0.7): Hypolimnetic mixing. Moderate values (0.4-0.5) balance deep temperature.615. **ch** (0.0005-0.002): Sensible heat transfer. Lower = less surface heat exchange.6263## Common Pitfalls64- Forgetting to create output directory before running65- Not preserving the exact nml format when editing (Fortran is picky)66- Confusing z (height from bottom) with depth from surface67- The `ch` parameter regex can match `catchrain` if not careful - use `\bch\s*=` or match line context