source: issm/branches/trunk-larour-NatGeoScience2016/src/m/classes/clusters/vilje.py@ 21243

Last change on this file since 21243 was 21234, checked in by bdef, 9 years ago

CHG:modifying cluster to take into account the new modules

File size: 5.3 KB
Line 
1import subprocess
2from fielddisplay import fielddisplay
3from pairoptions import pairoptions
4from issmssh import issmssh
5from issmscpin import issmscpin
6from issmscpout import issmscpout
7from QueueRequirements import QueueRequirements
8import datetime
9try:
10 from vilje_settings import vilje_settings
11except ImportError:
12 print 'You need vilje_settings.py to proceed, check presence and sys.path'
13
14class vilje(object):
15 """
16 Vilje cluster class definition
17
18 Usage:
19 cluster=vilje();
20 """
21
22 def __init__(self,*args):
23 # {{{
24 self.name = 'vilje'
25 self.login = ''
26 self.numnodes = 2
27 self.cpuspernode = 32
28 self.procspernodes = 16
29 self.mem = 28
30 self.queue = 'workq'
31 self.time = 2*60
32 self.codepath = ''
33 self.executionpath = ''
34 self.interactive = 0
35 self.port = []
36 self.accountname = ''
37
38 #use provided options to change fields
39 options=pairoptions(*args)
40
41 #initialize cluster using user settings if provided
42 self=vilje_settings(self)
43 self.np=self.numnodes*self.procspernodes
44 #OK get other fields
45 self=options.AssignObjectFields(self)
46
47 # }}}
48
49 def __repr__(self):
50 # {{{
51 # display the object
52 s = "class vilje object:"
53 s = "%s\n%s"%(s,fielddisplay(self,'name','name of the cluster'))
54 s = "%s\n%s"%(s,fielddisplay(self,'login','login'))
55 s = "%s\n%s"%(s,fielddisplay(self,'numnodes','number of nodes'))
56 s = "%s\n%s"%(s,fielddisplay(self,'cpuspernode','number of nodes per CPUs (32)'))
57 s = "%s\n%s"%(s,fielddisplay(self,'procspernodes','number of mpi procs per nodes'))
58 s = "%s\n%s"%(s,fielddisplay(self,'mem','node memory'))
59 s = "%s\n%s"%(s,fielddisplay(self,'queue','name of the queue'))
60 s = "%s\n%s"%(s,fielddisplay(self,'time','walltime requested in minutes'))
61 s = "%s\n%s"%(s,fielddisplay(self,'codepath','code path on the cluster'))
62 s = "%s\n%s"%(s,fielddisplay(self,'executionpath','execution path on the cluster'))
63 s = "%s\n%s"%(s,fielddisplay(self,'interactive',''))
64 s = "%s\n%s"%(s,fielddisplay(self,'accountname','your cluster account'))
65 return s
66 # }}}
67
68 def checkconsistency(self,md,solution,analyses):
69 # {{{
70 #Queue dictionarry gives queu name as key and max walltime and cpus as var
71 queuedict = {'workq' :[5*24*60, 30]}
72 QueueRequirements(queuedict,self.queue,self.np,self.time)
73
74 #Miscelaneous
75 if not self.login:
76 md = md.checkmessage('login empty')
77 if not self.codepath:
78 md = md.checkmessage('codepath empty')
79 if not self.executionpath:
80 md = md.checkmessage('executionpath empty')
81 if self.interactive==1:
82 md = md.checkmessage('interactive mode not implemented')
83 return self
84 # }}}
85 def BuildQueueScript(self,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota):
86 # {{{
87
88 executable='issm.exe'
89 if isdakota:
90 version=IssmConfig('_DAKOTA_VERSION_')[0:2]
91 version=float(version)
92 if version>=6:
93 executable='issm_dakota.exe'
94
95 #write queuing script
96 shortname=modelname[0:min(12,len(modelname))]
97 fid=open(modelname+'.queue','w')
98 fid.write('#PBS -S /bin/bash\n')
99 fid.write('#PBS -N %s \n' % shortname)
100 fid.write('#PBS -q %s \n' % self.queue)
101 fid.write('#PBS -l select=%i:ncpus=%i:mpiprocs=%s\n' % (self.numnodes,self.cpuspernode,self.procspernodes))
102 timestring= str(datetime.timedelta(minutes=self.time))
103 fid.write('#PBS -l walltime=%s\n' % timestring) #walltime is hh:mm:ss
104 #fid.write('#PBS -l mem=%igb\n' % self.mem)
105 fid.write('#PBS -A %s\n' % self.accountname)
106 fid.write('#PBS -o %s/%s/%s.outlog \n' % (self.executionpath,dirname,modelname))
107 fid.write('#PBS -e %s/%s/%s.errlog \n\n' % (self.executionpath,dirname,modelname))
108 fid.write('export ISSM_DIR="%s/../"\n' % self.codepath)
109 fid.write('module load intelcomp/13.0.1\n')
110 fid.write('module load mpt/2.06\n')
111 fid.write('module load petsc/3.4.1d\n')
112 fid.write('module load parmetis/4.0.2\n')
113 fid.write('module load mumps/4.10.0\n')
114 fid.write('cd %s/%s/\n\n' % (self.executionpath,dirname))
115 fid.write('mpiexec_mpt -np %i %s/%s %s %s/%s %s\n' % (self.np,self.codepath,executable,str(solution),self.executionpath,dirname,modelname))
116 fid.close()
117
118 # }}}
119 def UploadQueueJob(self,modelname,dirname,filelist):
120 # {{{
121
122 #compress the files into one zip.
123 compressstring='tar -zcf %s.tar.gz ' % dirname
124 for file in filelist:
125 compressstring += ' %s' % file
126 subprocess.call(compressstring,shell=True)
127
128 print 'uploading input file and queueing script'
129 issmscpout(self.name,self.executionpath,self.login,self.port,[dirname+'.tar.gz'])
130
131 # }}}
132 def LaunchQueueJob(self,modelname,dirname,filelist,restart,batch):
133 # {{{
134
135 print 'launching solution sequence on remote cluster'
136 if restart:
137 launchcommand='cd %s && cd %s && qsub %s.queue' % (self.executionpath,dirname,modelname)
138 else:
139 launchcommand='cd %s && rm -rf ./%s && mkdir %s && cd %s && mv ../%s.tar.gz ./ && tar -zxf %s.tar.gz && qsub %s.queue' % (self.executionpath,dirname,dirname,dirname,dirname,dirname,modelname)
140 issmssh(self.name,self.login,self.port,launchcommand)
141
142 # }}}
143 def Download(self,dirname,filelist):
144 # {{{
145
146 #copy files from cluster to current directory
147 directory='%s/%s/' % (self.executionpath,dirname)
148 issmscpin(self.name,self.login,self.port,directory,filelist)
149 # }}}
Note: See TracBrowser for help on using the repository browser.