示例#1
0
    def setUp(self):
        ert = clib.ert_load("libert_util")

        self.ert_wrapper = CWrapper(ert)

        self.ert_wrapper.registerType("pow_double", MaxDouble)
        self.double_max = self.ert_wrapper.prototype("pow_double util_double_max(double, double)")
示例#2
0
    def __init__(self, ert, function_name, argument_types, argument_count):
        super(FunctionErtScript, self).__init__(ert)

        lib = clib.ert_load(None)
        wrapper = CWrapper(lib)

        parsed_argument_types = []

        if ert is not None:
            self.__function = wrapper.prototype("c_void_p %s(c_void_p, stringlist)" % function_name)

        else:
            for arg in argument_types:
                if arg is bool:
                    parsed_argument_types.append("bool")
                elif arg is str:
                    parsed_argument_types.append("char*")
                elif arg is int:
                    parsed_argument_types.append("int")
                elif arg is float:
                    parsed_argument_types.append("float")
                else:
                    raise TypeError("Unknown type: %s" % arg)

            self.__function = wrapper.prototype("c_void_p %s(%s)" % (function_name, ", ".join(parsed_argument_types[:argument_count])))
示例#3
0
    def setUp(self):
        ert = clib.ert_load("libert_util")

        self.ert_wrapper = CWrapper(ert)

        self.ert_wrapper.registerType("time_t", TimeTValue)
        self.make_date = self.ert_wrapper.prototype("time_t util_make_date(int, int, int)")
示例#4
0
#  Copyright (C) 2011  Statoil ASA, Norway. 
#   
#  The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. 
#   
#  ERT is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details. 
"""
Simple package for working with 2D geometry.

"""
from ert.cwrap import clib

import ert.util

ERT_GEOMETRY_LIB = clib.ert_load("libert_geometry")

from .geo_polygon import GeoPolygon

from .polyline import Polyline
from .xyz_reader import XYZReader
from .geometry_tools import GeometryTools
示例#5
0
from ert.cwrap import CWrapper, BaseCClass, clib, CWrapError
from ert.test import ExtendedTestCase

test_lib = clib.ert_load(
    "libert_util"
)  # create a local namespace (so we don't overwrite StringList)
cwrapper = CWrapper(test_lib)


class StringListTest(BaseCClass):
    def __init__(self):
        c_pointer = self.cNamespace().alloc()
        super(StringListTest, self).__init__(c_pointer)

    def free(self):
        StringListTest.cNamespace().free(self)


CWrapper.registerObjectType("stringlisttest", StringListTest)

StringListTest.cNamespace().alloc = cwrapper.prototype(
    "c_void_p stringlist_alloc_new( )")
StringListTest.cNamespace().free = cwrapper.prototype(
    "void stringlist_free(stringlisttest )")


class CWrapTest(ExtendedTestCase):
    def test_return_type(self):
        stringlist_alloc = cwrapper.prototype(
            "c_void_p stringlist_alloc_new( )")
        string_list1 = StringListTest()
示例#6
0
#  Copyright (C) 2013  Statoil ASA, Norway.
#
#  The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool.
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
from ert.cwrap import clib

import ert.ecl
import ert.util
import ert.geo

SCHED_LIB = clib.ert_load("libsched")

from .sched_file import SchedFile
from .history_source_enum import HistorySourceEnum
from .history import History
示例#7
0
文件: librms.py 项目: blattms/ert
#  Copyright (C) 2011  Statoil ASA, Norway. 
#   
#  The file 'librms.py' is part of ERT - Ensemble based Reservoir Tool. 
#   
#  ERT is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details. 


import ert.cwrap.clib as clib
from ert.ecl import ECL_LIB

lib = clib.ert_load("librms.so")
    
示例#8
0
#  Copyright (C) 2011  Statoil ASA, Norway.
#
#  The file 'libconfig.py' is part of ERT - Ensemble based Reservoir Tool.
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.

import ert.cwrap.clib as clib
lib = clib.ert_load("libconfig.so")
示例#9
0
from ert.cwrap import clib, CWrapper
from ert.test import ExtendedTestCase, TestAreaContext
from ert.enkf import RunpathList, RunpathNode

test_lib = clib.ert_load("libenkf")  # create a local namespace
cwrapper = CWrapper(test_lib)

runpath_list_alloc = cwrapper.prototype(
    "runpath_list_obj runpath_list_alloc(char*)")


class RunpathListTest(ExtendedTestCase):
    def test_runpath_list(self):
        runpath_list = runpath_list_alloc("")
        """ @type runpath_list: RunpathList """

        self.assertEqual(len(runpath_list), 0)

        test_runpath_nodes = [
            RunpathNode(0, 0, "runpath0", "basename0"),
            RunpathNode(1, 0, "runpath1", "basename0")
        ]

        runpath_node = test_runpath_nodes[0]
        runpath_list.add(runpath_node.realization, runpath_node.iteration,
                         runpath_node.runpath, runpath_node.basename)

        self.assertEqual(len(runpath_list), 1)
        self.assertEqual(runpath_list[0], test_runpath_nodes[0])

        runpath_node = test_runpath_nodes[1]
