This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi! I have just finished downloading netcdf and am having problems compiling it. I editted CUSTOMIZE to setup CC as gcc -traditional and did a 'setenv CPPFLAGS'. I then ran configure which made no complaints in producing any of the makefiles. However, a 'make all' did produce some problems. The file in question was fortran/jackets.c I include the log of the make session as well as jackets.c below. Looking at jackets.c it is incomplete. I realise it is made from jackets.src using the script in fortc. I will have a bit more of a look at this and see if I can generate jackets.c manually, although I am loathe to mess with code that I really don't have any idea about. Even if that works I still felt I should report the bug. The machine this was being done on is a Sparc10 running SunOS 4.1.3 If you would like to see any of the other files that were generated by configure then I will be happy to email them to you. Thanks. - Greg ----------------------------------make.log-------------------------------------- making `all' in directory /usr/local/disks/three/glewis/spectral/netcdf/src/port gcc -traditional -O -c -I. -Dconst= -DNO_STRERROR -O uddummy.c ar rcuv libudport.a uddummy.o a - uddummy.o ranlib libudport.a returning to directory /usr/local/disks/three/glewis/spectral/netcdf/src making `all' in directory /usr/local/disks/three/glewis/spectral/netcdf/src/xdr returning to directory /usr/local/disks/three/glewis/spectral/netcdf/src making `all' in directory /usr/local/disks/three/glewis/spectral/netcdf/src/libsrc gcc -traditional -O -c -Dconst= -DNO_STRERROR -O array.c In file included from local_nc.h:14, from array.c:8: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O attr.c In file included from local_nc.h:14, from attr.c:8: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O cdf.c In file included from local_nc.h:14, from cdf.c:7: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O dim.c In file included from local_nc.h:14, from dim.c:8: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O file.c In file included from local_nc.h:14, from file.c:12: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O iarray.c In file included from local_nc.h:14, from iarray.c:7: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O error.c In file included from local_nc.h:14, from error.c:15: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O globdef.c gcc -traditional -O -c -Dconst= -DNO_STRERROR -O putget.c In file included from local_nc.h:14, from putget.c:8: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O putgetg.c In file included from local_nc.h:14, from putgetg.c:14: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O sharray.c In file included from local_nc.h:14, from sharray.c:7: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O string.c In file included from local_nc.h:14, from string.c:8: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O var.c In file included from local_nc.h:14, from var.c:8: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition gcc -traditional -O -c -Dconst= -DNO_STRERROR -O xdrposix.c In file included from local_nc.h:14, from xdrposix.c:50: /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stdio.h:38: warning: `NULL' redefined /local/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.6/include/stddef.h:215: warning: this is the location of the previous definition ar rcuv libnetcdf.a array.o attr.o cdf.o dim.o file.o iarray.o error.o globdef.o putget.o putgetg.o sharray.o string.o var.o xdrposix.o a - array.o a - attr.o a - cdf.o a - dim.o a - file.o a - iarray.o a - error.o a - globdef.o a - putget.o a - putgetg.o a - sharray.o a - string.o a - var.o a - xdrposix.o ranlib libnetcdf.a returning to directory /usr/local/disks/three/glewis/spectral/netcdf/src making `all' in directory /usr/local/disks/three/glewis/spectral/netcdf/src/fortran ./fortc -L . -O sunos common.inc > netcdf.inc ./fortc -L . -O sunos jackets.src > jackets.c gcc -traditional -O -c -I../libsrc -Dconst= -DNO_STRERROR -O jackets.c jackets.c:414: unterminated `#if' conditional *** Error code 1 make: Fatal error: Command failed for target `jackets.o' Current working directory /usr/local/disks/three/glewis/spectral/netcdf/src/fortran *** Error code 1 make: Fatal error: Command failed for target `all' Current working directory /usr/local/disks/three/glewis/spectral/netcdf/src/fortran *** Error code 1 make: Fatal error: Command failed for target `fortran/all' ------------------------------end make.log-------------------------------------- -------------------------------jackets.c---------------------------------------- /* * Copyright 1990, University Corporation for Atmospheric Research * See netcdf/COPYRIGHT file for copying and redistribution conditions. */ /* $Header: /upc/new/netcdf/src/fortran/RCS/jackets.src,v 1.27 1993/06/08 19:28:38 steve Exp $ */ /* * OVERVIEW * * This file contains jacket routines written in C for interfacing Fortran * netCDF function calls to the actual C binding for the NetCDF. This code * is written explicitly for Sun. In general, these functions handle * character-string parameter conventions, convert between * column-major-order arrays and row-major-order arrays, and map between * array indices beginning at one and array indices beginning at zero. * */ /* LINTLIBRARY */ #include <ctype.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include "netcdf.h" #if !NC_OLD_FILLVALUES struct ncfils { /* This will be a common block from Fortran */ double dd; #ifdef __alpha int ll; #else long ll; #endif float ff; short ss; char cc; char bb; } ncfils_ = { FILL_DOUBLE, FILL_LONG, FILL_FLOAT, FILL_SHORT, FILL_CHAR, FILL_BYTE }; #else /* NC_OLD_FILLVALUES below */ /* * This section is provided for backward compatibility only. Using * XDR infinities for floating-point fill values has caused more problems * than it has solved. We encourage you to define your own data-specific * fill values rather than use default ones. * If, however, you *must* use default fill values, then you should use * the above fill values rather than the ones in this section. */ struct ncfils { /* This will be a common block from Fortran */ double dd; #ifdef __alpha int ll; #else long ll; #endif float ff; short ss; char cc; char bb; } ncfils_ = { XDR_D_INFINITY, /* You may have to insert a constant here */ FILL_LONG, XDR_F_INFINITY, /* You may have to insert a constant here */ FILL_SHORT, FILL_CHAR, FILL_BYTE }; #endif /* NC_OLD_FILLVALUES above */ /* * global integer used for suppressing error messages and determining * the fatality of errors. */ extern int ncopts; /* default is (NC_FATAL | NC_VERBOSE) */ /* global integer that contains a netCDF-specific error code */ extern int ncerr; /* blank fill C string to make FORTRAN string */ static void fcdcpy (fstring, fslen, sstring) char *fstring; /* output string to be blank-filled */ int fslen; /* length of output string */ char *sstring; /* input string, null-terminated */ { int i, len = strlen(sstring); for (i = 0; i < len; i++) *(fstring + i) = *(sstring + i); for (i = len; i < fslen; i++) *(fstring + i) = ' '; } static void reverse (array, length) int array[]; /* array to be reversed */ int length; /* length of array */ { int temp, i, j; for (i = 0, j = length - 1; i < j; i++, j--) { temp = array[i]; array[i] = array[j]; array[j] = temp; } } static void revlongs (array, length) long array[]; /* array to be reversed */ int length; /* length of array */ { int i, j; long temp; for (i = 0, j = length - 1; i < j; i++, j--) { temp = array[i]; array[i] = array[j]; array[j] = temp; } } /* error handling function */ static void handle_err (pname, rcode) char *pname; /* procedure name */ int rcode; /* error return */ { extern void NCadvise(); extern char *cdf_routine_name; /* routine name in error messages */ cdf_routine_name = pname; NCadvise(rcode, "string won't fit in CHARACTER variable provided"); } /* copy function used to copy strings with embedded blanks */ static void fstrncpy (target, source, maxlen) char *target; /* space to be copied into */ char *source; /* string to be copied */ int maxlen; /* maximum length of *source */ { while (maxlen-- && *source != '\0') *target++ = *source++; *target = '\0'; } /* copy function used to copy strings terminated with blanks */ static void nstrncpy (target, source, maxlen) char *target; /* space to be copied into */ char *source; /* string to be copied */ int maxlen; /* maximum length of *source */ { while (maxlen-- && *source != ' ') *target++ = *source++; *target = '\0'; } /* * Compute product of dimensions. */ static long dimprod (dims, ndims) long *dims; /* list of dimensions */ int ndims; /* number of dimensions in list */ { long *ip; long prod = 1; for (ip = dims; ip < &dims[ndims]; ip++) prod *= *ip; return prod; } #ifdef FORTRAN_HAS_NO_BYTE /* * Convert multi-dimensional array of bytes stored in ints to packed array of * bytes, in malloc'ed space. Returns pointer to bytes or NULL if malloc * failed. */ static char * itob(ints, dims, ndims) int *ints; /* multi-dimensional array of integers */ long *dims; /* list of dimensions */ int ndims; /* number of dimensions in list */ { long iocount = dimprod (dims, ndims); /* product of dimensions */ char *bytes = (char *) malloc (iocount * sizeof (char)); int *ip; char *bp = bytes; if (bytes != NULL) for (ip = ints; iocount > 0; iocount--) *bp++ = (char) *ip++; return bytes; } /* * Convert a generalized multi-dimensional array of bytes stored in ints to * packed array of bytes, in malloc'ed space. Returns pointer to bytes or * NULL if malloc failed. */ static char * itobg(ints, dims, basis, ndims) int *ints; /* multi-dimensional array of integers */ long *dims; /* list of dimensions */ long *basis; /* memory access basis vector */ int ndims; /* number of dimensions in list */ { long iocount = dimprod (dims, ndims); /* product of dimensions */ char *bytes = (char *) malloc (iocount * sizeof (char)); if (bytes != NULL && iocount > 0) { int idim; char *bp = bytes; char *ip = (char*)ints; long length[MAX_NC_DIMS]; long coords[MAX_NC_DIMS]; for (idim = 0; idim < ndims; ++idim) { length[idim] = dims[idim]*basis[idim]; coords[idim] = 0; } for (;;) { *bp++ = (char)*(int*)ip; idim = ndims - 1; carry: ip += basis[idim]; if (++coords[idim] >= dims[idim]) { coords[idim] = 0; ip -= length[idim]; if (--idim < 0) break; goto carry; } } } return bytes; } /* * Convert a packed array of bytes into a generalized multi-dimensional array * of ints. */ static void btoig(bytes, ints, dims, basis, ndims) char *bytes; /* packed array of bytes */ int *ints; /* multi-dimensional array of integers */ long *dims; /* list of dimensions */ long *basis; /* memory access basis vector */ int ndims; /* number of dimensions in list */ { if (dimprod (dims, ndims) > 0) { int idim; char *bp = bytes; char *ip = (char*)ints; long length[MAX_NC_DIMS]; long coords[MAX_NC_DIMS]; for (idim = 0; idim < ndims; ++idim) { length[idim] = dims[idim]*basis[idim]; coords[idim] = 0; } for (;;) { *(int*)ip = *bp++; idim = ndims - 1; carry: ip += basis[idim]; if (++coords[idim] >= dims[idim]) { coords[idim] = 0; ip -= length[idim]; if (--idim < 0) break; goto carry; } } } } #endif /* FORTRAN_HAS_NO_BYTE */ #ifdef FORTRAN_HAS_NO_SHORT /* * Convert multi-dimensional array of shorts stored in ints to packed array of * shorts, in malloc'ed space. Returns pointer to shorts or NULL if malloc * failed. */ static short * itos(ints, dims, ndims) int *ints; /* multi-dimensional array of ints */ long *dims; /* list of dimensions */ int ndims; /* number of dimensions in list */ { long iocount = dimprod (dims, ndims); /* product of dimensions */ short *shorts = (short *) malloc (iocount * sizeof (short)); int *ip; short *sp = shorts; if (shorts != NULL) for (ip = ints; iocount > 0; iocount--) *sp++ = (short) *ip++; return shorts; } /* * Convert a generalized multi-dimensional array of shorts stored in ints to * packed array of shorts, in malloc'ed space. Returns pointer to shorts or * NULL if malloc failed. */ static short * itosg(ints, dims, basis, ndims) int *ints; /* multi-dimensional array of integers */ long *dims; /* list of dimensions */ long *basis; /* memory access basis vector */ int ndims; /* number of dimensions in list */ { long iocount = dimprod (dims, ndims); /* product of dimensions */ short *shorts = (short *) malloc (iocount * sizeof (short)); if (shorts != NULL && iocount > 0) { int idim; char *ip = (char*)ints; short *sp = shorts; long length[MAX_NC_DIMS]; long coords[MAX_NC_DIMS]; for (idim = 0; idim < ndims; ++idim) { length[idim] = dims[idim]*basis[idim]; coords[idim] = 0; } for (;;) { *sp++ = (short)*(int*)ip; idim = ndims - 1; carry: ip += basis[idim]; if (++coords[idim] >= dims[idim]) { coords[idim] = 0; ip -= length[idim]; if (--idim < 0) break; goto carry; } } } return shorts; } /* * Convert a packed array of shorts into a generalized multi-dimensional array * of ints. */ static void stoig(shorts, ints, dims, basis, ndims) short *shorts; /* packed array of shorts */ int *ints; /* multi-dimensional array of integers */ long *dims; /* list of dimensions */ long *basis; /* memory access basis vector */ int ndims; /* number of dimensions in list */ { if (dimprod (dims, ndims) > 0) { int idim; short *sp = shorts; char *ip = (char*)ints; long length[MAX_NC_DIMS]; long coords[MAX_NC_DIMS]; for (idim = 0; idim < ndims; ++idim) { length[idim] = dims[idim]*basis[idim]; coords[idim] = 0; } for (;;) { *(int*)ip = *sp++; idim = ndims - 1; carry: ip += basis[idim]; if (++coords[idim] >= dims[idim]) { coords[idim] = 0; ip -= length[idim]; if (--idim < 0) break; goto carry; } } } } #endif /* FORTRAN_HAS_NO_SHORT */ #ifdef __alpha /* * Convert multi-dimensional array of NCLONGs stored in ints to packed * array of longs, in malloc'ed space. Returns pointer to longs or NULL * if malloc failed. */ static long * itol(ints, dims, ndims) int *ints; /* multi-dimensional array of ints */ long *dims; /* list of dimensions */ int ndims; /* number of dimensions in list */ { long iocount = dimprod (dims, ndims); long *longs = (long *) malloc (iocount * sizeof (long)); int *ip; long *lp = longs; if (longs != NULL) for (ip = ints; iocount > 0; iocount--) *lp++ = (long) *ip++; return longs; } /* * Convert a generalized multi-dimensional array of longs stored in ints to * packed array of longs, in malloc'ed space. Returns pointer to longs or * NULL if malloc failed. */ static long * itolg(ints, dims, imap, ndims) int *ints; /* multi-dimensional array of integers */ long *dims; /* list of dimensions */ long *imap; /* memory access index mapping vector */ int ndims; /* number of dimensions in list */ { long iocount = dimprod (dims, ndims); long *longs = (long *) malloc (iocount * sizeof (long)); if (longs != NULL && iocount > 0) { int idim; char *ip = (char*)ints; long *lp = longs; long length[MAX_NC_DIMS]; long coords[MAX_NC_DIMS]; for (idim = 0; idim < ndims; ++idim) { length[idim] = dims[idim]*imap[idim]; coords[idim] = 0; } for (;;) { *lp++ = (long)*(int*)ip; idim = ndims - 1; carry: ip += imap[idim]; if (++coords[idim] >= dims[idim]) { coords[idim] = 0; ip -= length[idim]; if (--idim < 0) break; goto carry; } } } return longs; } /* * Convert a packed array of longs into a generalized multi-dimensional array * of ints. */ static void ltoig(longs, ints, dims, imap, ndims) long *longs; /* packed array -----------------------end of jackets.c that I get------------------------------ >From address@hidden Fri Feb 4 06:56:41 1994 It seems that generating jackets.c by hand works. I have no idea why it works when one types the command by hand rather than the makefile doing it... Anyway, sorry to bother you. I did get another bug in trying to make ncgentab.c in the ncgen directory Output as follows gcc -traditional -O -c -I../libsrc -Dconst= -DNO_STRERROR -O ncgentab.c In file included from ncgentab.c:14: /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.1/2.2.2/include/stdlib.h:29: conflicti ng types for `malloc' ncgentab.c:1: previous declaration of `malloc' /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.1/2.2.2/include/stdlib.h:33: conflicti ng types for `realloc' ncgentab.c:1: previous declaration of `realloc' *** Error code 1 make: Fatal error: Command failed for target `ncgentab.o' Current working directory /usr/local/disks/three/glewis/spectral/netcdf/src/ncge *** Error code 1 make: Fatal error: Command failed for target `ncgen/all' This was fixed by simply commenting out the declaration at the head of ncgentab.c - Greg