Changeset 2133


Ignore:
Timestamp:
09/09/09 10:13:26 (15 years ago)
Author:
Mathieu Morlighem
Message:

updated runme and updatearchive

Location:
issm/trunk/src/m/utils/Nightly
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/utils/Nightly/runme.m

    r2125 r2133  
    2424% free to tweak the tolerance variable.
    2525
    26 %recover options
    27 options=recover_options(varargin{:});
    28 
    2926%check arguments
    3027if nargout>1
     
    3330end
    3431
    35 %warning if a runme already exists:
    36 if exist('./runme.m')
    37         disp('this is the nighlty run runme, located in src/m/utils/Nightly/runme.m')
    38         disp('Another local runme exist but is not executed')
    39 end
    40 
    41 %read configuration
    42 configuration;
    43 
    44 %packages and analysis_types to be tested
    45 if nargin==2,
    46         solutions=varargin{2};
    47 end
    48 
    49 if nargin,
    50         packages=varargin{1};
    51 end
    52 
    53 %go through the sequences requested.
    54 for i=1:size(sequences,1),
    55         sequence=sequences{i};
    56 
    57         %recover what is being requested.
    58         analysis_type=sequence{1};
    59         sub_analysis_type=sequence{2};
    60         qmu=sequence{3};
    61         control=sequence{4};
    62         control_fit=sequence{5};
    63         parallel=sequence{6};
    64 
    65         %CHECK analysis_type
    66         analysis_type_arg=find_option(options,'analysis_type');
    67         if ~isempty(analysis_type_arg),
    68                 if ~ismember(analysis_type,analysis_type_arg)
    69                         continue
    70                 end
    71         end
    72 
    73         %CHECK sub_analysis_type
    74         sub_analysis_type_arg=find_option(options,'sub_analysis_type');
    75         if ~isempty(sub_analysis_type_arg),
    76                 if ~ismember(sub_analysis_type,sub_analysis_type_arg)
    77                         continue
    78                 end
    79         end
    80 
    81         %CHECK parallel
    82         parallel_arg=find_option(options,'parallel');
    83         if ~isempty(parallel_arg),
    84                 if parallel~=parallel_arg,
    85                         continue
    86                 end
    87         end
    88 
    89         %initialize model, using presolve if need be, or just the piece of generic code below.
    90         md=model;
    91         if ~rifts,
    92                 md=mesh(md,domainname,resolution);
    93         else
    94                 md=mesh(md,domainname,riftoutline,resolution);
    95                 md=meshprocessrifts(md);
    96         end
    97         md=geography(md,iceshelfname,icesheetname);
    98         md=parameterize(md,parametername);
    99         md=extrude(md,numlayers,extrusionexponent);
    100         eval(['md=setelementstype(md,' elementstype ');']);
    101 
    102         if parallel,
    103                 %this run will be done in parallel
    104                 md.cluster=oshostname;
    105                 %check and modify number of cpus if necessary
    106                 np=feature('numCores');
    107                 if np<md.np;
    108                         disp(['warning: changing number of cpus to ' num2str(np) ]);
    109                         md.np=np;
    110                 end
    111                 runtype='parallel';
    112         else
    113                 runtype='serial';
    114         end
    115 
    116         %some solution checks;
    117         if (  (strcmpi(analysis_type,'thermal') & strcmpi(sub_analysis_type,'steady')) | ...
    118                         (strcmpi(analysis_type,'steadystate'))...
    119                 )
    120                 md.dt=0;
    121         end
    122 
    123         if control,
    124                 md.control_analysis=1;
    125                 if strcmpi(control_fit,'absolute'),
    126                         md.fit(:)=0;
    127                 elseif strcmpi(control_fit,'relative'),
    128                         md.fit(:)=1;
    129                 elseif strcmpi(control_fit,'logarithmic'),
    130                         md.fit(:)=2;
    131                 else
    132                         error(['runme error message: for control solution, ' control_fit ' fit is not supported!']);
    133                 end
    134         end
    135        
    136         %try to run the test
    137         try,
    138 
    139                 %presolve
    140                 if exist('./testpresolve.m','file')==2,
    141                         testpresolve;
    142                 end
    143 
    144                 %solve
    145                 md=solve(md,'analysis_type',analysis_type,'sub_analysis_type',sub_analysis_type);
    146 
    147                 %postsolve
    148                 if exist('./testpostsolve.m','file')==2,
    149                         testpostsolve;
    150                 end
    151 
    152                 %compute fields to be checked
    153                 fields=testsgetfields2(md,sequence);
    154 
    155                 %load archive
    156                 eval(['load Archive_'  analysis_type '_' sub_analysis_type '_' runtype ]);
    157 
    158                 for k=1:length(fields),
    159 
    160                         %Get field and tolerance
    161                         field=fields{k};
    162                         tolerance=testsgettolerance2(md,sequence);
    163 
    164                         %compare to archive
    165                         eval(['Archive=Archive_'  analysis_type '_' sub_analysis_type '_' runtype '_field' num2str(k) ';']);
    166                         eval(['error_diff=full(max(abs(Archive-md.results.' field '))/(max(abs(Archive))+eps));']);
    167 
    168                         %disp test result
    169                         if (error_diff>tolerance);
    170                                 disp(sprintf(['\nERROR   difference: %-7.2g > %7.2g test: %-25s solution: %-16s type: %-9s field: ' field  '.\n\n'],error_diff,tolerance,testname,[analysis_type '_' sub_analysis_type],runtype));
    171                         else
    172                                 disp(sprintf(['\nSUCCESS difference: %-7.2g < %7.2g test: %-25s solution: %-16s type: %-9s field: ' field  '.\n\n'],error_diff,tolerance,testname,[analysis_type '_' sub_analysis_type],runtype));
    173                         end
    174                 end
    175 
    176         catch me,
    177 
    178                 %something went wrong, print failure message:
    179                 message=getReport(me)
    180                 disp(sprintf(['\n\nFAILURE difference: %-16s test: %-25s solution: %-16s type: %-9s field: ' field  '.\n\n'],'N/A',testname,[analysis_type '_' sub_analysis_type],runtype));
    181         end
    182 end
     32%call runme_core
     33md=runme_core('check',varargin{:});
    18334
    18435%output model md if requested
  • issm/trunk/src/m/utils/Nightly/updatearchive.m

    r2125 r2133  
    2525
    2626%check arguments
    27 if (nargin>2 | nargout>1)
     27if nargout>1
    2828        help updatearchive
    2929        error('updatearchive error message: bad usage');
    3030end
    3131
    32 %warning if a updatearchive already exists:
    33 if exist('./updatearchive.m')
    34         disp('this is the nighlty run updatearchive, located in src/m/utils/Nightly/updatearchive.m')
    35         disp('Another local updatearchive exist but is not executed')
    36 end
    37 
    38 %recover options
    39 options=recover_options(varargin{:});
    40 
    41 %read configuration
    42 configuration;
    43 
    44 %packages and analysis_types to be tested
    45 if nargin==2,
    46         solutions=varargin{2};
    47 end
    48 
    49 if nargin,
    50         packages=varargin{1};
    51 end
    52 
    53 %go through the sequences requested.
    54 for i=1:size(sequences,1),
    55         sequence=sequences{i};
    56 
    57         %recover what is being requested.
    58         analysis_type=sequence{1};
    59         sub_analysis_type=sequence{2};
    60         qmu=sequence{3};
    61         control=sequence{4};
    62         control_fit=sequence{5};
    63         parallel=sequence{6};
    64 
    65         %CHECK analysis_type
    66         analysis_type_arg=find_option(options,'analysis_type');
    67         if ~isempty(analysis_type_arg),
    68                 if ~ismember(analysis_type,analysis_type_arg)
    69                         continue
    70                 end
    71         end
    72 
    73         %CHECK sub_analysis_type
    74         sub_analysis_type_arg=find_option(options,'sub_analysis_type');
    75         if ~isempty(sub_analysis_type_arg),
    76                 if ~ismember(sub_analysis_type,sub_analysis_type_arg)
    77                         continue
    78                 end
    79         end
    80 
    81         %CHECK parallel
    82         parallel_arg=find_option(options,'parallel');
    83         if ~isempty(parallel_arg),
    84                 if parallel~=parallel_arg,
    85                         continue
    86                 end
    87         end
    88 
    89         %initialize model, using presolve if need be, or just the piece of generic code below.
    90         md=model;
    91         if ~rifts,
    92                 md=mesh(md,domainname,resolution);
    93         else
    94                 md=mesh(md,domainname,riftoutline,resolution);
    95                 md=meshprocessrifts(md);
    96         end
    97         md=geography(md,iceshelfname,icesheetname);
    98         md=parameterize(md,parametername);
    99         md=extrude(md,numlayers,extrusionexponent);
    100         eval(['md=setelementstype(md,' elementstype ');']);
    101 
    102         if parallel,
    103                 %this run will be done in parallel
    104                 md.cluster=oshostname;
    105                 %check and modify number of cpus if necessary
    106                 np=feature('numCores');
    107                 if np<md.np;
    108                         disp(['warning: changing number of cpus to ' num2str(np) ]);
    109                         md.np=np;
    110                 end
    111                 runtype='parallel';
    112         else
    113                 runtype='serial';
    114         end
    115 
    116         %some solution checks;
    117         if (  (strcmpi(analysis_type,'thermal') & strcmpi(sub_analysis_type,'steady')) | ...
    118                         (strcmpi(analysis_type,'steadystate'))...
    119                 )
    120                 md.dt=0;
    121         end
    122 
    123         if control,
    124                 md.control_analysis=1;
    125                 if strcmpi(control_fit,'absolute'),
    126                         md.fit(:)=0;
    127                 elseif strcmpi(control_fit,'relative'),
    128                         md.fit(:)=1;
    129                 elseif strcmpi(control_fit,'logarithmic'),
    130                         md.fit(:)=2;
    131                 else
    132                         error(['updatearchive error message: for control solution, ' control_fit ' fit is not supported!']);
    133                 end
    134         end
    135        
    136         %presolve
    137         if exist('./testpresolve.m','file')==2,
    138                 testpresolve;
    139         end
    140 
    141         %solve
    142         md=solve(md,'analysis_type',analysis_type,'sub_analysis_type',sub_analysis_type);
    143 
    144         %postsolve
    145         if exist('./testpostsolve.m','file')==2,
    146                 testpostsolve;
    147         end
    148         md=solve(md,'analysis_type',analysis_type,'sub_analysis_type',sub_analysis_type);
    149 
    150         %compute fields to be checked
    151         fields=testsgetfields2(md,sequence);
    152 
    153         %save new archive
    154         if parallel,
    155                 runtype='parallel';
    156         else
    157                 runtype='serial';
    158         end
    159         for k=1:length(fields),
    160                 field=fields{k};
    161                 eval(['Archive_'  analysis_type '_' sub_analysis_type '_' runtype '_field' num2str(k) ' = md.results. ' field  ';']);
    162         end
    163         eval(['save Archive_'  analysis_type '_' sub_analysis_type '_' runtype ' Archive_'  analysis_type '_' sub_analysis_type '_' runtype '_field*']);
    164         disp(sprintf(['File Archive_'  analysis_type '_' sub_analysis_type '_' runtype ' saved\n']));
    165 
    166 end
     32%call updatearchive_core
     33md=updatearchive_core(varargin{:},'update');
    16734
    16835%output model md if requested
Note: See TracChangeset for help on using the changeset viewer.