From 0cf47e0b1faad28c646221e2eba70713a78c9240 Mon Sep 17 00:00:00 2001
From: lkugler <lukas.kugler@gmail.com>
Date: Sun, 12 Feb 2023 21:33:31 +0100
Subject: [PATCH] improved config

---
 analysis_only.py                   |  3 +-
 config/cfg.py                      | 13 ++--
 config/clusters.py                 | 16 ++---
 cycled_exp.py                      | 46 +++++++-------
 dartwrf/assim_synth_obs.py         |  3 +-
 dartwrf/create_obs_upfront.py      |  3 +-
 dartwrf/create_obsseq.py           |  3 +-
 dartwrf/create_wbubble_wrfinput.py |  3 +-
 dartwrf/evaluate_posterior.py      |  3 +-
 dartwrf/evaluate_prior.py          |  3 +-
 dartwrf/link_dart_rttov.py         |  3 +-
 dartwrf/obsseq.py                  |  3 +-
 dartwrf/obsseq_2dim.py             |  3 +-
 dartwrf/obsseq_to_netcdf.py        |  3 +-
 dartwrf/prep_IC_prior.py           |  3 +-
 dartwrf/prepare_namelist.py        |  3 +-
 dartwrf/prepare_wrfrundir.py       |  3 +-
 dartwrf/run_obs_diag.py            |  3 +-
 dartwrf/update_IC.py               |  3 +-
 dartwrf/utils.py                   | 99 ++++++++++++++----------------
 dartwrf/wrfinput_add_geo.py        |  3 +-
 dartwrf/wrfout_add_geo.py          |  3 +-
 generate_free.py                   |  3 +-
 23 files changed, 121 insertions(+), 110 deletions(-)

diff --git a/analysis_only.py b/analysis_only.py
index fa735f9..9910102 100755
--- a/analysis_only.py
+++ b/analysis_only.py
@@ -6,7 +6,8 @@ import os, sys, shutil
 import datetime as dt
 
 from dartwrf import utils
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 
 log_dir = cluster.archivedir+'/logs/'
 slurm_scripts_dir = cluster.archivedir+'/slurm-scripts/'
diff --git a/config/cfg.py b/config/cfg.py
index 6dc6ee8..b9e356e 100755
--- a/config/cfg.py
+++ b/config/cfg.py
@@ -1,15 +1,13 @@
 from dartwrf import utils
-from config import clusters  # from . = problem in archivedir
-cluster = clusters.jet  # change cluster configuration here
 
 exp = utils.ExperimentConfiguration()
-exp.expname = "exp_v1.22_P2_rr_VIS+WV73_obs10_loc20_inf2"
+exp.expname = "exp_v1.22_P2_rr_WV62_obs10_loc20_oe2" #"exp_v1.22_P2_rr_VIS+WV73_obs10_loc20_inf5"
 exp.model_dx = 2000
 exp.n_ens = 40
 
 exp.filter_kind = 1
-exp.prior_inflation = 2
-exp.post_inflation = 0
+exp.prior_inflation = 0
+exp.post_inflation = 4
 exp.sec = True
 exp.reject_smallFGD = False
 exp.cov_loc_vert_km_horiz_km = (3, 20)
@@ -95,10 +93,7 @@ psfc = dict(plotname='SYNOP Pressure', plotunits='[Pa]',
             error_generate=50., error_assimilate=100.,
             cov_loc_radius_km=32)
 
-
-exp.observations = [vis,wv73]
+exp.observations = [wv62]
 exp.update_vars = ['U', 'V', 'W', 'THM', 'PH', 'MU', 'QVAPOR', 'QCLOUD', 'QICE', 'PSFC']
 #exp.update_vars = ['U', 'V', 'W', 'T', 'PH', 'MU', 'QVAPOR', 'PSFC']
 
-# directory paths depend on the name of the experiment
-cluster.expname = exp.expname
diff --git a/config/clusters.py b/config/clusters.py
index d2ae6f8..4d35429 100755
--- a/config/clusters.py
+++ b/config/clusters.py
@@ -1,6 +1,7 @@
 import os, sys
 import datetime as dt
 from dartwrf import utils
