From d8265e05b4a26153fd0d58c9fc6fe88b20a60f54 Mon Sep 17 00:00:00 2001 From: lkugler <lukas.kugler@gmail.com> Date: Mon, 14 Feb 2022 17:59:29 +0100 Subject: [PATCH] all exps at once --- dartwrf/cleanup_exp.py | 48 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/dartwrf/cleanup_exp.py b/dartwrf/cleanup_exp.py index 3b913cb..f9edebf 100644 --- a/dartwrf/cleanup_exp.py +++ b/dartwrf/cleanup_exp.py @@ -1,34 +1,26 @@ -import os, glob, shutil -from config.cfg import exp, cluster +import os, sys, glob, shutil 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 -2) remove run_DART folders from exp -3) remove run_WRF files from exp +Example call: + python ./cleanup_exp.py """ keep_last_init_wrfrst = True -print('removing files for exp', exp.expname) - -# 1) wrfrst -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 - - if not keep_last_init_wrfrst: - for f in rst_files: - try_remove(f) - else: - for f in rst_files: - try_remove(f) - -# 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.') +datadir = '/gpfs/data/fs71386/lkugler/sim_archive/' +#exp = sys.argv[1] +for exp in os.listdir(datadir): + + print('removing files for exp', exp) + + inits = glob.glob(datadir+exp+'/20??-??-??_??:??') + for init in inits: + for iens in range(1, 41): + rst_files = sorted(glob.glob(init+'/'+str(iens)+'/wrfrst_*')) + #print(rst_files) + if len(rst_files)>1: + for f in sorted(rst_files)[:-1]: + try_remove(f) + print(f, 'removed') + -- GitLab