Knowledge-Augmented Large Language Model for Autonomous MODFLOW 6 Input File Generation.
A large language model (LLM) coding agent can build complete MODFLOW 6 input file sets from natural-language descriptions when given the right reference material, without retraining the model. The reference material, which we call a plugin, comprises 42 plain-text package files (one per MODFLOW 6 package, written from the official Input/Output Guide, the Fortran source code, and the simulator's runtime error messages), plus seven workflow files and one configuration file. A suite of 59 pass-or-fail checks covered five tasks: steady-state flow, transient flow with pumping, coupled flow and solute transport, coupled flow and heat transport, and validation of an existing model. On the unmodified plugin, 52 of 59 checks passed (88%); the seven failures were all runtime errors, six of them caused by constraints spanning more than one input file. Two independent improvement strategies followed: an expert-guided batch correction and an automated one-failure-at-a-time loop. Both reached 59 of 59 (100%) and modified the same four skill files; the expert-guided strategy, which identified five root causes, made one additional edit to a workflow command file. This convergence indicates that the failures came from gaps in the reference files, not from random variation in the model's output. The automated loop required no human intervention. The methodology has been replicated on a sibling simulator (MODFLOW USG-Transport; Krčmář et al. 2026b) with 100% first-attempt success. The result is a reusable design pattern for adapting an LLM coding agent to a scientific simulator without retraining the model.