lmweather authoring skill

Guidance for authoring, running, and verifying rotating shallow-water weather and climate dynamics programs on the lmweather host.

Purpose

Help write deterministic lmscript programs for lmweather that simulate idealized atmospheric and oceanic dynamics on a rotating sphere (spectral transform method, Williamson test cases) or on a beta-plane channel (staggered C-grid finite differences).

When to use it

Use lmweather when a task needs spherical shallow-water integrations, Williamson benchmark cases (TC1 cosine-bell advection, TC2 steady geostrophic flow, TC5 mountain wave train, TC6 Rossby-Haurwitz wave), passive tracer transport, barotropic jet instability, or beta-plane Rossby, Kelvin, and gravity wave adjustments exported for plotting.

Install

Install the lmctl CLI toolchain with npm i -g @lmctl-ai/lmctl or download a release binary from GitHub Releases. Linux binaries require dynamic glibc 2.35 or newer (Ubuntu 22.04+) with C++ runtimes linked statically and zero external library dependencies. Bind install="github:lmctl-ai/lmweather@latest" on the _lmcode_ block so run_lmcode resolves or downloads the binary automatically.

Commands

lmscript rh.lms
lmweather --version
lmweather --notices
lmweather --lmcode-schema
lmweather --lmcode-schema --json
lmweather --lmcode-signatures
lmweather --dry-run --lmcode build/rh.dslb
lmweather --lmcode build/rh.dslb

Inputs and outputs

Safety rules

Worked examples

p = _lmcode_ cli="lmweather" install="github:lmctl-ai/lmweather@latest";
let s = wx.sphere(42).williamson6();
let m0 = s.mean_height();
let e0 = s.energy();
s.run_dt(7.0 * 86400.0, 900.0);
wx.print("crest of wave 4 at 45N: " + str(s.wave_crest(4, 45.0)) + " deg");
wx.assert_close(s.mean_height(), m0, 0.000000001);
wx.assert_close(s.energy() / e0, 1.0, 0.0001);
s.save_csv("rh_day7.csv");

let ch = wx.plane(128, 64, 6400000.0, 3200000.0)
  .depth(1000.0)
  .coriolis(0.0001, 1.6e-11)
  .linear()
  .fields("10.0 * exp(-((x - 0.5*lx)*(x - 0.5*lx) + (y - 0.5*ly)*(y - 0.5*ly)) / (300000.0*300000.0))", "0", "0");
ch.run(86400.0);
wx.assert_close(ch.mean_depth(), 1000.0, 0.0001);
ch.save_row(32, "ridge_midline.dat");
end _lmcode_
r = run_lmcode(p);
require(r.ok, "lmweather simulation failed");

Errors and exit codes

Exit 0 indicates that all bytecode slots loaded and completed. Exit 2 reports invalid command-line syntax, contradictory --dry-run flags, or an invalid LMWEATHER_MAX_MEMORY_MB setting. Exit 3 reports bytecode load or schema errors, expression syntax failures, RK4 CFL stability limit violations, non-finite divergence during integration, invalid method ordering (such as calling Plane.depth after Plane.fields or querying tracer metrics without a tracer), failed assertions, or memory budget exhaustion. Exit 4 reports application failures tagged APP_FAIL.

How to verify

  1. Run lmweather --version and lmweather --lmcode-schema --json to verify the binary version and embedded schema contract.
  2. Validate compiled bytecode without running time integrations by passing --dry-run --lmcode.
  3. Check mass conservation with wx.assert_close(s.mean_height(), m0, 1e-9) on the sphere or wx.assert_close(p.mean_depth(), H0, 1e-9) on the plane.
  4. Check energy conservation (s.energy() / e0 near 1.0), normalized Williamson errors (s.error_l2(), s.error_linf()), or linear potential vorticity conservation (p.pv_anomaly_rms()).