solve

PURPOSE ^

SOLVE - apply solution sequence for this model

SYNOPSIS ^

function md=solve(md,solutiontype,varargin)

DESCRIPTION ^

SOLVE - apply solution sequence for this model

   solutiontype is 'diagnostic','prognostic','transient','thermalsteady','thermaltransient','parameters' or 'control'
   and varargin is an optional package name ('cielo', 'ice' or 'macayeal')

   Usage:
       md=solve(md,solutiontype,varargin)

   Examples:
      md=solve(md,'diagnostic','macayeal');
      md=solve(md,'control','cielo');

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function md=solve(md,solutiontype,varargin)
0002 %SOLVE - apply solution sequence for this model
0003 %
0004 %   solutiontype is 'diagnostic','prognostic','transient','thermalsteady','thermaltransient','parameters' or 'control'
0005 %   and varargin is an optional package name ('cielo', 'ice' or 'macayeal')
0006 %
0007 %   Usage:
0008 %       md=solve(md,solutiontype,varargin)
0009 %
0010 %   Examples:
0011 %      md=solve(md,'diagnostic','macayeal');
0012 %      md=solve(md,'control','cielo');
0013 
0014 %some checks on list of arguments
0015 
0016 solutions={'mesh2grid','mesh','thermaltransient','thermalsteady','qmu','diagnostic','diagnostic_horiz','prognostic','transient','paramters','control'};
0017 found=0;
0018 for i=1:length(solutions),
0019     if strcmpi(solutiontype,solutions{i}),
0020         found=1;
0021         break;
0022     end
0023 end
0024 
0025 if found==0,
0026     error(['solve error messae: solution type ' solutiontype ' not supported yet!']);
0027 end
0028 
0029 %Recover type of package being used:
0030 if nargin==2,
0031     package='Ice';
0032 else
0033     package=varargin{1};
0034 end
0035 
0036 if ~ischar(package), 
0037     error('Package specified in varargin can only be ''ice'', or ''cielo''');
0038 end
0039 
0040 if ~(strcmpi(package,'ice') || strcmpi(package,'cielo') || strcmpi(package,'macayeal'))
0041     error('Package specified in varargin can only be ''ice'', ''macayeal'', or ''cielo''');
0042 end
0043 
0044 
0045 %Check model is self-consistent
0046 if ~strcmpi(solutiontype,'mesh2grid'),
0047     disp(sprintf('\n%s','checking model consistency'));
0048     if ~ismodelselfconsistent(md,solutiontype,package),
0049         error(' '); %previous error messages should explain what is going on.
0050     end
0051 end
0052 disp('launching solution sequence');
0053 
0054 %If running in parallel, we have a different way of launching the solution
0055 %sequences.
0056 if ~strcmpi(solutiontype,'qmu'),
0057     if ~strcmpi(md.cluster,'none'),
0058         md=solveparallel(md,solutiontype,package);
0059         return;
0060     end
0061 end
0062 
0063 %Lauch correct solution sequence
0064 if strcmpi(solutiontype,'diagnostic'),
0065     if strcmpi(package,'cielo'),
0066         md=cielodiagnostic(md);
0067     elseif strcmpi(package,'ice'),
0068         md=icediagnostic_wrapper(md);
0069     elseif strcmpi(package,'macayeal'),
0070         md=macayealdiagnostic(md);
0071     else
0072         disp('solve error message: wrong type of package for ''diagnostic'' solution');
0073         solveusage;
0074         error('');
0075     end
0076 
0077 elseif strcmpi(solutiontype,'mesh'),
0078     if strcmpi(package,'cielo'),
0079         md=cielomesh(md);
0080     else
0081         disp('solve error message: wrong type of package for ''mesh'' solution');
0082         solveusage;
0083         error('');
0084     end
0085 
0086 elseif strcmpi(solutiontype,'transient'),
0087     if strcmpi(package,'cielo'),
0088         md=cielotransient(md);;
0089     elseif strcmpi(package,'ice'),
0090         md=icetransient_wrapper(md);
0091     else
0092         disp('solve error message: wrong type of package for ''transient'' solution');
0093         solveusage;
0094         error('');
0095     end
0096 
0097 elseif strcmpi(solutiontype,'qmu'),
0098 
0099     md=qmu(md,package);
0100 
0101 elseif strcmpi(solutiontype,'parameters'),
0102     if strcmpi(package,'cielo'),
0103         md=cieloparameters(md);;
0104     elseif strcmpi(package,'ice'),
0105         md=iceparameters_wrapper(md);
0106     else
0107         disp('solve error message: wrong type of package for ''parameters'' solution');
0108         solveusage;
0109         error('');
0110     end
0111 
0112 elseif strcmpi(solutiontype,'mesh2grid'),
0113     if strcmpi(package,'cielo'),
0114         md=cielomesh2grid(md);;
0115     else
0116         disp('solve error message: ''mesh2grid'' solution not implemented on ice yet, sorry');
0117         solveusage;
0118         error('');
0119     end
0120 
0121 elseif strcmpi(solutiontype,'prognostic'),
0122     if strcmpi(package,'cielo'),
0123         md=cieloprognostic(md);;
0124     elseif strcmpi(package,'ice'),
0125         md=iceprognostic_wrapper(md);
0126     else
0127         disp('solve error message: wrong type of package for ''prognostic'' solution');
0128         solveusage;
0129         error('');
0130     end
0131 
0132 elseif strcmpi(solutiontype,'control'),
0133     if strcmpi(package,'cielo'),
0134         md=cielocontrol(md);
0135     elseif strcmpi(package,'ice'),
0136         error('Control methods not supported on ice, use CIELO')
0137     elseif strcmpi(package,'macayeal'),
0138         md=macayealcontrol(md);
0139     else
0140         disp('solve error message: wrong type of package for ''control'' solution');
0141         solveusage;
0142         error('');
0143     end
0144 
0145 elseif strcmpi(solutiontype,'thermalsteady') | strcmpi(solutiontype,'thermaltransient'),
0146         
0147     if strcmpi(package,'cielo'),
0148         md=cielothermal(md,solutiontype);
0149     elseif strcmpi(package,'ice'),
0150         md=icethermal_wrapper(md,solutiontype);
0151     else
0152         disp('solve error message: wrong type of package for ''thermal'' solution');
0153         solveusage;
0154         error('');
0155     end
0156 else
0157     error('solution type not supported for this model configuration.');
0158 end
0159 
0160 %Check result is consistent
0161 disp(sprintf('%s\n','checking result consistency'));
0162 if ~isresultconsistent(md,solutiontype),
0163     disp('!! results not consistent correct the model !!') %it would be very cruel to put an error, it would kill the computed results (even if not consistent...)
0164 end
0165 
0166 function solveusage();
0167 disp(' ');
0168 disp('   Solve usage: md=solve(md,solutiontype,package)');
0169 disp('         solutiontype can be ''diagnostic'',''transient'', ''thermalsteady'',''thermaltransient'',''parameters'',''mesh2grid''  or ''control''');
0170 disp('         package is either ''cielo'' or ''ice''');

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003