Changeset 12639
- Timestamp:
- 07/16/12 15:23:55 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/test/NightlyRun/runme.py
r12631 r12639 34 34 import socket 35 35 import numpy 36 import h5py 36 37 import sys 38 from parallelrange import parallelrange 37 39 from IdToName import IdToName 38 40 … … 73 75 74 76 #GET ids {{{1 75 # flist=os.listdir('.') #use dir, as it seems to act OS independent 76 flist=glob.glob('test*.m') #File name must start with 'test' and must end by '.m' 77 list_ids=[] 78 for file in flist: 79 # if file[:4] == 'test' and \ #File name must start with 'test' 80 # file[-2:] == '.m' and \ #File name must end by '.m' 81 # not file == 'test.m': #File name must be different than 'test.m' 82 if not file == 'test.m': #File name must be different than 'test.m' 83 list_ids.append(int(file[4:-2])) #Keep test id only (skip 'test' and '.m') 84 # [i1,i2]=parallelrange(rank,numprocs,length(list_ids)); #Get tests for this cpu only 85 # list_ids=list_ids(i1:i2); 77 flist=glob.glob('test*.py') #File name must start with 'test' and must end by '.py' and must be different than 'test.py' 78 list_ids=[int(file[4:-3]) for file in flist if not file == 'test.py'] #Keep test id only (skip 'test' and '.py') 86 79 print 'list_ids =',list_ids 80 81 i1,i2=parallelrange(rank,numprocs,len(list_ids)) #Get tests for this cpu only 82 list_ids=list_ids[i1:i2+1] 83 print 'list_ids after parallelrange =',list_ids 87 84 88 85 if id: … … 94 91 else: 95 92 test_ids=set(list_ids) 96 print 'test_ids after list =',test_ids93 # print 'test_ids after list =',test_ids 97 94 # }}} 98 95 … … 104 101 exclude_ids=[exclude] 105 102 test_ids=test_ids.difference(set(exclude_ids)) 106 print 'test_ids after exclude =',test_ids103 # print 'test_ids after exclude =',test_ids 107 104 # }}} 108 105 … … 122 119 elif benchmark.lower() == 'tranforcing': 123 120 test_ids=test_ids.intersection(set(range(1501,1503))) 124 print 'test_ids after benchmark =',test_ids121 # print 'test_ids after benchmark =',test_ids 125 122 test_ids=list(test_ids) 126 123 test_ids.sort() … … 136 133 os.chdir(root) 137 134 id_string=IdToName(id) 138 execfile('test'+str(id)+'.py' )135 execfile('test'+str(id)+'.py',globals()) 139 136 140 137 #UPDATE ARCHIVE? … … 143 140 144 141 if not socket.gethostname().lower().split('.')[0] == 'larsen': 145 raise RuntimeError('Nightly run archives must be saved on "larsen" (hostname is "'+socket.gethostname()+'")') 142 # raise RuntimeError("Nightly run archives must be saved on 'larsen' (hostname is '"+socket.gethostname()+"').") 143 print "Nightly run archives must be saved on 'larsen' (hostname is '"+socket.gethostname()+"')." 144 f = h5py.File(os.path.join('..','Archives',archive_name+'.hdf5'),'w') 146 145 for k,fieldname in enumerate(field_names): 147 field= field_values[k]148 exec(archive_name+'_field'+str(k)+' = field')149 # eval(['save ../Archives/' archive_name ' ' archive_name '_field*']); 150 print 'File ./../Archives/'+archive_name+' saved\n'146 field=numpy.array(field_values[k],dtype=float) 147 f.create_dataset(archive_name+'_field'+str(k),data=field) 148 f.close() 149 print "File '%s' saved.\n" % os.path.join('..','Archives',archive_name+'.hdf5') 151 150 152 151 #ELSE: CHECK TEST 153 152 else: 154 153 155 # #load archive 156 # load(['../Archives/' archive_name ]); 154 #load archive 155 if os.path.exists(os.path.join('..','Archives',archive_name+'.hdf5')): 156 f = h5py.File(os.path.join('..','Archives',archive_name+'.hdf5'),'r') 157 else: 158 raise IOError("Archive file '"+os.path.join('..','Archives',archive_name+'.hdf5')+"' does not exist.") 157 159 158 160 for k,fieldname in enumerate(field_names): … … 161 163 #Get field and tolerance 162 164 field=numpy.array(field_values[k],dtype=float) 165 # print 'field =',field 163 166 tolerance=field_tolerances[k] 167 # print 'tolerance =',tolerance 164 168 165 169 #compare to archive 166 exec('archive=numpy.array('+archive_name+'_field'+str(k)+',dtype=float)') 167 error_diff=max(abs(archive-field))/(max(abs(archive))+sys.float_info.epsilon) 170 if archive_name+'_field'+str(k) in f: 171 archive=f[archive_name+'_field'+str(k)][...] 172 else: 173 raise NameError("Field name '"+archive_name+'_field'+str(k)+"' does not exist in archive file.") 174 # print 'archive =',archive 175 error_diff=numpy.amax(numpy.abs(archive-field),axis=1)/ \ 176 (numpy.amax(numpy.abs(archive),axis=1)+sys.float_info.epsilon) 177 # print 'error_diff =',error_diff 168 178 169 179 #disp test result … … 181 191 message=me2 182 192 if output.lower() == 'nightly': 183 fid=open( ISSM_DIR+'/nightlylog/matlaberror.log', 'a')193 fid=open(os.path.join(ISSM_DIR,'nightlylog','matlaberror.log'), 'a') 184 194 fid.write('%s' % message) 185 195 fid.write('\n------------------------------------------------------------------\n') … … 187 197 print 'FAILURE difference: N/A test id: %i test name: %s field: %s' % (id,id_string,fieldname) 188 198 elif output.lower() == 'daily': 189 fid=open( ISSM_DIR+'/dailylog/matlaberror.log', 'a')199 fid=open(os.path.join(ISSM_DIR,'dailylog','matlaberror.log'), 'a') 190 200 fid.write('%s' % message) 191 201 fid.write('\n------------------------------------------------------------------\n') … … 196 206 raise RuntimeError(me2) 197 207 208 f.close() 209 198 210 except Exception as me: 199 211 … … 202 214 message=me 203 215 if output.lower() == 'nightly': 204 fid=open( ISSM_DIR+'/nightlylog/matlaberror.log', 'a')216 fid=open(os.path.join(ISSM_DIR+'nightlylog','matlaberror.log'), 'a') 205 217 fid.write('%s' % message) 206 218 fid.write('\n------------------------------------------------------------------\n') … … 208 220 print 'FAILURE difference: N/A test id: %i test name: %s field: %s' % (id,id_string,'N/A') 209 221 elif output.lower() == 'daily': 210 fid=open( ISSM_DIR+'/dailylog/matlaberror.log', 'a')222 fid=open(os.path.join(ISSM_DIR+'dailylog','matlaberror.log'), 'a') 211 223 fid.write('%s' % message) 212 224 fid.write('\n------------------------------------------------------------------\n')
Note:
See TracChangeset
for help on using the changeset viewer.