Changeset 24313 for issm/trunk/src/m/classes/clusters/vilje.py
- Timestamp:
- 11/01/19 12:01:57 (5 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/classes/clusters/vilje.py
r22758 r24313 6 6 from issmscpout import issmscpout 7 7 from QueueRequirements import QueueRequirements 8 from IssmConfig import IssmConfig 8 9 import datetime 9 10 try: 10 11 from vilje_settings import vilje_settings 11 12 except ImportError: 12 print 'You need vilje_settings.py to proceed, check presence and sys.path' 13 13 print('You need vilje_settings.py to proceed, check presence and sys.path') 14 15 14 16 class vilje(object): 15 """ 16 Vilje cluster class definition 17 18 Usage: 19 cluster=vilje(); 20 """ 17 """ 18 Vilje cluster class definition 21 19 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 = '' 20 Usage: 21 cluster = vilje() 22 """ 37 23 38 #use provided options to change fields 39 options=pairoptions(*args) 24 def __init__(self, *args): # {{{ 25 self.name = 'vilje' 26 self.login = '' 27 self.numnodes = 2 28 self.cpuspernode = 32 29 self.procspernodes = 16 30 self.mem = 28 31 self.queue = 'workq' 32 self.time = 2 * 60 33 self.codepath = '' 34 self.executionpath = '' 35 self.interactive = 0 36 self.port = [] 37 self.accountname = '' 40 38 41 #initialize cluster using user settings if provided 42 self=vilje_settings(self) 43 #OK get other fields 44 self=options.AssignObjectFields(self) 45 self.np=self.numnodes*self.procspernodes 46 # }}} 47 def __repr__(self): 48 # {{{ 49 # display the object 50 s = "class vilje object:" 51 s = "%s\n%s"%(s,fielddisplay(self,'name','name of the cluster')) 52 s = "%s\n%s"%(s,fielddisplay(self,'login','login')) 53 s = "%s\n%s"%(s,fielddisplay(self,'numnodes','number of nodes')) 54 s = "%s\n%s"%(s,fielddisplay(self,'cpuspernode','number of nodes per CPUs (32)')) 55 s = "%s\n%s"%(s,fielddisplay(self,'procspernodes','number of mpi procs per nodes')) 56 s = "%s\n%s"%(s,fielddisplay(self,'mem','node memory')) 57 s = "%s\n%s"%(s,fielddisplay(self,'queue','name of the queue (test is an option, workq the default)')) 58 s = "%s\n%s"%(s,fielddisplay(self,'time','walltime requested in minutes')) 59 s = "%s\n%s"%(s,fielddisplay(self,'codepath','code path on the cluster')) 60 s = "%s\n%s"%(s,fielddisplay(self,'executionpath','execution path on the cluster')) 61 s = "%s\n%s"%(s,fielddisplay(self,'interactive','')) 62 s = "%s\n%s"%(s,fielddisplay(self,'accountname','your cluster account')) 63 return s 64 # }}} 65 def checkconsistency(self,md,solution,analyses): 66 # {{{ 67 #Queue dictionarry gives queu name as key and max walltime and cpus as var 68 queuedict = {'workq':[5*24*60, 30], 69 'test':[30,4]} 70 QueueRequirements(queuedict,self.queue,self.np,self.time) 39 #use provided options to change fields 40 options = pairoptions(*args) 71 41 72 #Miscelaneous 73 if not self.login: 74 md = md.checkmessage('login empty') 75 if not self.codepath: 76 md = md.checkmessage('codepath empty') 77 if not self.executionpath: 78 md = md.checkmessage('executionpath empty') 79 if self.interactive==1: 80 md = md.checkmessage('interactive mode not implemented') 81 return self 82 # }}} 83 def BuildQueueScript(self,dirname,modelname,solution,io_gather,isvalgrind,isgprof,isdakota,isoceancoupling): 84 # {{{ 42 #initialize cluster using user settings if provided 43 self = vilje_settings(self) 44 #OK get other fields 45 self = options.AssignObjectFields(self) 46 self.np = self.numnodes * self.procspernodes 47 # }}} 85 48 86 executable='issm.exe' 87 if isdakota: 88 version=IssmConfig('_DAKOTA_VERSION_')[0:2] 89 version=float(version) 90 if version>=6: 91 executable='issm_dakota.exe' 92 if isoceancoupling: 93 executable='issm_ocean.exe' 49 def __repr__(self): # {{{ 50 # display the object 51 s = "class vilje object:" 52 s = "%s\n%s" % (s, fielddisplay(self, 'name', 'name of the cluster')) 53 s = "%s\n%s" % (s, fielddisplay(self, 'login', 'login')) 54 s = "%s\n%s" % (s, fielddisplay(self, 'numnodes', 'number of nodes')) 55 s = "%s\n%s" % (s, fielddisplay(self, 'cpuspernode', 'number of nodes per CPUs (32)')) 56 s = "%s\n%s" % (s, fielddisplay(self, 'procspernodes', 'number of mpi procs per nodes')) 57 s = "%s\n%s" % (s, fielddisplay(self, 'mem', 'node memory')) 58 s = "%s\n%s" % (s, fielddisplay(self, 'queue', 'name of the queue (test is an option, workq the default)')) 59 s = "%s\n%s" % (s, fielddisplay(self, 'time', 'walltime requested in minutes')) 60 s = "%s\n%s" % (s, fielddisplay(self, 'codepath', 'code path on the cluster')) 61 s = "%s\n%s" % (s, fielddisplay(self, 'executionpath', 'execution path on the cluster')) 62 s = "%s\n%s" % (s, fielddisplay(self, 'interactive', '')) 63 s = "%s\n%s" % (s, fielddisplay(self, 'accountname', 'your cluster account')) 64 return s 65 # }}} 94 66 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 timeobj=datetime.timedelta(minutes=self.time) 103 m,s=divmod(timeobj.total_seconds(), 60) 104 h,m=divmod(m, 60) 105 timestring="%02d:%02d:%02d" % (h, m, s) 106 fid.write('#PBS -l walltime=%s\n' % timestring) #walltime is hh:mm:ss 107 #fid.write('#PBS -l mem=%igb\n' % self.mem) 108 fid.write('#PBS -A %s\n' % self.accountname) 109 fid.write('#PBS -o %s/%s/%s.outlog \n' % (self.executionpath,dirname,modelname)) 110 fid.write('#PBS -e %s/%s/%s.errlog \n\n' % (self.executionpath,dirname,modelname)) 111 fid.write('export ISSM_DIR="%s/../"\n' % self.codepath) 112 fid.write('module load intelcomp/17.0.0\n') 113 fid.write('module load mpt/2.14\n') 114 fid.write('module load petsc/3.7.4d\n') 115 fid.write('module load parmetis/4.0.3\n') 116 fid.write('module load mumps/5.0.2\n') 117 fid.write('cd %s/%s/\n\n' % (self.executionpath,dirname)) 118 fid.write('mpiexec_mpt -np %i %s/%s %s %s/%s %s\n' % (self.np,self.codepath,executable,str(solution),self.executionpath,dirname,modelname)) 119 fid.close() 67 def checkconsistency(self, md, solution, analyses): # {{{ 68 #Queue dictionarry gives queu name as key and max walltime and cpus as var 69 queuedict = {'workq': [5 * 24 * 60, 30], 70 'test': [30, 4]} 71 QueueRequirements(queuedict, self.queue, self.np, self.time) 120 72 121 # }}} 122 def UploadQueueJob(self,modelname,dirname,filelist): 123 # {{{ 124 #compress the files into one zip. 125 compressstring='tar -zcf %s.tar.gz ' % dirname 126 for file in filelist: 127 compressstring += ' %s' % file 128 subprocess.call(compressstring,shell=True) 73 #Miscelaneous 74 if not self.login: 75 md = md.checkmessage('login empty') 76 if not self.codepath: 77 md = md.checkmessage('codepath empty') 78 if not self.executionpath: 79 md = md.checkmessage('executionpath empty') 80 if self.interactive == 1: 81 md = md.checkmessage('interactive mode not implemented') 82 return self 83 # }}} 129 84 130 print 'uploading input file and queueing script' 131 issmscpout(self.name,self.executionpath,self.login,self.port,[dirname+'.tar.gz']) 85 def BuildQueueScript(self, dirname, modelname, solution, io_gather, isvalgrind, isgprof, isdakota, isoceancoupling): # {{{ 86 executable = 'issm.exe' 87 if isdakota: 88 version = IssmConfig('_DAKOTA_VERSION_')[0:2] 89 version = float(version) 90 if version >= 6: 91 executable = 'issm_dakota.exe' 92 if isoceancoupling: 93 executable = 'issm_ocean.exe' 132 94 133 # }}} 134 def LaunchQueueJob(self,modelname,dirname,filelist,restart,batch): 135 # {{{ 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 timeobj = datetime.timedelta(minutes=self.time) 103 m, s = divmod(timeobj.total_seconds(), 60) 104 h, m = divmod(m, 60) 105 timestring = "%02d:%02d:%02d" % (h, m, s) 106 fid.write('#PBS -l walltime=%s\n' % timestring) #walltime is hh:mm:ss 107 fid.write('#PBS -A %s\n' % self.accountname) 108 fid.write('#PBS -o %s/%s/%s.outlog \n' % (self.executionpath, dirname, modelname)) 109 fid.write('#PBS -e %s/%s/%s.errlog \n\n' % (self.executionpath, dirname, modelname)) 110 fid.write('export ISSM_DIR="%s/../ "\n' % self.codepath) 111 fid.write('module load intelcomp/17.0.0\n') 112 fid.write('module load mpt/2.14\n') 113 fid.write('module load petsc/3.7.4d\n') 114 fid.write('module load parmetis/4.0.3\n') 115 fid.write('module load mumps/5.0.2\n') 116 fid.write('cd %s/%s/\n\n' % (self.executionpath, dirname)) 117 fid.write('mpiexec_mpt -np %i %s/%s %s %s/%s %s\n' % (self.np, self.codepath, executable, str(solution), self.executionpath, dirname, modelname)) 118 fid.close() 119 # }}} 136 120 137 print 'launching solution sequence on remote cluster' 138 if restart: 139 launchcommand='cd %s && cd %s && qsub %s.queue' % (self.executionpath,dirname,modelname) 140 else:141 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) 142 issmssh(self.name,self.login,self.port,launchcommand)121 def UploadQueueJob(self, modelname, dirname, filelist): # {{{ 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) 143 127 144 # }}} 145 def Download(self,dirname,filelist): 146 # {{{ 128 print('uploading input file and queueing script') 129 issmscpout(self.name, self.executionpath, self.login, self.port, [dirname + '.tar.gz']) 130 # }}} 147 131 148 #copy files from cluster to current directory 149 directory='%s/%s/' % (self.executionpath,dirname) 150 issmscpin(self.name,self.login,self.port,directory,filelist) 151 # }}} 132 def LaunchQueueJob(self, modelname, dirname, filelist, restart, batch): # {{{ 133 print('launching solution sequence on remote cluster') 134 if restart: 135 launchcommand = 'cd %s && cd %s && qsub %s.queue' % (self.executionpath, dirname, modelname) 136 else: 137 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) 138 issmssh(self.name, self.login, self.port, launchcommand) 139 # }}} 140 141 def Download(self, dirname, filelist): # {{{ 142 #copy files from cluster to current directory 143 directory = '%s/%s/' % (self.executionpath, dirname) 144 issmscpin(self.name, self.login, self.port, directory, filelist) 145 # }}}
Note:
See TracChangeset
for help on using the changeset viewer.