示例#10
0
import ert.cwrap.clib as clib
import ert.util
import ert.geo
import ert.ecl

ECL_WELL_LIB = clib.ert_load("libecl_well")


from .well_type_enum import WellTypeEnum
from .well_connection_direction_enum import WellConnectionDirectionEnum
from .well_connection import WellConnection
from .well_segment import WellSegment
from .well_state import WellState
from .well_time_line import WellTimeLine
from .well_info  import WellInfo
示例#11
0
import ert.cwrap.clib as clib

ECL_WELL_LIB = clib.ert_load("libecl_well")

from .well_type_enum import WellTypeEnum
from .well_connection_direction_enum import WellConnectionDirectionEnum
from .well_connection import WellConnection
from .well_segment import WellSegment
from .well_state import WellState
from .well_time_line import WellTimeLine
from .well_info import WellInfo
示例#12
0
#   
#  ERT is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details. 
"""
This module will load the libecl.so shared library.
"""

# This statement is necessary for side-effects (i.e. the final
# dlopen("libutil.so") call).
import ert.util.libutil               
import ert.geo.libgeo

import ert.cwrap.clib as clib

try:
    clib.load("libgomp" , "libgomp.so.1")
    openmp = True
except ImportError:
    openmp = False
    
lib = clib.ert_load("libecl.so")
示例#13
0
from ert.cwrap import clib


RMS_LIB = clib.ert_load("librms")
示例#14
0
#  Copyright (C) 2011  Statoil ASA, Norway.
#
#  The file 'libsched.py' is part of ERT - Ensemble based Reservoir Tool.
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.

import ctypes
import ert.cwrap.clib as clib
import ert.util.libutil
import ert.geo.libgeo
import ert.ecl.libecl

lib = clib.ert_load("libsched.so")
示例#15
0
import ctypes
from ert.cwrap import clib, CWrapper
from ert.ecl import EclKW, EclFile, EclTypeEnum, FortIO
from ert.test import ExtendedTestCase, TestAreaContext
from ert.util import IntVector


ecl_lib = clib.ert_load("libecl")
ecl_wrapper = CWrapper(ecl_lib)


freadIndexedData = ecl_wrapper.prototype("void ecl_kw_fread_indexed_data(fortio, int, int, int, int_vector, char*)") # fortio, offset, type, count, index_map, buffer
eclFileIndexedRead = ecl_wrapper.prototype("void ecl_file_indexed_read(ecl_file, char*, int, int_vector, char*)") # ecl_file, kw, index, index_map, buffer


class EclIndexedReadTest(ExtendedTestCase):
    def test_ecl_kw_indexed_read(self):
        with TestAreaContext("ecl_kw_indexed_read") as area:
            fortio = FortIO("index_test", mode=FortIO.WRITE_MODE)

            element_count = 100000
            ecl_kw = EclKW.create("TEST", element_count, EclTypeEnum.ECL_INT_TYPE)

            for index in range(element_count):
                ecl_kw[index] = index

            ecl_kw.fwrite(fortio)

            fortio.close()

