source: CONFIG_DEVT/IPSLCM6.5_work_ENSEMBLES/oasis3-mct/pyoasis/src/mod_oasis_var.py @ 5863

Last change on this file since 5863 was 5725, checked in by aclsce, 3 years ago

Added new oasis3-MCT version to be used to handle ensembles simulations with XIOS.

File size: 1.6 KB
Line 
1# pyOASIS - A Python wrapper for OASIS
2# Authors: Philippe Gambron, Rupert Ford
3# Copyright (C) 2019 UKRI - STFC
4
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as
7# published by the Free Software Foundation, either version 3 of the
8# License, or any later version.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Lesser General Public License for more details.
14
15# A copy of the GNU Lesser General Public License, version 3, is supplied
16# with this program, in the file lgpl-3.0.txt. It is also available at
17# <https://www.gnu.org/licenses/lgpl-3.0.html>.
18
19
20"""OASIS variable data and methods"""
21
22from enum import Enum
23import ctypes
24from ctypes import cdll, CDLL, c_int, c_char_p
25
26
27class OasisVarParameters(Enum):
28    """"""
29    OASIS_DOUBLE = 8
30
31
32cdll.LoadLibrary("liboasis.cbind.so")
33LIB = CDLL("liboasis.cbind.so")
34
35
36LIB.oasis_c_def_var.argtypes = [ctypes.POINTER(ctypes.c_int), c_char_p, ctypes.c_int,
37                                ctypes.c_int, ctypes.c_int, ctypes.c_int]
38LIB.oasis_c_def_var.restype = ctypes.c_int
39
40def def_var(id_part, cdport, id_var_nodims, kinout):
41    """The OASIS user interface to define variables"""
42    id_nports = c_int(0)
43    kinfo = c_int(0)
44    kinfo = LIB.oasis_c_def_var(id_nports, cdport.encode(), id_part, id_var_nodims,
45                                kinout, OasisVarParameters.OASIS_DOUBLE.value)
46    return id_nports.value, kinfo
Note: See TracBrowser for help on using the repository browser.