File: tst_nc_converts.c

package info (click to toggle)
netcdf-parallel 1%3A4.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 101,668 kB
  • sloc: ansic: 200,241; sh: 10,807; yacc: 2,522; makefile: 1,306; lex: 1,153; xml: 173; awk: 2
file content (56 lines) | stat: -rw-r--r-- 1,629 bytes parent folder | download | duplicates (3)
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
/* This is part of the netCDF package.
   Copyright 2005 University Corporation for Atmospheric Research/Unidata
   See COPYRIGHT file for conditions of use.

   Test some things about how classic netCDF behaves.

   $Id: tst_nc_converts.c,v 1.3 2005/12/06 19:01:01 ed Exp $
*/
#include <nc_tests.h>
#include <limits.h>

#define FILE_NAME "tst_nc_converts.nc"
#define VAR_NAME "var"
#define DIM1_NAME "dim1"
#define DIM1_LEN 1

int
main()
{
   int ncid, varid, dimids[DIM1_LEN];
   double double_max_int = INT_MAX;
   float float_max_int = INT_MAX;
   int value_in;

   printf("\n*** Testing netcdf type conversion.\n");
   printf("*** testing netcdf-4...");
      
   /* Create a netcdf-4 format file one int variable. */
   if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
   if (nc_def_var(ncid, VAR_NAME, NC_INT, 0, dimids, &varid)) ERR;
   if (nc_enddef(ncid)) ERR;
   if (nc_put_var_float(ncid, varid, &float_max_int)) ERR;
   /*if (nc_put_var_double(ncid, varid, &double_max_int)) ERR;*/
   if (nc_close(ncid)) ERR;

   if (nc_open(FILE_NAME, 0, &ncid)) ERR;
   if (nc_get_var(ncid, 0, &value_in)) ERR;
/*   if (value_in != INT_MAX) ERR;*/
   if (nc_close(ncid)) ERR;

   SUMMARIZE_ERR;

   printf("*** testing netcdf classic...");
   /* Create a classic format file one int variable. */
   if (nc_create(FILE_NAME, 0, &ncid)) ERR;
   if (nc_def_var(ncid, VAR_NAME, NC_INT, 0, dimids, &varid)) ERR;
   if (nc_enddef(ncid)) ERR;
/*   if (nc_put_var_float(ncid, varid, &float_max_int)) ERR;*/
   if (nc_put_var_double(ncid, varid, &double_max_int)) ERR;
   if (nc_close(ncid)) ERR;

   SUMMARIZE_ERR;

   FINAL_RESULTS;
}