示例#16
0
"""
from ert.cwrap import clib

import ert.util
import ert.geo



try:
    clib.load("libgomp" , "libgomp.so.1")
    openmp = True
except ImportError:
    openmp = False

ECL_LIB = clib.ert_load("libecl.so")


from .ecl_sum import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode
from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclTypeEnum, EclUtil
from .ecl_default import EclDefault
from .ecl_rft_cell import EclPLTCell, EclRFTCell
from .ecl_rft import EclRFT, EclRFTFile
from .fortio import FortIO
from .ecl_kw import EclKW
from .ecl_file import EclFile
from .ecl_grid import EclGrid
from .ecl_region import EclRegion
from .ecl_subsidence import EclSubsidence
from .ecl_grav_calc import phase_deltag, deltag
from .ecl_queue import EclQueue
示例#17
0
import ctypes
from ert.cwrap import clib, CWrapper
from ert.ecl import EclKW, EclFile, EclTypeEnum, FortIO
from ert.test import ExtendedTestCase, TestAreaContext
from ert.util import IntVector

ecl_lib = clib.ert_load("libecl")
ecl_wrapper = CWrapper(ecl_lib)

freadIndexedData = ecl_wrapper.prototype(
    "void ecl_kw_fread_indexed_data(fortio, int, int, int, int_vector, char*)"
)  # fortio, offset, type, count, index_map, buffer
eclFileIndexedRead = ecl_wrapper.prototype(
    "void ecl_file_indexed_read(ecl_file, char*, int, int_vector, char*)"
)  # ecl_file, kw, index, index_map, buffer


class EclIndexedReadTest(ExtendedTestCase):
    def test_ecl_kw_indexed_read(self):
        with TestAreaContext("ecl_kw_indexed_read") as area:
            fortio = FortIO("index_test", mode=FortIO.WRITE_MODE)

            element_count = 100000
            ecl_kw = EclKW.create("TEST", element_count,
                                  EclTypeEnum.ECL_INT_TYPE)

            for index in range(element_count):
                ecl_kw[index] = index

            ecl_kw.fwrite(fortio)
示例#18
0
#  Copyright (C) 2011  Statoil ASA, Norway. 
#   
#  The file 'libecl.py' is part of ERT - Ensemble based Reservoir Tool. 
#   
#  ERT is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details. 
"""
This module will load the libgeometry.so shared library.
"""

# This statement is necessary for side-effects (i.e. the final
# dlopen("libutil.so") call).
import ctypes
import ert.util.libutil               
import ert.cwrap.clib as clib

lib = clib.ert_load("libert_geometry.so")
示例#19
0
#  Copyright (C) 2011  Statoil ASA, Norway. 
#   
#  The file 'libenkf.py' is part of ERT - Ensemble based Reservoir Tool. 
#   
#  ERT is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details. 
import ert.util.libutil               
import ert.ecl.libecl
import ert.job_queue.libjob_queue
import ert.rms.librms
import ert.cwrap.clib as clib

clib.ert_load("libsched.so")
clib.ert_load("libanalysis.so")
lib = clib.ert_load("libenkf.so")
    
示例#20
0
from ert.cwrap import clib

import ert.util
import ert.geo
import ert.ecl

RMS_LIB = clib.ert_load("librms")
示例#21
0
def setenv(var, value):
    if not os.getenv(var):
        os.environ[var] = value


# Set up the full LSF environment - based onf LSF_HOME
LSF_HOME = os.getenv("LSF_HOME")
if LSF_HOME:
    setenv("LSF_BINDIR", "%s/bin" % LSF_HOME)
    setenv("LSF_LIBDIR", "%s/lib" % LSF_HOME)
    setenv("XLSF_UIDDIR", "%s/lib/uid" % LSF_HOME)
    setenv("LSF_SERVERDIR", "%s/etc" % LSF_HOME)
    setenv("LSF_ENVDIR",
           "%s/conf" % LSF_HOME)  # This is wrong: Statoil: /prog/LSF/conf

JOB_QUEUE_LIB = clib.ert_load("libjob_queue")

from .job_status_type_enum import JobStatusType
from .job import Job
from .queue import JobList, JobQueue, statusList, exList, runtimeList
from .job_queue_manager import JobQueueManager
from .driver import QueueDriverEnum, Driver, LSFDriver, RSHDriver, LocalDriver
from .ext_job import ExtJob
from .ext_joblist import ExtJoblist
from .forward_model import ForwardModel

from .ert_script import ErtScript
from .function_ert_script import FunctionErtScript
from .external_ert_script import ExternalErtScript

from .workflow_job import WorkflowJob
示例#22
0
import time
import ctypes
from ert.cwrap import clib
from ert.util import CThreadPool , startCThreadPool
from ert.test import ExtendedTestCase

TEST_LIB = clib.ert_load("libtest_util")


class CThreadPoolTest(ExtendedTestCase):

    def test_cfunc(self):
        with self.assertRaises( TypeError ):
            func = CThreadPool.lookupCFunction( "WRONG-TYPE" , "no-this-does-not-exist")
        
        with self.assertRaises( AttributeError ):
            func = CThreadPool.lookupCFunction( TEST_LIB , "no-this-does-not-exist")
            
            
            
    def test_create(self):
        pool = CThreadPool(32 , start = True)
        job = CThreadPool.lookupCFunction( TEST_LIB , "thread_pool_test_func1")
        arg = ctypes.c_int(0)

        N = 256
        for i in range(N):
            pool.addTask( job , ctypes.byref( arg ) )
        pool.join()
        self.assertEqual( arg.value , N )
示例#23
0
    clib.load("libnsl.so.1")
    if LSF_LIBDIR:
        clib.load("%s/liblsf.so" % LSF_LIBDIR)
        clib.load("%s/libbat.so" % LSF_LIBDIR)
    else:
        clib.load( "liblsf.so" )
        clib.load( "libbat.so" )
    HAVE_LSF = True
except:
    HAVE_LSF = False


# 3: Loading the libjob_queue library, which might (depending on the
#    value of INCLUDE_LSF used when building) depend on the LSF
#    libraries we tried to load at the previous step.
clib.ert_load("libconfig.so" )
try:
    lib  = clib.ert_load("libjob_queue.so")
except:
    if HAVE_LSF == False:
        sys.stderr.write("** Failed to load the libjob_queue library, \n")
        sys.stderr.write("** have previosuly failed to load the LSF\n")
        sys.stderr.write("** libraries liblsf & libbat - that might be\n")
        sys.stderr.write("** the reason ... ")
        if LSF_LIBDIR:
            sys.stderr.write("** LSF_LIBDIR = %s\n" % LSF_LIBDIR)
        else:
            sys.stderr.write("** LSF_LIBDIR = <NOT SET>\n")
    sys.exit("Failed to load library: libjob_queue")

示例#24
0
from ert.cwrap import clib, CWrapper
from ert.job_queue import WorkflowJob
from ert.test import TestAreaContext, ExtendedTestCase
from ert_tests.job_queue.workflow_common import WorkflowCommon

test_lib = clib.ert_load("libjob_queue")  # create a local namespace
cwrapper = CWrapper(test_lib)

alloc_config = cwrapper.prototype("c_void_p workflow_job_alloc_config()")
alloc_from_file = cwrapper.prototype(
    "workflow_job_obj workflow_job_config_alloc(char*, c_void_p, char*)")


class WorkflowJobTest(ExtendedTestCase):
    def test_workflow_job_creation(self):
        workflow_job = WorkflowJob("Test")

        self.assertTrue(workflow_job.isInternal())
        self.assertEqual(workflow_job.name(), "Test")

    def test_read_internal_function(self):
        with TestAreaContext("python/job_queue/workflow_job") as work_area:
            WorkflowCommon.createInternalFunctionJob()
            WorkflowCommon.createErtScriptsJob()

            config = alloc_config()
            workflow_job = alloc_from_file("SELECT_CASE", config,
                                           "select_case_job")

            self.assertEqual(workflow_job.name(), "SELECT_CASE")
            self.assertTrue(workflow_job.isInternal())
示例#25
0
#  Copyright (C) 2013  Statoil ASA, Norway.
#
#  The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool.
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
from ert.cwrap import clib

import ert.ecl
import ert.util
import ert.geo

SCHED_LIB = clib.ert_load("libsched.so")


from .sched_file import SchedFile
from .history_source_enum import HistorySourceEnum
from .history import History
示例#26
0
文件: __init__.py 项目: jepebe/ert
from ert.cwrap.metacwrap import Prototype

def setenv( var, value):
    if not os.getenv(var):
        os.environ[var] = value

# Set up the full LSF environment - based onf LSF_HOME
LSF_HOME = os.getenv("LSF_HOME")
if LSF_HOME:
    setenv("LSF_BINDIR", "%s/bin" % LSF_HOME)
    setenv("LSF_LIBDIR", "%s/lib" % LSF_HOME)
    setenv("XLSF_UIDDIR", "%s/lib/uid" % LSF_HOME)
    setenv("LSF_SERVERDIR", "%s/etc" % LSF_HOME)
    setenv("LSF_ENVDIR", "%s/conf" % LSF_HOME)   # This is wrong: Statoil: /prog/LSF/conf

JOB_QUEUE_LIB = clib.ert_load("libjob_queue")

class QueuePrototype(Prototype):
    lib = clib.ert_load("libjob_queue")

    def __init__(self, prototype, bind=True):
        super(QueuePrototype, self).__init__(QueuePrototype.lib, prototype, bind=bind)

    
#from .job_status_type_enum import JobStatusType
from .job_status_type_enum import JobStatusType
from .job import Job
from .queue import JobList, JobQueue, statusList, exList, runtimeList
from .job_queue_manager import JobQueueManager
from .driver import QueueDriverEnum, Driver, LSFDriver, RSHDriver, LocalDriver
from .ext_job import ExtJob
示例#27
0
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details. 


import ert.cwrap.clib as clib

clib.load("libz" , "libz.so.1")

# Depending on the Fortran compiler which has been used to compile
# blas / lapack the there might be an additional dependency on libg2c:

try:
    # First try to load without libg2c
    clib.load("libblas.so" , "libblas.so.3")
    clib.load("liblapack.so")
except:
    # Then try to load with libg2c
    clib.load("libg2c.so.0")
    clib.load("libblas.so" , "libblas.so.3")
    clib.load("liblapack.so")

lib = clib.ert_load("libert_util.so")
    
示例#28
0
文件: __init__.py 项目: bramirex/ert
  ecl_util: This is mainly a collection of constants, and a few
     stateless functions.

  ecl: This module is purely for convenience, all the symbols in the
     package are explicitly imported into this module, ensuring that
     all symbols in the package are available under the common
     namespace 'ecl'.

"""
from ert.cwrap import clib

