Public interface

NEMO.NemoConfiguration — Type
NemoConfiguration(; name, source, output_directory, ...)

Everything needed to build, run, and identify one NEMO configuration: the source tree it was built from, the resulting library and run directory, the namelists that drive it, and a UUID so multiple configurations coexist on disk.

source
NEMO.NemoError — Type
NemoError(message)

Thrown when NEMO encounters a fatal error. The Fortran STOP is intercepted by the C error handler so the Julia process survives — the captured message travels back as this exception.

source
NEMO.NemoLibrary — Type
NemoLibrary(library_path, run_directory; verbose, mpi_communicator)

A loaded NEMO shared library bound to a single run directory. Construct it, then drive it with initialize!, step!, finalize!.

mpi_communicator is the raw integer MPI communicator handle. Pass -1 (or MPI_COMM_NULL from MPI.jl via the extension) to disable MPI.

source
NEMO.NemoNamelist — Type
NemoNamelist(groups, parameters)

A Fortran namelist file represented as ordered (group, parameters) pairs. Each group maps to an OrderedDict{Symbol, Any} so insertion order survives round-trips through read_namelist / write_namelist.

source
NEMO.ORCA2_ICE_configuration — Method
ORCA2_ICE_configuration(; source, output_directory, name = "NEMO_JULIA_ORCA2_ICE", mpi = false)

Build a NemoConfiguration for the ORCA2 + SI3 sea-ice setup (no biogeochemistry), derived from NEMO's ORCA2_ICE_PISCES reference configuration in cfgs/.

source
NEMO.build_nemo_library — Method
build_nemo_library(source, output_directory, configuration_name;
                   reference = "ORCA2_ICE_PISCES", academic = false, mpi = false)

Build NEMO as a shared library by invoking lib/build_nemo_library.sh. Returns the path to the resulting libnemo.{dylib,so}. The accompanying run directory is at output_directory/run.

  • source — path to a NEMO 4.2.x source tree (use download_nemo_source() to fetch one).
  • output_directory — destination for build artifacts and run directory.
  • configuration_name — name for the new configuration created from reference.
  • reference — NEMO configuration to derive from: a reference configuration in cfgs/ (e.g. "ORCA2_ICE_PISCES") or, with academic = true, a test case in tests/ (e.g. "CANAL").
  • academic — derive from a tests/ academic case (makenemo -a) instead of a cfgs/ reference configuration (makenemo -r).
  • my_src — user Fortran files (or directories of them) copied into the configuration's MY_SRC before compilation; NEMO compiles them with precedence over the base sources, which is how custom physics and idealized domains are set up.
  • mpi — build with MPI; MPI_HOME is resolved from mpifort on PATH if unset.
source
NEMO.build_nemo_library — Method
build_nemo_library(configuration::NemoConfiguration)

Build the library described by configuration, pulling the reference configuration, academic flag, MY_SRC files, and MPI setting from the struct.

source
NEMO.channel_configuration — Method
channel_configuration(; source, output_directory, name = "NEMO_JULIA_CANAL", mpi = false)

Build a NemoConfiguration for the re-entrant zonal channel, derived from NEMO's CANAL academic test case in tests/. CANAL is an idealized, ocean-only setup (no sea ice, no biogeochemistry) that generates its own initial state, so — unlike ORCA2_ICE_configuration — it needs no downloaded input files.

source
NEMO.clean_run_directory! — Method
clean_run_directory!(configuration::NemoConfiguration)

Remove the artifacts a previous NEMO run leaves in the run directory — restarts, diagnostic output files, the step/date trackers, and the .output/.stat logs — so the configuration can be re-run in place without rebuilding. NEMO ctl_stops at initialization when output files from a prior run are present; this clears them. Namelists, XML I/O definitions, the library, and staged input files (domain_cfg.nc, bathymetry, forcing) are kept. Returns the run directory.

source
NEMO.download_nemo_source — Method
download_nemo_source(; version = "4.2.2", branch = "branch_4.2", force = false)

Clone the NEMO source tree at the given version into a persistent cache directory and return its path. Subsequent calls return the cached path without re-cloning unless force = true.

A local NEMO source can be used instead by passing it via the NEMO_SOURCE environment variable; in that case this function returns the env-var value without touching the cache.

source
NEMO.download_orca2_ice_inputs — Method
download_orca2_ice_inputs(target_directory; release = "4.2.0", force = false)

Download and extract the SETTE input archive for ORCA2ICE (bathymetry, mesh, initial state, CORE-IA atmospheric forcing) into `targetdirectory. Thin wrapper around [downloadsetteinputs`](@ref).

source
NEMO.download_sette_inputs — Method
download_sette_inputs(name, target_directory; release = "4.2.0", force = false)

