Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CTDAS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CTDAS
CTDAS
Commits
8574e546
Commit
8574e546
authored
13 years ago
by
Peters, Wouter
Browse files
Options
Downloads
Patches
Plain Diff
TM5 now compiled before run
parent
f7406577
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
da/tm5/observationoperator.py
+86
-5
86 additions, 5 deletions
da/tm5/observationoperator.py
da/tools/pipeline.py
+3
-1
3 additions, 1 deletion
da/tools/pipeline.py
with
89 additions
and
6 deletions
da/tm5/observationoperator.py
+
86
−
5
View file @
8574e546
...
@@ -26,6 +26,7 @@ import logging
...
@@ -26,6 +26,7 @@ import logging
import
shutil
import
shutil
sys
.
path
.
append
(
os
.
getcwd
())
sys
.
path
.
append
(
os
.
getcwd
())
sys
.
path
.
append
(
"
../../
"
)
identifier
=
'
TM5
'
identifier
=
'
TM5
'
version
=
'
release 3.0
'
version
=
'
release 3.0
'
...
@@ -79,13 +80,77 @@ class TM5ObservationOperator(ObservationOperator):
...
@@ -79,13 +80,77 @@ class TM5ObservationOperator(ObservationOperator):
msg
=
'
Observation Operator initialized: %s (%s)
'
%
(
self
.
Identifier
,
self
.
Version
,)
;
logging
.
info
(
msg
)
msg
=
'
Observation Operator initialized: %s (%s)
'
%
(
self
.
Identifier
,
self
.
Version
,)
;
logging
.
info
(
msg
)
def
Initialize
(
self
):
"""
Execute all steps needed to prepare the ObsOperator for use inside CTDAS, only done at the very first cycle normally
"""
from
da.tools.general
import
CreateDirs
if
self
.
DaCycle
[
'
time.restart
'
]
==
False
:
msg
=
'
First time step, setting up and compiling the TM5 model before proceeding!
'
;
logging
.
info
(
msg
)
# Modify the rc-file to reflect directory structure defined by CTDAS
NewItems
=
{
'
my.basedir
'
:
self
.
DaCycle
[
'
dir.exec
'
]
,
}
self
.
ModifyRC
(
NewItems
)
# Create the TM5 run directory to hold a copy of the modified rc-file
tm5compiledir
=
self
.
tm_settings
[
self
.
rundirkey
]
dummy
=
CreateDirs
(
tm5compiledir
)
self
.
RcFileName
=
self
.
WriteRc
()
# Compile TM5 in the new directory, but only if this is a fresh start
self
.
CompileTM5
()
return
0
def
CompileTM5
(
self
):
"""
Compile TM5 model using setup_tm5 and the modified rc-file
"""
import
subprocess
from
string
import
join
try
:
os
.
chdir
(
self
.
DaCycle
[
'
da.obsoperator.home
'
])
except
:
tm5_dir
=
os
.
path
.
split
(
self
.
DaCycle
[
'
da.obsoperator.rc
'
])[
0
]
msg
=
'
Guessing your TM5 root dir from the rc filename
'
;
logging
.
warning
(
msg
)
msg
=
'
Try adding a key da.obsoperator.home to your da.rc
'
;
logging
.
warning
(
msg
)
msg
=
'
Proceeding from guessed TM5 root dir (%s)
'
%
tm5_dir
;
logging
.
warning
(
msg
)
os
.
chdir
(
tm5_dir
)
cmd
=
[
'
python
'
,
'
setup_tm5
'
,
'
-q
'
,
self
.
RcFileName
]
msg
=
'
Starting the external TM5 setup script
'
;
logging
.
info
(
msg
)
msg
=
'
using command ... %s
'
%
join
(
cmd
)
;
logging
.
info
(
msg
)
retcode
=
subprocess
.
call
(
cmd
)
os
.
chdir
(
self
.
DaCycle
[
'
dir.da_submit
'
])
if
retcode
!=
0
:
msg
=
'
Compilation failed, quitting CTDAS
'
;
logging
.
error
(
msg
)
raise
IOError
sys
.
exit
(
2
)
else
:
msg
=
'
Compilation successful, continuing
'
;
logging
.
info
(
msg
)
def
getid
(
self
):
def
getid
(
self
):
return
identifier
return
identifier
def
getversion
(
self
):
def
getversion
(
self
):
return
version
return
version
def
Initialize
(
self
):
def
PrepareRun
(
self
):
"""
"""
Prepare a forward model TM5 run, this consists of:
Prepare a forward model TM5 run, this consists of:
...
@@ -103,6 +168,7 @@ class TM5ObservationOperator(ObservationOperator):
...
@@ -103,6 +168,7 @@ class TM5ObservationOperator(ObservationOperator):
dummy
=
self
.
LoadRc
(
self
.
RcFileName
)
# load the specified rc-file
dummy
=
self
.
LoadRc
(
self
.
RcFileName
)
# load the specified rc-file
dummy
=
self
.
ValidateRc
()
# validate the contents
dummy
=
self
.
ValidateRc
()
# validate the contents
# Create a link from TM5 to the rundirectory of the das system
# Create a link from TM5 to the rundirectory of the das system
sourcedir
=
self
.
tm_settings
[
self
.
rundirkey
]
sourcedir
=
self
.
tm_settings
[
self
.
rundirkey
]
...
@@ -133,7 +199,7 @@ class TM5ObservationOperator(ObservationOperator):
...
@@ -133,7 +199,7 @@ class TM5ObservationOperator(ObservationOperator):
self
.
ModifyRC
(
NewItems
)
self
.
ModifyRC
(
NewItems
)
self
.
WriteRc
()
newrcfile
=
self
.
WriteRc
()
#self.WriteRunRc() No longer needed with pycasso !
#self.WriteRunRc() No longer needed with pycasso !
...
@@ -146,7 +212,8 @@ class TM5ObservationOperator(ObservationOperator):
...
@@ -146,7 +212,8 @@ class TM5ObservationOperator(ObservationOperator):
"""
"""
import
da.tools.rcn
as
rc
import
da.tools.rcn
as
rc
self
.
tm_settings
=
rc
.
read
(
RcFileName
)
self
.
rcfile
=
rc
.
RcFile
(
RcFileName
)
self
.
tm_settings
=
self
.
rcfile
.
values
self
.
RcFileName
=
RcFileName
self
.
RcFileName
=
RcFileName
self
.
Tm5RcLoaded
=
True
self
.
Tm5RcLoaded
=
True
...
@@ -263,11 +330,13 @@ class TM5ObservationOperator(ObservationOperator):
...
@@ -263,11 +330,13 @@ class TM5ObservationOperator(ObservationOperator):
"""
"""
import
da.tools.rc
as
rc
import
da.tools.rc
as
rc
tm5rcfilename
=
os
.
path
.
join
(
self
.
tm_settings
[
self
.
rundirkey
],
'
tm5.rc
'
)
tm5rcfilename
=
os
.
path
.
join
(
self
.
tm_settings
[
self
.
rundirkey
],
'
tm5
_ctdas_setup
.rc
'
)
dummy
=
rc
.
write
(
tm5rcfilename
,
self
.
tm_settings
)
dummy
=
rc
.
write
(
tm5rcfilename
,
self
.
tm_settings
)
msg
=
"
Modified tm5.rc written (%s)
"
%
tm5rcfilename
;
logging
.
debug
(
msg
)
msg
=
"
Modified rc file for TM5 written (%s)
"
%
tm5rcfilename
;
logging
.
debug
(
msg
)
return
tm5rcfilename
def
WriteRunRc
(
self
):
def
WriteRunRc
(
self
):
"""
"""
...
@@ -510,6 +579,15 @@ class TM5ObservationOperator(ObservationOperator):
...
@@ -510,6 +579,15 @@ class TM5ObservationOperator(ObservationOperator):
if
os
.
path
.
exists
(
okfile
):
if
os
.
path
.
exists
(
okfile
):
dummy
=
os
.
remove
(
okfile
)
dummy
=
os
.
remove
(
okfile
)
# Prepare a job for the current platform, this job needs to account for all job parameters such as
# runtime, queue request, number of processors, and other platform specific parameters
# It is easiest if all of these options are 'pre-configured' through the tm5.rc file that is used, then
# running the ObsOperator on all platforms simply becomes a matter of running the ./setup_tm5 script
# that was also used to compile TM5 when not actually running CTDAS. The first run of CTDAS
# then could be one where TM5 is actually compiled and run, the rest of the jobs would then *not* re-compile.
# An option would need to be added to force a re-compile of the TM5 code, for debugging purposes.
# file ID and names
# file ID and names
jobid
=
'
tm5
'
jobid
=
'
tm5
'
jobfile
=
os
.
path
.
join
(
targetdir
,
'
jb.%s.jb
'
%
jobid
)
jobfile
=
os
.
path
.
join
(
targetdir
,
'
jb.%s.jb
'
%
jobid
)
...
@@ -625,6 +703,8 @@ class TM5ObservationOperator(ObservationOperator):
...
@@ -625,6 +703,8 @@ class TM5ObservationOperator(ObservationOperator):
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
sys
.
path
.
append
(
'
../../
'
)
from
da.tools.initexit
import
StartLogger
from
da.tools.initexit
import
StartLogger
from
da.tools.pipeline
import
JobStart
from
da.tools.pipeline
import
JobStart
import
datetime
as
dtm
import
datetime
as
dtm
...
@@ -641,6 +721,7 @@ if __name__ == "__main__":
...
@@ -641,6 +721,7 @@ if __name__ == "__main__":
DaCycle
[
'
time.sample.window
'
]
=
0
DaCycle
[
'
time.sample.window
'
]
=
0
tm
=
TM5ObservationOperator
()
tm
=
TM5ObservationOperator
()
tm
.
Setup
()
tm
.
Initialize
()
tm
.
Initialize
()
tm
.
Run
()
tm
.
Run
()
tm
.
SaveData
()
tm
.
SaveData
()
...
...
This diff is collapsed.
Click to expand it.
da/tools/pipeline.py
+
3
−
1
View file @
8574e546
...
@@ -79,6 +79,8 @@ def JobStart(DaCycle, DaSystem, DaPlatForm, StateVector, Samples, ObsOperator):
...
@@ -79,6 +79,8 @@ def JobStart(DaCycle, DaSystem, DaPlatForm, StateVector, Samples, ObsOperator):
ObsOperator
.
DaCycle
=
DaCycle
# also embed object in ObsOperator object so it can access cycle information for I/O etc
ObsOperator
.
DaCycle
=
DaCycle
# also embed object in ObsOperator object so it can access cycle information for I/O etc
status
=
ObsOperator
.
Initialize
()
# Setup Observation Operator
return
None
return
None
...
@@ -340,7 +342,7 @@ def RunForecastModel(DaCycle,ObsOperator):
...
@@ -340,7 +342,7 @@ def RunForecastModel(DaCycle,ObsOperator):
submitting a string of jobs to the queue, or simply spawning a subprocess, or ...
submitting a string of jobs to the queue, or simply spawning a subprocess, or ...
"""
"""
status
=
ObsOperator
.
Initialize
()
status
=
ObsOperator
.
PrepareRun
()
status
=
ObsOperator
.
ValidateInput
()
status
=
ObsOperator
.
ValidateInput
()
...
...
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