Esempio n. 1
0
    def genSuite(self):
        """See base class :meth:`~credo.systest.api.SysTest.genSuite`.

        The generated suite will contain model runs all with the same model
        XML files, but with increasing resolution as specified by the 
        :attr:`.resSet` attribute.
        """
        for res in self.resSet:
            resStr = mrun.strRes(res)
            modelName = self.testName+'-'+resStr
            mRun = self._createDefaultModelRun(modelName,
                os.path.join(self.outputPathBase, resStr))
            customOpts = mrun.generateResOpts(res)
            self.mSuite.addRun(mRun, "Run the model at res %s" % (resStr), customOpts)
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])

#For now just copy all args as input files
inputFiles = args
modelName, ext = os.path.splitext(args[0])
# Do the following live on an options struct?
outputPath = 'output/' + modelName
nproc = 1

resSet = [(10, 10), (20, 20), (30, 30), (40, 40)]

print "Running all resolutions in resolution set:"
print resSet

for res in resSet:
    mOutputPath = outputPath + os.sep + mrun.strRes(res)

    mRun = mrun.ModelRun(modelName, inputFiles, mOutputPath, nproc=nproc)

    customOpts = "--pluginData.appendToAnalysisFile=True "
    customOpts += mrun.generateResOpts(res)

    # For analytic test, assume the user has specified what fields to analyse
    # in the XML (In the background this will generate the flattened XML
    # for the model
    fTests = mRun.analysis['fieldTests']
    fTests.readFromStgXML(mRun.modelInputFiles)
    # Set all field tolerances at once. Of course, should allow this to
    # be over-ridden
    fTests.setAllTols(defaultFieldTol)
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])

#For now just copy all args as input files
inputFiles = args
modelName, ext = os.path.splitext(args[0])
# Do the following live on an options struct?
outputPath = 'output/'+modelName
nproc=1

resSet = [(10,10),(20,20),(30,30),(40,40)]

print "Running all resolutions in resolution set:"
print resSet

for res in resSet:
    mOutputPath = outputPath+os.sep+mrun.strRes(res)

    mRun = mrun.ModelRun(modelName, inputFiles, mOutputPath, nproc=nproc)

    customOpts = "--pluginData.appendToAnalysisFile=True "
    customOpts += mrun.generateResOpts(res)

    # For analytic test, assume the user has specified what fields to analyse
    # in the XML (In the background this will generate the flattened XML
    # for the model
    fTests = mRun.analysis['fieldTests']
    fTests.readFromStgXML(mRun.modelInputFiles)
    # Set all field tolerances at once. Of course, should allow this to
    # be over-ridden
    fTests.setAllTols(defaultFieldTol)