Download and extract the SETTE input archive <name>_v<release>.tar.gz (bathymetry, mesh, initial state, and forcing) into target_directory. This is the generic entry point for fetching the inputs of any SETTE-provided configuration — e.g. "ORCA2_ICE" or "AMM12". The tarball is cached so repeated calls only re-extract.

release selects which SETTE inputs version to fetch. Pass force = true to re-download even if the cache is populated.

source
NEMO.finalize! — Method
finalize!(lib::NemoLibrary)

Close NEMO files, run timer reports, then unload the shared library.

source
NEMO.get_temperature! — Function
get_temperature!(lib, array_3d)
set_temperature!(lib, array_3d)

Access NEMO's active temperature tracer. Under EOS-80 (ln_eos80 = .true.) this is potential temperature in °C; under TEOS-10 (ln_teos10 = .true.) it is Conservative Temperature in °C. The same memory slot in NEMO's ts array holds whichever variable the equation of state expects.

source
NEMO.initialize! — Method
initialize!(lib::NemoLibrary)

Load the shared library, run nemo_init, populate grid dimensions and working precision. Throws NemoError if NEMO hits a fatal STOP.

source
NEMO.nemo_configuration — Method
nemo_configuration(; source, output_directory, reference, academic = false,
                   name = "NEMO_JULIA_" * reference, namelist_files = ["namelist_cfg"], mpi = false)

Build a NemoConfiguration for any NEMO configuration — without needing a dedicated constructor.

  • reference — the NEMO configuration to derive from: a reference configuration in cfgs/ (e.g. "GYRE_PISCES", "AMM12") by default, or, with academic = true, an academic test case in tests/ (e.g. "VORTEX", "OVERFLOW").
  • namelist_files — the namelist files setup_run_directory loads for applying overrides; most configurations need only "namelist_cfg", while sea-ice configurations also need "namelist_ice_cfg".
  • my_src — paths to user Fortran files (or directories of them) copied into the configuration's MY_SRC at build time. NEMO compiles MY_SRC with precedence over the base sources, so this is how custom physics or idealized domains are set up: override usrdef_hgr.F90, usrdef_zgr.F90, usrdef_istate.F90, usrdef_sbc.F90, etc. by supplying same-named files.
  • external_forcing — when true, the surface fluxes are owned by an external driver: NEMO.jl injects a no-op usrdef_sbc.F90 so the momentum, heat, and freshwater fluxes set from Julia (via set_zonal_wind_stress!, set_nonsolar_heat_flux!, …) survive each step instead of being recomputed by NEMO, and setup_run_directory sets ln_usr = .true.. This is the path for forcing a NEMO configuration with externally-computed fluxes.

The configuration is created without performing the build; pass it to build_nemo_library to compile it. ORCA2_ICE_configuration and channel_configuration are thin wrappers around this constructor with the appropriate reference/academic/namelist_files preset.

source
NEMO.read_namelist — Method
read_namelist(filename)

Parse a Fortran namelist file (NEMO namelist_cfg, namelist_ref, etc.) into a NemoNamelist. Comments (!), continuation lines, integer / float / boolean / string / list values, and double-precision d exponents are handled.

source
NEMO.setup_run_directory — Method
setup_run_directory(configuration::NemoConfiguration; overrides = Dict())

Apply user-supplied namelist overrides to the configuration's run directory.

overrides maps (filename, group, key) triples to new values, e.g.

overrides = Dict(
    ("namelist_cfg", :namrun, :nn_itend) => 10,
    ("namelist_cfg", :namdom, :rn_Dt)    => 5400.0,
)

Namelists are loaded if not already present, modified in memory, then written back to disk.

When the configuration was built with external_forcing = true, ln_usr = .true. and ln_blk = .false. are set in namsbc so the externally-provided surface fluxes drive the model.

source
NEMO.stage_inputs! — Method
stage_inputs!(configuration::NemoConfiguration, inputs)

Copy input files into the configuration's run directory. inputs is a collection of paths — files or directories — typically the domain_cfg.nc, bathymetry, and atmospheric forcing a custom configuration needs. Existing files are overwritten. Returns the run directory.

This is the generic counterpart to download_orca2_ice_inputs for configurations that bring their own inputs; together with nemo_configuration's my_src and setup_run_directory's namelist overrides, it is the path for setting up a custom configuration from Julia.

source
NEMO.step! — Method
step!(lib::NemoLibrary)

Advance NEMO by one time step. Throws NemoError if NEMO hits a fatal STOP.

source
NEMO.write_namelist — Method
write_namelist(filename, namelist::NemoNamelist)

Write a NemoNamelist back to disk in standard Fortran namelist format (group, indented key = value pairs, terminating /).

source