def _make_sim(domain_dir, compiler, source_dir, configuration, option_suite, ncores, nnodes, scheduler, account, walltime, queue): model = wrfhydropy.Model(compiler=compiler, source_dir=source_dir, model_config=configuration) domain = wrfhydropy.Domain(domain_top_dir=domain_dir, domain_config=configuration) sim = wrfhydropy.Simulation() sim.add(model) sim.add(domain) # Update base namelists with option suite if specified if option_suite is not None: pass if scheduler: sim.add( wrfhydropy.schedulers.PBSCheyenne(account=account, nproc=int(ncores), nnodes=int(nnodes), walltime=walltime, queue=queue)) return sim
str(experiment_dir / 'croton_NY.tar.gz')) get_ipython().run_cell_magic( 'bash', '', 'cd /glade/scratch/jamesmcc/ens_cycle_example/ ;\n' + 'tar xzf croton_NY.tar.gz ;\n' + 'mv example_case croton_NY') # ## Building Blocks # ### Domain domain = wrfhydropy.Domain(domain_top_dir=domain_dir, domain_config=configuration) # ### Model model = wrfhydropy.Model(source_dir=model_dir / 'trunk/NDHMS', model_config=configuration, compiler='ifort') model_pkl = compile_dir / 'WrfHydroModel.pkl' if not model_pkl.exists(): model.compile(compile_dir) else: model = pickle.load(model_pkl.open('rb')) # ### Job model_start_time = datetime.datetime(2018, 8, 1, 0) model_end_time = model_start_time + datetime.timedelta(hours=2) job = wrfhydropy.Job(job_id='flo_sim', model_start_time=model_start_time, model_end_time=model_end_time,
def setup_wrf_hydro(config): print('wrfhydropy.Domain object.') wrf_hydro_domain = wrfhydropy.Domain( domain_top_dir=config['wrf_hydro']['domain_src'], domain_config=config['wrf_hydro']['model_config'] #model_version=config['wrf_hydro']['domain_version'] ) print('wrfhydropy.Model object.') wrf_hydro_build_dir = config['experiment']['experiment_dir'] / config[ 'wrf_hydro']['build_dir'] wrf_hydro_model_pickle = wrf_hydro_build_dir / 'WrfHydroModel.pkl' if config['wrf_hydro']['use_existing_build']: if wrf_hydro_model_pickle.exists(): print('WrfHydroModel object: using existing pickle.') wrf_hydro_model = pickle.load(open(wrf_hydro_model_pickle, 'rb')) else: raise ValueError( 'Existing WRF_HYDRO model requested but no pickle file found') else: # TODO(JLM): If fork specified, pull fork. Check out desired commit. # TODO(JLM): clone to build_dir? or make a clone_dir in this case? # If not fork, only use local repo state. wrf_hydro_model = wrfhydropy.Model( source_dir=config['wrf_hydro']['wrf_hydro_src'] / 'trunk/NDHMS/', model_config=config['wrf_hydro']['model_config'], compiler=config['wrf_hydro']['compiler'], hydro_namelist_config_file=config['wrf_hydro'] ['hydro_namelist_config_file'], hrldas_namelist_config_file=config['wrf_hydro'] ['hrldas_namelist_config_file'], compile_options_config_file=config['wrf_hydro'] ['compile_options_config_file']) # Apply compile option patches. if config['wrf_hydro']['compile_options'] is not None: wrf_hydro_model.compile_options.update( config['wrf_hydro']['compile_options']) wrf_hydro_model.compile( compile_dir=config['experiment']['experiment_dir'] / config['wrf_hydro']['build_dir']) print('wrfhydropy.Job object') job = wrfhydropy.Job(exe_cmd='mpirun -np 4 ./wrf_hydro.exe', job_id='nwm_spinup', restart=False) print('wrfhydropy.Simulation object.') wrf_hydro_sim = wrfhydropy.Simulation() wrf_hydro_sim.add(wrf_hydro_model) wrf_hydro_sim.add(wrf_hydro_domain) # These were deep copied, delete them. del wrf_hydro_model, wrf_hydro_domain return wrf_hydro_sim