import ert.util
import ert.geo

ECL_LIB = clib.ert_load("libecl")

from .ecl_sum_tstep import EclSumTStep
from .ecl_sum import EclSum  #, EclSumVector, EclSumNode, EclSMSPECNode
from .ecl_sum_keyword_vector import EclSumKeyWordVector
from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclTypeEnum, EclUtil
from .ecl_default import EclDefault
from .ecl_rft_cell import EclPLTCell, EclRFTCell
from .ecl_rft import EclRFT, EclRFTFile
from .fortio import FortIO, openFortIO
from .ecl_kw import EclKW
from .ecl_3dkw import Ecl3DKW
from .ecl_file import EclFile, openEclFile
from .ecl_3d_file import Ecl3DFile
from .ecl_init_file import EclInitFile
from .ecl_restart_file import EclRestartFile
示例#29
0
#  Copyright (C) 2011  Statoil ASA, Norway. 
#   
#  The file 'libsched.py' is part of ERT - Ensemble based Reservoir Tool. 
#   
#  ERT is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details. 


import ctypes
import ert.cwrap.clib as clib
import ert.util.libutil               
import ert.geo.libgeo
import ert.ecl.libecl

lib = clib.ert_load("libsched.so")
    
示例#30
0
文件: __init__.py 项目: chflo/ert
import ert.ecl
import ert.rms
import ert.analysis
import ert.sched
import ert.config
import ert.job_queue

class EnkfPrototype(Prototype):
    lib = clib.ert_load("libenkf")

    def __init__(self, prototype, bind=True):
        super(EnkfPrototype, self).__init__(EnkfPrototype.lib, prototype, bind=bind)

        

