Changeset 13012
- Timestamp:
- 08/13/12 12:11:44 (13 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 1 added
- 6 deleted
- 5 edited
- 7 moved
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/modellist.m
r13008 r13012 292 292 end 293 293 end 294 295 function BuildMultipleQueueingScript(cluster,name,executionpath,codepath)% {{{ 296 %BUILDMULTIPLEQUEUEINGSCRIPT - 297 % 298 % Usage: 299 % BuildMultipleQueueingScript(executionpath,codepath) 300 301 disp('building queueing script'); 302 303 %First try and figure out if there is a special script for this particular cluster 304 function_name=['BuildMultipleQueueingScript' cluster]; 305 306 %some specific treatment of identical cluster, gemini, castor and pollux 307 if strcmpi(cluster,'castor') || strcmpi(cluster,'pollux'), 308 function_name='BuildMultipleQueueingScriptgemini'; 309 end 310 311 if exist(function_name,'file'), 312 %Call this function: 313 eval([function_name '(name,executionpath,codepath);']); 314 else 315 %Call the generic BuildQueueingScript: 316 BuildMultipleQueueingScriptGeneric(name,executionpath,codepath); 317 end 318 end % }}} 319 function BuildQueueingScriptgemini(name,executionpath,codepath)% {{{ 320 %BUILDQUEUEINGSCRIPTGEMINI - ... 321 % 322 % Usage: 323 % BuildQueueingScriptgemini(md,executionpath,codepath) 324 325 scriptname=[name '.queue']; 326 327 fid=fopen(scriptname,'w'); 328 if fid==-1, 329 error(['BuildQueueingScriptgeminierror message: could not open ' scriptname ' file for ascii writing']); 330 end 331 332 fprintf(fid,'#!/bin/sh\n'); 333 fprintf(fid,'cd %s\n',executionpath); 334 fprintf(fid,'mkdir %s\n',name); 335 fprintf(fid,'cd %s\n',name); 336 fprintf(fid,'mv ../ModelList.tar.gz ./\n'); 337 fprintf(fid,'tar -zxvf ModelList.tar.gz\n'); 338 fprintf(fid,'foreach i (%s-*vs*.queue)\n',name); 339 fprintf(fid,'qsub $i\n'); 340 fprintf(fid,'end\n'); 341 fclose(fid); 342 end% }}} 343 function LaunchMultipleQueueJob(cluster,name,executionpath)% {{{ 344 %LAUNCHMULTIPLEQUEUEJOB - ... 345 % 346 % Usage: 347 % LaunchMultipleQueueJob(executionpath) 348 349 %First try and figure out if there is a special script for thie particular cluster 350 function_name=['LaunchMultipleQueueJob' cluster]; 351 352 %some specific treatment of identical cluster, gemini, castor and pollux 353 if strcmpi(cluster,'castor') || strcmpi(cluster,'pollux'), 354 function_name='LaunchMultipleQueueJobgemini'; 355 end 356 357 if exist(function_name,'file'), 358 %Call this function: 359 eval([function_name '(cluster,name,executionpath);']); 360 else 361 %Call the generic LaunchMultipleQueueJob: 362 LaunchMultipleQueueJobGeneric(cluster,name,executionpath); 363 end 364 end% }}} 365 function md=LaunchMultipleQueueJobgemini(cluster,name,executionpath)% {{{ 366 %LAUNCHMULTIPLEQUEUEJOBGEMINI - Launch multiple queueing script on Gemini cluster 367 % 368 % Usage: 369 % LaunchMultipleQueueJobgemini(cluster,name,executionpath) 370 371 372 %first, check we have the binary file and the queueing script 373 if ~exist([ name '.queue'],'file'), 374 error('LaunchMultipleQueueJobgemini error message: queueing script issing, cannot go forward'); 375 end 376 377 if ~exist('ModelList.tar.gz','file'), 378 error('LaunchMultipleQueueJobgemini error message: inputs models file missing, cannot go forward'); 379 end 380 381 %upload both files to cluster 382 disp('uploading input file, queueing script and variables script'); 383 eval(['!scp ModelList.tar.gz ' name '.queue ' cluster ':' executionpath]); 384 385 disp('launching solution sequence on remote cluster'); 386 issmssh(cluster,login,['"cd ' executionpath ' && source ' name '.queue "']); 387 end% }}} -
issm/trunk-jpl/src/m/mesh/FixMesh.m
r7810 r13012 1 1 function [index2 x2 y2 value2]=FixMesh(index,x,y,value) 2 % FixMesh fix mesh with broken triangles, orphan vertices, etc ...2 % FIXMESH - FixMesh fix mesh with broken triangles, orphan vertices, etc ... 3 3 % 4 % Usage:5 % 6 % 7 % 8 % 4 % Usage: 5 % [index2 x2 y2 value2]=FixMesh(index,x,y,value) 6 % where index,x,y is a delaunay triangulation, 7 % value is a field on the input triangulation, with values at the vertices 8 % index2,x2,y2,value2 is the repaired triangulation, with new values on new vertices 9 9 % 10 10 % -
issm/trunk-jpl/src/m/mesh/NodeInElement.m
r9729 r13012 1 1 function node_in_element=NodeInElement(newx,newy,elements,x,y,nodeconnectivity); 2 % NODEINELEMENT:find for a list of nodes (in newx,newy), which elements in the mesh (elements,x,y) they belong to.2 % NODEINELEMENT - find for a list of nodes (in newx,newy), which elements in the mesh (elements,x,y) they belong to. 3 3 % 4 % Usage: node_in_element=NodeInElement(newx,newy,elements,x,y,md.mesh.vertexconnectivity); 4 % Usage: 5 % node_in_element=NodeInElement(newx,newy,elements,x,y,md.mesh.vertexconnectivity); 5 6 % 6 7 % See also Nodeconnectivity -
issm/trunk-jpl/src/m/mesh/rifts/meshprocessoutsiderifts.m
r9734 r13012 93 93 md.mesh.elementonbed=ones(md.mesh.numberofelements,1); 94 94 md.mesh.elementonsurface=ones(md.mesh.numberofelements,1); 95 end 96 97 function flag=isconnected(elements,A,B)% {{{ 98 %ISCONNECTED: are two nodes connected by a triangulation? 99 % 100 % Usage: flag=isconnected(elements,A,B) 101 % 102 % 103 104 elements=ElementsFromEdge(elements,A,B); 105 if isempty(elements), 106 flag=0; 107 else 108 flag=1; 109 end 110 end % }}} -
issm/trunk-jpl/src/m/miscellaneous/netcdf2struct.m
r8583 r13012 6 6 7 7 %Read netcdf file 8 data= netcdf(File);8 data=readnetcdf(File); 9 9 10 10 %initialize output … … 26 26 S.(fieldname)=fieldvalue; 27 27 end 28 end 29 30 function S = readnetcdf(File,varargin) 31 % Function to read NetCDF files 32 % S = netcdf(File) 33 % Input Arguments 34 % File = NetCDF file to read 35 % Optional Input Arguments: 36 % 'Var',Var - Read data for VarArray(Var), default [1:length(S.VarArray)] 37 % 'Rec',Rec - Read data for Record(Rec), default [1:S.NumRecs] 38 % Output Arguments: 39 % S = Structure of NetCDF data organised as per NetCDF definition 40 % Notes: 41 % Only version 1, classic 32bit, NetCDF files are supported. By default 42 % data are extracted into the S.VarArray().Data field for all variables. 43 % To read the header only call S = netcdf(File,'Var',[]); 44 % 45 % SEE ALSO 46 % --------------------------------------------------------------------------- 47 S = []; 48 49 try 50 if exist(File,'file') fp = fopen(File,'r','b'); 51 else fp = []; error('File not found'); end 52 if fp == -1 error('Unable to open file'); end 53 54 % Read header 55 Magic = fread(fp,4,'uint8=>char'); 56 if strcmp(Magic(1:3),'CDF') error('Not a NetCDF file'); end 57 if uint8(Magic(4))~=1 error('Version not supported'); end 58 S.NumRecs = fread(fp,1,'uint32=>uint32'); 59 S.DimArray = DimArray(fp); 60 S.AttArray = AttArray(fp); 61 S.VarArray = VarArray(fp); 62 63 % Setup indexing to arrays and records 64 Var = ones(1,length(S.VarArray)); 65 Rec = ones(1,S.NumRecs); 66 for i = 1:2:length(varargin) 67 if strcmp(upper(varargin{i}),'VAR') Var=Var*0; Var(varargin{i+1})=1; 68 elseif strcmp(upper(varargin{i}),'REC') Rec=Rec*0; Rec(varargin{i+1})=1; 69 else error('Optional input argument not recognised'); end 70 end 71 if sum(Var)==0 fclose(fp); return; end 72 73 % Read non-record variables 74 Dim = double(cat(2,S.DimArray.Dim)); 75 ID = double(cat(2,S.VarArray.Type)); 76 77 for i = 1:length(S.VarArray) 78 D = Dim(S.VarArray(i).DimID+1); N = prod(D); RecID{i}=find(D==0); 79 if isempty(RecID{i}) 80 if length(D)==0 D = [1,1]; N = 1; elseif length(D)==1 D=[D,1]; end 81 if Var(i) 82 S.VarArray(i).Data = ReOrder(fread(fp,N,[Type(ID(i)),'=>',Type(ID(i))]),D); 83 fread(fp,(Pad(N,ID(i))-N)*Size(ID(i)),'uint8=>uint8'); 84 else fseek(fp,Pad(N,ID(i))*Size(ID(i)),'cof'); end 85 else S.VarArray(i).Data = []; end 86 end 87 88 % Read record variables 89 for k = 1:S.NumRecs 90 for i = 1:length(S.VarArray) 91 if ~isempty(RecID{i}) 92 D = Dim(S.VarArray(i).DimID+1); D(RecID{i}) = 1; N = prod(D); 93 if length(D)==1 D=[D,1]; end 94 if Var(i) & Rec(k) 95 S.VarArray(i).Data = cat(RecID{i},S.VarArray(i).Data,... 96 ReOrder(fread(fp,N,[Type(ID(i)),'=>',Type(ID(i))]),D)); 97 if N > 1 fread(fp,(Pad(N,ID(i))-N)*Size(ID(i)),'uint8=>uint8'); end 98 else fseek(fp,Pad(N,ID(i))*Size(ID(i)),'cof'); end 99 end 100 end 101 end 102 103 fclose(fp); 104 catch 105 Err = lasterror; fprintf('%s\n',Err.message); 106 if ~isempty(fp) && fp ~= -1 fclose(fp); end 107 end 108 109 % --------------------------------------------------------------------------------------- 110 % Utility functions 111 112 function S = Size(ID) 113 % Size of NetCDF data type, ID, in bytes 114 S = subsref([1,1,2,4,4,8],struct('type','()','subs',{{ID}})); 115 116 function T = Type(ID) 117 % Matlab string for CDF data type, ID 118 T = subsref({'int8','char','int16','int32','single','double'},... 119 struct('type','{}','subs',{{ID}})); 120 121 function N = Pad(Num,ID) 122 % Number of elements to read after padding to 4 bytes for type ID 123 N = (double(Num) + mod(4-double(Num)*Size(ID),4)/Size(ID)).*(Num~=0); 124 125 function S = String(fp) 126 % Read a CDF string; Size,[String,[Padding]] 127 S = fread(fp,Pad(fread(fp,1,'uint32=>uint32'),1),'uint8=>char').'; 128 129 function A = ReOrder(A,S) 130 % Rearrange CDF array A to size S with matlab ordering 131 A = permute(reshape(A,fliplr(S)),fliplr(1:length(S))); 132 133 function S = DimArray(fp) 134 % Read DimArray into structure 135 if fread(fp,1,'uint32=>uint32') == 10 % NC_DIMENSION 136 for i = 1:fread(fp,1,'uint32=>uint32') 137 S(i).Str = String(fp); 138 S(i).Dim = fread(fp,1,'uint32=>uint32'); 139 end 140 else fread(fp,1,'uint32=>uint32'); S = []; end 141 142 function S = AttArray(fp) 143 % Read AttArray into structure 144 if fread(fp,1,'uint32=>uint32') == 12 % NC_ATTRIBUTE 145 for i = 1:fread(fp,1,'uint32=>uint32') 146 S(i).Str = String(fp); 147 ID = fread(fp,1,'uint32=>uint32'); 148 Num = fread(fp,1,'uint32=>uint32'); 149 S(i).Val = fread(fp,Pad(Num,ID),[Type(ID),'=>',Type(ID)]).'; 150 end 151 else fread(fp,1,'uint32=>uint32'); S = []; end 152 153 function S = VarArray(fp) 154 % Read VarArray into structure 155 if fread(fp,1,'uint32=>uint32') == 11 % NC_VARIABLE 156 for i = 1:fread(fp,1,'uint32=>uint32') 157 S(i).Str = String(fp); 158 Num = double(fread(fp,1,'uint32=>uint32')); 159 S(i).DimID = double(fread(fp,Num,'uint32=>uint32')); 160 S(i).AttArray = AttArray(fp); 161 S(i).Type = fread(fp,1,'uint32=>uint32'); 162 S(i).VSize = fread(fp,1,'uint32=>uint32'); 163 S(i).Begin = fread(fp,1,'uint32=>uint32'); % Classic 32 bit format only 164 end 165 else fread(fp,1,'uint32=>uint32'); S = []; end 166 end
Note:
See TracChangeset
for help on using the changeset viewer.