source: XIOS/trunk/extern/src_netcdf4/error4.c @ 409

Last change on this file since 409 was 409, checked in by ymipsl, 11 years ago

Add improved nectdf internal library src

YM

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1/*
2
3This file is part of netcdf-4, a netCDF-like interface for HDF5, or a
4HDF5 backend for netCDF, depending on your point of view.
5
6This file contains functions relating to logging errors. Also it
7contains the functions nc_malloc, nc_calloc, and nc_free.
8
9Copyright 2003, University Corporation for Atmospheric Research. See
10netcdf-4/docs/COPYRIGHT file for copying and redistribution
11conditions.
12
13$Id: error4.c,v 1.4 2010/06/01 17:48:55 ed Exp $
14*/
15
16#include <config.h>
17#include <stdarg.h>
18#include <stdlib.h>
19#include <stdio.h>
20#include <assert.h>
21#include <hdf5.h>
22
23/* This contents of this file get skipped if LOGGING is not defined
24 * during compile. */
25#ifdef LOGGING
26
27extern int nc_log_level;
28
29/* This function prints out a message, if the severity of the message
30   is lower than the global nc_log_level. To use it, do something like
31   this:
32   
33   nc_log(0, "this computer will explode in %d seconds", i);
34
35   After the first arg (the severity), use the rest like a normal
36   printf statement. Output will appear on stdout.
37
38   This function is heavily based on the function in section 15.5 of
39   the C FAQ. */
40void 
41nc_log(int severity, const char *fmt, ...)
42{
43   va_list argp;
44   int t;
45
46   /* If the severity is greater than the log level, we don' care to
47      print this message. */
48   if (severity > nc_log_level)
49      return;
50
51   /* If the severity is zero, this is an error. Otherwise insert that
52      many tabs before the message. */
53   if (!severity)
54      fprintf(stdout, "ERROR: ");
55   for (t=0; t<severity; t++)
56      fprintf(stdout, "\t");
57
58   /* Print out the variable list of args with vprintf. */
59   va_start(argp, fmt);
60   vfprintf(stdout, fmt, argp);
61   va_end(argp);
62   
63   /* Put on a final linefeed. */
64   fprintf(stdout, "\n");
65   fflush(stdout);
66}
67
68void 
69nc_log_hdf5(void)
70{
71    H5Eprint(NULL);
72}
73
74#endif /* ifdef LOGGING */
75
Note: See TracBrowser for help on using the repository browser.