ENKF_LIB = clib.ert_load("libenkf")

from .enums import *

from .node_id import NodeId

from .enkf_linalg import EnkfLinalg
from .util import TimeMap
from .state_map import StateMap
from .summary_key_set import SummaryKeySet
from .summary_key_matcher import SummaryKeyMatcher
from .custom_kw_config_set import CustomKWConfigSet
from .enkf_fs import EnkfFs

from .ert_workflow_list import ErtWorkflowList
from .active_list import ActiveList
示例#31
0
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.

import ert.cwrap.clib as clib

clib.load("libz", "libz.so.1")

# Depending on the Fortran compiler which has been used to compile
# blas / lapack the there might be an additional dependency on libg2c:

try:
    # First try to load without libg2c
    clib.load("libblas.so", "libblas.so.3")
    clib.load("liblapack.so")
except:
    # Then try to load with libg2c
    clib.load("libg2c.so.0")
    clib.load("libblas.so", "libblas.so.3")
    clib.load("liblapack.so")

lib = clib.ert_load("libert_util.so")
示例#32
0
文件: libecl.py 项目: rolk/ert
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
"""
This module will load the libecl.so shared library.
"""

# This statement is necessary for side-effects (i.e. the final
# dlopen("libutil.so") call).
import ert.util.libutil
import ert.geo.libgeo

import ert.cwrap.clib as clib

try:
    clib.load("libgomp", "libgomp.so.1")
    openmp = True
except ImportError:
    openmp = False

lib = clib.ert_load("libecl.so")
示例#33
0
#  Copyright (C) 2011  Statoil ASA, Norway.
#
#  The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool.
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
"""
Simple package for working with 2D geometry.

"""
from ert.cwrap import clib

import ert.util

ERT_GEOMETRY_LIB = clib.ert_load("libert_geometry")

from .geo_polygon import GeoPolygon

from .polyline import Polyline
from .xyz_io import XYZIo
from .geometry_tools import GeometryTools
示例#34
0
文件: __init__.py 项目: akva2/ert
#  Copyright (C) 2013  Statoil ASA, Norway. 
#   
#  The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. 
#   
#  ERT is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details. 


import ert.cwrap.clib as clib
import ert.util

ANALYSIS_LIB = clib.ert_load("libanalysis")

from .enums import AnalysisModuleOptionsEnum, AnalysisModuleLoadStatusEnum

from .analysis_module import AnalysisModule
from .linalg import Linalg
示例#35
0
from os import path, symlink, remove

from ert.cwrap import clib, CWrapper
from ert.test import ExtendedTestCase, TestAreaContext,ErtTestContext
from ert.enkf import RunpathList, RunpathNode
from ert.util import BoolVector

test_lib  = clib.ert_load("libenkf") # create a local namespace
cwrapper =  CWrapper(test_lib)

runpath_list_alloc = cwrapper.prototype("runpath_list_obj runpath_list_alloc(char*)")

class RunpathListTest(ExtendedTestCase):

    def test_runpath_list(self):
        runpath_list = runpath_list_alloc("")
        """ @type runpath_list: RunpathList """

        self.assertEqual(len(runpath_list), 0)

        test_runpath_nodes = [RunpathNode(0, 0, "runpath0", "basename0"), RunpathNode(1, 0, "runpath1", "basename0")]

        runpath_node = test_runpath_nodes[0]
        runpath_list.add(runpath_node.realization, runpath_node.iteration, runpath_node.runpath, runpath_node.basename)

        self.assertEqual(len(runpath_list), 1)
        self.assertEqual(runpath_list[0], test_runpath_nodes[0])

        runpath_node = test_runpath_nodes[1]
        runpath_list.add(runpath_node.realization, runpath_node.iteration, runpath_node.runpath, runpath_node.basename)
示例#36
0
from ert.cwrap import clib, CWrapper
from ert.enkf.data.enkf_node import EnkfNode
from ert.enkf.data import GenDataConfig
from ert.enkf.enums.enkf_state_type_enum import EnkfStateType
from ert.enkf.node_id import NodeId
from ert.test import ErtTestContext
from ert.test.extended_testcase import ExtendedTestCase
from ert.util import BoolVector

test_lib  = clib.ert_load("libenkf")
cwrapper =  CWrapper(test_lib)

get_active_mask = cwrapper.prototype("bool_vector_ref gen_data_config_get_active_mask( gen_data_config )")
update_active_mask = cwrapper.prototype("void gen_data_config_update_active( gen_data_config, int, bool_vector)")

class GenDataConfigTest(ExtendedTestCase):
    def setUp(self):
        self.config_file = self.createTestPath("Statoil/config/with_GEN_DATA/config")

    def load_active_masks(self, case1, case2 ):
        with ErtTestContext("gen_data_config_test", self.config_file) as test_context:
            ert = test_context.getErt()

            fs1 =  ert.getEnkfFsManager().getFileSystem(case1)
            config_node = ert.ensembleConfig().getNode("TIMESHIFT")
            data_node = EnkfNode(config_node)
            data_node.tryLoad(fs1, NodeId(60, 0, EnkfStateType.FORECAST))

            active_mask = get_active_mask( config_node.getDataModelConfig() )
            first_active_mask_length = len(active_mask)
            self.assertEqual(first_active_mask_length, 2560)
