Doxygen Source Code Documentation
dumplib.c File Reference
#include <stdarg.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "netcdf.h"#include "dumplib.h"Go to the source code of this file.
Defines | |
| #define | LINEPIND " " |
| #define | C_FMT_NAME "C_format" |
| #define | MAX_CFMT_LEN 100 |
Functions | |
| char * | has_c_format_att (int ncid, int varid) |
| vnode * | newvnode (void) |
| void | error (const char *fmt,...) |
| void | set_indent (int in) |
| void | set_max_len (int len) |
| void | lput (const char *cp) |
| void | set_formats (int float_digits, int double_digits) |
| char * | get_fmt (int ncid, int varid, nc_type type) |
| vnode * | newvlist (void) |
| void | varadd (vnode *vlist, int varid) |
| int | varmember (const vnode *vlist, int varid) |
Variables | |
| int | float_precision_specified = 0 |
| int | double_precision_specified = 0 |
| char | float_var_fmt [] = "%.NNg" |
| char | double_var_fmt [] = "%.NNg" |
| char | float_att_fmt [] = "%#.NNgf" |
| char | double_att_fmt [] = "%#.NNg" |
| int | linep |
| int | max_line_len |
Define Documentation
|
|
|
|
|
Definition at line 47 of file dumplib.c. Referenced by lput(). |
|
|
|
Function Documentation
|
||||||||||||
|
Definition at line 33 of file dumplib.c. References args. Referenced by crop_image(), do_ncdump(), find_background(), find_color_or_error(), frame_argument(), get_fmt(), get_input_stream(), gifread_error(), input_stream(), main(), make_lvars(), merge_frame_interval(), name_path(), new_viewer(), newvnode(), output_information(), pipe_color_transformer(), pr_att(), pr_att_vals(), read_colormap_file(), read_text_colormap(), set_precision(), set_sigdigs(), type_name(), vardata(), and write_stream().
00034 {
00035 va_list args ;
00036
00037 (void) fprintf(stderr,"%s: ", progname);
00038 va_start(args, fmt) ;
00039 (void) vfprintf(stderr,fmt,args) ;
00040 va_end(args) ;
00041
00042 (void) fprintf(stderr, "\n") ;
00043 (void) fflush(stderr); /* to ensure log files are current */
00044 exit(EXIT_FAILURE);
00045 }
|
|
||||||||||||||||
|
Definition at line 130 of file dumplib.c. References double_precision_specified, double_var_fmt, error(), float_precision_specified, float_var_fmt, and has_c_format_att(). Referenced by vardata().
00135 {
00136 char *c_format_att;
00137
00138 /* float or double precision specified with -p option overrides any
00139 C_format attribute value, so check for that first. */
00140
00141 if (float_precision_specified && type == NC_FLOAT)
00142 return float_var_fmt;
00143
00144 if (double_precision_specified && type == NC_DOUBLE)
00145 return double_var_fmt;
00146
00147 /* If C_format attribute exists, return it */
00148 c_format_att = has_c_format_att(ncid, varid);
00149 if (c_format_att)
00150 return c_format_att;
00151
00152 /* Otherwise return sensible default. */
00153 switch (type) {
00154 case NC_BYTE:
00155 return "%d";
00156 case NC_CHAR:
00157 return "%s";
00158 case NC_SHORT:
00159 return "%d";
00160 case NC_INT:
00161 return "%d";
00162 case NC_FLOAT:
00163 return float_var_fmt;
00164 case NC_DOUBLE:
00165 return double_var_fmt;
00166 default:
00167 error("pr_vals: bad type");
00168 }
00169
00170 return 0;
00171 }
|
|
||||||||||||
|
Definition at line 92 of file dumplib.c. References nc_advise(), nc_get_att_text(), and nc_inq_att(). Referenced by get_fmt().
00096 {
00097 nc_type cfmt_type;
00098 size_t cfmt_len;
00099 #define C_FMT_NAME "C_format" /* name of C format attribute */
00100 #define MAX_CFMT_LEN 100 /* max length of C format attribute */
00101 static char cfmt[MAX_CFMT_LEN];
00102
00103 /* we expect nc_inq_att to fail if there is no "C_format" attribute */
00104 int nc_stat = nc_inq_att(ncid, varid, "C_format", &cfmt_type, &cfmt_len);
00105
00106 switch(nc_stat) {
00107 case NC_NOERR:
00108 if (cfmt_type == NC_CHAR && cfmt_len != 0 && cfmt_len < MAX_CFMT_LEN) {
00109 int nc_stat = nc_get_att_text(ncid, varid, "C_format", cfmt);
00110 if(nc_stat != NC_NOERR)
00111 nc_advise("Getting 'C_format' attribute", nc_stat, "");
00112 return &cfmt[0];
00113 }
00114 break;
00115 case NC_ENOTATT:
00116 break;
00117 default:
00118 nc_advise("Inquiring about 'C_format' attribute", nc_stat, "");
00119 break;
00120 }
00121 return 0;
00122 }
|
|
|
Definition at line 67 of file dumplib.c. References linep, LINEPIND, and max_line_len. Referenced by lastdelim2(), pr_bvals(), pr_dvals(), pr_fvals(), pr_ivals(), pr_svals(), and pr_tvals().
|
|
|
Definition at line 190 of file dumplib.c. References newvnode(). Referenced by do_ncdump().
|
|
|
Definition at line 175 of file dumplib.c. References error(), and malloc. Referenced by newvlist(), and varadd().
|
|
||||||||||||
|
Definition at line 82 of file dumplib.c. References double_att_fmt, double_var_fmt, float_att_fmt, and float_var_fmt. Referenced by main(), set_precision(), and set_sigdigs().
00083 {
00084 (void) sprintf(float_var_fmt, "%%.%dg", float_digits);
00085 (void) sprintf(double_var_fmt, "%%.%dg", double_digits);
00086 (void) sprintf(float_att_fmt, "%%#.%dgf", float_digits);
00087 (void) sprintf(double_att_fmt, "%%#.%dg", double_digits);
00088 }
|
|
|
Definition at line 53 of file dumplib.c. References linep. Referenced by vardata().
00054 {
00055 linep = in;
00056 }
|
|
|
Definition at line 60 of file dumplib.c. References max_line_len. Referenced by main().
00061 {
00062 max_line_len = len-2;
00063 }
|
|
||||||||||||
|
Definition at line 202 of file dumplib.c. References newvnode(). Referenced by do_ncdump().
|
|
||||||||||||
|
Definition at line 213 of file dumplib.c. References vnode::id, and vnode::next. Referenced by do_ncdump().
|
Variable Documentation
|
|
Definition at line 27 of file dumplib.c. Referenced by set_formats(). |
|
|
Definition at line 23 of file dumplib.c. Referenced by get_fmt(). |
|
|
Definition at line 25 of file dumplib.c. Referenced by get_fmt(), and set_formats(). |
|
|
Definition at line 26 of file dumplib.c. Referenced by set_formats(). |
|
|
Definition at line 22 of file dumplib.c. Referenced by get_fmt(). |
|
|
Definition at line 24 of file dumplib.c. Referenced by get_fmt(), and set_formats(). |
|
|
Definition at line 49 of file dumplib.c. Referenced by lput(), and set_indent(). |
|
|
Definition at line 50 of file dumplib.c. Referenced by lput(), and set_max_len(). |