source: issm/trunk-jpl/src/m/classes/verbose.m@ 13435

Last change on this file since 13435 was 13435, checked in by Eric.Larour, 12 years ago

CHG: Added new level of verbosity for autodiff mode.
Also updated Synchronize.sh to reflect new structure of m code, and
to stop outputting Verbose*.m files, which are not needed anymore since
we have stopped supporting the serial m-code.

File size: 4.1 KB
Line 
1%VERBOSE class definition
2%
3% Available verbosity levels:
4% mprocessor : model processing
5% module : modules
6% solution : solution sequence
7% solver : solver info (extensive)
8% convergence : convergence criteria
9% control : control method
10% qmu : sensitivity analysis
11% autodiff : AD analysis
12%
13% Usage:
14% verbose=verbose();
15% verbose=verbose(3);
16% verbose=verbose('001100');
17% verbose=verbose('module',true,'solver',false);
18
19%WARNING: some parts of this file are Synchronized with src/c/shared/Numerics/Verbosity.h
20% Do not modify these sections. See src/c/shared/Numerics/README for more info
21
22classdef verbose
23 properties (SetAccess=public)
24 % {{{
25 %BEGINFIELDS
26 mprocessor=false;
27 module=false;
28 solution=false;
29 solver=false;
30 convergence=false;
31 control=false;
32 qmu=false;
33 autodiff=false;
34 %ENDFIELDS
35 % }}}
36 end
37 %}}}
38 methods
39 function verbose=verbose(varargin) % {{{
40
41 switch(nargin),
42 case 0,
43 %Don't do anything
44 case 1,
45 binary=varargin{1};
46 if ischar(binary),
47 if strcmpi(binary,'all'),
48 binary=2^11-1; %all ones
49 verbose=BinaryToVerbose(verbose,binary);
50 verbose.solver=false; %Do not use by default
51 else
52 binary=bin2dec(binary);
53 verbose=BinaryToVerbose(verbose,binary);
54 end
55 elseif isnumeric(binary),
56 verbose=BinaryToVerbose(verbose,binary);
57 end
58 otherwise,
59 %Use options to initialize object
60 verbose=AssignObjectFields(pairoptions(varargin{:}),verbose);
61
62 %Cast to logicals
63 listproperties=properties('verbose');
64 for i=1:numel(listproperties),
65 fieldname=listproperties{i};
66 fieldvalue=verbose.(fieldname);
67 if (islogical(fieldvalue) | isnumeric(fieldvalue)) & numel(fieldvalue)==1,
68 verbose.(fieldname)=logical(fieldvalue);
69 else
70 error('verbose supported field values are logicals only (true or false)');
71 end
72 end
73 end
74 end
75 %}}}
76 function binary=VerboseToBinary(verbose) % {{{
77
78 %BEGINVERB2BIN
79 binary=0;
80 if (verbose.mprocessor), binary=bitor(binary,1); end
81 if (verbose.module), binary=bitor(binary,2); end
82 if (verbose.solution), binary=bitor(binary,4); end
83 if (verbose.solver), binary=bitor(binary,8); end
84 if (verbose.convergence), binary=bitor(binary,16); end
85 if (verbose.control), binary=bitor(binary,32); end
86 if (verbose.qmu), binary=bitor(binary,64); end
87 if (verbose.autodiff), binary=bitor(binary,128); end
88 %ENDVERB2BIN
89
90 end
91 %}}}
92 function verbose=BinaryToVerbose(verbose,binary) % {{{
93
94 %BEGINBIN2VERB
95 if bitand(binary,1), verbose.mprocessor=true; else verbose.mprocessor=false; end
96 if bitand(binary,2), verbose.module=true; else verbose.module=false; end
97 if bitand(binary,4), verbose.solution=true; else verbose.solution=false; end
98 if bitand(binary,8), verbose.solver=true; else verbose.solver=false; end
99 if bitand(binary,16), verbose.convergence=true; else verbose.convergence=false; end
100 if bitand(binary,32), verbose.control=true; else verbose.control=false; end
101 if bitand(binary,64), verbose.qmu=true; else verbose.qmu=false; end
102 if bitand(binary,128), verbose.autodiff=true; else verbose.autodiff=false; end
103 %ENDBIN2VERB
104
105 end
106 %}}}
107 function md = checkconsistency(obj,md,solution,analyses) % {{{
108
109 end % }}}
110 function disp(verbose) % {{{
111
112 %BEGINDISP
113 disp(sprintf('class ''%s'' = ',class(verbose)));
114 disp(sprintf(' %15s : %s','mprocessor',mat2str(verbose.mprocessor)));
115 disp(sprintf(' %15s : %s','module',mat2str(verbose.module)));
116 disp(sprintf(' %15s : %s','solution',mat2str(verbose.solution)));
117 disp(sprintf(' %15s : %s','solver',mat2str(verbose.solver)));
118 disp(sprintf(' %15s : %s','convergence',mat2str(verbose.convergence)));
119 disp(sprintf(' %15s : %s','control',mat2str(verbose.control)));
120 disp(sprintf(' %15s : %s','qmu',mat2str(verbose.qmu)));
121 disp(sprintf(' %15s : %s','autodiff',mat2str(verbose.autodiff)));
122 %ENDDISP
123
124 end
125 %}}}
126 function marshall(obj,fid) % {{{
127 WriteData(fid,'data',VerboseToBinary(obj),'enum',VerboseEnum(),'format','Integer');
128 end % }}}
129 end
130end
Note: See TracBrowser for help on using the repository browser.