示例#37
0
class GeoPrototype(Prototype):
    lib = clib.ert_load("libert_geometry")

    def __init__(self, prototype, bind=True):
        super(GeoPrototype, self).__init__(GeoPrototype.lib, prototype, bind=bind)
示例#38
0
import ctypes

from ert.cwrap import clib
from ert.test import ExtendedTestCase
from ert.util import CThreadPool, startCThreadPool

TEST_LIB = clib.ert_load("libtest_util")


class CThreadPoolTest(ExtendedTestCase):
    def test_cfunc(self):
        with self.assertRaises(TypeError):
            func = CThreadPool.lookupCFunction("WRONG-TYPE",
                                               "no-this-does-not-exist")

        with self.assertRaises(AttributeError):
            func = CThreadPool.lookupCFunction(TEST_LIB,
                                               "no-this-does-not-exist")

    def test_create(self):
        pool = CThreadPool(32, start=True)
        job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1")
        arg = ctypes.c_int(0)

        N = 256
        for i in range(N):
            pool.addTask(job, ctypes.byref(arg))
        pool.join()
        self.assertEqual(arg.value, N)

    def test_context(self):
示例#39
0
from unittest import TestCase
from ert.cwrap import clib, CWrapper

test_lib = clib.ert_load("libert_util")
cwrapper = CWrapper(test_lib)
alloc_string_copy = cwrapper.prototype(
    "cstring_obj util_alloc_string_copy(char*)")


class CStringTest(TestCase):
    def test_get(self):
        s1 = "String123"
        s2 = alloc_string_copy(s1)
        self.assertEqual(s1, s2)
示例#40
0
#  Copyright (C) 2013  Statoil ASA, Norway.
#
#  The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool.
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
from ert.cwrap import clib
import ert.util

CONFIG_LIB = clib.ert_load("libconfig")

from .unrecognized_enum import UnrecognizedEnum
from .content_type_enum import ContentTypeEnum
from .config_error import ConfigError
from .config_content import ConfigContent , ContentItem, ContentNode
from .config_parser import ConfigParser, SchemaItem

示例#41
0
#  ERT is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details.

from ert.cwrap import clib, BaseCClass, CWrapper


lib = clib.ert_load("libtest_util.so")


class TestArea(BaseCClass):
    def __init__(self, test_name, store_area=False):
        c_ptr = TestArea.cNamespace().test_area_alloc(test_name, store_area)
        super(TestArea, self).__init__(c_ptr)



    def install_file( self, filename):
        TestArea.cNamespace().install_file(self, filename)


    def copy_directory( self, directory):
        TestArea.cNamespace().copy_directory(self, directory)
示例#42
0
"""

import ert.cwrap.clib as clib

# The libert_util library requires the libraries libz, libblas and
# liblapack. It is assumed that the library has been compiled with a
# suitable RPATH option (i.e. ERT_USE_RPATH has been set to True in
# the build process) and we 'just' load the final libert_util library
# directly. In principle it would be possible preload these libraries
# with calls like:
#
# clib.load("libz" , "libz.so.1")
# clib.load("libblas" , "libblas.so" , "libblas.so.3")
# clib.load("liblapack" , "liblapack.so")

UTIL_LIB = clib.ert_load("libert_util")

from .version import Version

from .enums import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum

from .ctime import CTime

from .vector_template import VectorTemplate, PermutationVector
from .double_vector import DoubleVector
from .int_vector import IntVector
from .bool_vector import BoolVector
from .time_vector import TimeVector
from .stringlist import StringList
from .rng import RandomNumberGenerator
from .matrix import Matrix
示例#43
0
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.

import ert.cwrap.clib as clib
import ert.util
import ert.geo
import ert.ecl
import ert.rms
import ert.analysis
import ert.sched
import ert.config
import ert.job_queue

ENKF_LIB = clib.ert_load("libenkf")

from .enums import *

from .node_id import NodeId

from .enkf_linalg import EnkfLinalg
from .util import TimeMap
from .state_map import StateMap
from .summary_key_set import SummaryKeySet
from .summary_key_matcher import SummaryKeyMatcher
from .enkf_fs import EnkfFs

from .ert_workflow_list import ErtWorkflowList
from .active_list import ActiveList
from .data import *
示例#44
0
class TestPrototype(Prototype):
    lib = clib.ert_load("libert_util")

    def __init__(self, prototype):
        super(TestPrototype, self).__init__(self.lib, prototype)
示例#45
0
from ert.cwrap import clib, CWrapper
from ert.job_queue import WorkflowJob
from ert.test import TestAreaContext, ExtendedTestCase
from .workflow_common import WorkflowCommon

test_lib  = clib.ert_load("libjob_queue") # create a local namespace
cwrapper =  CWrapper(test_lib)

alloc_config = cwrapper.prototype("c_void_p workflow_job_alloc_config()")
alloc_from_file = cwrapper.prototype("workflow_job_obj workflow_job_config_alloc(char*, c_void_p, char*)")

class WorkflowJobTest(ExtendedTestCase):

    def test_workflow_job_creation(self):
        workflow_job = WorkflowJob("Test")

        self.assertTrue(workflow_job.isInternal())
        self.assertEqual(workflow_job.name(), "Test")


    def test_read_internal_function(self):
        with TestAreaContext("python/job_queue/workflow_job") as work_area:
            WorkflowCommon.createInternalFunctionJob()
            WorkflowCommon.createErtScriptsJob()

            config = alloc_config()
            workflow_job = alloc_from_file("SELECT_CASE", config, "select_case_job")

            self.assertEqual(workflow_job.name(), "SELECT_CASE")
            self.assertTrue(workflow_job.isInternal())
            self.assertEqual(workflow_job.functionName(), "enkf_main_select_case_JOB")
示例#46
0
文件: __init__.py 项目: flikka/ert
"""
import ert.util
import ert.geo

