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.
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.
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.
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.
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/.
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 (usedownload_nemo_source()to fetch one).output_directory— destination for build artifacts and run directory.configuration_name— name for the new configuration created fromreference.reference— NEMO configuration to derive from: a reference configuration incfgs/(e.g."ORCA2_ICE_PISCES") or, withacademic = true, a test case intests/(e.g."CANAL").academic— derive from atests/academic case (makenemo -a) instead of acfgs/reference configuration (makenemo -r).my_src— user Fortran files (or directories of them) copied into the configuration'sMY_SRCbefore 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_HOMEis resolved frommpifortonPATHif unset.
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.
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.
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.
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.
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).
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.
NEMO.finalize! — Method
finalize!(lib::NemoLibrary)Close NEMO files, run timer reports, then unload the shared library.
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.
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.
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 incfgs/(e.g."GYRE_PISCES","AMM12") by default, or, withacademic = true, an academic test case intests/(e.g."VORTEX","OVERFLOW").namelist_files— the namelist filessetup_run_directoryloads 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'sMY_SRCat build time. NEMO compilesMY_SRCwith precedence over the base sources, so this is how custom physics or idealized domains are set up: overrideusrdef_hgr.F90,usrdef_zgr.F90,usrdef_istate.F90,usrdef_sbc.F90, etc. by supplying same-named files.external_forcing— whentrue, the surface fluxes are owned by an external driver: NEMO.jl injects a no-opusrdef_sbc.F90so the momentum, heat, and freshwater fluxes set from Julia (viaset_zonal_wind_stress!,set_nonsolar_heat_flux!, …) survive each step instead of being recomputed by NEMO, andsetup_run_directorysetsln_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.
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.
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.
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.
NEMO.step! — Method
step!(lib::NemoLibrary)Advance NEMO by one time step. Throws NemoError if NEMO hits a fatal STOP.
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 /).