11/* Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2- 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
3- 2013, 2014, 2015, 2016, 2017, 2018 University Corporation for
4- Atmospheric Research/Unidata. See \ref copyright file for more
5- info. */
2+ 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
3+ 2013, 2014, 2015, 2016, 2017, 2018 University Corporation for
4+ Atmospheric Research/Unidata. See \ref copyright file for more
5+ info. */
66/**
77 * @file
88 * This example program is part of Unidata's netCDF library for
@@ -12,7 +12,7 @@ info. */
1212 * netcdf formats (i.e. classic vs. 64-bit-offset).
1313 *
1414 * @author Ed Hartnett, 7/13/4
15- */
15+ */
1616
1717#include <config.h>
1818#include <netcdf.h>
@@ -22,11 +22,11 @@ info. */
2222/* This macro handles errors by outputting a message to stdout and
2323 then exiting. */
2424#define NC_EXAMPLE_ERROR 2 /* This is the exit code for failure. */
25- #define BAIL (e ) do { \
26- printf("Bailing out in file %s, line %d, error:%s.\n", \
27- __FILE__, __LINE__, nc_strerror(e)); \
28- return NC_EXAMPLE_ERROR; \
29- } while (0)
25+ #define BAIL (e ) do { \
26+ printf("Bailing out in file %s, line %d, error:%s.\n", \
27+ __FILE__, __LINE__, nc_strerror(e)); \
28+ return NC_EXAMPLE_ERROR; \
29+ } while (0)
3030
3131#define NUMDIMS 2
3232#define NUMVARS 1
@@ -36,53 +36,53 @@ return NC_EXAMPLE_ERROR; \
3636int
3737main ()
3838{
39- int ncid , temp_varid , dimids [NUMDIMS ];
40- float temp [LAT_LEN ][LON_LEN ], * fp ;
41- char classic_file [] = "classic.nc" , offset64_file [] = "offset.nc" ;
42- char * file = classic_file ;
43- int i , res ;
39+ int ncid , temp_varid , dimids [NUMDIMS ];
40+ float temp [LAT_LEN ][LON_LEN ], * fp ;
41+ char classic_file [] = "classic.nc" , offset64_file [] = "offset.nc" ;
42+ char * file = classic_file ;
43+ int i , res ;
4444
45- /* Create a bunch of phoney data so we have something to write in
46- the example file. */
47- for (fp = (float * )temp , i = 0 ; i < LAT_LEN * LON_LEN ; i ++ )
48- * fp ++ = 10. + i /10. ;
45+ /* Create a bunch of phoney data so we have something to write in
46+ the example file. */
47+ for (fp = (float * )temp , i = 0 ; i < LAT_LEN * LON_LEN ; i ++ )
48+ * fp ++ = 10. + i /10. ;
4949
50- /* Now create the file in both formats with the same code. */
51- for (i = 0 ; i < 2 ; i ++ )
52- {
53- if (i == 1 ) /* 64-bit offset format file */
54- {
55- file = offset64_file ;
56- if ((res = nc_set_default_format (NC_FORMAT_64BIT , NULL )))
57- BAIL (res );
58- }
50+ /* Now create the file in both formats with the same code. */
51+ for (i = 0 ; i < 2 ; i ++ )
52+ {
53+ if (i == 1 ) /* 64-bit offset format file */
54+ {
55+ file = offset64_file ;
56+ if ((res = nc_set_default_format (NC_FORMAT_64BIT , NULL )))
57+ BAIL (res );
58+ }
5959
60- /* Create the netCDF file. */
61- if ((res = nc_create (file , NC_CLOBBER , & ncid )))
62- BAIL (res );
60+ /* Create the netCDF file. */
61+ if ((res = nc_create (file , NC_CLOBBER , & ncid )))
62+ BAIL (res );
6363
64- /* Define dimensions. */
65- if ((res = nc_def_dim (ncid , "latitude" , LAT_LEN , dimids )))
66- BAIL (res );
67- if ((res = nc_def_dim (ncid , "longitude" , LON_LEN , & dimids [1 ])))
68- BAIL (res );
64+ /* Define dimensions. */
65+ if ((res = nc_def_dim (ncid , "latitude" , LAT_LEN , dimids )))
66+ BAIL (res );
67+ if ((res = nc_def_dim (ncid , "longitude" , LON_LEN , & dimids [1 ])))
68+ BAIL (res );
6969
70- /* Define the variable. */
71- if ((res = nc_def_var (ncid , "sfc_temp" , NC_FLOAT , NUMDIMS ,
72- dimids , & temp_varid )))
73- BAIL (res );
70+ /* Define the variable. */
71+ if ((res = nc_def_var (ncid , "sfc_temp" , NC_FLOAT , NUMDIMS ,
72+ dimids , & temp_varid )))
73+ BAIL (res );
7474
75- /* We're finished defining metadata. */
76- if ((res = nc_enddef (ncid )))
77- BAIL (res );
75+ /* We're finished defining metadata. */
76+ if ((res = nc_enddef (ncid )))
77+ BAIL (res );
7878
79- if ((res = nc_put_var_float (ncid , temp_varid , (float * )temp )))
80- BAIL (res );
79+ if ((res = nc_put_var_float (ncid , temp_varid , (float * )temp )))
80+ BAIL (res );
8181
82- /* We're done! */
83- if ((res = nc_close (ncid )))
84- BAIL (res );
85- }
82+ /* We're done! */
83+ if ((res = nc_close (ncid )))
84+ BAIL (res );
85+ }
8686
87- return 0 ;
87+ return 0 ;
8888}
0 commit comments