glm-config-management
Managing and modifying GLM configuration files (glm3.nml) for calibration. Use this skill whenever you need to safely update GLM parameters, preserve non-calibration settings, validate configuration syntax, or manage multiple parameter sets. Essential for iterative calibration workflows where parameters must change reliably without corrupting the config.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- glm-config-management
- description
- Managing and modifying GLM configuration files (glm3.nml) for calibration. Use this skill whenever you need to safely update GLM parameters, preserve non-calibration settings, validate configuration syntax, or manage multiple parameter sets. Essential for iterative calibration workflows where parameters must change reliably without corrupting the config.
03 SKILL.md 正文
GLM Configuration File Management
Configuration File Format
GLM uses Fortran namelist format (.nml files). Structure:
§ion_name
parameter1 = value1
parameter2 = value2
/
Key rules:
- Sections delimited by
§ion_name(start) and/(end) - Each parameter on its own line
- Values must match Fortran types (reals for decimals, integers for ints, strings in quotes, logicals .true./.false.)
- Commas optional but allow consistency
- Comments not allowed in namelist sections
Calibration-Safe Parameter Updates
Parameters You CAN Modify
In &light:
Kw: Real number, currently ~0.3
In &mixing:
coef_mix_hyp: Real number, currently ~0.5
In &meteorology:
wind_factor: Real number, currently ~1.0lw_factor: Real number, currently ~1.0ch: Real number, currently ~0.0013
Parameters You MUST NOT MODIFY
&meteorology:
sw_factor(solar shortwave multiplier)cd(drag coefficient)ce(evaporation coefficient)
&init_profiles:
the_depths(initial depth levels)the_temps(initial temperatures)the_sals(initial salinities)
All other sections:
- Time period, morphometry, inflows, outflows, etc.
Safe Update Procedure
Python Method (Recommended)
import re
def update_glm_parameter(nml_file, section, param, value):
"""
Update a single parameter in GLM config, preserving all else.
Args:
nml_file: Path to glm3.nml
section: Section name (e.g., 'light', 'mixing', 'meteorology')
param: Parameter name (e.g., 'Kw', 'wind_factor')
value: New value (will be formatted appropriately)
"""
with open(nml_file, 'r') as f:
content = f.read()
# Build regex pattern for the parameter line
# Matches: param = value (with possible whitespace, commas)
pattern = rf'({param}\s*=\s*)[-+]?\d*\.?\d+([eE][-+]?\d+)?'
# Format value
if isinstance(value, float):
replacement = rf'\g<1>{value}'
else:
replacement = rf'\g<1>{value}'
# Replace only first occurrence (assumes one per section)
content_new = re.sub(pattern, replacement, content, count=1)
# Verify replacement happened
if content == content_new:
raise ValueError(f"Parameter {param} not found in &{section}")
# Write back
with open(nml_file, 'w') as f:
f.write(content_new)
print(f"Updated {section}.{param} to {value}")
# Usage:
update_glm_parameter('/root/glm3.nml', 'light', 'Kw', 0.35)
update_glm_parameter('/root/glm3.nml', 'mixing', 'coef_mix_hyp', 0.45)
Bash Method (Using sed)
# Update Kw in &light section
sed -i 's/Kw = [0-9.e]*/Kw = 0.35/' /root/glm3.nml
# Verify update
grep -A 5 '&light' /root/glm3.nml | grep Kw
Warning: Bash sed is fragile with Fortran format. Use Python for safety.
Validation Procedures
Syntax Check (Python)
import f90wrap # or similar parser
# Can validate Fortran namelist format
# OR simply run: glm --help (if supported)
Functional Check
cd /root
glm # Will fail with clear error if config is invalid
# If GLM runs without error, config is OK
Diff Before/After
diff -u glm3.nml.backup glm3.nml
Parameter Ranges and Defaults
| Parameter | Section | Min | Default | Max | Type |
|---|---|---|---|---|---|
| Kw | light | 0.1 | 0.3 | 0.5 | real |
| coef_mix_hyp | mixing | 0.3 | 0.5 | 0.7 | real |
| wind_factor | meteorology | 0.7 | 1.0 | 1.3 | real |
| lw_factor | meteorology | 0.7 | 1.0 | 1.3 | real |
| ch | meteorology | 0.0005 | 0.0013 | 0.002 | real |
| sw_factor | meteorology | - | 0.95 | - | (locked) |
| cd | meteorology | - | 0.0013 | - | (locked) |
| ce | meteorology | - | 0.0013 | - | (locked) |
Backup Strategy
Before starting calibration:
cp /root/glm3.nml /root/glm3.nml.backup
If config becomes corrupted, restore:
cp /root/glm3.nml.backup /root/glm3.nml
Multi-Iteration Record
For tracking iterations, use a log:
{
"iteration": 1,
"parameters": {
"Kw": 0.30,
"coef_mix_hyp": 0.50,
"wind_factor": 1.0,
"lw_factor": 1.0,
"ch": 0.0013
},
"rmse": {
"overall": 1.82,
"annual_deep": 1.90,
"summer_deep": 1.95
},
"timestamp": "2024-03-23T10:30:00Z"
}
This allows retracing steps if needed.
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.