Exemple #1
0
 def test1(self):
     comm = MPI.COMM_WORLD
     pe1 = comm.Get_rank()
     nprocs1 = comm.Get_size()
     vm = ESMP.ESMP_VMGetGlobal()
     pe2, nprocs2 = ESMP.ESMP_VMGet(vm)
     self.assertEqual(pe1, pe2)
     self.assertEqual(nprocs1, nprocs2)
Exemple #2
0
    def __init__(self, esmfGrid, name, datatype, staggerloc = CENTER):
        """
        Creator for structured ESMF Field
        @param esmfGrid instance of an ESMP_Grid
        @param name field name (must be unique)
        @param datatype data type, one of 'float64', 'float32', 'int64', or 'int32'
                        (or equivalent numpy dtype)
        @param staggerloc ESMP_STAGGERLOC_CENTER
                          ESMP_STAGGERLOC_CORNER
        """
        # field object
        self.field = None
        # the local processor rank
        self.pe = 0
        # the number of processors
        self.nprocs = 1
        # associated grid
        self.grid = esmfGrid
        # staggering
        self.staggerloc = staggerloc
        # communicator
        self.comm = None

        try:
            from mpi4py import MPI
            self.comm = MPI.COMM_WORLD
        except:
            pass

        vm = ESMP.ESMP_VMGetGlobal()
        self.pe, self.nprocs = ESMP.ESMP_VMGet(vm)

        etype = None
        sdatatype = str(datatype) # in case user passes a numpy dtype
        if re.search('float64', sdatatype):
            etype = R8
        elif re.search('float32', sdatatype):
            etype = R4
        elif re.search('int64', sdatatype):
            etype = I8
        elif re.search('int32', sdatatype):
            etype = I4
        else:
            msg = 'esmf.EsmfStructField.__init__: ERROR invalid type %s' % datatype
            raise RegridError, msg

        self.field = ESMP.ESMP_FieldCreateGrid(esmfGrid.grid,
                                               name,
                                               staggerloc = staggerloc,
                                               typekind = etype)
Exemple #3
0
    def __init__(self, numTopoDims, numSpaceDims):
        """
        Constructor
        @param numTopoDims number of topological dimensions
        @param numSpaceDims number of space dimensions
        """
        # handle to the grid object
        self.grid = None
        # whether or not nodes were added
        self.nodesAdded = False
        # whether or not cells were added
        self.cellsAdded = False
        # the local processor rank
        self.pe = 0
        # number of processors
        self.nprocs = 1
        # communicator
        self.comm = None

        vm = ESMP.ESMP_VMGetGlobal()
        self.pe, self.nprocs = ESMP.ESMP_VMGet(vm)

        self.grid = ESMP.ESMP_MeshCreate(numTopoDims, numSpaceDims)