mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
[g2clib] Fix warning about conversion from double to float
This commit is contained in:
@@ -77,12 +77,12 @@ void compack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
g2int missopt, miss1, miss2, ier;
|
||||
g2float bscale,dscale,rmax,rmin,temp;
|
||||
static g2int simple_alg = 0;
|
||||
static g2float alog2=0.69314718; // ln(2.0)
|
||||
static g2float alog2=0.69314718f; // ln(2.0)
|
||||
static g2int one=1;
|
||||
ival1 = 0;
|
||||
|
||||
bscale=int_power(2.0,-idrstmpl[1]);
|
||||
dscale=int_power(10.0,idrstmpl[2]);
|
||||
bscale=(g2float)int_power(2.0,-idrstmpl[1]);
|
||||
dscale=(g2float)int_power(10.0,idrstmpl[2]);
|
||||
//
|
||||
// Find max and min values in the data
|
||||
//
|
||||
@@ -151,7 +151,7 @@ void compack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
// find num of bits need to store minsd and add 1 extra bit
|
||||
// to indicate sign
|
||||
//
|
||||
temp=log((double)(abs(minsd)+1))/alog2;
|
||||
temp=(g2float)log((double)(abs(minsd)+1))/alog2;
|
||||
nbitsd=(g2int)ceil(temp)+1;
|
||||
//
|
||||
// find num of bits need to store ifld[0] ( and ifld[1]
|
||||
@@ -159,7 +159,7 @@ void compack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
//
|
||||
maxorig=ival1;
|
||||
if (idrstmpl[16]==2 && ival2>ival1) maxorig=ival2;
|
||||
temp=log((double)(maxorig+1))/alog2;
|
||||
temp=(g2float)log((double)(maxorig+1))/alog2;
|
||||
nbitorig=(g2int)ceil(temp)+1;
|
||||
if (nbitorig > nbitsd) nbitsd=nbitorig;
|
||||
// increase number of bits to even multiple of 8 ( octet )
|
||||
@@ -261,7 +261,7 @@ void compack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
}
|
||||
// calc num of bits needed to hold data
|
||||
if ( gref[ng] != imax ) {
|
||||
temp=log((double)(imax-gref[ng]+1))/alog2;
|
||||
temp=(g2float)log((double)(imax-gref[ng]+1))/alog2;
|
||||
gwidth[ng]=(g2int)ceil(temp);
|
||||
}
|
||||
else
|
||||
@@ -283,7 +283,7 @@ void compack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
igmax=gref[0];
|
||||
for (j=1;j<ngroups;j++) if (gref[j] > igmax) igmax=gref[j];
|
||||
if (igmax != 0) {
|
||||
temp=log((double)(igmax+1))/alog2;
|
||||
temp=(g2float)log((double)(igmax+1))/alog2;
|
||||
nbitsgref=(g2int)ceil(temp);
|
||||
sbits(cpack,gref,iofst,nbitsgref,0,ngroups);
|
||||
itemp=nbitsgref*ngroups;
|
||||
@@ -309,7 +309,7 @@ void compack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
if (gwidth[j] < ngwidthref) ngwidthref=gwidth[j];
|
||||
}
|
||||
if (iwmax != ngwidthref) {
|
||||
temp=log((double)(iwmax-ngwidthref+1))/alog2;
|
||||
temp=(g2float)log((double)(iwmax-ngwidthref+1))/alog2;
|
||||
nbitsgwidth=(g2int)ceil(temp);
|
||||
for (i=0;i<ngroups;i++)
|
||||
gwidth[i]=gwidth[i]-ngwidthref;
|
||||
@@ -341,7 +341,7 @@ void compack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
}
|
||||
nglenlast=glen[ngroups-1];
|
||||
if (ilmax != nglenref) {
|
||||
temp=log((double)(ilmax-nglenref+1))/alog2;
|
||||
temp=(g2float)log((double)(ilmax-nglenref+1))/alog2;
|
||||
nbitsglen=(g2int)ceil(temp);
|
||||
for (i=0;i<ngroups-1;i++) glen[i]=glen[i]-nglenref;
|
||||
sbits(cpack,glen,iofst,nbitsglen,0,ngroups);
|
||||
|
||||
@@ -78,15 +78,15 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
g2int kfildo, minpk, inc, maxgrps, ibit, jbit, kbit, novref, lbitref;
|
||||
g2float rmissp, rmisss, bscale, dscale, rmin, temp;
|
||||
static g2int simple_alg = 0;
|
||||
static g2float alog2=0.69314718; // ln(2.0)
|
||||
static g2float alog2=0.69314718f; // ln(2.0)
|
||||
static g2int one=1;
|
||||
ival1 = 0;
|
||||
nbitsd = 0;
|
||||
|
||||
(void) ij;
|
||||
|
||||
bscale=int_power(2.0,-idrstmpl[1]);
|
||||
dscale=int_power(10.0,idrstmpl[2]);
|
||||
bscale=(g2float)int_power(2.0,-idrstmpl[1]);
|
||||
dscale=(g2float)int_power(10.0,idrstmpl[2]);
|
||||
missopt=idrstmpl[6];
|
||||
if ( missopt != 1 && missopt != 2 ) {
|
||||
printf("misspack: Unrecognized option.\n");
|
||||
@@ -102,7 +102,7 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
// AND set up missing value mapping of the field.
|
||||
//
|
||||
ifldmiss = calloc(ndpts,sizeof(g2int));
|
||||
rmin=1E+37;
|
||||
rmin=1E+37f;
|
||||
if ( missopt == 1 ) { // Primary missing value only
|
||||
for ( j=0; j<ndpts; j++) {
|
||||
if (fld[j] == rmissp) {
|
||||
@@ -198,7 +198,7 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
// find num of bits need to store minsd and add 1 extra bit
|
||||
// to indicate sign
|
||||
//
|
||||
temp=log((double)(abs(minsd)+1))/alog2;
|
||||
temp=(g2float)log((double)(abs(minsd)+1))/alog2;
|
||||
nbitsd=(g2int)ceil(temp)+1;
|
||||
//
|
||||
// find num of bits need to store ifld[0] ( and ifld[1]
|
||||
@@ -206,7 +206,7 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
//
|
||||
maxorig=ival1;
|
||||
if (idrstmpl[16]==2 && ival2>ival1) maxorig=ival2;
|
||||
temp=log((double)(maxorig+1))/alog2;
|
||||
temp=(g2float)log((double)(maxorig+1))/alog2;
|
||||
nbitorig=(g2int)ceil(temp)+1;
|
||||
if (nbitorig > nbitsd) nbitsd=nbitorig;
|
||||
// increase number of bits to even multiple of 8 ( octet )
|
||||
@@ -353,7 +353,7 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
if (missopt == 2) imax=imax+2;
|
||||
// calc num of bits needed to hold data
|
||||
if ( gref[ng] != imax ) {
|
||||
temp=log((double)(imax-gref[ng]+1))/alog2;
|
||||
temp=(g2float)log((double)(imax-gref[ng]+1))/alog2;
|
||||
gwidth[ng]=(g2int)ceil(temp);
|
||||
}
|
||||
else {
|
||||
@@ -388,7 +388,7 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
if (missopt == 1) igmax=igmax+1;
|
||||
if (missopt == 2) igmax=igmax+2;
|
||||
if (igmax != 0) {
|
||||
temp=log((double)(igmax+1))/alog2;
|
||||
temp=(g2float)log((double)(igmax+1))/alog2;
|
||||
nbitsgref=(g2int)ceil(temp);
|
||||
// reset the ref values of any "missing only" groups.
|
||||
mtemp=(g2int)int_power(2.,nbitsgref);
|
||||
@@ -422,7 +422,7 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
if (gwidth[j] < ngwidthref) ngwidthref=gwidth[j];
|
||||
}
|
||||
if (iwmax != ngwidthref) {
|
||||
temp=log((double)(iwmax-ngwidthref+1))/alog2;
|
||||
temp=(g2float)log((double)(iwmax-ngwidthref+1))/alog2;
|
||||
nbitsgwidth=(g2int)ceil(temp);
|
||||
for ( i=0; i<ngroups; i++) gwidth[i]=gwidth[i]-ngwidthref;
|
||||
sbits(cpack,gwidth,iofst,nbitsgwidth,0,ngroups);
|
||||
@@ -454,7 +454,7 @@ void misspack(g2float *fld,g2int ndpts,g2int idrsnum,g2int *idrstmpl,
|
||||
}
|
||||
nglenlast=glen[ngroups-1];
|
||||
if (ilmax != nglenref) {
|
||||
temp=log((double)(ilmax-nglenref+1))/alog2;
|
||||
temp=(g2float)log((double)(ilmax-nglenref+1))/alog2;
|
||||
nbitsglen=(g2int)ceil(temp);
|
||||
for ( i=0; i<ngroups-1; i++) glen[i]=glen[i]-nglenref;
|
||||
sbits(cpack,glen,iofst,nbitsglen,0,ngroups);
|
||||
|
||||
@@ -60,17 +60,17 @@ void rdieee(g2int *rieee,g2float *a,g2int num)
|
||||
|
||||
if ( (iexp > 0) && (iexp < 255) ) {
|
||||
temp=(g2float)int_power(2.0,(iexp-127));
|
||||
a[j]=sign*temp*(1.0+(two23*(g2float)imant));
|
||||
a[j]=sign*temp*(1.0f+(two23*(g2float)imant));
|
||||
}
|
||||
else if ( iexp == 0 ) {
|
||||
if ( imant != 0 )
|
||||
a[j]=sign*two126*two23*(g2float)imant;
|
||||
else
|
||||
a[j]=sign*0.0;
|
||||
a[j]=sign*0.0f;
|
||||
|
||||
}
|
||||
else if ( iexp == 255 )
|
||||
a[j]=sign*(1E+37);
|
||||
a[j]=sign*(1E+37f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ void simpack(g2float *fld,g2int ndpts,g2int *idrstmpl,unsigned char *cpack,g2int
|
||||
g2int j,nbits,imin,imax,maxdif,nbittot,left;
|
||||
g2float bscale,dscale,rmax,rmin,temp;
|
||||
double maxnum;
|
||||
static g2float alog2=0.69314718; // ln(2.0)
|
||||
static g2float alog2=0.69314718f; // ln(2.0)
|
||||
|
||||
bscale=int_power(2.0,-idrstmpl[1]);
|
||||
dscale=int_power(10.0,idrstmpl[2]);
|
||||
bscale=(g2float)int_power(2.0,-idrstmpl[1]);
|
||||
dscale=(g2float)int_power(10.0,idrstmpl[2]);
|
||||
if (idrstmpl[3] <= 0 || idrstmpl[3] > 31)
|
||||
nbits=0;
|
||||
else
|
||||
@@ -102,7 +102,7 @@ void simpack(g2float *fld,g2int ndpts,g2int *idrstmpl,unsigned char *cpack,g2int
|
||||
imin=(g2int)rint(rmin*dscale);
|
||||
imax=(g2int)rint(rmax*dscale);
|
||||
maxdif=imax-imin;
|
||||
temp=log((double)(maxdif+1))/alog2;
|
||||
temp=(g2float)log((double)(maxdif+1))/alog2;
|
||||
nbits=(g2int)ceil(temp);
|
||||
rmin=(g2float)imin;
|
||||
// scale data
|
||||
@@ -117,9 +117,9 @@ void simpack(g2float *fld,g2int ndpts,g2int *idrstmpl,unsigned char *cpack,g2int
|
||||
rmin=rmin*dscale;
|
||||
rmax=rmax*dscale;
|
||||
maxnum=int_power(2.0,nbits)-1;
|
||||
temp=log(maxnum/(rmax-rmin))/alog2;
|
||||
temp=(g2float)log(maxnum/(rmax-rmin))/alog2;
|
||||
idrstmpl[1]=(g2int)ceil(-1.0*temp);
|
||||
bscale=int_power(2.0,-idrstmpl[1]);
|
||||
bscale=(g2float)int_power(2.0,-idrstmpl[1]);
|
||||
// scale data
|
||||
for (j=0;j<ndpts;j++)
|
||||
ifld[j]=(g2int)rint(((fld[j]*dscale)-rmin)*bscale);
|
||||
@@ -132,7 +132,7 @@ void simpack(g2float *fld,g2int ndpts,g2int *idrstmpl,unsigned char *cpack,g2int
|
||||
rmin=rmin*dscale;
|
||||
rmax=rmax*dscale;
|
||||
maxdif=(g2int)rint((rmax-rmin)*bscale);
|
||||
temp=log((double)(maxdif+1))/alog2;
|
||||
temp=(g2float)log((double)(maxdif+1))/alog2;
|
||||
nbits=(g2int)ceil(temp);
|
||||
// scale data
|
||||
for (j=0;j<ndpts;j++)
|
||||
|
||||
@@ -43,8 +43,8 @@ g2int simunpack(unsigned char *cpack,g2int *idrstmpl,g2int ndpts,g2float *fld)
|
||||
g2float ref,bscale,dscale;
|
||||
|
||||
rdieee(idrstmpl+0,&ref,1);
|
||||
bscale = int_power(2.0,idrstmpl[1]);
|
||||
dscale = int_power(10.0,-idrstmpl[2]);
|
||||
bscale = (g2float)int_power(2.0,idrstmpl[1]);
|
||||
dscale = (g2float)int_power(10.0,-idrstmpl[2]);
|
||||
nbits = idrstmpl[3];
|
||||
|
||||
ifld=(g2int *)calloc((ndpts ? ndpts : 1),sizeof(g2int));
|
||||
|
||||
@@ -49,6 +49,7 @@ void specpack(g2float *fld,g2int ndpts,g2int JJ,g2int KK,g2int MM,
|
||||
|
||||
int_power(2.0,-idrstmpl[1]);
|
||||
int_power(10.0,idrstmpl[2]);
|
||||
|
||||
Js=idrstmpl[5];
|
||||
Ks=idrstmpl[6];
|
||||
Ms=idrstmpl[7];
|
||||
@@ -58,9 +59,9 @@ void specpack(g2float *fld,g2int ndpts,g2int JJ,g2int KK,g2int MM,
|
||||
// Calculate Laplacian scaling factors for each possible wave number.
|
||||
//
|
||||
pscale=(g2float *)malloc((JJ+MM)*sizeof(g2float));
|
||||
tscale=(g2float)idrstmpl[4]*1E-6;
|
||||
tscale=(g2float)idrstmpl[4]*1E-6f;
|
||||
for (n=Js;n<=JJ+MM;n++)
|
||||
pscale[n]=pow((g2float)(n*(n+1)),tscale);
|
||||
pscale[n]=(g2float)pow((g2float)(n*(n+1)),tscale);
|
||||
//
|
||||
// Separate spectral coeffs into two lists; one to contain unpacked
|
||||
// values within the sub-spectrum Js, Ks, Ms, and the other with values
|
||||
|
||||
@@ -51,8 +51,8 @@ g2int specunpack(unsigned char *cpack,g2int *idrstmpl,g2int ndpts,g2int JJ,
|
||||
g2int inc,incu,incp;
|
||||
|
||||
rdieee(idrstmpl+0,&ref,1);
|
||||
bscale = int_power(2.0,idrstmpl[1]);
|
||||
dscale = int_power(10.0,-idrstmpl[2]);
|
||||
bscale = (g2float)int_power(2.0,idrstmpl[1]);
|
||||
dscale = (g2float)int_power(10.0,-idrstmpl[2]);
|
||||
nbits = idrstmpl[3];
|
||||
Js=idrstmpl[5];
|
||||
Ks=idrstmpl[6];
|
||||
@@ -72,9 +72,9 @@ g2int specunpack(unsigned char *cpack,g2int *idrstmpl,g2int ndpts,g2int JJ,
|
||||
// Calculate Laplacian scaling factors for each possible wave number.
|
||||
//
|
||||
pscale=(g2float *)malloc((JJ+MM+1)*sizeof(g2float));
|
||||
tscale=(g2float)idrstmpl[4]*1E-6;
|
||||
tscale=(g2float)idrstmpl[4]*1E-6f;
|
||||
for (n=Js;n<=JJ+MM;n++)
|
||||
pscale[n]=pow((g2float)(n*(n+1)),-tscale);
|
||||
pscale[n]=(g2float)pow((g2float)(n*(n+1)),-tscale);
|
||||
//
|
||||
// Assemble spectral coeffs back to original order.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user