from ert.cwrap import clib
from ert.cwrap.metacwrap import Prototype


class EclPrototype(Prototype):
    lib = clib.ert_load("libecl")

    def __init__(self, prototype, bind=True):
        super(EclPrototype, self).__init__(EclPrototype.lib, prototype, bind=bind)

ECL_LIB = clib.ert_load("libecl")

from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclTypeEnum, EclUnitTypeEnum , EclUtil
from .ecl_sum_var_type import EclSumVarType
from .ecl_sum_tstep import EclSumTStep
from .ecl_sum import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode
from .ecl_sum_keyword_vector import EclSumKeyWordVector
from .ecl_rft_cell import EclPLTCell, EclRFTCell
from .ecl_rft import EclRFT, EclRFTFile
from .fortio import FortIO, openFortIO
from .ecl_kw import EclKW
from .ecl_3dkw import Ecl3DKW
from .ecl_file import EclFile , openEclFile
from .ecl_3d_file import Ecl3DFile
from .ecl_init_file import EclInitFile
from .ecl_restart_file import EclRestartFile
示例#47
0
#
#           LSF_BINDIR    = $LSF_HOME/bin
#           LSF_LIBDIR    = $LSF_HOME/lib
#           XLSF_UIDDIR   = $LSF_HOME/lib/uid
#           LSF_SERVERDIR = $LSF_HOME/etc
#           LSF_ENVDIR    = $LSF_HOME/conf
#           PATH          = $PATH:$LSF_BINDIR
#
#      Observe that none of these variables are modified if they
#      already have a value, furthermore it should be observed that
#      the use of an LSF_HOME variable is something invented with ERT,
#      and not standard LSF approach.


def setenv(var, value):
    if not os.getenv(var):
        os.environ[var] = value


# Set up the full LSF environment - based onf LSF_HOME
LSF_HOME = os.getenv("LSF_HOME")
if LSF_HOME:
    setenv("LSF_BINDIR", "%s/bin" % LSF_HOME)
    setenv("LSF_LIBDIR", "%s/lib" % LSF_HOME)
    setenv("XLSF_UIDDIR", "%s/lib/uid" % LSF_HOME)
    setenv("LSF_SERVERDIR", "%s/etc" % LSF_HOME)
    setenv("LSF_ENVDIR",
           "%s/conf" % LSF_HOME)  # This is wrong: Statoil: /prog/LSF/conf

lib = clib.ert_load("libjob_queue.so")
示例#48
0
#  Copyright (C) 2011  Statoil ASA, Norway.
#
#  The file 'libecl.py' is part of ERT - Ensemble based Reservoir Tool.
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
"""
This module will load the libgeometry.so shared library.
"""

# This statement is necessary for side-effects (i.e. the final
# dlopen("libutil.so") call).
import ctypes
import ert.util.libutil
import ert.cwrap.clib as clib

lib = clib.ert_load("libert_geometry.so")
示例#49
0
文件: librms.py 项目: rolk/ert
#  Copyright (C) 2011  Statoil ASA, Norway.
#
#  The file 'librms.py' is part of ERT - Ensemble based Reservoir Tool.
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.

import ert.cwrap.clib as clib
lib = clib.ert_load("librms.so")
示例#50
0
文件: storage.py 项目: akva2/ert
from ert_gui.shell import ErtShellCollection
from ert_gui.shell.libshell import splitArguments, getPossibleFilenameCompletions, extractFullArgument


import ctypes
import os

NO_SORT = 0
STRING_SORT = 1
OFFSET_SORT = 2

import ert.cwrap.clib as clib
UTIL_LIB = clib.ert_load("libert_util")

UTIL_LIB.block_fs_is_mount.restype = ctypes.c_bool
UTIL_LIB.block_fs_mount.restype = ctypes.c_void_p
UTIL_LIB.block_fs_alloc_filelist.restype = ctypes.c_void_p
UTIL_LIB.block_fs_close.restype = ctypes.c_void_p

UTIL_LIB.vector_get_size.restype = ctypes.c_int
UTIL_LIB.vector_iget_const.restype = ctypes.c_void_p
UTIL_LIB.vector_free.restype = ctypes.c_void_p

