Commit 44f1c29d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cgribexlib update

parent fe9abef6
/* Automatically generated by m214003 at 2015-12-11, do not edit */
/* Automatically generated by m214003 at 2016-02-03, do not edit */
/* CGRIBEXLIB_VERSION="1.7.4" */
......@@ -112,11 +112,6 @@
#endif
#endif
#ifndef DBL_IS_EQUAL
/*#define DBL_IS_EQUAL(x,y) (!(x < y || y < x)) */
# define DBL_IS_EQUAL(x,y) (DBL_IS_NAN(x)||DBL_IS_NAN(y)?(DBL_IS_NAN(x)&&DBL_IS_NAN(y)?1:0):!(x < y || y < x))
#endif
#ifndef IS_EQUAL
# define IS_NOT_EQUAL(x,y) (x < y || y < x)
# define IS_EQUAL(x,y) (!IS_NOT_EQUAL(x,y))
......@@ -135,7 +130,7 @@
extern "C" {
#endif
double intpow2(int x);
#define intpow2(x) (ldexp(1.0, (x)))
int gribrec_len(unsigned b1, unsigned b2, unsigned b3);
int correct_bdslen(int bdslen, long recsize, long gribpos);
......@@ -182,8 +177,8 @@ void scale_complex_double(double *fpdata, int pcStart, int pcScale, int trunc,
void scale_complex_float(float *fpdata, int pcStart, int pcScale, int trunc, int inv);
void scatter_complex_double(double *fpdata, int pcStart, int trunc, int nsp);
void scatter_complex_float(float *fpdata, int pcStart, int trunc, int nsp);
void gather_complex_double(double *fpdata, int pcStart, int trunc, int nsp);
void gather_complex_float(float *fpdata, int pcStart, int trunc, int nsp);
void gather_complex_double(double *fpdata, size_t pcStart, size_t trunc, size_t nsp);
void gather_complex_float(float *fpdata, size_t pcStart, size_t trunc, size_t nsp);
void scm0_double(double *pdl, double *pdr, double *pfl, double *pfr, int klg);
int qu2reg2(double *pfield, int *kpoint, int klat, int klon,
......@@ -329,7 +324,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
#define GDS_ScanFlag GET_UINT1(gds[27])
#define GDS_LatSP GET_INT3(gds[32], gds[33], gds[34])
#define GDS_LonSP GET_INT3(gds[35], gds[36], gds[37])
#define GDS_RotAngle GET_Real(&(gds[38]))
#define GDS_RotAngle (GET_Real(&(gds[38])))
/* GRIB1 Lambert */
#define GDS_Lambert_Lov GET_INT3(gds[17], gds[18], gds[19])
......@@ -354,9 +349,9 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
#define BDS_Len ((int) ((bds[0]<<16)+(bds[1]<<8)+bds[2]))
#define BDS_Flag (bds[3])
#define BDS_BinScale GET_INT2(bds[ 4], bds[ 5])
#define BDS_RefValue decfp2((int)bds[ 6], GET_UINT3(bds[ 7], bds[ 8], bds[ 9]))
#define BDS_RefValue (decfp2((int)bds[ 6], GET_UINT3(bds[ 7], bds[ 8], bds[ 9])))
#define BDS_NumBits ((int) bds[10])
#define BDS_RealCoef decfp2((int)bds[zoff+11], GET_UINT3(bds[zoff+12], bds[zoff+13], bds[zoff+14]))
#define BDS_RealCoef (decfp2((int)bds[zoff+11], GET_UINT3(bds[zoff+12], bds[zoff+13], bds[zoff+14])))
#define BDS_PackData ((int) ((bds[zoff+11]<<8) + bds[zoff+12]))
#define BDS_Power GET_INT2(bds[zoff+13], bds[zoff+14])
#define BDS_Z (bds[13])
......@@ -375,21 +370,20 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
#define PutnZero(n) \
{ \
int i; \
for ( i = z; i < z+n; i++ ) lGrib[i] = 0; \
for ( size_t i = z >= 0 ? (size_t)z : 0; i < (size_t)(z+n); i++ ) lGrib[i] = 0; \
z += n; \
}
#define Put1Byte(Value) (lGrib[z++] = (Value))
#define Put2Byte(Value) ((lGrib[z++] = (Value) >> 8), \
(lGrib[z++] = (Value)))
#define Put3Byte(Value) ((lGrib[z++] = (Value) >> 16), \
(lGrib[z++] = (Value) >> 8), \
(lGrib[z++] = (Value)))
#define Put4Byte(Value) ((lGrib[z++] = (Value) >> 24), \
(lGrib[z++] = (Value) >> 16), \
(lGrib[z++] = (Value) >> 8), \
(lGrib[z++] = (Value)))
#define Put1Byte(Value) (lGrib[z++] = (GRIBPACK)(Value))
#define Put2Byte(Value) ((lGrib[z++] = (GRIBPACK)((Value) >> 8)), \
(lGrib[z++] = (GRIBPACK)(Value)))
#define Put3Byte(Value) ((lGrib[z++] = (GRIBPACK)((Value) >> 16)), \
(lGrib[z++] = (GRIBPACK)((Value) >> 8)), \
(lGrib[z++] = (GRIBPACK)(Value)))
#define Put4Byte(Value) ((lGrib[z++] = (GRIBPACK)((Value) >> 24)), \
(lGrib[z++] = (GRIBPACK)((Value) >> 16)), \
(lGrib[z++] = (GRIBPACK)((Value) >> 8)), \
(lGrib[z++] = (GRIBPACK)(Value)))
#define Put1Int(Value) {ival = Value; if ( ival < 0 ) ival = 0x80 - ival; Put1Byte(ival);}
#define Put2Int(Value) {ival = Value; if ( ival < 0 ) ival = 0x8000 - ival; Put2Byte(ival);}
......@@ -403,277 +397,10 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
}
#endif /* _GRIB_ENCODE_H */
#include <stdio.h>
#include <math.h>
const double _pow2tab[158] = {
/* pow(2.0, 0.0) */ 1.0,
/* pow(2.0, 1.0) */ 2.0,
/* pow(2.0, 2.0) */ 4.0,
/* pow(2.0, 3.0) */ 8.0,
/* pow(2.0, 4.0) */ 16.0,
/* pow(2.0, 5.0) */ 32.0,
/* pow(2.0, 6.0) */ 64.0,
/* pow(2.0, 7.0) */ 128.0,
/* pow(2.0, 8.0) */ 256.0,
/* pow(2.0, 9.0) */ 512.0,
/* pow(2.0, 10.0) */ 1024.0,
/* pow(2.0, 11.0) */ 2048.0,
/* pow(2.0, 12.0) */ 4096.0,
/* pow(2.0, 13.0) */ 8192.0,
/* pow(2.0, 14.0) */ 16384.0,
/* pow(2.0, 15.0) */ 32768.0,
/* pow(2.0, 16.0) */ 65536.0,
/* pow(2.0, 17.0) */ 131072.0,
/* pow(2.0, 18.0) */ 262144.0,
/* pow(2.0, 19.0) */ 524288.0,
/* pow(2.0, 20.0) */ 1048576.0,
/* pow(2.0, 21.0) */ 2097152.0,
/* pow(2.0, 22.0) */ 4194304.0,
/* pow(2.0, 23.0) */ 8388608.0,
/* pow(2.0, 24.0) */ 16777216.0,
/* pow(2.0, 25.0) */ 33554432.0,
/* pow(2.0, 26.0) */ 67108864.0,
/* pow(2.0, 27.0) */ 134217728.0,
/* pow(2.0, 28.0) */ 268435456.0,
/* pow(2.0, 29.0) */ 536870912.0,
/* pow(2.0, 30.0) */ 1073741824.0,
/* pow(2.0, 31.0) */ 2147483648.0,
/* pow(2.0, 32.0) */ 4294967296.0,
/* pow(2.0, 33.0) */ 8589934592.0,
/* pow(2.0, 34.0) */ 17179869184.0,
/* pow(2.0, 35.0) */ 34359738368.0,
/* pow(2.0, 36.0) */ 68719476736.0,
/* pow(2.0, 37.0) */ 137438953472.0,
/* pow(2.0, 38.0) */ 274877906944.0,
/* pow(2.0, 39.0) */ 549755813888.0,
/* pow(2.0, 40.0) */ 1099511627776.0,
/* pow(2.0, 41.0) */ 2199023255552.0,
/* pow(2.0, 42.0) */ 4398046511104.0,
/* pow(2.0, 43.0) */ 8796093022208.0,
/* pow(2.0, 44.0) */ 17592186044416.0,
/* pow(2.0, 45.0) */ 35184372088832.0,
/* pow(2.0, 46.0) */ 70368744177664.0,
/* pow(2.0, 47.0) */ 140737488355328.0,
/* pow(2.0, 48.0) */ 281474976710656.0,
/* pow(2.0, 49.0) */ 562949953421312.0,
/* pow(2.0, 50.0) */ 1125899906842624.0,
/* pow(2.0, 51.0) */ 2251799813685248.0,
/* pow(2.0, 52.0) */ 4503599627370496.0,
/* pow(2.0, 53.0) */ 9007199254740992.0,
/* pow(2.0, 54.0) */ 18014398509481984.0,
/* pow(2.0, 55.0) */ 36028797018963968.0,
/* pow(2.0, 56.0) */ 72057594037927936.0,
/* pow(2.0, 57.0) */ 144115188075855872.0,
/* pow(2.0, 58.0) */ 288230376151711744.0,
/* pow(2.0, 59.0) */ 576460752303423488.0,
/* pow(2.0, 60.0) */ 1152921504606846976.0,
/* pow(2.0, 61.0) */ 2305843009213693952.0,
/* pow(2.0, 62.0) */ 4611686018427387904.0,
/* pow(2.0, 63.0) */ 9223372036854775808.0,
/* pow(2.0, 64.0) */ 18446744073709551616.0,
/* pow(2.0, 65.0) */ 36893488147419103232.0,
/* pow(2.0, 66.0) */ 73786976294838206464.0,
/* pow(2.0, 67.0) */ 147573952589676412928.0,
/* pow(2.0, 68.0) */ 295147905179352825856.0,
/* pow(2.0, 69.0) */ 590295810358705651712.0,
/* pow(2.0, 70.0) */ 1180591620717411303424.0,
/* pow(2.0, 71.0) */ 2361183241434822606848.0,
/* pow(2.0, 72.0) */ 4722366482869645213696.0,
/* pow(2.0, 73.0) */ 9444732965739290427392.0,
/* pow(2.0, 74.0) */ 18889465931478580854784.0,
/* pow(2.0, 75.0) */ 37778931862957161709568.0,
/* pow(2.0, 76.0) */ 75557863725914323419136.0,
/* pow(2.0, 77.0) */ 151115727451828646838272.0,
/* pow(2.0, 78.0) */ 302231454903657293676544.0,
/* pow(2.0, 79.0) */ 604462909807314587353088.0,
/* pow(2.0, 80.0) */ 1208925819614629174706176.0,
/* pow(2.0, 81.0) */ 2417851639229258349412352.0,
/* pow(2.0, 82.0) */ 4835703278458516698824704.0,
/* pow(2.0, 83.0) */ 9671406556917033397649408.0,
/* pow(2.0, 84.0) */ 19342813113834066795298816.0,
/* pow(2.0, 85.0) */ 38685626227668133590597632.0,
/* pow(2.0, 86.0) */ 77371252455336267181195264.0,
/* pow(2.0, 87.0) */ 154742504910672534362390528.0,
/* pow(2.0, 88.0) */ 309485009821345068724781056.0,
/* pow(2.0, 89.0) */ 618970019642690137449562112.0,
/* pow(2.0, 90.0) */ 1237940039285380274899124224.0,
/* pow(2.0, 91.0) */ 2475880078570760549798248448.0,
/* pow(2.0, 92.0) */ 4951760157141521099596496896.0,
/* pow(2.0, 93.0) */ 9903520314283042199192993792.0,
/* pow(2.0, 94.0) */ 19807040628566084398385987584.0,
/* pow(2.0, 95.0) */ 39614081257132168796771975168.0,
/* pow(2.0, 96.0) */ 79228162514264337593543950336.0,
/* pow(2.0, 97.0) */ 158456325028528675187087900672.0,
/* pow(2.0, 98.0) */ 316912650057057350374175801344.0,
/* pow(2.0, 99.0) */ 633825300114114700748351602688.0,
/* pow(2.0, 100.0) */ 1267650600228229401496703205376.0,
/* pow(2.0, 101.0) */ 2535301200456458802993406410752.0,
/* pow(2.0, 102.0) */ 5070602400912917605986812821504.0,
/* pow(2.0, 103.0) */ 10141204801825835211973625643008.0,
/* pow(2.0, 104.0) */ 20282409603651670423947251286016.0,
/* pow(2.0, 105.0) */ 40564819207303340847894502572032.0,
/* pow(2.0, 106.0) */ 81129638414606681695789005144064.0,
/* pow(2.0, 107.0) */ 162259276829213363391578010288128.0,
/* pow(2.0, 108.0) */ 324518553658426726783156020576256.0,
/* pow(2.0, 109.0) */ 649037107316853453566312041152512.0,
/* pow(2.0, 110.0) */ 1298074214633706907132624082305024.0,
/* pow(2.0, 111.0) */ 2596148429267413814265248164610048.0,
/* pow(2.0, 112.0) */ 5192296858534827628530496329220096.0,
/* pow(2.0, 113.0) */ 10384593717069655257060992658440192.0,
/* pow(2.0, 114.0) */ 20769187434139310514121985316880384.0,
/* pow(2.0, 115.0) */ 41538374868278621028243970633760768.0,
/* pow(2.0, 116.0) */ 83076749736557242056487941267521536.0,
/* pow(2.0, 117.0) */ 166153499473114484112975882535043072.0,
/* pow(2.0, 118.0) */ 332306998946228968225951765070086144.0,
/* pow(2.0, 119.0) */ 664613997892457936451903530140172288.0,
/* pow(2.0, 120.0) */ 1329227995784915872903807060280344576.0,
/* pow(2.0, 121.0) */ 2658455991569831745807614120560689152.0,
/* pow(2.0, 122.0) */ 5316911983139663491615228241121378304.0,
/* pow(2.0, 123.0) */ 10633823966279326983230456482242756608.0,
/* pow(2.0, 124.0) */ 21267647932558653966460912964485513216.0,
/* pow(2.0, 125.0) */ 42535295865117307932921825928971026432.0,
/* pow(2.0, 126.0) */ 85070591730234615865843651857942052864.0,
/* pow(2.0, 127.0) */ 170141183460469231731687303715884105728.0,
/* pow(2.0, 128.0) */ 340282366920938463463374607431768211456.0,
/* pow(2.0, 129.0) */ 680564733841876926926749214863536422912.0,
/* pow(2.0, 130.0) */ 1361129467683753853853498429727072845824.0,
/* pow(2.0, 131.0) */ 2722258935367507707706996859454145691648.0,
/* pow(2.0, 132.0) */ 5444517870735015415413993718908291383296.0,
/* pow(2.0, 133.0) */ 10889035741470030830827987437816582766592.0,
/* pow(2.0, 134.0) */ 21778071482940061661655974875633165533184.0,
/* pow(2.0, 135.0) */ 43556142965880123323311949751266331066368.0,
/* pow(2.0, 136.0) */ 87112285931760246646623899502532662132736.0,
/* pow(2.0, 137.0) */ 174224571863520493293247799005065324265472.0,
/* pow(2.0, 138.0) */ 348449143727040986586495598010130648530944.0,
/* pow(2.0, 139.0) */ 696898287454081973172991196020261297061888.0,
/* pow(2.0, 140.0) */ 1393796574908163946345982392040522594123776.0,
/* pow(2.0, 141.0) */ 2787593149816327892691964784081045188247552.0,
/* pow(2.0, 142.0) */ 5575186299632655785383929568162090376495104.0,
/* pow(2.0, 143.0) */ 11150372599265311570767859136324180752990208.0,
/* pow(2.0, 144.0) */ 22300745198530623141535718272648361505980416.0,
/* pow(2.0, 145.0) */ 44601490397061246283071436545296723011960832.0,
/* pow(2.0, 146.0) */ 89202980794122492566142873090593446023921664.0,
/* pow(2.0, 147.0) */ 178405961588244985132285746181186892047843328.0,
/* pow(2.0, 148.0) */ 356811923176489970264571492362373784095686656.0,
/* pow(2.0, 149.0) */ 713623846352979940529142984724747568191373312.0,
/* pow(2.0, 150.0) */ 1427247692705959881058285969449495136382746624.0,
/* pow(2.0, 151.0) */ 2854495385411919762116571938898990272765493248.0,
/* pow(2.0, 152.0) */ 5708990770823839524233143877797980545530986496.0,
/* pow(2.0, 153.0) */ 11417981541647679048466287755595961091061972992.0,
/* pow(2.0, 154.0) */ 22835963083295358096932575511191922182123945984.0,
/* pow(2.0, 155.0) */ 45671926166590716193865151022383844364247891968.0,
/* pow(2.0, 156.0) */ 91343852333181432387730302044767688728495783936.0,
/* pow(2.0, 157.0) */ 182687704666362864775460604089535377456991567872.0,
};
const double _pow16tab[71] = {
/* pow(16.0, 0.0) */ 1.0,
/* pow(16.0, 1.0) */ 16.0,
/* pow(16.0, 2.0) */ 256.0,
/* pow(16.0, 3.0) */ 4096.0,
/* pow(16.0, 4.0) */ 65536.0,
/* pow(16.0, 5.0) */ 1048576.0,
/* pow(16.0, 6.0) */ 16777216.0,
/* pow(16.0, 7.0) */ 268435456.0,
/* pow(16.0, 8.0) */ 4294967296.0,
/* pow(16.0, 9.0) */ 68719476736.0,
/* pow(16.0, 10.0) */ 1099511627776.0,
/* pow(16.0, 11.0) */ 17592186044416.0,
/* pow(16.0, 12.0) */ 281474976710656.0,
/* pow(16.0, 13.0) */ 4503599627370496.0,
/* pow(16.0, 14.0) */ 72057594037927936.0,
/* pow(16.0, 15.0) */ 1152921504606846976.0,
/* pow(16.0, 16.0) */ 18446744073709551616.0,
/* pow(16.0, 17.0) */ 295147905179352825856.0,
/* pow(16.0, 18.0) */ 4722366482869645213696.0,
/* pow(16.0, 19.0) */ 75557863725914323419136.0,
/* pow(16.0, 20.0) */ 1208925819614629174706176.0,
/* pow(16.0, 21.0) */ 19342813113834066795298816.0,
/* pow(16.0, 22.0) */ 309485009821345068724781056.0,
/* pow(16.0, 23.0) */ 4951760157141521099596496896.0,
/* pow(16.0, 24.0) */ 79228162514264337593543950336.0,
/* pow(16.0, 25.0) */ 1267650600228229401496703205376.0,
/* pow(16.0, 26.0) */ 20282409603651670423947251286016.0,
/* pow(16.0, 27.0) */ 324518553658426726783156020576256.0,
/* pow(16.0, 28.0) */ 5192296858534827628530496329220096.0,
/* pow(16.0, 29.0) */ 83076749736557242056487941267521536.0,
/* pow(16.0, 30.0) */ 1329227995784915872903807060280344576.0,
/* pow(16.0, 31.0) */ 21267647932558653966460912964485513216.0,
/* pow(16.0, 32.0) */ 340282366920938463463374607431768211456.0,
/* pow(16.0, 33.0) */ 5444517870735015415413993718908291383296.0,
/* pow(16.0, 34.0) */ 87112285931760246646623899502532662132736.0,
/* pow(16.0, 35.0) */ 1393796574908163946345982392040522594123776.0,
/* pow(16.0, 36.0) */ 22300745198530623141535718272648361505980416.0,
/* pow(16.0, 37.0) */ 356811923176489970264571492362373784095686656.0,
/* pow(16.0, 38.0) */ 5708990770823839524233143877797980545530986496.0,
/* pow(16.0, 39.0) */ 91343852333181432387730302044767688728495783936.0,
/* pow(16.0, 40.0) */ 1461501637330902918203684832716283019655932542976.0,
/* pow(16.0, 41.0) */ 23384026197294446691258957323460528314494920687616.0,
/* pow(16.0, 42.0) */ 374144419156711147060143317175368453031918731001856.0,
/* pow(16.0, 43.0) */ 5986310706507378352962293074805895248510699696029696.0,
/* pow(16.0, 44.0) */ 95780971304118053647396689196894323976171195136475136.0,
/* pow(16.0, 45.0) */ 1532495540865888858358347027150309183618739122183602176.0,
/* pow(16.0, 46.0) */ 24519928653854221733733552434404946937899825954937634816.0,
/* pow(16.0, 47.0) */ 392318858461667547739736838950479151006397215279002157056.0,
/* pow(16.0, 48.0) */ 6277101735386680763835789423207666416102355444464034512896.0,
/* pow(16.0, 49.0) */ 100433627766186892221372630771322662657637687111424552206336.0,
/* pow(16.0, 50.0) */ 1606938044258990275541962092341162602522202993782792835301376.0,
/* pow(16.0, 51.0) */ 25711008708143844408671393477458601640355247900524685364822016.0,
/* pow(16.0, 52.0) */ 411376139330301510538742295639337626245683966408394965837152256.0,
/* pow(16.0, 53.0) */ 6582018229284824168619876730229402019930943462534319453394436096.0,
/* pow(16.0, 54.0) */ 105312291668557186697918027683670432318895095400549111254310977536.0,
/* pow(16.0, 55.0) */ 1684996666696914987166688442938726917102321526408785780068975640576.0,
/* pow(16.0, 56.0) */ 26959946667150639794667015087019630673637144422540572481103610249216.0,
/* pow(16.0, 57.0) */ 431359146674410236714672241392314090778194310760649159697657763987456.0,
/* pow(16.0, 58.0) */ 6901746346790563787434755862277025452451108972170386555162524223799296.0,
/* pow(16.0, 59.0) */ 110427941548649020598956093796432407239217743554726184882600387580788736.0,
/* pow(16.0, 60.0) */ 1766847064778384329583297500742918515827483896875618958121606201292619776.0,
/* pow(16.0, 61.0) */ 28269553036454149273332760011886696253239742350009903329945699220681916416.0,
/* pow(16.0, 62.0) */ 452312848583266388373324160190187140051835877600158453279131187530910662656.0,
/* pow(16.0, 63.0) */ 7237005577332262213973186563042994240829374041602535252466099000494570602496.0,
/* pow(16.0, 64.0) */ 115792089237316195423570985008687907853269984665640564039457584007913129639936.0,
/* pow(16.0, 65.0) */ 1852673427797059126777135760139006525652319754650249024631321344126610074238976.0,
/* pow(16.0, 66.0) */ 29642774844752946028434172162224104410437116074403984394101141506025761187823616.0,
/* pow(16.0, 67.0) */ 474284397516047136454946754595585670566993857190463750305618264096412179005177856.0,
/* pow(16.0, 68.0) */ 7588550360256754183279148073529370729071901715047420004889892225542594864082845696.0,
/* pow(16.0, 69.0) */ 121416805764108066932466369176469931665150427440758720078238275608681517825325531136.0,
/* pow(16.0, 70.0) */ 1942668892225729070919461906823518906642406839052139521251812409738904285205208498176.0,
};
static int _pow2tab_size = sizeof(_pow2tab)/sizeof(double);
void gen_pow2tab(void)
{
int jloop;
for ( jloop = 0; jloop < 158; jloop++ )
printf(" /* pow(2.0, %2d.0) */ %.1f,\n", jloop, pow(2.0, (double) jloop));
}
void gen_pow16tab(void)
{
double pval;
int iexp;
for ( iexp = 0; iexp < 71; iexp++ )
{
pval = pow(16.0, (double)(iexp));
printf(" /* pow(16.0, %2d.0) */ %.1f,\n", iexp, pval);
}
}
double intpow2(int x)
{
if ( x < _pow2tab_size )
return (_pow2tab[x]);
else
return (pow(2.0, (double) x));
}
#ifndef CODEC_COMMON_H
#define CODEC_COMMON_H
#define gribSwapByteOrder_uint16(ui16) ((uint16_t)((ui16<<8) | (ui16>>8)))
#endif /* CODEC_COMMON_H */
/*
icc -g -Wall -O3 -march=native -std=c99 -qopt-report=5 -DTEST_MINMAXVAL -openmp -DOMP_SIMD minmax_val.c
result on hama2 (icc 16.0.0):
......@@ -947,10 +674,9 @@ void sse2_minmax_val_double(const double *restrict buf, size_t nframes, double *
#if defined(_ARCH_PWR6)
static
void pwr6_minmax_val_double_unrolled6(const double *restrict data, long idatasize, double *fmin, double *fmax)
void pwr6_minmax_val_double_unrolled6(const double *restrict data, size_t datasize, double *fmin, double *fmax)
{
#define __UNROLL_DEPTH_1 6
size_t datasize = idatasize;
// to allow pipelining we have to unroll
......@@ -994,9 +720,9 @@ void pwr6_minmax_val_double_unrolled6(const double *restrict data, long idatasiz
#if defined(TEST_MINMAXVAL) && defined(__GNUC__)
static
void minmax_val_double_orig(const double *restrict data, long idatasize, double *fmin, double *fmax) __attribute__ ((noinline));
void minmax_val_double_orig(const double *restrict data, size_t datasize, double *fmin, double *fmax) __attribute__ ((noinline));
static
void minmax_val_double_simd(const double *restrict data, long idatasize, double *fmin, double *fmax) __attribute__ ((noinline));
void minmax_val_double_simd(const double *restrict data, size_t datasize, double *fmin, double *fmax) __attribute__ ((noinline));
#endif
#if defined(GNUC_PUSH_POP)
......@@ -1004,9 +730,8 @@ void minmax_val_double_simd(const double *restrict data, long idatasize, double
#pragma GCC optimize ("O3", "fast-math")
#endif
static
void minmax_val_double_orig(const double *restrict data, long idatasize, double *fmin, double *fmax)
void minmax_val_double_orig(const double *restrict data, size_t datasize, double *fmin, double *fmax)
{
size_t datasize = idatasize;
double dmin = *fmin, dmax = *fmax;
#if defined(CRAY)
......@@ -1031,7 +756,7 @@ void minmax_val_double_orig(const double *restrict data, long idatasize, double
static
void minmax_val_float(const float *restrict data, long idatasize, float *fmin, float *fmax)
{
size_t datasize = idatasize;
size_t datasize = (size_t)idatasize;
float dmin = *fmin, dmax = *fmax;
#if defined(CRAY)
......@@ -1064,9 +789,8 @@ void minmax_val_float(const float *restrict data, long idatasize, float *fmin, f
#pragma GCC optimize ("O3", "fast-math")
#endif
static
void minmax_val_double_simd(const double *restrict data, long idatasize, double *fmin, double *fmax)
void minmax_val_double_simd(const double *restrict data, size_t datasize, double *fmin, double *fmax)
{
size_t datasize = idatasize;
double dmin = *fmin, dmax = *fmax;
#if defined(_OPENMP)
......@@ -1092,9 +816,9 @@ void minmax_val_double(const double *restrict data, long idatasize, double *fmin
#if defined(_GET_X86_COUNTER) || defined(_GET_MACH_COUNTER)
uint64_t start_minmax, end_minmax;
#endif
size_t datasize = idatasize;
size_t datasize = (size_t)idatasize;
if ( idatasize < 1 ) return;
if ( idatasize >= 1 ) ; else return;
#if defined(_GET_X86_COUNTER)
start_minmax = _rdtsc();
......@@ -1873,12 +1597,7 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
- replace 1.0 / pow(16.0, (double)(iexp - 70)) by rpow16m70tab[iexp]
*/
double rpowref;
double zref, zeps;
int iexp, isign;
int iround;
// extern int CGRIBEX_Debug;
extern const double _pow16tab[71];
/* ----------------------------------------------------------------- */
/* Section 1 . Initialise */
......@@ -1886,7 +1605,7 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
/* Check conversion type parameter. */
iround = kround;
int iround = kround;
if ( iround != 0 && iround != 1 )
{
Error("Invalid conversion type = %d", iround);
......@@ -1911,42 +1630,35 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
/* ----------------------------------------------------------------- */
/* Section 3 . Convert other values. */
/* ----------------------------------------------------------------- */
{
double zeps = kbits != 32 ? 1.0e-12 : 1.0e-8;
double zref = pval;
zeps = 1.0e-12;
if ( kbits == 32 ) zeps = 1.0e-8;
zref = pval;
/* Sign of value. */
/* Sign of value. */
isign = 0;
if ( zref < 0.0 )
{
isign = 128;
zref = - zref;
}
int isign = zref >= 0.0 ? 0 : 128;
zref = fabs(zref);
/* Exponent. */
/* Exponent. */
iexp = (int) (log(zref)/log(16.0) + 65.0 + zeps);
int iexp = (int) (log(zref)/log(16.0) + 65.0 + zeps);
/* only ANSI C99 has log2 */
/* iexp = (int) (log2(zref) * 0.25 + 65.0 + zeps); */
/* only ANSI C99 has log2 */
/* iexp = (int) (log2(zref) * 0.25 + 65.0 + zeps); */
if ( iexp < 0 ) iexp = 0;
if ( iexp > 127 ) iexp = 127;
if ( iexp < 0 ) iexp = 0;
if ( iexp > 127 ) iexp = 127;
/*
rpowref = zref / pow(16.0, (double)(iexp - 70));
*/
double rpowref;
/*
rpowref = zref / pow(16.0, (double)(iexp - 70));
*/
if ( (iexp - 70) < 0 )
rpowref = zref * _pow16tab[-(iexp - 70)];
else
rpowref = zref / _pow16tab[(iexp - 70)];
rpowref = ldexp(zref, 4 * -(iexp - 70));
/* Mantissa. */
/* Mantissa. */
if ( iround == 0 )
if ( iround == 0 )
{
/* Closest number in GRIB format less than original number. */
/* Truncate for positive numbers. */
......@@ -1957,7 +1669,7 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
else
*kmant = (int)lround(rpowref + 0.5);
}
else
else
{
/* Closest number in GRIB format to the original number */
/* (equal to, greater than or less than original number). */
......@@ -1965,12 +1677,12 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
*kmant = (int)lround(rpowref);
}
/* Check that mantissa value does not exceed 24 bits. */
/* If it does, adjust the exponent upwards and recalculate */
/* the mantissa. */
/* 16777215 = 2**24 - 1 */
/* Check that mantissa value does not exceed 24 bits. */
/* If it does, adjust the exponent upwards and recalculate */
/* the mantissa. */
/* 16777215 = 2**24 - 1 */
if ( *kmant > 16777215 )
if ( *kmant > 16777215 )
{
LABEL350:
......@@ -1980,47 +1692,44 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
/* Check for exponent overflow during adjustment */
if ( iexp > 127 )
{
Message("Exponent overflow");
Message("Original number = %30.20f", pval);
Message("Sign = %3d, Exponent = %3d, Mantissa = %12d",
isign, iexp, *kmant);
{
Message("Exponent overflow");
Message("Original number = %30.20f", pval);
Message("Sign = %3d, Exponent = %3d, Mantissa = %12d",
isign, iexp, *kmant);
Error("Exponent overflow");
Error("Exponent overflow");
/* If not aborting, arbitrarily set value to zero */
/* If not aborting, arbitrarily set value to zero */
Message("Value arbitrarily set to zero.");
*kexp = 0;
*kmant = 0;
// iexp = 0;
// isign = 0;
goto LABEL900;
}
Message("Value arbitrarily set to zero.");
*kexp = 0;
*kmant = 0;
// iexp = 0;
// isign = 0;
goto LABEL900;
}
if ( (iexp - 70) < 0 )
rpowref = zref * _pow16tab[-(iexp - 70)];
else
rpowref = zref / _pow16tab[(iexp - 70)];
rpowref = ldexp(zref, 4 * -(iexp - 70));
if ( iround == 0 )
{
/* Closest number in GRIB format less than original number. */
/* Truncate for positive numbers. */
/* Round up for negative numbers. */
{
/* Closest number in GRIB format less than original number. */
/* Truncate for positive numbers. */
/* Round up for negative numbers. */
if ( isign == 0 )
*kmant = (int)rpowref;
else
*kmant = (int)lround(rpowref + 0.5);
}
if ( isign == 0 )
*kmant = (int)rpowref;
else
*kmant = (int)lround(rpowref + 0.5);
}
else
{
/* Closest number in GRIB format to the original number */
/* (equal to, greater or less than original number). */
{
/* Closest number in GRIB format to the original number */
/* (equal to, greater or less than original number). */
*kmant = (int)lround(rpowref);
}
*kmant = (int)lround(rpowref);
}
/* Repeat calculation (with modified exponent) if still have */
/* mantissa overflow. */
......@@ -2028,9 +1737,10 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
if ( *kmant > 16777215 ) goto LABEL350;