Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DART-WRF
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DataAssimilation
DART-WRF
Commits
ecc05ceb
Commit
ecc05ceb
authored
1 year ago
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
docs
parent
c5c9e166
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dartwrf/workflows.py
+41
-29
41 additions, 29 deletions
dartwrf/workflows.py
with
41 additions
and
29 deletions
dartwrf/workflows.py
+
41
−
29
View file @
ecc05ceb
...
@@ -14,13 +14,12 @@ class WorkFlows(object):
...
@@ -14,13 +14,12 @@ class WorkFlows(object):
def
__init__
(
self
,
exp_config
=
'
cfg.py
'
,
server_config
=
'
server.py
'
):
def
__init__
(
self
,
exp_config
=
'
cfg.py
'
,
server_config
=
'
server.py
'
):
"""
Set up the experiment folder in `archivedir`.
"""
Set up the experiment folder in `archivedir`.
1. Copy the DART-WRF scripts to `archivedir`
1. Copy the selected config files
2. Copy the config files to `archivedir/dartwrf`
2. Import configurations
3. Set log paths
3. Prepare obskind.py file (dictionary of observation types)
4. Write obskind.py file (dictionary of observation types)
4. Copy the scripts and configs to `archivedir`
5. Set python path
Note:
6. Set log path and slurm scripts path
Later, the config is loaded from dartwrf/config/exp_config.py and dartwrf/config/server_config.py
Args:
Args:
exp_config (str): Path to exp config file
exp_config (str): Path to exp config file
...
@@ -75,11 +74,11 @@ class WorkFlows(object):
...
@@ -75,11 +74,11 @@ class WorkFlows(object):
def
_dict_to_py
(
d
,
outfile
):
def
_dict_to_py
(
d
,
outfile
):
"""
Write a python dictionary to a .py file
"""
Write a python dictionary to a .py file
Args:
Args:
d (dict): dictionary to write
d (dict): dictionary to write
outfile (str): path to output file
outfile (str): path to output file
Returns:
Returns:
None
None
"""
"""
...
@@ -92,40 +91,49 @@ class WorkFlows(object):
...
@@ -92,40 +91,49 @@ class WorkFlows(object):
print
(
'
------ start exp from
'
,
exp_config
,
'
and
'
,
server_config
,
'
------
'
)
print
(
'
------ start exp from
'
,
exp_config
,
'
and
'
,
server_config
,
'
------
'
)
#
experiment starts, we dont know where the code shall run
#
### 1
#
=> read the configuration file
#
copy the selected config files (arguments to Workflows(...)) to the scripts directory
# ./DART-WRF/dartwrf/server_config.py and ./DART-WRF/dartwrf/exp_config.py
#
copy
the config files
t
o th
is fold
er
# th
es
e config files
will be used later, and n
o
o
ther
s!
thi
s_dir
=
'
/
'
.
join
(
__file__
.
split
(
'
/
'
)[:
-
1
])
original_script
s_dir
=
'
/
'
.
join
(
__file__
.
split
(
'
/
'
)[:
-
1
])
# usually /home/DART-WRF/dartwrf/
try
:
try
:
shutil
.
copyfile
(
'
config/
'
+
server_config
,
thi
s_dir
+
'
/server_config.py
'
)
shutil
.
copyfile
(
'
config/
'
+
server_config
,
original_script
s_dir
+
'
/server_config.py
'
)
except
shutil
.
SameFileError
:
except
shutil
.
SameFileError
:
pass
pass
try
:
try
:
shutil
.
copyfile
(
'
config/
'
+
exp_config
,
thi
s_dir
+
'
/exp_config.py
'
)
shutil
.
copyfile
(
'
config/
'
+
exp_config
,
original_script
s_dir
+
'
/exp_config.py
'
)
except
shutil
.
SameFileError
:
except
shutil
.
SameFileError
:
pass
pass
sys
.
path
.
append
(
this_dir
)
#### 2
# import the configuration files from where we copied them just before
sys
.
path
.
append
(
original_scripts_dir
)
from
server_config
import
cluster
from
server_config
import
cluster
self
.
cluster
=
cluster
self
.
cluster
=
cluster
from
exp_config
import
exp
from
exp_config
import
exp
self
.
exp
=
exp
self
.
exp
=
exp
# copy obs kind def to config, we will read a table from there
#### 3
# file needs to exist within package so sphinx can read it
# to be able to generate obs_seq.in files, we need a dictionary to convert obs kinds to numbers
_dict_to_py
(
_obskind_read
(),
this_dir
+
'
/obs/obskind.py
'
)
# a) we read the obs kind definitions (obs_kind_mod.f90 from DART code)
# b) we generate a python file with this dictionary
# Note: to include it in the documentary, the file needs to exist also in the repository
# (so the documentation generator SPHINX can read it)
_dict_to_py
(
_obskind_read
(),
original_scripts_dir
+
'
/obs/obskind.py
'
)
_copy_dartwrf_to_archive
()
# includes config files
#### 4
# Copy scripts and config files to `self.cluster.archivedir` folder
_copy_dartwrf_to_archive
()
#### 5
# we set the path from where python should import dartwrf modules
# we set the path from where python should import dartwrf modules
#
pythonpath is the folder above the dartwrf folder
#
every python command then imports DART-WRF from self.cluster.archivedir+'/DART-WRF/dartwrf/'
self
.
cluster
.
python
=
'
export PYTHONPATH=
'
+
self
.
cluster
.
scripts_rundir
+
'
/../;
'
+
self
.
cluster
.
python
self
.
cluster
.
python
=
'
export PYTHONPATH=
'
+
self
.
cluster
.
scripts_rundir
+
'
/../;
'
+
self
.
cluster
.
python
#### 6
# Set paths and backup scripts
# Set paths and backup scripts
self
.
cluster
.
log_dir
=
self
.
cluster
.
archivedir
+
'
/logs/
'
self
.
cluster
.
log_dir
=
self
.
cluster
.
archivedir
+
'
/logs/
'
print
(
'
logging to
'
,
self
.
cluster
.
log_dir
)
print
(
'
logging to
'
,
self
.
cluster
.
log_dir
)
if
self
.
cluster
.
use_slurm
:
if
self
.
cluster
.
use_slurm
:
self
.
cluster
.
slurm_scripts_dir
=
self
.
cluster
.
archivedir
+
'
/slurm-scripts/
'
self
.
cluster
.
slurm_scripts_dir
=
self
.
cluster
.
archivedir
+
'
/slurm-scripts/
'
print
(
'
SLURM scripts will be in
'
,
self
.
cluster
.
slurm_scripts_dir
)
print
(
'
SLURM scripts will be in
'
,
self
.
cluster
.
slurm_scripts_dir
)
...
@@ -282,8 +290,8 @@ class WorkFlows(object):
...
@@ -282,8 +290,8 @@ class WorkFlows(object):
runtime_wallclock_mins_expected
=
int
(
8
+
time_in_simulation_hours
*
9
)
# usually below 9 min/hour
runtime_wallclock_mins_expected
=
int
(
8
+
time_in_simulation_hours
*
9
)
# usually below 9 min/hour
cfg_update
=
{
"
array
"
:
"
1-
"
+
str
(
self
.
cluster
.
size_WRF_jobarray
),
"
ntasks
"
:
"
10
"
,
"
nodes
"
:
"
1
"
,
cfg_update
=
{
"
array
"
:
"
1-
"
+
str
(
self
.
cluster
.
size_WRF_jobarray
),
"
ntasks
"
:
"
10
"
,
"
nodes
"
:
"
1
"
,
"
time
"
:
str
(
runtime_wallclock_mins_expected
),
"
mem
"
:
"
40G
"
,
}
"
time
"
:
str
(
runtime_wallclock_mins_expected
),
"
mem
"
:
"
40G
"
,
}
#if runtime_wallclock_mins_expected > 10:
#
if runtime_wallclock_mins_expected > 10:
# cfg_update.update({"nodelist": "jet0
8
"})
#
cfg_update.update({"nodelist": "jet0
5
"})
id
=
self
.
cluster
.
run_job
(
wrf_cmd
,
"
WRF-
"
+
self
.
exp
.
expname
,
cfg_update
=
cfg_update
,
depends_on
=
[
id
])
id
=
self
.
cluster
.
run_job
(
wrf_cmd
,
"
WRF-
"
+
self
.
exp
.
expname
,
cfg_update
=
cfg_update
,
depends_on
=
[
id
])
return
id
return
id
...
@@ -375,13 +383,17 @@ class WorkFlows(object):
...
@@ -375,13 +383,17 @@ class WorkFlows(object):
depends_on
=
[
depends_on
])
depends_on
=
[
depends_on
])
return
id
return
id
def
evaluate_obs_posterior_after_analysis
(
self
,
init_valid_tuples
,
depends_on
=
None
):
def
evaluate_obs_posterior_after_analysis
(
self
,
init
,
valid
,
depends_on
=
None
):
arg
=
'
'
.
join
([
init
.
strftime
(
'
%Y-%m-%d_%H:%M,
'
)
+
valid
.
strftime
(
'
%Y-%m-%d_%H:%M:%S
'
)
for
(
init
,
valid
)
in
init_valid_tuples
])
cmd
=
self
.
cluster
.
python
+
'
'
+
self
.
cluster
.
scripts_rundir
+
'
/evaluate_obs_space.py
'
+
init
.
strftime
(
'
%Y-%m-%d_%H:%M,
'
)
+
valid
.
strftime
(
'
%Y-%m-%d_%H:%M:%S
'
)
cmd
=
self
.
cluster
.
python
+
'
'
+
self
.
cluster
.
scripts_rundir
+
'
/evaluate_obs_space.py
'
+
arg
id
=
self
.
cluster
.
run_job
(
cmd
,
'
eval+1
'
+
self
.
exp
.
expname
,
cfg_update
=
{
"
ntasks
"
:
"
12
"
,
"
mem
"
:
"
50G
"
,
"
ntasks-per-node
"
:
"
12
"
,
"
ntasks-per-core
"
:
"
2
"
,
id
=
self
.
cluster
.
run_job
(
cmd
,
'
eval+1
'
+
self
.
exp
.
expname
,
cfg_update
=
{
"
ntasks
"
:
"
12
"
,
"
mem
"
:
"
50G
"
,
"
ntasks-per-node
"
:
"
12
"
,
"
ntasks-per-core
"
:
"
2
"
,
"
time
"
:
"
15
"
,
"
mail-type
"
:
"
FAIL
"
},
"
time
"
:
"
15
"
,
"
mail-type
"
:
"
FAIL
"
},
depends_on
=
[
depends_on
])
depends_on
=
[
depends_on
])
cmd
=
self
.
cluster
.
python
+
'
'
+
self
.
cluster
.
scripts_rundir
+
'
/calc_linear_posterior.py
'
+
init
.
strftime
(
'
%Y-%m-%d_%H:%M
'
)
id
=
self
.
cluster
.
run_job
(
cmd
,
'
linpost
'
+
self
.
exp
.
expname
,
cfg_update
=
{
"
ntasks
"
:
"
12
"
,
"
mem
"
:
"
50G
"
,
"
ntasks-per-node
"
:
"
12
"
,
"
ntasks-per-core
"
:
"
2
"
,
"
time
"
:
"
15
"
,
"
mail-type
"
:
"
FAIL
"
},
depends_on
=
[
id
])
return
id
return
id
def
verify_sat
(
self
,
depends_on
=
None
):
def
verify_sat
(
self
,
depends_on
=
None
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment