-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy patherror.tex
260 lines (228 loc) · 7.82 KB
/
error.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
\section{Error handling\label{sec:errors}}
The PSBLAS library error handling policy has been completely rewritten
in version 2.0. The idea behind the design of this new error handling
strategy is to keep error messages on a stack allowing the user to
trace back up to the point where the first error message has been
generated. Every routine in the PSBLAS-2.0 library has, as last
non-optional argument, an integer \verb|info| variable; whenever,
inside the routine, an error is detected, this variable is set to a
value corresponding to a specific error code. Then this error code is
also pushed on the error stack and then either control is returned to
the caller routine or the execution is aborted, depending on the users
choice. At the time when the execution is aborted, an error message is
printed on standard output with a level of verbosity than can be
chosen by the user. If the execution is not aborted, then, the caller
routine checks the value returned in the \verb|info| variable and, if
not zero, an error condition is raised. This process continues on all the
levels of nested calls until the level where the user decides to abort
the program execution.
Figure~\ref{fig:routerr} shows the layout of a generic \verb|psb_foo|
routine with respect to the PSBLAS-2.0 error handling policy. It is
possible to see how, whenever an error condition is detected, the
\verb|info| variable is set to the corresponding error code which is,
then, pushed on top of the stack by means of the
\verb|psb_errpush|. An error condition may be directly detected inside
a routine or indirectly checking the error code returned returned by a
called routine. Whenever an error is encountered, after it has been
pushed on stack, the program execution skips to a point where the
error condition is handled; the error condition is handled either by
returning control to the caller routine or by calling the
\verb|psb\_error| routine which prints the content of the error stack
and aborts the program execution, according to the choice made by the
user with \verb|psb_set_erraction|. The default is to print the error
and terminate the program, but the user may choose to handle the error
explicitly.
\begin{listing}[h!]
\ifpdf
\begin{minted}[breaklines=true,bgcolor=bg]{fortran}
subroutine psb_foo(some args, info)
!...
if(error detected) then
info=errcode1
call psb_errpush('psb_foo', errcode1)
goto 9999
end if
!...
call psb_bar(some args, info)
if(info .ne. zero) then
info=errcode2
call psb_errpush('psb_foo', errcode2)
goto 9999
end if
!...
9999 continue
if (err_act .eq. act_abort) then
call psb_error(icontxt)
return
else
return
end if
end subroutine psb_foo
\end{minted}
\else
\begin{Sbox}
\begin{minipage}[tl]{0.95\textwidth}
\small
\begin{lstlisting}
subroutine psb_foo(some args, info)
...
if(error detected) then
info=errcode1
call psb_errpush('psb_foo', errcode1)
goto 9999
end if
...
call psb_bar(some args, info)
if(info .ne. zero) then
info=errcode2
call psb_errpush('psb_foo', errcode2)
goto 9999
end if
...
9999 continue
if (err_act .eq. act_abort) then
call psb_error(icontxt)
return
else
return
end if
end subroutine psb_foo
\end{lstlisting}
\end{minipage}
\end{Sbox}
\setlength{\fboxsep}{8pt}
\begin{center}
\fbox{\TheSbox}
\end{center}
\fi
\caption{\label{fig:routerr}The layout of a generic \texttt{psb\_foo}
routine with respect to PSBLAS-2.0 error handling policy.}
\end{listing}
Figure~\ref{fig:errormsg} reports a sample error message generated by
the PSBLAS-2.0 library. This error has been generated by the fact that
the user has chosen the invalid ``FOO'' storage format to represent
the sparse matrix. From this error message it is possible to see that
the error has been detected inside the \verb|psb_cest| subroutine
called by \verb|psb_spasb| ... by process 0 (i.e. the root process).
\begin{listing}[h!]
\ifpdf
\begin{minted}{bash}
==========================================================
Process: 0. PSBLAS Error (4010) in subroutine: df_sample
Error from call to subroutine mat dist
==========================================================
Process: 0. PSBLAS Error (4010) in subroutine: mat_distv
Error from call to subroutine psb_spasb
==========================================================
Process: 0. PSBLAS Error (4010) in subroutine: psb_spasb
Error from call to subroutine psb_cest
==========================================================
Process: 0. PSBLAS Error (136) in subroutine: psb_cest
Format FOO is unknown
==========================================================
Aborting...
\end{minted}
\else
\begin{Sbox}
\begin{minipage}[tl]{0.95\textwidth}
\begin{verbatim}
==========================================================
Process: 0. PSBLAS Error (4010) in subroutine: df_sample
Error from call to subroutine mat dist
==========================================================
Process: 0. PSBLAS Error (4010) in subroutine: mat_distv
Error from call to subroutine psb_spasb
==========================================================
Process: 0. PSBLAS Error (4010) in subroutine: psb_spasb
Error from call to subroutine psb_cest
==========================================================
Process: 0. PSBLAS Error (136) in subroutine: psb_cest
Format FOO is unknown
==========================================================
Aborting...
\end{verbatim}
\end{minipage}
\end{Sbox}
\setlength{\fboxsep}{8pt}
\begin{center}
\fbox{\TheSbox}
\end{center}
\fi
\caption{\label{fig:errormsg}A sample PSBLAS-3.0 error
message. Process 0 detected an error condition inside the {\textrm
psb\_cest} subroutine}
\end{listing}
\clearpage\subsection{psb\_errpush --- Pushes an error code onto the error
stack}
\begin{lstlisting}
call psb_errpush(err_c, r_name, i_err, a_err)
\end{lstlisting}
\begin{description}
\item[Type:] Asynchronous.
\item[\bf On Entry]
\item[err\_c] the error code\\
Scope: {\bf local} \\
Type: {\bf required}\\
Intent: {\bf in}.\\
Specified as: an integer.
\item[r\_name] the soutine where the error has been caught.\\
Scope: {\bf local} \\
Type: {\bf required}\\
Intent: {\bf in}.\\
Specified as: a string.\\
\item[i\_err] addional info for error code\\
Scope: {\bf local} \\
Type: {\bf optional}\\
Specified as: an integer array\\
\item[a\_err] addional info for error code\\
Scope: {\bf local} \\
Type: {\bf optional}\\
Specified as: a string.\\
\end{description}
\clearpage\subsection{psb\_error --- Prints the error stack content and aborts
execution}
\begin{lstlisting}
call psb_error(icontxt)
\end{lstlisting}
\begin{description}
\item[Type:] Asynchronous.
\item[\bf On Entry]
\item[icontxt] the communication context.\\
Scope: {\bf global} \\
Type: {\bf optional}\\
Intent: {\bf in}.\\
Specified as: an integer.
\end{description}
\clearpage\subsection{psb\_set\_errverbosity --- Sets the verbosity of error
messages}
\begin{lstlisting}
call psb_set_errverbosity(v)
\end{lstlisting}
\begin{description}
\item[Type:] Asynchronous.
\item[\bf On Entry]
\item[v] the verbosity level\\
Scope: {\bf global}\\
Type: {\bf required}\\
Intent: {\bf in}.\\
Specified as: an integer.
\end{description}
\clearpage\subsection{psb\_set\_erraction --- Set the type of action to be
taken upon error condition}
\begin{lstlisting}
call psb_set_erraction(err_act)
\end{lstlisting}
\begin{description}
\item[Type:] Asynchronous.
\item[\bf On Entry]
\item[err\_act] the type of action.\\
Scope: {\bf global} \\
Type: {\bf required}\\
Intent: {\bf in}.\\
Specified as: an integer. Possible values: \verb|psb_act_ret|,
\verb|psb_act_abort|.
\end{description}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "userguide"
%%% End: