Ejemplo n.º 1
0
    def stopESMP(self, delete_log=False):
        '''
        Calls ESMP.ESMP_Finalize if ESMP had been initialized using
        startCheckESMP.  This function is registered with atexit
        by startCheckESMP when it calls ESMP.ESMP_Initialize to
        ensure ESMP.ESMP_Finalize is always called before exiting
        Python.  However, this function can be called directly
        (presumably to delete the log file) before exiting without
        causing problems.

        Arguments:
            delete_log: if True, the ESMF log file 'PET0.ESMF_LogFile'
                        will be deleted after ESMP.ESMP_Finalize is
                        called.  Any failure to delete the log file
                        is silently ignored.
        Returns:
            None
        '''
        # If ESMP not initialize, or already finalized, just return
        if not self.__esmp_initialized:
            return
        if self.__esmp_finalized:
            return
        # Call ESMP_Finalize and set flags indicating this has been done
        ESMP.ESMP_Finalize()
        self.__esmp_initialized = False
        self.__esmp_finalized = True
        # Optionally delete the ESMF log file
        if delete_log:
            try:
                os.remove('PET0.ESMF_LogFile')
            except Exception:
                pass
print '1. ', srcPtr.size, srcCrds[0].size

ESMP.ESMP_GridAddCoord(srcGrid1, staggerloc=CENTER)

srcPtr = ESMP.ESMP_FieldGetPtr(srcFeld1)
print '1. ', srcPtr.size, srcCrds[0].size

srcGrid2 = ESMP.ESMP_GridCreateNoPeriDim(maxIndex, coordSys=COORDSYS)
dstGrid2 = ESMP.ESMP_GridCreateNoPeriDim(maxIndex, coordSys=COORDSYS)

ESMP.ESMP_GridAddCoord(srcGrid2, staggerloc=CENTER)
srcFeld2 = ESMP.ESMP_FieldCreateGrid(srcGrid2,
                                     'srcFeld2',
                                     staggerloc=CENTER,
                                     typekind=R4)
dstFeld2 = ESMP.ESMP_FieldCreateGrid(dstGrid2,
                                     'dstFeld',
                                     staggerloc=CENTER,
                                     typekind=R4)

srcPtr = ESMP.ESMP_FieldGetPtr(srcFeld2)
print '2. ', srcPtr.size, srcCrds[0].size

srcStuff = createGridAndField(maxIndex)

aa = srcStuff.getDataPointer()
bb = srcStuff.getCoordPointer()
print '3. ', aa.size, bb.size

ESMP.ESMP_Finalize()
Ejemplo n.º 3
0
 def test4_multipleFinalize(self):
     ESMP.ESMP_Initialize()
     ESMP.ESMP_Finalize()
     ESMP.ESMP_Finalize()
Ejemplo n.º 4
0
 def test1_pairedInitializeFinalize(self):
     ESMP.ESMP_Initialize()
     ESMP.ESMP_Finalize()
Ejemplo n.º 5
0
 def test3_multitpleInitialize(self):
     ESMP.ESMP_Initialize()
     ESMP.ESMP_Initialize()
     ESMP.ESMP_Finalize()