UTIL_LIB.user_file_node_get_filename.restype = ctypes.c_char_p
UTIL_LIB.user_file_node_get_data_size.restype = ctypes.c_int
UTIL_LIB.user_file_node_get_node_offset.restype = ctypes.c_long

class Storage(ErtShellCollection):
    def __init__(self, parent):
        super(Storage, self).__init__("storage", parent)
示例#51
0
#      If the environment variable LSF_HOME is set we set the
#      remaining LSF variables according to:
#
#           LSF_BINDIR    = $LSF_HOME/bin
#           LSF_LIBDIR    = $LSF_HOME/lib
#           XLSF_UIDDIR   = $LSF_HOME/lib/uid
#           LSF_SERVERDIR = $LSF_HOME/etc
#           LSF_ENVDIR    = $LSF_HOME/conf
#           PATH          = $PATH:$LSF_BINDIR
# 
#      Observe that none of these variables are modified if they
#      already have a value, furthermore it should be observed that
#      the use of an LSF_HOME variable is something invented with ERT,
#      and not standard LSF approach.


def setenv( var , value):
    if not os.getenv( var ):
        os.environ[ var ] = value

# Set up the full LSF environment - based onf LSF_HOME
LSF_HOME = os.getenv( "LSF_HOME")
if LSF_HOME:
    setenv( "LSF_BINDIR"    , "%s/bin" % LSF_HOME )
    setenv( "LSF_LIBDIR"    , "%s/lib" % LSF_HOME )
    setenv( "XLSF_UIDDIR"   , "%s/lib/uid" % LSF_HOME )
    setenv( "LSF_SERVERDIR" , "%s/etc" % LSF_HOME)
    setenv( "LSF_ENVDIR"    , "%s/conf" % LSF_HOME)   # This is wrong: Statoil: /prog/LSF/conf

lib  = clib.ert_load("libjob_queue.so")
示例#52
0
#  Copyright (C) 2013  Statoil ASA, Norway.
#
#  The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool.
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.

import ert.cwrap.clib as clib
import ert.util

ANALYSIS_LIB = clib.ert_load("libanalysis")

from .enums import AnalysisModuleOptionsEnum, AnalysisModuleLoadStatusEnum

from .analysis_module import AnalysisModule
from .linalg import Linalg
示例#53
0
文件: libwell.py 项目: rolk/ert
import ert.ecl.libecl
import ert.cwrap.clib as clib
lib = clib.ert_load("libecl_well.so")
示例#54
0
from ert.cwrap import clib, CWrapper
from ert.enkf.data import EnkfNode
from ert.enkf.config import GenDataConfig
from ert.enkf import NodeId
from ert.enkf import ForwardLoadContext
from ert.test import ErtTestContext, ExtendedTestCase
from ert.util import BoolVector

test_lib  = clib.ert_load("libenkf")
cwrapper =  CWrapper(test_lib)

get_active_mask = cwrapper.prototype("bool_vector_ref gen_data_config_get_active_mask( gen_data_config )")
update_active_mask = cwrapper.prototype("void gen_data_config_update_active( gen_data_config, forward_load_context , bool_vector)")

alloc_run_arg = cwrapper.prototype("run_arg_obj run_arg_alloc_ENSEMBLE_EXPERIMENT( enkf_fs , int , int , char*) ")


def updateMask(gen_data_config , report_step , fs, active_mask):
    run_arg = alloc_run_arg( fs , 0 , 0 , "Path")
    load_context = ForwardLoadContext( run_arg = run_arg , report_step = report_step )
    update_active_mask( gen_data_config , load_context , active_mask )

    

class GenDataConfigTest(ExtendedTestCase):
    def setUp(self):
        self.config_file = self.createTestPath("Statoil/config/with_GEN_DATA/config")

    def load_active_masks(self, case1, case2 ):
        with ErtTestContext("gen_data_config_test", self.config_file) as test_context:
            ert = test_context.getErt()
示例#55
0
文件: test_cwrap.py 项目: akva2/ert
import ctypes
from ert.cwrap import CWrapper, BaseCClass, clib, CWrapError
from ert.test  import ExtendedTestCase

test_lib  = clib.ert_load("libert_util") # create a local namespace (so we don't overwrite StringList)
cwrapper =  CWrapper(test_lib)

class StringListTest(BaseCClass):
    def __init__(self):
        c_pointer = self.cNamespace().alloc()
        super(StringListTest, self).__init__(c_pointer)

    def free(self):
        StringListTest.cNamespace().free(self)

CWrapper.registerObjectType("stringlisttest", StringListTest)

StringListTest.cNamespace().alloc = cwrapper.prototype("c_void_p stringlist_alloc_new( )")
StringListTest.cNamespace().free  = cwrapper.prototype("void stringlist_free(stringlisttest )")


class CWrapTest(ExtendedTestCase):

    def test_return_type(self):
        stringlist_alloc = cwrapper.prototype("c_void_p stringlist_alloc_new( )")
        string_list1 = StringListTest()

        stringlist_alloc = cwrapper.prototype("stringlisttest_obj stringlist_alloc_new( )")
        string_list2 = stringlist_alloc()

        stringlist_alloc = cwrapper.prototype("stringlisttest_ref stringlist_alloc_new( )")