+from config.cfg import exp
 
 """Configuration name docs
 
@@ -39,12 +40,9 @@ slurm_cfg               python dictionary, containing options of SLURM
                             this configuration can be overwritten later on, for example:
                             'dict(cluster.slurm_cfg, **cfg_update)' where
                             'cfg_update = {"nodes": "2"}'
-"""                 
+"""
 
-
-
-
-vsc = utils.ClusterConfig()
+vsc = utils.ClusterConfig(exp)
 vsc.name = 'vsc' 
 vsc.max_nproc = 20
 vsc.size_jobarray = 10  # 10 jobs with each 4 WRF processes per node
@@ -77,7 +75,7 @@ vsc.slurm_cfg = {"account": "p71386", "partition": "skylake_0384", "qos": "p7138
                  "nodes": "1", "ntasks": "1", "ntasks-per-node": "48", "ntasks-per-core": "1",
                  "mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"}
 
-jet = utils.ClusterConfig()
+jet = utils.ClusterConfig(exp)
 jet.name = 'jet'
 jet.max_nproc = 12
 jet.use_slurm = True
@@ -113,7 +111,7 @@ jet.slurm_cfg = {"account": "lkugler", "partition": "compute", #"nodelist": "jet
                  "mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"}
 
 
-srvx1 = utils.ClusterConfig()
+srvx1 = utils.ClusterConfig(exp)
 srvx1.name = 'srvx1'
 srvx1.max_nproc = 6
 srvx1.size_jobarray = 40
@@ -146,3 +144,7 @@ srvx1.run_WRF = srvx1.scriptsdir+'/run_ens.jet.sh'
 srvx1.slurm_cfg = {"account": "lkugler", "partition": "compute",
                  "ntasks": "1", "ntasks-per-core": "1", "mem": "50G",
                  "mail-type": "FAIL", "mail-user": "lukas.kugler@univie.ac.at"}
+
+########
+# select cluster configuration here
+cluster = jet
diff --git a/cycled_exp.py b/cycled_exp.py
index 4e30e99..204be18 100755
--- a/cycled_exp.py
+++ b/cycled_exp.py
@@ -1,13 +1,13 @@
 #!/usr/bin/python3
 """
-high level control script
-submitting jobs into SLURM queue
+Run a cycled OSSE with WRF and DART.
 """
 import os, sys, shutil, glob, warnings
 import datetime as dt
 
-from dartwrf.utils import script_to_str, symlink, copy, create_job
-from config.cfg import exp, cluster
+from dartwrf.utils import script_to_str
+from config.cfg import exp
+from config.clusters import cluster
 
 log_dir = cluster.archivedir+'/logs/'
 slurm_scripts_dir = cluster.archivedir+'/slurm-scripts/'
@@ -32,7 +32,7 @@ do
     mv $rundir/rsl.out.0000 $rundir/rsl.out.input
 done
 """
