Skip to content
Snippets Groups Projects
Commit d8265e05 authored by lkugler's avatar lkugler
Browse files

all exps at once

parent 8eda9dbe
No related branches found
No related tags found
No related merge requests found
import os, glob, shutil import os, sys, glob, shutil
from config.cfg import exp, cluster
from utils import try_remove from utils import try_remove
"""Run this script after an experiment to reduce cluster disk usage. """Run this script to reduce wrfrst files
1) remove wrfrst Example call:
2) remove run_DART folders from exp python ./cleanup_exp.py
3) remove run_WRF files from exp
""" """
keep_last_init_wrfrst = True keep_last_init_wrfrst = True
print('removing files for exp', exp.expname) datadir = '/gpfs/data/fs71386/lkugler/sim_archive/'
#exp = sys.argv[1]
for exp in os.listdir(datadir):
# 1) wrfrst print('removing files for exp', exp)
inits = reversed(sorted(glob.glob(cluster.archivedir+'/20??-??-??_??:??')))
for k, init in enumerate(inits):
rst_files = glob.glob(init+'/*/wrfrst_*')
if k == 0: # last init of exp inits = glob.glob(datadir+exp+'/20??-??-??_??:??')
for init in inits:
if not keep_last_init_wrfrst: for iens in range(1, 41):
for f in rst_files: rst_files = sorted(glob.glob(init+'/'+str(iens)+'/wrfrst_*'))
try_remove(f) #print(rst_files)
else: if len(rst_files)>1:
for f in rst_files: for f in sorted(rst_files)[:-1]:
try_remove(f) try_remove(f)
print(f, 'removed')
# 2) run_DART/exp
shutil.rmtree(cluster.dartrundir, ignore_errors=True)
# 3) run_WRF/exp
shutil.rmtree(cluster.wrf_rundir_base+'/'+exp.expname, ignore_errors=True)
print(cluster.wrf_rundir_base+'/'+exp.expname, 'removed.')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment