~ubuntu-branches/ubuntu/karmic/paraview/karmic

« back to all changes in this revision

Viewing changes to VTK/Utilities/vtkexodus2/exerr.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2008-06-15 22:04:41 UTC
  • Revision ID: james.westby@ubuntu.com-20080615220441-8us51vf6ra2umcov
Tags: upstream-3.2.2
ImportĀ upstreamĀ versionĀ 3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2005 Sandia Corporation. Under the terms of Contract
 
3
 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Governement
 
4
 * retains certain rights in this software.
 
5
 * 
 
6
 * Redistribution and use in source and binary forms, with or without
 
7
 * modification, are permitted provided that the following conditions are
 
8
 * met:
 
9
 * 
 
10
 *     * Redistributions of source code must retain the above copyright
 
11
 *       notice, this list of conditions and the following disclaimer.
 
12
 * 
 
13
 *     * Redistributions in binary form must reproduce the above
 
14
 *       copyright notice, this list of conditions and the following
 
15
 *       disclaimer in the documentation and/or other materials provided
 
16
 *       with the distribution.  
 
17
 * 
 
18
 *     * Neither the name of Sandia Corporation nor the names of its
 
19
 *       contributors may be used to endorse or promote products derived
 
20
 *       from this software without specific prior written permission.
 
21
 * 
 
22
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
23
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
24
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
25
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
26
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
27
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
28
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
29
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
30
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
31
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
32
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
33
 * 
 
34
 */
 
35
/*****************************************************************************
 
36
*
 
37
* exerr - ex_err
 
38
*
 
39
* author - Sandia National Laboratories
 
40
*          Vic Yarberry    - Original
 
41
*
 
42
*          
 
43
* environment - UNIX
 
44
*
 
45
* entry conditions - 
 
46
*   input parameters:
 
47
*       char*   pname                   procedure name
 
48
*       char*   err_string              error message string
 
49
*       int     errcode                 error code
 
50
*
 
51
* exit conditions - 
 
52
*
 
53
* revision history - 
 
54
*
 
55
*  $Id: exerr.c,v 1.2 2006/11/29 18:09:13 dcthomp Exp $
 
56
*
 
57
*****************************************************************************/
 
58
 
 
59
/* Generalized error reporting function
 
60
 * global integer used for suppressing error messages and determining
 
61
 * the fatality of errors.
 
62
 */
 
63
 
 
64
#include <string.h>
 
65
#include <stdio.h>
 
66
#include <stdlib.h>
 
67
#include "netcdf.h"
 
68
#include "exodusII.h"
 
69
 
 
70
int exerrval = 0;               /* clear initial global error code value */
 
71
 
 
72
static char last_pname[MAX_ERR_LENGTH];
 
73
static char last_errmsg[MAX_ERR_LENGTH];
 
74
static int last_errcode;
 
75
 
 
76
void ex_err( const char *pname, /* procedure name */
 
77
             const char *err_string,    /* error message string */
 
78
             int errcode)       /* error code */
 
79
{
 
80
  if (errcode == 0)             /* zero is no error, ignore and return */
 
81
    return;
 
82
 
 
83
  else if (errcode ==  EX_PRTLASTMSG)
 
84
  {
 
85
    fprintf(stderr, "[%s] %s\n",last_pname,last_errmsg);
 
86
    fprintf(stderr, "    exerrval = %d\n",last_errcode);
 
87
    return;
 
88
  }
 
89
 
 
90
  else if (exoptval & EX_VERBOSE) /* check see if we really want to hear this */
 
91
  {
 
92
    fprintf(stderr, "[%s] %s\n",pname,err_string);
 
93
    if (exoptval & EX_VERBOSE)
 
94
      fprintf(stderr, "    exerrval = %d\n",errcode);
 
95
    switch (errcode) 
 
96
    {
 
97
      case NC_ESTS:
 
98
        fprintf (stderr," In FORTRAN interface, string too small\n");
 
99
        break;
 
100
      case NC_ENTOOL:
 
101
        fprintf (stderr," length of name exceeds MAX_NC_NAME\n");
 
102
        break;
 
103
      case EX_MSG:
 
104
        break;
 
105
    }
 
106
  } 
 
107
  /* save the error message for replays */
 
108
  strcpy(last_errmsg, err_string);
 
109
  strcpy(last_pname, pname);
 
110
  last_errcode = errcode;
 
111
 
 
112
  fflush(stderr);
 
113
 
 
114
  /* with netCDF 3.4, (fatal) system error codes are > 0; 
 
115
     so all EXODUS fatal error codes are > 0    */
 
116
  if ((errcode > 0) && (exoptval & EX_ABORT))
 
117
    exit (errcode);
 
118
}