-    s = create_job("ideal", cfg_update={"ntasks": str(exp.n_ens),
+    s = cluster.create_job("ideal", cfg_update={"ntasks": str(exp.n_ens),
                                       "time": "10", "mem": "100G"})
     id = s.run(cmd, depends_on=[depends_on])
     return id
@@ -41,7 +41,7 @@ def wrfinput_insert_wbubble(perturb=True, depends_on=None):
     """Given that directories with wrfinput files exist,
     update these wrfinput files with warm bubbles
     """
-    s = create_job("ins_wbubble", cfg_update={"time": "5"})
+    s = cluster.create_job("ins_wbubble", cfg_update={"time": "5"})
     pstr = ' '
     if perturb:
         pstr = ' perturb'
@@ -64,7 +64,7 @@ def run_ENS(begin, end, depends_on=None, first_minute=True,
     #     hist_interval = 1
     #     radt = 1  # calc CFRAC also in first minute
     #     begin_plus1 = begin+dt.timedelta(minutes=1)
-    #     s = create_job("preWRF1", cfg_update=dict(time="2"))
+    #     s = cluster.create_job("preWRF1", cfg_update=dict(time="2"))
     #     args = [cluster.python, cluster.scripts_rundir+'/prepare_namelist.py',
     #             begin.strftime('%Y-%m-%d_%H:%M'),
     #             begin_plus1.strftime('%Y-%m-%d_%H:%M'),
@@ -73,13 +73,13 @@ def run_ENS(begin, end, depends_on=None, first_minute=True,
     #             '--restart='+restart_flag,]
     #     id = s.run(' '.join(args), depends_on=[id])
 
-    #     s = create_job("runWRF1", cfg_update={"nodes": "1", "array": "1-"+str(exp.n_nodes),
+    #     s = cluster.create_job("runWRF1", cfg_update={"nodes": "1", "array": "1-"+str(exp.n_nodes),
     #                 "time": "2", "mem-per-cpu": "2G"})
     #     cmd = script_to_str(cluster.run_WRF).replace('<expname>', exp.expname)
     #     id = s.run(cmd, depends_on=[id])
 
     #     # apply forward operator (DART filter without assimilation)
-    #     s = create_job("fwOP-1m", cfg_update=dict(time="10", ntasks=48))
+    #     s = cluster.create_job("fwOP-1m", cfg_update=dict(time="10", ntasks=48))
     #     id = s.run(cluster.python+' '+cluster.scripts_rundir+'/apply_obs_op_dart.py '
     #                + begin.strftime('%Y-%m-%d_%H:%M')+' '
     #                + begin_plus1.strftime('%Y-%m-%d_%H:%M'),
@@ -98,12 +98,12 @@ def run_ENS(begin, end, depends_on=None, first_minute=True,
     if output_restart_interval:
         args.append('--restart_interval='+str(int(float(output_restart_interval))))
 
-    s = create_job("preWRF", cfg_update=dict(time="2"))
+    s = cluster.create_job("preWRF", cfg_update=dict(time="2"))
     id = s.run(' '.join(args), depends_on=[id])
 
     time_in_simulation_hours = (end-begin).total_seconds()/3600
     runtime_wallclock_mins_expected = int(8+time_in_simulation_hours*9.5)  # usually below 9 min/hour
-    s = create_job("WRF", cfg_update={"array": "1-"+str(cluster.size_jobarray), "ntasks": "10", "nodes": "1",
+    s = cluster.create_job("WRF", cfg_update={"array": "1-"+str(cluster.size_jobarray), "ntasks": "10", "nodes": "1",
                 "time": str(runtime_wallclock_mins_expected), "mem": "140G"})
     cmd = script_to_str(cluster.run_WRF).replace('<exp.expname>', exp.expname
                                        ).replace('<cluster.wrf_rundir_base>', cluster.wrf_rundir_base)
@@ -123,7 +123,7 @@ def assimilate(assim_time, prior_init_time, prior_valid_time, prior_path_exp,
     if not os.path.exists(prior_path_exp):
         raise IOError('prior_path_exp does not exist: '+prior_path_exp)
 
-    id = create_job("Assim", cfg_update={"ntasks": "12", "time": "60",
+    id = cluster.create_job("Assim", cfg_update={"ntasks": "12", "time": "60",
                              "mem": "200G", "ntasks-per-node": "12", "ntasks-per-core": "2"}
             ).run(cluster.python+' '+cluster.scripts_rundir+'/assim_synth_obs.py '
                +assim_time.strftime('%Y-%m-%d_%H:%M ')
@@ -140,7 +140,7 @@ def prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, new
     else:
         tnew = ''
 
-    id = create_job("IC-prior", cfg_update=dict(time="8")
+    id = cluster.create_job("IC-prior", cfg_update=dict(time="8")
             ).run(cluster.python+' '+cluster.scripts_rundir+'/prep_IC_prior.py '
                 +prior_path_exp 
                 +prior_init_time.strftime(' %Y-%m-%d_%H:%M')
@@ -150,14 +150,14 @@ def prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, new
 
 
 def update_IC_from_DA(assim_time, depends_on=None):
-    id = create_job("IC-update", cfg_update=dict(time="8")
+    id = cluster.create_job("IC-update", cfg_update=dict(time="8")
             ).run(cluster.python+' '+cluster.scripts_rundir+'/update_IC.py '
                 +assim_time.strftime('%Y-%m-%d_%H:%M'), depends_on=[depends_on])
     return id
 
 
 def create_satimages(init_time, depends_on=None):
-    s = create_job("RTTOV", cfg_update={"ntasks": "12", "time": "80", "mem": "200G"})
+    s = cluster.create_job("RTTOV", cfg_update={"ntasks": "12", "time": "80", "mem": "200G"})
     id = s.run(cluster.python_verif+' ~/RTTOV-WRF/run_init.py '+cluster.archivedir
                +init_time.strftime('/%Y-%m-%d_%H:%M/'),
           depends_on=[depends_on])
@@ -166,31 +166,31 @@ def create_satimages(init_time, depends_on=None):
 
 def mailme(depends_on=None):
     if depends_on:
-        s = create_job("AllFinished", cfg_update={"time": "1", "mail-type": "BEGIN"})
+        s = cluster.create_job("AllFinished", cfg_update={"time": "1", "mail-type": "BEGIN"})
         s.run('sleep 1', depends_on=[depends_on])
 
 
 def gen_obsseq(depends_on=None):
-    s = create_job("obsseq_netcdf", cfg_update={"time": "10", "mail-type": "FAIL,END"})
+    s = cluster.create_job("obsseq_netcdf", cfg_update={"time": "10", "mail-type": "FAIL,END"})
     id = s.run(cluster.python+' '+cluster.scripts_rundir+'/obsseq_to_netcdf.py',
                depends_on=[depends_on])
     return id
 
 
 def verify_sat(depends_on=None):
-    s = create_job("verif-SAT-"+exp.expname, cfg_update={"time": "60", "mail-type": "FAIL,END", "ntasks": "20", 
+    s = cluster.create_job("verif-SAT-"+exp.expname, cfg_update={"time": "60", "mail-type": "FAIL,END", "ntasks": "20", 
             "ntasks-per-node": "20", "ntasks-per-core": "1", "mem": "100G",})
     cmd = cluster.python_verif+' /jetfs/home/lkugler/osse_analysis/plot_from_raw/analyze_fc.py '+exp.expname+' has_node sat verif1d FSS BS'
     s.run(cmd, depends_on=[depends_on])
 
 def verify_wrf(depends_on=None):
-    s = create_job("verif-WRF-"+exp.expname, cfg_update={"time": "120", "mail-type": "FAIL,END", "ntasks": "20", 
+    s = cluster.create_job("verif-WRF-"+exp.expname, cfg_update={"time": "120", "mail-type": "FAIL,END", "ntasks": "20", 
                  "ntasks-per-node": "20", "ntasks-per-core": "1", "mem": "250G"})
     cmd = cluster.python_verif+' /jetfs/home/lkugler/osse_analysis/plot_from_raw/analyze_fc.py '+exp.expname+' has_node wrf verif1d verif3d FSS BS'
     s.run(cmd, depends_on=[depends_on])
 
 def verify_fast(depends_on=None):
-    s = create_job("verif-fast-"+exp.expname, cfg_update={"time": "10", "mail-type": "FAIL", "ntasks": "1",
+    s = cluster.create_job("verif-fast-"+exp.expname, cfg_update={"time": "10", "mail-type": "FAIL", "ntasks": "1",
         "ntasks-per-node": "1", "ntasks-per-core": "1"})
     cmd = cluster.python_verif+' /jetfs/home/lkugler/osse_analysis/plot_fast/plot_single_exp.py '+exp.expname
     s.run(cmd, depends_on=[depends_on])
@@ -202,10 +202,10 @@ if __name__ == "__main__":
     timedelta_integrate = dt.timedelta(minutes=15)
     timedelta_btw_assim = dt.timedelta(minutes=15)
 
-    backup_scripts()
+    cluster.backup_scripts()
     id = None
 
-    if True:  # warm bubble
+    if False:  # warm bubble
         prior_path_exp = '/jetfs/home/lkugler/data/sim_archive/exp_v1.19_P3_wbub7_noDA'
 
         init_time = dt.datetime(2008, 7, 30, 12)
@@ -217,7 +217,7 @@ if __name__ == "__main__":
         # id = run_ideal(depends_on=id)
         # id = wrfinput_insert_wbubble(depends_on=id)    
 
-    if False:  # random
+    if True:  # random
         prior_path_exp = '/jetfs/home/lkugler/data/sim_archive/exp_v1.19_P2_noDA'
 
         init_time = dt.datetime(2008, 7, 30, 12)
diff --git a/dartwrf/assim_synth_obs.py b/dartwrf/assim_synth_obs.py
index 3b66917..738561b 100755
--- a/dartwrf/assim_synth_obs.py
+++ b/dartwrf/assim_synth_obs.py
@@ -3,7 +3,8 @@ import time as time_module
 import datetime as dt
 import numpy as np
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from dartwrf.utils import symlink, copy, sed_inplace, append_file, mkdir, try_remove, print, shell
 from dartwrf.obs import error_models as err
 import dartwrf.create_obsseq as osq
diff --git a/dartwrf/create_obs_upfront.py b/dartwrf/create_obs_upfront.py
index 515d168..3e107cf 100755
--- a/dartwrf/create_obs_upfront.py
+++ b/dartwrf/create_obs_upfront.py
@@ -4,7 +4,8 @@ import time as time_module
 import datetime as dt
 import numpy as np
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from dartwrf.utils import copy, print
 import dartwrf.create_obsseq as osq
 from dartwrf import obsseq
diff --git a/dartwrf/create_obsseq.py b/dartwrf/create_obsseq.py
index 2b2e9c4..6caaf7e 100755
--- a/dartwrf/create_obsseq.py
+++ b/dartwrf/create_obsseq.py
@@ -7,7 +7,8 @@ import numpy as np
 import datetime as dt
 from pysolar.solar import get_altitude, get_azimuth
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from dartwrf.obs import calculate_obs_locations as col
 
 def obskind_read():
diff --git a/dartwrf/create_wbubble_wrfinput.py b/dartwrf/create_wbubble_wrfinput.py
index 846cbe4..69ca8a0 100644
--- a/dartwrf/create_wbubble_wrfinput.py
+++ b/dartwrf/create_wbubble_wrfinput.py
@@ -3,7 +3,8 @@ from re import U
 import datetime as dt
 import numpy as np
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 import netCDF4 as nc
 
 dx_km = 2
diff --git a/dartwrf/evaluate_posterior.py b/dartwrf/evaluate_posterior.py
index 66e7ea2..dcc40b5 100755
--- a/dartwrf/evaluate_posterior.py
+++ b/dartwrf/evaluate_posterior.py
@@ -3,7 +3,8 @@ import time as time_module
 import datetime as dt
 import numpy as np
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from dartwrf import assim_synth_obs as aso
 
 
diff --git a/dartwrf/evaluate_prior.py b/dartwrf/evaluate_prior.py
index 43a4388..f7d63c7 100755
--- a/dartwrf/evaluate_prior.py
+++ b/dartwrf/evaluate_prior.py
@@ -3,7 +3,8 @@ import time as time_module
 import datetime as dt
 import numpy as np
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from dartwrf.utils import symlink, copy, sed_inplace, append_file, mkdir, try_remove, print, shell
 from dartwrf import assim_synth_obs as aso
 
diff --git a/dartwrf/link_dart_rttov.py b/dartwrf/link_dart_rttov.py
index ec6d0ae..a133956 100644
--- a/dartwrf/link_dart_rttov.py
+++ b/dartwrf/link_dart_rttov.py
@@ -1,5 +1,6 @@
 import os
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from utils import symlink, copy_scp_srvx8, copy, sed_inplace
 
 joinp = os.path.join
diff --git a/dartwrf/obsseq.py b/dartwrf/obsseq.py
index 69a5f6e..0e36216 100755
--- a/dartwrf/obsseq.py
+++ b/dartwrf/obsseq.py
@@ -7,7 +7,8 @@ import os, sys, shutil, warnings
 import numpy as np
 import pandas as pd
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from dartwrf.utils import symlink, copy, sed_inplace, append_file, mkdir, try_remove
 
 
diff --git a/dartwrf/obsseq_2dim.py b/dartwrf/obsseq_2dim.py
index c61d865..f4c675a 100755
--- a/dartwrf/obsseq_2dim.py
+++ b/dartwrf/obsseq_2dim.py
@@ -8,7 +8,8 @@ import time as time_module
 import datetime as dt
 import numpy as np
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from dartwrf import assim_synth_obs as aso
 from dartwrf import obsseq
 
diff --git a/dartwrf/obsseq_to_netcdf.py b/dartwrf/obsseq_to_netcdf.py
index 43feeda..fe3cc4a 100644
--- a/dartwrf/obsseq_to_netcdf.py
+++ b/dartwrf/obsseq_to_netcdf.py
@@ -1,6 +1,7 @@
 import os, sys, glob, warnings
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 import run_obs_diag as rod
 
 def listdir_dirs(path):
diff --git a/dartwrf/prep_IC_prior.py b/dartwrf/prep_IC_prior.py
index 84e1c6a..a5b1f85 100755
--- a/dartwrf/prep_IC_prior.py
+++ b/dartwrf/prep_IC_prior.py
@@ -2,7 +2,8 @@ import os, sys, warnings, glob
 import datetime as dt
 import numpy as np
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from utils import copy, clean_wrfdir, try_remove
 
 """
diff --git a/dartwrf/prepare_namelist.py b/dartwrf/prepare_namelist.py
index 71cc747..ac2ff1a 100755
--- a/dartwrf/prepare_namelist.py
+++ b/dartwrf/prepare_namelist.py
@@ -12,7 +12,8 @@ import os, sys, shutil, warnings
 import datetime as dt
 from docopt import docopt
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from utils import sed_inplace, copy, symlink, mkdir
 
 def run(iens, begin, end, hist_interval=5, radt=5, archive=True,
diff --git a/dartwrf/prepare_wrfrundir.py b/dartwrf/prepare_wrfrundir.py
index 772e0c4..3cfe2f9 100755
--- a/dartwrf/prepare_wrfrundir.py
+++ b/dartwrf/prepare_wrfrundir.py
@@ -1,7 +1,8 @@
 import os, sys, shutil
 import datetime as dt
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from utils import symlink, copy, link_contents
 import prepare_namelist
 
diff --git a/dartwrf/run_obs_diag.py b/dartwrf/run_obs_diag.py
index 5499103..d292292 100644
--- a/dartwrf/run_obs_diag.py
+++ b/dartwrf/run_obs_diag.py
@@ -1,6 +1,7 @@
 import os, sys, shutil, glob
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from utils import symlink, copy, sed_inplace, append_file, shell
 
 rundir_program = '/home/fs71386/lkugler/data/run_DART/'
diff --git a/dartwrf/update_IC.py b/dartwrf/update_IC.py
index 24425c4..3247030 100755
--- a/dartwrf/update_IC.py
+++ b/dartwrf/update_IC.py
@@ -2,7 +2,8 @@ import os, sys, warnings
 import datetime as dt
 import netCDF4 as nc
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 
 def update_initials_in_WRF_rundir(time):
     """Updates wrfrst-files in `/run_WRF/` directory 
diff --git a/dartwrf/utils.py b/dartwrf/utils.py
index d4a5560..ed49a81 100755
--- a/dartwrf/utils.py
+++ b/dartwrf/utils.py
@@ -3,33 +3,12 @@ import builtins as __builtin__
 import subprocess
 import datetime as dt
 from slurmpy import Slurm
-from config.cfg import cluster
 
 class ExperimentConfiguration(object):
     """Collection of variables to use in code later on"""
     def __init__(self):
         pass
 
-class ClusterConfig(object):
-    """Collection of variables to use in code later on"""
-    def __init__(self):
-        pass
-
-    @property
-    def archivedir(self):
-        return self.archive_base+'/'+self.expname
-
-    def wrf_rundir(self, iens):
-        return self.wrf_rundir_base+'/'+self.expname+'/'+str(iens)
-
-    @property
-    def scripts_rundir(self):
-        return self.archivedir+'/DART-WRF/'
-
-    @property
-    def dartrundir(self):
-        return self.dart_rundir_base+'/'+self.expname+'/'
-
 class Shellslurm():
     """Like Slurmpy class, but runs locally"""
     def __init__(self, *args, **kwargs):
@@ -38,41 +17,57 @@ class Shellslurm():
         print(args[0])
         os.system(args[0])
 
-def create_job(*args, cfg_update=dict(), **kwargs):
-    """Shortcut to slurmpy's class; keep certain default kwargs
-    and only update some with kwarg `cfg_update`
-    see https://github.com/brentp/slurmpy
+class ClusterConfig(object):
+    """Collection of variables to use in code later on"""
+    def __init__(self, exp):
+        self.exp = exp
 
-    with_slurm (bool) : if True, use SLURM, else run locally
+    def archivedir(self):
+        return self.archive_base+'/'+self.exp.expname
 
-    """
-    if cluster.use_slurm:
-        return Slurm(*args, slurm_kwargs=dict(cluster.slurm_cfg, **cfg_update), 
-                 log_dir=log_dir, scripts_dir=slurm_scripts_dir, **kwargs)
-    else:
-        return Shellslurm(*args)
+    def wrf_rundir(self, iens):
+        return self.wrf_rundir_base+'/'+self.exp.expname+'/'+str(iens)
 
-def backup_scripts():
-    """Copies scripts and configuration to archive dir output folder"""
-    os.makedirs(cluster.archivedir, exist_ok=True)
+    def scripts_rundir(self):
+        return self.archivedir+'/DART-WRF/'
 
-    try:
-        shutil.copytree(cluster.scriptsdir, cluster.scripts_rundir)
-    except FileExistsError:
-        pass
-    except:
-        raise
-    try:
-        copy(os.path.basename(__file__), cluster.scripts_rundir+'/')
-    except Exception as e:
-        warnings.warn(str(e))
-
-def prepare_WRFrundir(init_time):
-    """Create WRF/run directories and wrfinput files
-    """
-    cmd = cluster.python+' '+cluster.scripts_rundir+'/prepare_wrfrundir.py '+init_time.strftime('%Y-%m-%d_%H:%M')
-    print(cmd)
-    os.system(cmd)
+    def dartrundir(self):
+        return self.dart_rundir_base+'/'+self.exp.expname+'/'
+
+    def create_job(self, *args, cfg_update=dict(), **kwargs):
+        """Shortcut to slurmpy's class; keep certain default kwargs
+        and only update some with kwarg `cfg_update`
+        see https://github.com/brentp/slurmpy
+
+        depending on cluster config : run either locally or via SLURM 
+        """
+        if self.use_slurm:
+            return Slurm(*args, slurm_kwargs=dict(self.slurm_cfg, **cfg_update), 
+                     log_dir=log_dir, scripts_dir=slurm_scripts_dir, **kwargs)
+        else:
+            return Shellslurm(*args)
+
+    def backup_scripts():
+        """Copies scripts and configuration to archive dir output folder"""
+        os.makedirs(self.archivedir, exist_ok=True)
+    
+        try:
+            shutil.copytree(self.scriptsdir, self.scripts_rundir)
+        except FileExistsError:
+            pass
+        except:
+            raise
+        try:
+            copy(os.path.basename(__file__), self.scripts_rundir+'/')
+        except Exception as e:
+            warnings.warn(str(e))
+    
+    def prepare_WRFrundir(init_time):
+        """Create WRF/run directories and wrfinput files
+        """
+        cmd = self.python+' '+self.scripts_rundir+'/prepare_wrfrundir.py '+init_time.strftime('%Y-%m-%d_%H:%M')
+        print(cmd)
+        os.system(cmd)
 
 def shell(args):
     print(args)
diff --git a/dartwrf/wrfinput_add_geo.py b/dartwrf/wrfinput_add_geo.py
index 0f3aa5d..fe4e155 100755
--- a/dartwrf/wrfinput_add_geo.py
+++ b/dartwrf/wrfinput_add_geo.py
@@ -11,7 +11,8 @@ example call:
 import os, sys
 import netCDF4 as nc
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 
 def run(geo_data_file, wrfinput_file):
     geo_ds = nc.Dataset(geo_data_file, 'r')
diff --git a/dartwrf/wrfout_add_geo.py b/dartwrf/wrfout_add_geo.py
index e399dcf..57ae2e0 100755
--- a/dartwrf/wrfout_add_geo.py
+++ b/dartwrf/wrfout_add_geo.py
@@ -10,7 +10,8 @@ Example call:
 import os, sys
 import netCDF4 as nc
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 
 fields_old = ["XLAT_M",   "XLONG_M",      "CLAT",
                 "XLONG_U",  "XLONG_V",     "XLAT_U",    "XLAT_V"]
diff --git a/generate_free.py b/generate_free.py
index acb1fc0..45bf3cb 100755
--- a/generate_free.py
+++ b/generate_free.py
@@ -7,7 +7,8 @@ import datetime as dt
 import pandas as pd
 from slurmpy import Slurm
 
-from config.cfg import exp, cluster
+from config.cfg import exp
+from config.clusters import cluster
 from dartwrf.utils import script_to_str, symlink, backup_scripts
 from cycled_exp import *
 
-- 
GitLab