eophis.coupling package

Submodules

eophis.coupling.namcouple module

Contains tools to create and manipulate OASIS namelist sections in right format.

  • Copyright (c) 2023 IGE-MEOM

    Eophis is released under an MIT License. See the LICENSE file for details.

eophis.coupling.namcouple.close_tunnels(reread=True)

Namcouple API: terminates coupling environement if set up. Resets Namcouple with same initialization attributes.

eophis.coupling.namcouple.init_namcouple(cpl_nml_tmp, cpl_nml)

Namcouple API: init and reads namcouple file. Completely reinit Namcouple if it is already instantiated.

Parameters:
  • cpl_nml_tmp (string) – input namcouple file name

  • cpl_nml (string) – output namcouple file name

Raises:

eophis.warning() – if Namcouple is already initialized

Notes

This function is automatically called when importing eophis package.

eophis.coupling.namcouple.open_tunnels()

Namcouple API: starts coupling environment, creates OASIS objects in Tunnels.

Raises:

eophis.abort() – if called in preproduction mode

eophis.coupling.namcouple.register_tunnels(configs)

Namcouple API: updates namcouple content and init Tunnel.

Parameters:

config (list) – list of input metadata to create Tunnels

Returns:

tunnels – List of created Tunnel objects

Return type:

list( eophis.Tunnel )

eophis.coupling.namcouple.tunnels_ready()

Namcouple API: checks if Tunnels are ready to start time loop. A Tunnel is ready if all the static exchanges have been done.

eophis.coupling.namcouple.write_coupling_namelist(simulation_time=31536000.0)

Namcouple API: writes namcouple at its current state. Also writes Eophis Fortran namelist.

Parameters:

simulation_time (float) – Simulation time to write in namcouple header section

Raises:

eophis.abort() – if called in production mode

eophis.coupling.namelist module

Tools to manipulate namelist content.

  • Copyright (c) 2023 IGE-MEOM

    Eophis is released under an MIT License. See the LICENSE file for details.

class eophis.coupling.namelist.FortranNamelist(file_path, warn_if_not_found=True)

Bases: object

This class is a wrapper to manipulate formatted Fortran namelists.

file_path

path to namelist file

Type:

string

formatted

content of the namelist file in Fortran format

Type:

f90nml.namelist.Namelist

warn_if_not_found

raise error if file not found, return empty dict otherwise

Type:

bool

get(*labels)

Accesses the values of variables labels contained in namelist.

Parameters:

labels (string) – list of labels to find in namelist

Returns:

values – List of values corresponding to labels

Return type:

list

write(content=None)

Writes namelist under Fortran format with additional content if given.

Parameters:

content (dict) – dictionary containing items to add in the namelist

eophis.coupling.tunnel module

This module is a wrapper for python OASIS API.

  • Copyright (c) 2023 IGE-MEOM

    Eophis is released under an MIT License. See the LICENSE file for details.

class eophis.coupling.tunnel.Tunnel(label, grids, exchs, geo_aliases, py_aliases)

Bases: object

This class gathers a set of OASIS objects created during an Eophis execution under a common entity. This allows to spread OASIS commands between different identified coupled geoscientific codes.

label

Tunnel name

Type:

string

grids

registered Grid objects

Type:

dict( eophis.Grid )

exchs

Tunnel user-defined exchanges

Type:

list

geo_aliases

Correspondence between Tunnel and namcouple fields names from geophysical side

Type:

dict

py_aliases

Correspondence between Tunnel and namcouple fields names from Python side

Type:

dict

_partitions

list of pyoasis.Partition objects

Type:

dict

_variables

list of pyoasis.Var objects to receive (‘rcv’ key) and to send (‘snd’ key)

Type:

dict

_static_used

status of static variables (exchanged or not)

Type:

dict

arriving_list()

Returns list of non-static receiveable variables.

departure_list()

Returns list of non-static sendable variables.

receive(var_label, date=86579)

Requests a variable reception from geoscientific code.

Parameters:
  • var_label (string) – variable name to receive

  • date (int) – current simulation time

Raises:

eophis.warning() – if try to receive an already received static variable, then skip

Returns:

rcv_fld – array sent by geoscientific code, None if date does not match frequency exchange

Return type:

numpy.ndarray

send(var_label, values, date=86579)

Sends variable value to geoscientific code if date does match frequency exchange, nothing otherwise.

Parameters:
  • var_label (string) – variable name to send

  • date (int) – current simulation time

  • values (numpy.ndarray) – array to send through OASIS under var_label

Raises:
  • eophis.warning() – if try to send an already sent static variable, then skip

  • eophis.abort() – if values does not match sending format

Module contents

coupling subpackage

This subpackage contains wrappers for:
  • OASIS component initialization and termination

  • partitions and variables definition

  • steps to perform data exchanges with coupled geophysical code

  • tools to create and manipulate OASIS and Fortran namelists

  • Copyright (c) 2023 IGE-MEOM

    Eophis is released under an MIT License. See the LICENSE file for details.