~ubuntu-branches/ubuntu/warty/petsc/warty

« back to all changes in this revision

Viewing changes to src/contrib/libtfs/error.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2004-06-07 13:41:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040607134143-92p586zrauvie0le
Tags: 2.2.0-2
* Upstream patch level 2.
* New PETSC_BOPT_EXTRA option for different BOPT and lib names, with _c++
  symlinks only for plain and single (closes: #249617).
* New DEBIAN_DIST=contrib option to link with hypre, parmetis (closes:
  #249619).
* Combined petsc-c and petsc-fortran substvars into petsc-compilers.
* Extra quote in -dev prerm eliminates "too many arguments" problem.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*$Id: error.c,v 1.2 2001/04/10 19:37:38 bsmith Exp $*/
2
 
/**********************************error.c*************************************
3
 
SPARSE GATHER-SCATTER PACKAGE: bss_malloc bss_malloc ivec error comm gs queue
4
 
 
5
 
Author: Henry M. Tufo III
6
 
 
7
 
e-mail: hmt@cs.brown.edu
8
 
 
9
 
snail-mail:
10
 
Division of Applied Mathematics
11
 
Brown University
12
 
Providence, RI 02912
13
 
 
14
 
Last Modification: 
15
 
6.21.97
16
 
***********************************error.c************************************/
17
 
 
18
 
/**********************************error.c*************************************
19
 
File Description:
20
 
-----------------
21
 
 
22
 
***********************************error.c************************************/
23
 
#include <stdio.h>
24
 
#include <stdlib.h>
25
 
#include <stdarg.h>
26
 
 
27
 
#if   defined NXSRC
28
 
#ifndef DELTA
29
 
#include <nx.h>
30
 
#endif
31
 
 
32
 
#elif defined MPISRC
33
 
#include <mpi.h>
34
 
 
35
 
#endif
36
 
 
37
 
#if   defined NXSRC
38
 
#include "const.h"
39
 
#include "types.h"
40
 
#include "error.h"
41
 
#include "comm.h"
42
 
 
43
 
 
44
 
#elif defined MPISRC
45
 
#include <mpi.h>
46
 
#include "const.h"
47
 
#include "types.h"
48
 
#include "error.h"
49
 
#include "comm.h"
50
 
 
51
 
#else
52
 
#include "const.h"
53
 
#include "error.h"
54
 
 
55
 
static int my_id=0;
56
 
 
57
 
#endif
58
 
 
59
 
 
60
 
void 
61
 
error_msg_fatal_ (char *msg)
62
 
{
63
 
  error_msg_fatal(msg);
64
 
}
65
 
 
66
 
 
67
 
 
68
 
/**********************************error.c*************************************
69
 
Function error_msg_fatal()
70
 
 
71
 
Input : pointer to formatted error message.
72
 
Output: prints message to stdout.
73
 
Return: na.
74
 
Description: prints error message and terminates program.
75
 
***********************************error.c************************************/
76
 
void 
77
 
error_msg_fatal(char *msg, ...)
78
 
{
79
 
  va_list ap;
80
 
  char *p, *sval, cval;
81
 
  int ival;
82
 
  REAL dval;
83
 
 
84
 
 
85
 
  /* print error message along w/node identifier */
86
 
  va_start(ap,msg);
87
 
  printf("%d :: FATAL :: ", my_id);
88
 
  for (p=msg; *p; p++)
89
 
    {
90
 
      if (*p != '%')
91
 
        {
92
 
          putchar(*p);
93
 
          continue;
94
 
        }
95
 
      switch (*++p) {
96
 
      case 'c':
97
 
        cval = va_arg(ap,int);
98
 
          putchar(cval);
99
 
        break;
100
 
      case 'd':
101
 
        ival = va_arg(ap,int);
102
 
        printf("%d",ival);
103
 
        break;
104
 
      case 'e':
105
 
        dval = va_arg(ap,REAL);
106
 
        printf("%e",dval);
107
 
        break;
108
 
      case 'f':
109
 
        dval = va_arg(ap,REAL);
110
 
        printf("%f",dval);
111
 
        break;
112
 
      case 'g':
113
 
        dval = va_arg(ap,REAL);
114
 
        printf("%g",dval);
115
 
        break;
116
 
      case 's':
117
 
        for (sval=va_arg(ap,char *); *sval; sval++)
118
 
          {putchar(*sval);}
119
 
        break;
120
 
      default:
121
 
        putchar(*p);
122
 
        break;
123
 
      }
124
 
    }
125
 
  /* printf("\n"); */
126
 
  va_end(ap);
127
 
 
128
 
#ifdef DELTA  
129
 
  fflush(stdout);
130
 
#else
131
 
  fflush(stdout);
132
 
  /*  fflush(NULL); */
133
 
#endif
134
 
 
135
 
 
136
 
  /* exit program */
137
 
#if   defined NXSRC
138
 
  abort();
139
 
 
140
 
 
141
 
#elif defined MPISRC
142
 
  /* Try with MPI_Finalize() as well _only_ if all procs call this routine */
143
 
  /* Choose a more meaningful error code than -12 */
144
 
  MPI_Abort(MPI_COMM_WORLD, -12);
145
 
 
146
 
#else
147
 
  exit(1);
148
 
 
149
 
 
150
 
#endif
151
 
}
152
 
 
153
 
 
154
 
 
155
 
/**********************************error.c*************************************
156
 
Function error_msg_warning()
157
 
 
158
 
Input : formatted string and arguments.
159
 
Output: conversion printed to stdout.
160
 
Return: na.
161
 
Description: prints error message.
162
 
***********************************error.c************************************/
163
 
void 
164
 
error_msg_warning(char *msg, ...)
165
 
{
166
 
  /* print error message along w/node identifier */
167
 
#if   defined V
168
 
  va_list ap;
169
 
  char *p, *sval, cval;
170
 
  int ival;
171
 
  REAL dval;
172
 
 
173
 
  va_start(ap,msg);
174
 
  if (!my_id)
175
 
    {
176
 
      printf("%d :: WARNING :: ", my_id);
177
 
      for (p=msg; *p; p++)
178
 
        {
179
 
          if (*p != '%')
180
 
            {
181
 
              putchar(*p);
182
 
              continue;
183
 
            }
184
 
          switch (*++p) {
185
 
          case 'c':
186
 
            cval = va_arg(ap,char);
187
 
            putchar(cval);
188
 
            break;
189
 
          case 'd':
190
 
            ival = va_arg(ap,int);
191
 
            printf("%d",ival);
192
 
            break;
193
 
          case 'e':
194
 
            dval = va_arg(ap,REAL);
195
 
            printf("%e",dval);
196
 
            break;
197
 
          case 'f':
198
 
            dval = va_arg(ap,REAL);
199
 
            printf("%f",dval);
200
 
            break;
201
 
          case 'g':
202
 
            dval = va_arg(ap,REAL);
203
 
            printf("%g",dval);
204
 
            break;
205
 
          case 's':
206
 
            for (sval=va_arg(ap,char *); *sval; sval++)
207
 
              {putchar(*sval);}
208
 
            break;
209
 
          default:
210
 
            putchar(*p);
211
 
            break;
212
 
          }
213
 
        }
214
 
      /*      printf("\n"); */
215
 
    }
216
 
  va_end(ap);
217
 
 
218
 
 
219
 
#elif defined VV
220
 
  va_list ap;
221
 
  char *p, *sval, cval;
222
 
  int ival;
223
 
  REAL dval;
224
 
  va_start(ap,msg);
225
 
  if (my_id>=0)
226
 
    {
227
 
      printf("%d :: WARNING :: ", my_id);
228
 
      for (p=msg; *p; p++)
229
 
        {
230
 
          if (*p != '%')
231
 
            {
232
 
              putchar(*p);
233
 
              continue;
234
 
            }
235
 
          switch (*++p) {
236
 
          case 'c':
237
 
            cval = va_arg(ap,char);
238
 
            putchar(cval);
239
 
            break;
240
 
          case 'd':
241
 
            ival = va_arg(ap,int);
242
 
            printf("%d",ival);
243
 
            break;
244
 
          case 'e':
245
 
            dval = va_arg(ap,REAL);
246
 
            printf("%e",dval);
247
 
            break;
248
 
          case 'f':
249
 
            dval = va_arg(ap,REAL);
250
 
            printf("%f",dval);
251
 
            break;
252
 
          case 'g':
253
 
            dval = va_arg(ap,REAL);
254
 
            printf("%g",dval);
255
 
            break;
256
 
          case 's':
257
 
            for (sval=va_arg(ap,char *); *sval; sval++)
258
 
              {putchar(*sval);}
259
 
            break;
260
 
          default:
261
 
            putchar(*p);
262
 
            break;
263
 
          }
264
 
        }
265
 
      /* printf("\n"); */
266
 
    }
267
 
  va_end(ap);
268
 
#endif
269
 
 
270
 
#ifdef DELTA  
271
 
  fflush(stdout);
272
 
#else
273
 
  fflush(stdout);
274
 
  /*  fflush(NULL); */
275
 
#endif
276
 
 
277
 
}
278
 
 
279
 
 
280
 
 
281