Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ra499
s2p3_rv2.0
Commits
7b49b8c5
Commit
7b49b8c5
authored
May 21, 2019
by
ph290
Browse files
making sure that parallel jobs are cleaned up after running
parent
291a0dd6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
main/run_map_parallel.py
main/run_map_parallel.py
+8
-6
No files found.
main/run_map_parallel.py
View file @
7b49b8c5
...
...
@@ -130,7 +130,7 @@ def run_model(domain_file_name,lats_lons,year,start_year,unique_job_id,met_data_
if
lon_domain_tmp
<
0.0
:
lon_domain_tmp
=
360.0
+
lon_domain_tmp
# forcing_lat_lon = closest(lats_lons, float(lat_domain[i]),float(lon_domain[i]))
print
i
#
print i
# print str(forcing_lat_lon[0])
# print str(forcing_lat_lon[1])
# print str(float(lat_domain[i]))
...
...
@@ -241,8 +241,8 @@ unique_job_id = str(uuid.uuid4())
num_lines
=
sum
(
1
for
line
in
open
(
base_directory
+
'domain/'
+
domain_file_name
))
-
1
# num_lines = 10
subprocess
.
call
(
'tar -C '
+
met_data_temporary_location
+
' -zx
v
f '
+
met_data_location
+
'met_data_'
+
str
(
start_year
)
+
'.tar.gz'
,
shell
=
True
)
print
'initial unzipping of met data to extrcat lat and lon data'
subprocess
.
call
(
'tar -C '
+
met_data_temporary_location
+
' -zxf '
+
met_data_location
+
'met_data_'
+
str
(
start_year
)
+
'.tar.gz'
,
shell
=
True
)
files
=
glob
.
glob
(
met_data_temporary_location
+
'*_'
+
str
(
start_year
)
+
'.dat'
)
w
,
h
=
2
,
len
(
files
)
;
...
...
@@ -266,15 +266,17 @@ for i,file in enumerate(files):
# pool.close()
print
'looping through years'
for
year
in
range
(
start_year
,
end_year
+
1
):
print
year
#clean up and prexisting met files
try
:
files_to_delete
=
glob
.
glob
(
met_data_temporary_location
+
'*.dat'
)
[
os
.
remove
(
f
)
for
f
in
files_to_delete
]
except
:
print
'no met files to clean up'
subprocess
.
call
(
'tar -C '
+
met_data_temporary_location
+
' -zx
v
f '
+
met_data_location
+
'met_data_'
+
str
(
year
)
+
'.tar.gz'
,
shell
=
True
)
subprocess
.
call
(
'tar -C '
+
met_data_temporary_location
+
' -zxf '
+
met_data_location
+
'met_data_'
+
str
(
year
)
+
'.tar.gz'
,
shell
=
True
)
try
:
shutil
.
move
(
output_directory
+
output_file_name
+
'_'
+
str
(
year
),
output_directory
+
output_file_name
+
'_'
+
str
(
year
)
+
'_previous'
)
except
:
...
...
@@ -298,7 +300,7 @@ for year in range(start_year,end_year+1):
[
os
.
remove
(
f
)
for
f
in
files_to_delete
]
except
:
print
'no met files to clean up'
pool
.
close
()
remove_files
=
glob
.
glob
(
base_directory
+
'main/*'
+
unique_job_id
+
'*'
)
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment