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
d9f52d13
Commit
d9f52d13
authored
2 years ago
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
prints
parent
a13e8801
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
+37
-34
37 additions, 34 deletions
dartwrf/workflows.py
with
37 additions
and
34 deletions
dartwrf/workflows.py
+
37
−
34
View file @
d9f52d13
...
...
@@ -12,9 +12,6 @@ import importlib
from
dartwrf.utils
import
script_to_str
from
config.cfg
import
exp
def
dict_to_py
(
d
,
outfile
):
with
open
(
outfile
,
'
w
'
)
as
f
:
txt
=
'
# this file is autogenerated
\n
obs_kind_nrs = {
'
...
...
@@ -23,6 +20,33 @@ def dict_to_py(d, outfile):
txt
+=
'
}
'
f
.
write
(
txt
)
def
_obskind_read
():
"""
Read dictionary of observation types + ID numbers (
"
kind
"
)
from DART f90 script
"""
definitionfile
=
self
.
cluster
.
dart_srcdir
+
'
/../../../assimilation_code/modules/observations/obs_kind_mod.f90
'
with
open
(
definitionfile
,
'
r
'
)
as
f
:
kind_def_f
=
f
.
readlines
()
obskind_nrs
=
{}
for
i
,
line
in
enumerate
(
kind_def_f
):
if
'
Integer definitions for DART OBS TYPES
'
in
line
:
# data starts below this line
i_start
=
i
break
for
line
in
kind_def_f
[
i_start
+
1
:]:
if
'
MAX_DEFINED_TYPES_OF_OBS
'
in
line
:
# end of data
break
if
'
::
'
in
line
:
# a line looks like this
# integer, parameter, public :: MSG_4_SEVIRI_TB = 261
data
=
line
.
split
(
'
::
'
)[
-
1
].
split
(
'
=
'
)
kind_str
=
data
[
0
].
strip
()
kind_nr
=
int
(
data
[
1
].
strip
())
obskind_nrs
[
kind_str
]
=
kind_nr
return
obskind_nrs
class
WorkFlows
(
object
):
def
__init__
(
self
,
exp_config
=
'
cfg.py
'
,
server_config
=
'
server.py
'
):
"""
Set up the experiment folder in `archivedir`.
...
...
@@ -30,10 +54,14 @@ class WorkFlows(object):
Args:
exp (str): Path to exp config file
config (str): Path to the cluster config file
Note:
in WorkFlows, we load the config from the git cloned folder
in all other dartwrf scripts, load the config from cluster.scripts_rundir
"""
# in WorkFlows, we load the config from the git cloned folder
# in all other dartwrf scripts, load the config from cluster.scripts_rundir
print
(
'
------ start exp from
'
,
exp_config
,
'
and
'
,
server_config
,
'
------
'
)
# exp = __import__('config/'+exp_config)
# load python config file
self
.
cluster
=
importlib
.
import_module
(
'
config.
'
+
server_config
.
strip
(
'
.py
'
)).
cluster
# Set paths and backup scripts
...
...
@@ -42,38 +70,11 @@ class WorkFlows(object):
if
self
.
cluster
.
use_slurm
:
self
.
cluster
.
slurm_scripts_dir
=
self
.
cluster
.
archivedir
+
'
/slurm-scripts/
'
print
(
'
scripts
,
w
hich are submitted to SLURM:
'
,
self
.
cluster
.
slurm_scripts_dir
)
print
(
'
SLURM
scripts w
ill be in
'
,
self
.
cluster
.
slurm_scripts_dir
)
# copy obs kind def to config, we will read a table from there
# file needs to exist within package so sphinx can read it
def
obskind_read
():
"""
Read dictionary of observation types + ID numbers (
"
kind
"
)
from DART f90 script
"""
definitionfile
=
self
.
cluster
.
dart_srcdir
+
'
/../../../assimilation_code/modules/observations/obs_kind_mod.f90
'
with
open
(
definitionfile
,
'
r
'
)
as
f
:
kind_def_f
=
f
.
readlines
()
obskind_nrs
=
{}
for
i
,
line
in
enumerate
(
kind_def_f
):
if
'
Integer definitions for DART OBS TYPES
'
in
line
:
# data starts below this line
i_start
=
i
break
for
line
in
kind_def_f
[
i_start
+
1
:]:
if
'
MAX_DEFINED_TYPES_OF_OBS
'
in
line
:
# end of data
break
if
'
::
'
in
line
:
# a line looks like this
# integer, parameter, public :: MSG_4_SEVIRI_TB = 261
data
=
line
.
split
(
'
::
'
)[
-
1
].
split
(
'
=
'
)
kind_str
=
data
[
0
].
strip
()
kind_nr
=
int
(
data
[
1
].
strip
())
obskind_nrs
[
kind_str
]
=
kind_nr
return
obskind_nrs
dict_to_py
(
obskind_read
(),
self
.
cluster
.
scriptsdir
+
'
/../config/obskind.py
'
)
dict_to_py
(
_obskind_read
(),
self
.
cluster
.
scriptsdir
+
'
/../config/obskind.py
'
)
# Copy scripts to self.cluster.archivedir folder
os
.
makedirs
(
self
.
cluster
.
archivedir
,
exist_ok
=
True
)
...
...
@@ -93,6 +94,8 @@ class WorkFlows(object):
# probably not needed
# shutil.copy('config/'+server_config, 'config/cluster.py') # whatever server, the config name is always the same!
print
(
'
------ dartwrf experiment initialized ------
'
)
print
(
'
--------------------------------------------
'
)
def
prepare_WRFrundir
(
self
,
init_time
):
"""
Create WRF/run directories and wrfinput files
...
...
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