Commit 39366b0c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Changed boolean ints to stdbool.

parent a8e62ebc
2017-09-16 Uwe Schulzweida
* using CGRIBEX library version 1.8.1
* Version 1.9.0 released
2017-06-06 Uwe Schulzweida
* Changed boolean ints to stdbool
2017-05-16 Uwe Schulzweida
* Version 1.8.2 released
......
......@@ -24,7 +24,7 @@ case "${HOSTNAME}" in
--enable-iso-c-interface \
--enable-swig \
--enable-python \
--with-grib_api=$HOME/local/gribapi-1.12.3 \
--with-grib_api=$HOME/local/grib_api-1.14.7 \
--with-netcdf=$HOME/local \
--with-szlib=$HOME/local \
CC=icc CFLAGS="-g -D_REENTRANT -Wall -Wwrite-strings -O3 -march=native -fp-model source"
......@@ -35,7 +35,7 @@ case "${HOSTNAME}" in
--enable-iso-c-interface \
--enable-swig \
--enable-python \
--with-grib_api=$HOME/local/grib_api-1.13.1 \
--with-grib_api=$HOME/local/grib_api-1.14.7 \
--with-netcdf=$HOME/local/netcdf-c-4.3.3.1-threadsafe \
--with-szlib=$HOME/local \
CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -Wwrite-strings -W -Wfloat-equal -pedantic -O3 -march=native"
......
......@@ -945,8 +945,8 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
@ENABLE_CDI_LIB_FALSE@install-exec-local:
@ENABLE_CDI_LIB_FALSE@uninstall-local:
@ENABLE_CDI_LIB_FALSE@install-exec-local:
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
......
......@@ -163,15 +163,15 @@ int cdfOpen(const char *filename, const char *mode)
int cdfOpen64(const char *filename, const char *mode)
{
int fileID = -1;
int open_file = TRUE;
int filetype = CDI_FILETYPE_NC2;
bool open_file = true;
if ( CDF_Debug )
Message("Open %s with mode %c", filename, *mode);
#if defined (HAVE_LIBNETCDF)
#if ! defined (NC_64BIT_OFFSET)
open_file = FALSE;
open_file = false;
#endif
#endif
......@@ -194,13 +194,13 @@ int cdfOpen64(const char *filename, const char *mode)
int cdf4Open(const char *filename, const char *mode, int *filetype)
{
int fileID = -1;
int open_file = FALSE;
bool open_file = false;
if ( CDF_Debug )
Message("Open %s with mode %c", filename, *mode);
#if defined (HAVE_NETCDF4)
open_file = TRUE;
open_file = true;
#endif
if ( open_file )
......
......@@ -76,12 +76,12 @@ void cdf_create(const char *path, int cmode, int *ncidp)
int cdf_open(const char *path, int omode, int *ncidp)
{
int status = 0;
int dapfile = FALSE;
bool dapfile = false;
struct stat filestat;
size_t chunksizehint = 0;
#if defined (HAVE_LIBNC_DAP)
if ( strncmp(path, "http:", 5) == 0 || strncmp(path, "https:", 6) == 0 ) dapfile = TRUE;
if ( strncmp(path, "http:", 5) == 0 || strncmp(path, "https:", 6) == 0 ) dapfile = true;
#endif
if ( dapfile )
......
......@@ -32,9 +32,9 @@ int cdiNcChunksizehint = CDI_UNDEFID;
int cdiChunkType = CDI_CHUNK_GRID;
int cdiSplitLtype105 = CDI_UNDEFID;
int cdiIgnoreAttCoordinates = FALSE;
int cdiCoordinatesLonLat = FALSE;
int cdiIgnoreValidRange = FALSE;
bool cdiIgnoreAttCoordinates = false;
bool cdiCoordinatesLonLat = false;
bool cdiIgnoreValidRange = false;
int cdiSkipRecords = 0;
int cdiConvention = CDI_CONVENTION_ECHAM;
int cdiInventoryMode = 1;
......@@ -314,13 +314,13 @@ void cdiSetChunk(const char *chunkAlgo)
void cdiInitialize(void)
{
static int Init_CDI = FALSE;
char *envstr;
long value;
static bool Init_CDI = false;
if ( ! Init_CDI )
{
Init_CDI = TRUE;
Init_CDI = true;
char *envstr;
long value;
#if defined (HAVE_LIBCGRIBEX)
gribFixZSE(1); // 1: Fix ZeroShiftError of simple packed spherical harmonics
......@@ -370,13 +370,13 @@ void cdiInitialize(void)
if ( envstr ) cdiSplitLtype105 = atoi(envstr);
envstr = getenv("IGNORE_ATT_COORDINATES");
if ( envstr ) cdiIgnoreAttCoordinates = atoi(envstr);
if ( envstr ) cdiIgnoreAttCoordinates = atoi(envstr) > 0;
envstr = getenv("CDI_COORDINATES_LONLAT");
if ( envstr ) cdiCoordinatesLonLat = atoi(envstr);
if ( envstr ) cdiCoordinatesLonLat = atoi(envstr) > 0;
envstr = getenv("IGNORE_VALID_RANGE");
if ( envstr ) cdiIgnoreValidRange = atoi(envstr);
if ( envstr ) cdiIgnoreValidRange = atoi(envstr) > 0;
envstr = getenv("CDI_SKIP_RECORDS");
if ( envstr )
......
......@@ -160,9 +160,9 @@ typedef struct
// (181; 105, 0, timeRangeIndicator=0) .. instantanous rain
// (181; 105, 0, timeRangeIndicator=4) .. accumulated rain .. both can be in the same grib file
#endif // HIRLAM_EXTENSIONS
short used;
short varID;
short levelID;
short used;
char varname[32]; /* needed for grib decoding with GRIB_API */
var_tile_t tiles; /* tile-related meta-data, currently for GRIB-API only. */
}
......@@ -178,7 +178,7 @@ typedef struct {
/* tsID>0 number of non constant records */
int nallrecs; /* number of all records */
int curRecID; /* current record ID */
long next;
bool next;
off_t position; /* timestep file position */
taxis_t taxis;
}
......@@ -297,7 +297,7 @@ typedef enum {
typedef struct
{
char* keyword; /* keyword string */
int update;
bool update;
key_val_pair_datatype data_type; /* data type of this key/value pair */
double dbl_val; /* double value (data_type == t_double) */
int int_val; /* integer value (data_type == t_int) */
......@@ -333,9 +333,9 @@ extern int cdiDataUnreduced;
extern int cdiSortName;
extern int cdiSortParam;
extern int cdiHaveMissval;
extern int cdiIgnoreAttCoordinates;
extern int cdiCoordinatesLonLat;
extern int cdiIgnoreValidRange;
extern bool cdiIgnoreAttCoordinates;
extern bool cdiCoordinatesLonLat;
extern bool cdiIgnoreValidRange;
extern int cdiSkipRecords;
extern int cdiConvention;
extern int cdiInventoryMode;
......
#ifndef _CGRIBEX_H
#define _CGRIBEX_H
#ifndef CGRIBEX_H
#define CGRIBEX_H
#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
#define GRIB_MISSVAL -9.E33
......@@ -206,7 +207,7 @@ void gribSetCalendar(int calendar);
void gribDateTime(int *isec1, int *date, int *time);
int gribRefDate(int *isec1);
int gribRefTime(int *isec1);
int gribTimeIsFC(int *isec1);
bool gribTimeIsFC(int *isec1);
void gribPrintSec0(int *isec0);
void gribPrintSec1(int *isec0, int *isec1);
......@@ -254,5 +255,5 @@ double calculate_pfactor_double(const double* spectralField, long fieldTruncatio
}
#endif
#endif /* _CGRIBEX_H */
#endif /* CGRIBEX_H */
/* Automatically generated by m214003 at 2016-12-20, do not edit */
/* Automatically generated by m214003 at 2017-06-06, do not edit */
/* CGRIBEXLIB_VERSION="1.7.6" */
/* CGRIBEXLIB_VERSION="1.8.1" */
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5) || defined (__clang__)
#pragma GCC diagnostic push
......@@ -21,6 +21,7 @@
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdbool.h>
#include <sys/types.h>
#include <inttypes.h>
......@@ -31,8 +32,8 @@
#include "calendar.h"
#include "timebase.h"
#ifndef _TEMPLATES_H
#define _TEMPLATES_H
#ifndef CGRIBEX_TEMPLATES_H
#define CGRIBEX_TEMPLATES_H
#define CAT(X,Y) X##_##Y
#define TEMPLATE(X,Y) CAT(X,Y)
......@@ -42,32 +43,26 @@
#define GRIB_INT_H
#if defined (HAVE_CONFIG_H)
# include "config.h"
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <float.h>
#if ! defined (_CGRIBEX_H)
#if ! defined (CGRIBEX_H)
# include "cgribex.h"
#endif
#if ! defined (ERROR_H)
# include "error.h"
#endif
#if ! defined (_DTYPES_H)
#if ! defined (DTYPES_H)
# include "dtypes.h"
#endif
#if ! defined (FALSE)
# define FALSE 0
#endif
#if ! defined (TRUE)
# define TRUE 1
#endif
#if ! defined (UCHAR)
# define UCHAR unsigned char
......@@ -223,8 +218,8 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
#endif
#endif /* GRIB_INT_H */
#ifndef _GRIBDECODE_H
#define _GRIBDECODE_H
#ifndef GRIBDECODE_H
#define GRIBDECODE_H
#define UNDEFINED 9.999e20
......@@ -363,9 +358,9 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
#define GRIB2_SECLEN(section) (GET_UINT4(section[0], section[1], section[2], section[3]))
#define GRIB2_SECNUM(section) (GET_UINT1(section[4]))
#endif /* _GRIBDECODE_H */
#ifndef _GRIB_ENCODE_H
#define _GRIB_ENCODE_H
#endif /* GRIBDECODE_H */
#ifndef CGRIBEX_GRIB_ENCODE_H
#define CGRIBEX_GRIB_ENCODE_H
#include <limits.h>
......@@ -402,7 +397,7 @@ enum {
Put3Byte(mantissa); \
}
#endif /* _GRIB_ENCODE_H */
#endif /* CGRIBEX_GRIB_ENCODE_H */
#ifndef CODEC_COMMON_H
#define CODEC_COMMON_H
#define gribSwapByteOrder_uint16(ui16) ((uint16_t)((ui16<<8) | (ui16>>8)))
......@@ -1173,6 +1168,7 @@ xlc_r -g -O3 -qhot -q64 -qarch=auto -qtune=auto -qreport -DTEST_ENCODE encode_ar
#endif
#include <stdint.h>
#include <math.h>
#ifndef DISABLE_SIMD
#if defined(__GNUC__) && (__GNUC__ >= 4)
......@@ -1942,7 +1938,6 @@ LABEL900:
return (pval);
} /* decfp2 */
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
......@@ -1951,14 +1946,11 @@ LABEL900:
int gribRefDate(int *isec1)
{
int date, ryear, rmonth, rday;
int century;
century = ISEC1_Century;
int century = ISEC1_Century;
if ( century < 0 ) century = -century;
century -= 1;
ryear = ISEC1_Year;
int ryear = ISEC1_Year;
/* if ( century != 0 ) */
{
......@@ -1977,50 +1969,44 @@ int gribRefDate(int *isec1)
ryear = 1;
}
rmonth = ISEC1_Month;
rday = ISEC1_Day;
int rmonth = ISEC1_Month;
int rday = ISEC1_Day;
date = cdiEncodeDate(ryear, rmonth, rday);
int date = cdiEncodeDate(ryear, rmonth, rday);
return (date) ;
return date ;
}
int gribRefTime(int *isec1)
{
int time, rhour, rminute;
rhour = ISEC1_Hour;
rminute = ISEC1_Minute;
int rhour = ISEC1_Hour;
int rminute = ISEC1_Minute;
time = cdiEncodeTime(rhour, rminute, 0);
int time = cdiEncodeTime(rhour, rminute, 0);
return (time) ;
return time;
}
int gribTimeIsFC(int *isec1)
bool gribTimeIsFC(int *isec1)
{
int isFC = FALSE;
int time_period;
bool isFC = false;
if ( ISEC1_TimeRange == 10 )
time_period = (ISEC1_TimePeriod1<<8) + ISEC1_TimePeriod2;
else
time_period = ISEC1_TimePeriod1;
int time_period = (ISEC1_TimeRange == 10) ? (ISEC1_TimePeriod1<<8) + ISEC1_TimePeriod2 : ISEC1_TimePeriod1;
if ( time_period > 0 && ISEC1_Day > 0 )
{
if ( ISEC1_TimeRange == 0 || ISEC1_TimeRange == 10 ) isFC = TRUE;
if ( ISEC1_TimeRange == 0 || ISEC1_TimeRange == 10 ) isFC = true;
}
return (isFC);
return isFC;
}
void gribDateTime(int *isec1, int *date, int *time)
{
static int lprint = TRUE;
static bool lprint = true;
int julday, secofday;
int64_t addsec = 0;
int64_t time_period = 0;
......@@ -2092,7 +2078,7 @@ void gribDateTime(int *isec1, int *date, int *time)
if ( lprint )
{
gprintf(__func__, "Time unit %d unsupported", ISEC1_TimeUnit);
lprint = FALSE;
lprint = false;
}
break;
}
......@@ -4169,7 +4155,6 @@ int gribrec_len(unsigned b1, unsigned b2, unsigned b3)
return gribsize;
}
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
......@@ -4268,7 +4253,7 @@ C ----------------------------------------------------------------
*/
char *envString;
char *env_stream;
static int lfirst = TRUE;
static bool lfirst = true;
extern int CGRIBEX_Const;
if ( ! lfirst ) return;
......@@ -4410,7 +4395,7 @@ C ----------------------------------------------------------------
/*
Mark common area values set by user.
*/
lfirst = FALSE;
lfirst = false;
/*
Exhaustive use of all possible second-order packing methods
for HOPER='K'. Set to off.
......@@ -5042,7 +5027,7 @@ int correct_bdslen(int bdslen, long recsize, long gribpos)
the (default) rounding for GRIB products is 120 bytes.
*/
if ( recsize > JP23SET ) bdslen = (int)(recsize - gribpos - bdslen);
return (bdslen);
return bdslen;
}
......@@ -5067,7 +5052,7 @@ int grib1Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **p
{
fprintf(stderr, "Wrong GRIB indicator section: found >%c%c%c%c<\n",
section[0], section[1], section[2], section[3]);
return (-1);
return -1;
}
recsize = gribrec_len(section[4], section[5], section[6]);
......@@ -5123,7 +5108,7 @@ int grib1Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **p
if ( gribbufsize < gribsize )
{
fprintf(stderr, "Length of GRIB message is inconsistent (grib_buffer_size=%ld < grib_record_size=%ld)!\n", gribbufsize, gribsize);
return (1);
return 1;
}
/* end section - "7777" in ascii */
......@@ -5131,10 +5116,10 @@ int grib1Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **p
{
fprintf(stderr, "Missing GRIB end section: found >%c%c%c%c<\n",
bufpointer[0], bufpointer[1], bufpointer[2], bufpointer[3]);
return (-2);
return -2;
}
return (0);
return 0;
}
......@@ -5167,14 +5152,14 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
{
fprintf(stderr, "wrong indicator section >%c%c%c%c<\n",
section[0], section[1], section[2], section[3]);
return (-1);
return -1;
}
gribversion = GRIB_EDITION(section);
if ( gribversion != 2 )
{
fprintf(stderr, "wrong GRIB version %d\n", gribversion);
return (-1);
return -1;
}
gribsize = 0;
......@@ -5191,7 +5176,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
if ( sec_num != 1 )
{
fprintf(stderr, "Unexpected section1 number %d\n", sec_num);
return (-1);
return -1;
}
*idsp = section;
......@@ -5225,7 +5210,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
else
{
fprintf(stderr, "Unexpected section3 number %d\n", sec_num);
return (-1);
return -1;
}
grib_len += sec_len;
......@@ -5239,7 +5224,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
if ( sec_num != 4 )
{
fprintf(stderr, "Unexpected section4 number %d\n", sec_num);
return (-1);
return -1;
}
*pdsp = section;
......@@ -5255,7 +5240,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
if ( sec_num != 5 )
{
fprintf(stderr, "Unexpected section5 number %d\n", sec_num);
return (-1);
return -1;
}
*drsp = section;
......@@ -5271,7 +5256,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
if ( sec_num != 6 )
{
fprintf(stderr, "Unexpected section6 number %d\n", sec_num);
return (-1);
return -1;
}
*bmsp = section;
......@@ -5287,7 +5272,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
if ( sec_num != 7 )
{
fprintf(stderr, "Unexpected section7 number %d\n", sec_num);
return (-1);
return -1;
}
*bdsp = section;
......@@ -5318,10 +5303,10 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
{
fprintf(stderr, "Missing end section >%2x %2x %2x %2x<\n",
section[0], section[1], section[2], section[3]);
return (-2);
return -2;
}
return (0);
return 0;
}
......@@ -5342,7 +5327,7 @@ int grib_info_for_grads(off_t recpos, long recsize, unsigned char *gribbuffer,
{
fprintf(stderr, "wrong indicator section >%c%c%c%c<\n",
section[0], section[1], section[2], section[3]);
return (-1);
return -1;
}
gribversion = GRIB_EDITION(section);
......@@ -5395,7 +5380,7 @@ int grib_info_for_grads(off_t recpos, long recsize, unsigned char *gribbuffer,
if ( gribsize > recsize )
{
fprintf(stderr, "GRIB buffer size %ld too small! Min size = %ld\n", recsize, gribsize);
return (1);
return 1;
}
/* end section - "7777" in ascii */
......@@ -5423,7 +5408,7 @@ int grib_info_for_grads(off_t recpos, long recsize, unsigned char *gribbuffer,
printf("intnum %d %d %d\n", intnum[0], intnum[1], intnum[2]);
printf("fltnum %g %g %g\n", fltnum[0], fltnum[1], fltnum[2]);
*/
return (0);
return 0;
}
......@@ -5939,7 +5924,7 @@ void repair1(unsigned char *gbuf, long gbufsize)
int bds_head = 11;
int bds_ext = 0, bds_ubits;
int datstart = 0;
/* int llarge = FALSE; */
// bool llarge = false;
long gribrecsize;
nerr = grib1Sections(gbuf, gbufsize, &pds, &gds, &bms, &bds, &gribrecsize);
......@@ -5956,7 +5941,7 @@ void repair1(unsigned char *gbuf, long gbufsize)
}
/* recLen = gribrec_len(gbuf[4], gbuf[5], gbuf[6]); */
/* if ( recLen > JP23SET ) llarge = TRUE; */
/* if ( recLen > JP23SET ) llarge = true; */
bds_len = BDS_Len;
bds_nbits = BDS_NumBits;
......@@ -6048,7 +6033,6 @@ void gribRepair1(int nrec, long recsize, unsigned char *gribbuffer)
#include <string.h>
#if defined (HAVE_CONFIG_H)
# include "config.h"
#endif
#if defined (HAVE_LIBSZ)
......@@ -6388,7 +6372,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
size_t destLen, sourceLen;
enum { bds_head = 11 };
int bds_ext = 0;
int llarge = FALSE;
bool llarge = false;
UNUSED(dbufsize);
......@@ -6409,7 +6393,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
int bds_zstart = 14;
int recLen = gribrec_len(bds[bds_zstart], bds[bds_zstart+1], bds[bds_zstart+2]);
if ( recLen > JP23SET ) llarge = TRUE;
if ( recLen > JP23SET ) llarge = true;
int bds_zoffset = 12;
if ( llarge ) bds_zoffset += 2;
......@@ -8466,18 +8450,16 @@ int gribVersion(unsigned char *is, size_t buffersize)
if ( buffersize < 8 )
Error("Buffer too small (current size %d)!", (int) buffersize);
return (GRIB_EDITION(is));
return GRIB_EDITION(is);
}
static
double GET_Real(unsigned char *grib)
{
int iexp, imant;
iexp = GET_UINT1(grib[0]);
imant = GET_UINT3(grib[1], grib[2], grib[3]);
int iexp = GET_UINT1(grib[0]);
int imant = GET_UINT3(grib[1], grib[2], grib[3]);
return (decfp2(iexp, imant));
return decfp2(iexp, imant);
}
static
......@@ -8485,7 +8467,7 @@ int decodeIS(unsigned char *is, int *isec0, int *iret)
{
int isLen = 0;
int grib1offset;
int lgrib = FALSE, lbudg = FALSE, ltide = FALSE;