def archive(self, **kwargs): # Archive restart files before processing model output mkdir_p(self.res_path) restart_files = [f for f in os.listdir(self.work_path) if f.startswith('pickup.') and not f.split('.')[1].startswith('ckpt')] for f in restart_files: f_src = os.path.join(self.work_path, f) #f_dest = os.path.join(self.res_path, f) sh.move(f_src, self.res_path) super(mitgcm, self).archive(**kwargs)
def setup(self, use_symlinks=True, repeat_run=False): # payu setup: # work path and symlink, config file copy super(fms, self).setup() # Create experiment directory structure work_res_path = os.path.join(self.work_path, 'RESTART') mkdir_p(work_res_path) # David Singleton's striping recommedation cmd = ['lfs', 'setstripe', '-c', '8', '-s', '8m', work_res_path] rc = sp.Popen(cmd).wait() assert rc == 0 # Either create a new INPUT path or link a previous RESTART as INPUT input_path = os.path.join(self.work_path, 'INPUT') mkdir_p(input_path) if self.counter > 1 and not repeat_run: restart_files = os.listdir(self.prior_res_path) for f in restart_files: f_res = os.path.join(self.prior_res_path, f) f_input = os.path.join(input_path, f) if use_symlinks: os.symlink(f_res, f_input) else: sh.copy(f_res, f_input) # Link any forcing data to INPUT if self.forcing_path: forcing_files = os.listdir(self.forcing_path) for f in forcing_files: f_forcing = os.path.join(self.forcing_path, f) f_input = os.path.join(input_path, f) # Do not use forcing file if it is in RESTART if not os.path.exists(f_input): if use_symlinks: os.symlink(f_forcing, f_input) else: sh.copy(f_forcing, f_input)