def compile(self, extra_pathnames=[], executable_name=None, debug=False, optimisation=None): env = get_env_file() mkdir(self.builddir) compile_flags = [] # if debug: # compile_flags.append('-g') # compile_flags.append('-traceback') # compile_flags.append('-debug all') # if optimisation is not None: # compile_flags.append('-O%d' % optimisation) compile_flags.extend(self.compile_flags) compile_flags_str = ' '.join(compile_flags) # get path_names from the directory if not self.path_names: self.path_names = self.read_path_names( P(self.srcdir, 'extra', 'model', self.name, 'path_names')) # wykang: add extra path_names if extra_pathnames: self.path_names = extra_pathnames + self.path_names self.write_path_names(self.path_names) path_names_str = P(self.builddir, 'path_names') # wykang: use different excutable_name if executable_name: self.executable_name = executable_name vars = { 'execdir': self.builddir, 'template_dir': self.templatedir, 'srcdir': self.srcdir, 'workdir': self.workdir, 'compile_flags': compile_flags_str, 'env_source': env, 'path_names': path_names_str, 'executable_name': self.executable_name, 'debug': debug } self.templates.get_template('compile.sh').stream(**vars).dump( P(self.builddir, 'compile.sh')) self.log.info('Running compiler') for line in sh.bash(P(self.builddir, 'compile.sh'), _iter=True, _err_to_out=True): self._log_line(line) self.log.info('Compilation complete.')
def __init__(self, name, codebase, safe_mode=False, workbase=GFDL_WORK, database=GFDL_DATA): super(Experiment, self).__init__() self.name = name self.codebase = codebase self.safe_mode = safe_mode # set the default locations of working directory, # executable directory, restart file storage, and # output data directory. self.workdir = P(workbase, 'experiment', self.name) self.rundir = P( self.workdir, 'run') # temporary area an individual run will be performed self.datadir = P( database, self.name) # where run data will be moved to upon completion self.restartdir = P(self.datadir, 'restarts') # where restarts will be stored self.template_dir = P(_module_directory, 'templates') self.env_source = get_env_file() self.templates = Environment( loader=FileSystemLoader(self.template_dir)) self.diag_table = DiagTable() self.field_table_file = P(self.codebase.srcdir, 'extra', 'model', self.codebase.name, 'field_table') self.inputfiles = [] self.namelist = Namelist()