Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
toolbox
WindEnergyToolbox
Commits
ebc16a36
Commit
ebc16a36
authored
8 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
bug fix in hawc2.simulation
parent
3db9cbb5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wetb/hawc2/simulation.py
+13
-8
13 additions, 8 deletions
wetb/hawc2/simulation.py
with
13 additions
and
8 deletions
wetb/hawc2/simulation.py
+
13
−
8
View file @
ebc16a36
...
...
@@ -86,7 +86,7 @@ class Simulation(object):
if
not
os
.
path
.
isabs
(
htcfilename
):
htcfilename
=
os
.
path
.
join
(
modelpath
,
htcfilename
)
self
.
filename
=
os
.
path
.
basename
(
htcfilename
)
self
.
htcFile
=
HTCFile
(
htcfilename
)
self
.
htcFile
=
HTCFile
(
htcfilename
,
os
.
path
.
relpath
(
self
.
modelpath
,
os
.
path
.
dirname
(
htcfilename
))
)
self
.
time_stop
=
self
.
htcFile
.
simulation
.
time_stop
[
0
]
self
.
hawc2exe
=
hawc2exe
self
.
copy_turbulence
=
copy_turbulence
...
...
@@ -127,7 +127,7 @@ class Simulation(object):
def
abort
(
self
,
update_status
=
True
):
if
self
.
status
!=
QUEUED
:
self
.
host
.
stop
()
for
_
in
range
(
10
0
):
for
_
in
range
(
5
0
):
if
self
.
is_simulating
is
False
:
break
time
.
sleep
(
0.1
)
...
...
@@ -175,7 +175,7 @@ class Simulation(object):
src
=
os
.
path
.
relpath
(
src
)
assert
not
src
.
startswith
(
"
..
"
),
"
%s referes to a file outside the model path
\n
All input files be inside model path
"
%
src
return
src
input_patterns
=
[
fmt
(
src
)
for
src
in
self
.
htcFile
.
input_files
()
+
self
.
htcFile
.
turbulence_files
()
+
self
.
additional_files
().
get
(
'
input
'
,
[])]
input_patterns
=
[
fmt
(
src
)
for
src
in
self
.
htcFile
.
input_files
()
+
([],
self
.
htcFile
.
turbulence_files
()
)[
self
.
copy_turbulence
]
+
self
.
additional_files
().
get
(
'
input
'
,
[])]
input_files
=
set
([
f
for
pattern
in
input_patterns
for
f
in
glob
.
glob
(
os
.
path
.
join
(
self
.
modelpath
,
pattern
))
if
os
.
path
.
isfile
(
f
)])
if
not
os
.
path
.
isdir
(
os
.
path
.
dirname
(
self
.
modelpath
+
self
.
stdout_filename
)):
os
.
makedirs
(
os
.
path
.
dirname
(
self
.
modelpath
+
self
.
stdout_filename
))
...
...
@@ -435,7 +435,6 @@ class LocalSimulationHost(SimulationResource):
self
.
logFile
.
update_status
()
def
stop
(
self
):
if
self
.
simulationThread
.
is_alive
():
self
.
simulationThread
.
stop
()
self
.
simulationThread
.
join
()
...
...
@@ -466,7 +465,8 @@ class SimulationThread(Thread):
with
open
(
os
.
path
.
join
(
self
.
modelpath
,
stdout
),
'
wb
'
)
as
stdout
:
if
isinstance
(
hawc2exe
,
tuple
):
self
.
process
=
subprocess
.
Popen
(
list
(
hawc2exe
+
(
htcfile
,
stdout
)),
stdout
=
stdout
,
stderr
=
STDOUT
,
shell
=
False
,
cwd
=
modelpath
)
wine
,
hawc2exe
=
hawc2exe
self
.
process
=
subprocess
.
Popen
([
wine
,
hawc2exe
,
htcfile
],
stdout
=
stdout
,
stderr
=
STDOUT
,
shell
=
True
,
cwd
=
modelpath
)
#shell must be True to inwoke wine
else
:
self
.
process
=
subprocess
.
Popen
([
hawc2exe
,
htcfile
],
stdout
=
stdout
,
stderr
=
STDOUT
,
shell
=
False
,
cwd
=
modelpath
)
#, creationflags=CREATE_NO_WINDOW)
self
.
process
.
communicate
()
...
...
@@ -506,7 +506,7 @@ class SimulationThread(Thread):
def
stop
(
self
):
if
hasattr
(
self
,
'
process
'
):
subprocess
.
Popen
(
"
TASKKILL /F /PID {pid} /T
"
.
format
(
pid
=
self
.
process
.
pid
))
class
PBSClusterSimulationHost
(
SimulationResource
,
SSHClient
):
def
__init__
(
self
,
simulation
,
resource
,
host
,
username
,
password
,
port
=
22
):
...
...
@@ -649,7 +649,7 @@ class PBSClusterSimulationHost(SimulationResource, SSHClient):
#PBS -j oe
#PBS -o %s
### Maximum wallclock time format HOURS:MINUTES:SECONDS
#PBS -l walltime=0
1
:00:00
#PBS -l walltime=0
4
:00:00
###PBS -a 201547.53
#PBS -lnodes=1:ppn=1
### Queue name
...
...
@@ -661,6 +661,11 @@ cp -R . /scratch/$USER/$PBS_JOBID
### Execute commands on scratch nodes
cd /scratch/$USER/$PBS_JOBID
pwd
export PATH=/home/python/miniconda3/bin:$PATH
source activate wetb_py3
WINEARCH=win32 WINEPREFIX=~/.wine32 winefix
### modelpath: %s
### htc: %s
echo
"
---------------------
"
%s -c
"
from wetb.hawc2.cluster_simulation import ClusterSimulation;ClusterSimulation(
'
.
'
,
'
%s
'
, (
'
%s
'
,
'
%s
'
))
"
echo
"
---------------------
"
...
...
@@ -672,7 +677,7 @@ cd /scratch/$USER/$PBS_JOBID
echo $PBS_JOBID
cd /scratch/
### rm -r $PBS_JOBID
exit
"""
%
(
self
.
simulation_id
,
self
.
stdout_filename
,
self
.
resource
.
python_cmd
,
rel_htcfilename
,
self
.
resource
.
wine_cmd
,
self
.
hawc2exe
,
cp_back
)
exit
"""
%
(
self
.
simulation_id
,
self
.
stdout_filename
,
self
.
modelpath
,
self
.
htcFile
.
filename
,
self
.
resource
.
python_cmd
,
rel_htcfilename
,
self
.
resource
.
wine_cmd
,
self
.
hawc2exe
,
cp_back
)
...
...
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