Changeset 13012


Ignore:
Timestamp:
08/13/12 12:11:44 (13 years ago)
Author:
Mathieu Morlighem
Message:

CHG: moving stuff around

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  
    292292        end
    293293end
     294
     295function BuildMultipleQueueingScript(cluster,name,executionpath,codepath)% {{{
     296%BUILDMULTIPLEQUEUEINGSCRIPT -
     297%
     298%   Usage:
     299%      BuildMultipleQueueingScript(executionpath,codepath)
     300
     301disp('building queueing script');
     302
     303%First try and figure out if there is a special script for this particular cluster
     304function_name=['BuildMultipleQueueingScript' cluster];
     305
     306%some specific treatment of identical cluster, gemini, castor and pollux
     307if strcmpi(cluster,'castor') || strcmpi(cluster,'pollux'),
     308        function_name='BuildMultipleQueueingScriptgemini';
     309end
     310
     311if exist(function_name,'file'),
     312        %Call this function:
     313        eval([function_name '(name,executionpath,codepath);']);
     314else
     315        %Call the generic BuildQueueingScript:
     316        BuildMultipleQueueingScriptGeneric(name,executionpath,codepath);
     317end
     318end % }}}
     319function BuildQueueingScriptgemini(name,executionpath,codepath)% {{{
     320%BUILDQUEUEINGSCRIPTGEMINI - ...
     321%
     322%   Usage:
     323%      BuildQueueingScriptgemini(md,executionpath,codepath)
     324
     325scriptname=[name '.queue'];
     326
     327fid=fopen(scriptname,'w');
     328if fid==-1,
     329        error(['BuildQueueingScriptgeminierror message: could not open ' scriptname ' file for ascii writing']);
     330end
     331
     332fprintf(fid,'#!/bin/sh\n');
     333fprintf(fid,'cd %s\n',executionpath);
     334fprintf(fid,'mkdir %s\n',name);
     335fprintf(fid,'cd %s\n',name);
     336fprintf(fid,'mv ../ModelList.tar.gz ./\n');
     337fprintf(fid,'tar -zxvf ModelList.tar.gz\n');
     338fprintf(fid,'foreach i (%s-*vs*.queue)\n',name);
     339fprintf(fid,'qsub $i\n');
     340fprintf(fid,'end\n');
     341fclose(fid);
     342end% }}}
     343function 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
     350function_name=['LaunchMultipleQueueJob' cluster];
     351
     352%some specific treatment of identical cluster, gemini, castor and pollux
     353if strcmpi(cluster,'castor') || strcmpi(cluster,'pollux'),
     354        function_name='LaunchMultipleQueueJobgemini';
     355end
     356
     357if exist(function_name,'file'),
     358        %Call this function:
     359        eval([function_name '(cluster,name,executionpath);']);
     360else
     361        %Call the generic LaunchMultipleQueueJob:
     362        LaunchMultipleQueueJobGeneric(cluster,name,executionpath);
     363end
     364end% }}}
     365function 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
     373if ~exist([ name '.queue'],'file'),
     374        error('LaunchMultipleQueueJobgemini error message: queueing script issing, cannot go forward');
     375end
     376
     377if ~exist('ModelList.tar.gz','file'),
     378        error('LaunchMultipleQueueJobgemini error message: inputs models file missing, cannot go forward');
     379end
     380
     381%upload both files to cluster
     382disp('uploading input file,  queueing script and variables script');
     383eval(['!scp ModelList.tar.gz ' name '.queue '  cluster ':' executionpath]);
     384
     385disp('launching solution sequence on remote cluster');
     386issmssh(cluster,login,['"cd ' executionpath ' && source ' name '.queue "']);
     387end% }}}
  • issm/trunk-jpl/src/m/mesh/FixMesh.m

    r7810 r13012  
    11function  [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 ...
    33%
    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
     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
    99%
    1010%
  • issm/trunk-jpl/src/m/mesh/NodeInElement.m

    r9729 r13012  
    11function 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.
    33%
    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);
    56%
    67%  See also Nodeconnectivity
  • issm/trunk-jpl/src/m/mesh/rifts/meshprocessoutsiderifts.m

    r9734 r13012  
    9393md.mesh.elementonbed=ones(md.mesh.numberofelements,1);
    9494md.mesh.elementonsurface=ones(md.mesh.numberofelements,1);
     95end
     96
     97function 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
     110end % }}}
  • issm/trunk-jpl/src/m/miscellaneous/netcdf2struct.m

    r8583 r13012  
    66
    77%Read netcdf file
    8 data=netcdf(File);
     8data=readnetcdf(File);
    99
    1010%initialize output
     
    2626        S.(fieldname)=fieldvalue;
    2727end
     28end
     29
     30function 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% ---------------------------------------------------------------------------
     47S = [];
     48
     49try
     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);
     104catch
     105   Err = lasterror; fprintf('%s\n',Err.message);
     106   if ~isempty(fp) && fp ~= -1 fclose(fp); end
     107end
     108
     109% ---------------------------------------------------------------------------------------
     110% Utility functions
     111
     112function 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
     116function 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
     121function 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
     125function 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
     129function 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
     133function 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
     142function 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
     153function 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
     166end
Note: See TracChangeset for help on using the changeset viewer.