if os.path.exists(os.environ['GFDL_DATA'] + casename): shutil.rmtree(os.environ['GFDL_DATA'] + casename) #Step 2. Provide the necessary input files and user source code: if not os.path.exists(builddir): os.makedirs(builddir) if not os.path.exists(builddir + '/Isca'): os.symlink(os.environ['GFDL_BASE'], builddir + '/Isca') #cb = IscaCodeBase.from_directory(builddir+'/Isca',storedir=builddir) # for saving obj files in Isca_caseroot/ if radiation_scheme == 'grey': cb = GreyCodeBase.from_directory(builddir + '/Isca') do_grey = True do_rrtm = False do_socrates = False if radiation_scheme == 'rrtm': cb = IscaCodeBase.from_directory(builddir + '/Isca') do_grey = False do_rrtm = True do_socrates = False if radiation_scheme == 'socrates': cb = SocratesCodeBase.from_directory(builddir + '/Isca') do_grey = False do_rrtm = False do_socrates = True if 'compile' in todo or 'configure' in todo: if mothercase is not None: mom_builddir = isca_caseroot + mothercase mom_objdir = mom_builddir.replace('/', '_') + '_Isca' if os.path.exists(os.environ['GFDL_WORK'] + '/codebase/' + mom_objdir): print('found mother case: ' + mothercase + ', copying .......')
import os import numpy as np from isca import IscaCodeBase, DiagTable, Experiment, Namelist, GFDL_BASE NCORES = 8 base_dir = os.path.dirname(os.path.realpath(__file__)) # a CodeBase can be a directory on the computer, # useful for iterative development cb = IscaCodeBase.from_directory(GFDL_BASE) # or it can point to a specific git repo and commit id. # This method should ensure future, independent, reproducibility of results. # cb = DryCodeBase.from_repo(repo='https://github.com/isca/isca', commit='isca1.1') # compilation depends on computer specific settings. The $GFDL_ENV # environment variable is used to determine which `$GFDL_BASE/src/extra/env` file # is used to load the correct compilers. The env file is always loaded from # $GFDL_BASE and not the checked out git repo. cb.compile( ) # compile the source code to working directory $GFDL_WORK/codebase # create an Experiment object to handle the configuration of model parameters # and output diagnostics exp = Experiment('frierson_rotate_slow', codebase=cb) #Tell model how to write diagnostics diag = DiagTable() diag.add_file('atmos_monthly', 30, 'days', time_units='days')
def test_isca_codebase(): cb = IscaCodeBase.from_directory(GFDL_BASE) cb.compile()