-
Notifications
You must be signed in to change notification settings - Fork 1
/
mat_proc_loop.py
37 lines (30 loc) · 1.02 KB
/
mat_proc_loop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# /usr/bin/env python3
import numpy as np
import os
import fileinput
bname = 'PIPO_'
outputs = [1,2,3,4,5,6]
reg = 2
if reg==0:
# Global:
regions = ['Global']*len(outputs)
types = ['']*len(outputs)
names = ['%02dG' % x for x in outputs]
elif reg==1:
# Indo-Pacific:
regions = ['IndoPacific2BAS']*len(outputs)
types = ['_ZAREG']*len(outputs)
names = ['%02dP' % x for x in outputs]
elif reg==2:
# Atlantic:
regions = ['Atlantic2BAS']*len(outputs)
types = ['_ZAREG']*len(outputs)
names = ['%02dA' % x for x in outputs]
for i in range(len(outputs)):
fname = bname + names[i] + '.qsub'
os.system('cp Process_MOM_template ' + fname)
with fileinput.FileInput(fname, inplace=True) as file:
for line in file:
line_out = line.replace('XXNAMEXX', bname + names[i]).replace('XXOUTPUTXX', '%01d' % outputs[i]).replace('XXREGIONXX', regions[i]).replace('XXTYPEXX', types[i])
print(line_out, end='')
os.system('qsub ' + fname)