Skip to content

Commit

Permalink
Minor source code updates to fre-nctools to eliminate
Browse files Browse the repository at this point in the history
compiler warnings.

Fixes ufs-community#879.
  • Loading branch information
George Gayno committed Aug 14, 2024
1 parent 76c137a commit 82bfcd8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions sorc/fre-nctools.fd/shared_lib/create_xgrid.c
Original file line number Diff line number Diff line change
Expand Up @@ -2115,15 +2115,15 @@ double poly_ctrlon(const double x[], const double y[], int n, double clon)
if( dphi2 > M_PI) dphi2 -= 2.0*M_PI;
if( dphi2 <-M_PI) dphi2 += 2.0*M_PI;

if(abs(dphi2 -dphi1) < M_PI) {
if(fabs(dphi2 -dphi1) < M_PI) {
ctrlon -= dphi * (dphi1*f1+dphi2*f2)/2.0;
}
else {
if(dphi1 > 0.0)
fac = M_PI;
else
fac = -M_PI;
fint = f1 + (f2-f1)*(fac-dphi1)/abs(dphi);
fint = f1 + (f2-f1)*(fac-dphi1)/fabs(dphi);
ctrlon -= 0.5*dphi1*(dphi1-fac)*f1 - 0.5*dphi2*(dphi2+fac)*f2
+ 0.5*fac*(dphi1+dphi2)*fint;
}
Expand Down Expand Up @@ -2183,15 +2183,15 @@ double box_ctrlon(double ll_lon, double ll_lat, double ur_lon, double ur_lat, do
if( dphi2 > M_PI) dphi2 -= 2.0*M_PI;
if( dphi2 <-M_PI) dphi2 += 2.0*M_PI;

if(abs(dphi2 -dphi1) < M_PI) {
if(fabs(dphi2 -dphi1) < M_PI) {
ctrlon -= dphi * (dphi1*f1+dphi2*f2)/2.0;
}
else {
if(dphi1 > 0.0)
fac = M_PI;
else
fac = -M_PI;
fint = f1 + (f2-f1)*(fac-dphi1)/abs(dphi);
fint = f1 + (f2-f1)*(fac-dphi1)/fabs(dphi);
ctrlon -= 0.5*dphi1*(dphi1-fac)*f1 - 0.5*dphi2*(dphi2+fac)*f2
+ 0.5*fac*(dphi1+dphi2)*fint;
}
Expand Down
4 changes: 2 additions & 2 deletions sorc/fre-nctools.fd/shared_lib/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ End slopes
d[0] = 0.0;
}
else {
if ( delta[0]*delta[1] < 0.0 && abs(d[0]) > abs(3.0*delta[0])) {
if ( delta[0]*delta[1] < 0.0 && fabs(d[0]) > fabs(3.0*delta[0])) {
d[0]=3.0*delta[0];
}
}
Expand All @@ -88,7 +88,7 @@ End slopes
d[kmax] = 0.0;
}
else {
if ( delta[kmax-1]*delta[kmax-2] < 0.0 && abs(d[kmax]) > abs(3.0*delta[kmax-1])) {
if ( delta[kmax-1]*delta[kmax-2] < 0.0 && fabs(d[kmax]) > fabs(3.0*delta[kmax-1])) {
d[kmax]=3.0*delta[kmax-1];
}
}
Expand Down
6 changes: 3 additions & 3 deletions sorc/fre-nctools.fd/shared_lib/mosaic_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ double spherical_angle(const double *v1, const double *v2, const double *v3)
angle = 0. ;
else {
ddd = (px*qx+py*qy+pz*qz) / sqrt(ddd);
if( fabs(ddd-1) < EPSLN30 ) ddd = 1;
if( fabs(ddd+1) < EPSLN30 ) ddd = -1;
if( fabsl(ddd-1) < EPSLN30 ) ddd = 1;
if( fabsl(ddd+1) < EPSLN30 ) ddd = -1;
if ( ddd>1. || ddd<-1. ) {
/*FIX (lmh) to correctly handle co-linear points (angle near pi or 0) */
if (ddd < 0.)
Expand Down Expand Up @@ -731,7 +731,7 @@ int invert_matrix_3x3(long double m[], long double m_inv[]) {
#ifdef test_invert_matrix_3x3
printf("det = %Lf\n", det);
#endif
if (fabs(det) < EPSLN15 ) return 0;
if (fabsl(det) < EPSLN15 ) return 0;

const long double deti = 1.0/det;

Expand Down
8 changes: 4 additions & 4 deletions sorc/fre-nctools.fd/tools/make_hgrid/make_hgrid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ int main(int argc, char* argv[])
}
}

if (verbose) fprintf(stderr, "[INFO] Allocating arrays of size %d for x, y based on nxp: %d nyp: %d ntiles: %d\n", size1, nxp, nyp, ntiles);
if (verbose) fprintf(stderr, "[INFO] Allocating arrays of size %lu for x, y based on nxp: %d nyp: %d ntiles: %d\n", size1, nxp, nyp, ntiles);
x = (double *) malloc(size1*sizeof(double));
y = (double *) malloc(size1*sizeof(double));
area = (double *) malloc(size4*sizeof(double));
Expand Down Expand Up @@ -1198,7 +1198,7 @@ int main(int argc, char* argv[])

if(out_halo ==0) {
if (verbose) {
fprintf(stderr, "[INFO] START NC XARRAY write out_halo=0 tile number = n: %d offset = pos_c: %d\n", n, pos_c);
fprintf(stderr, "[INFO] START NC XARRAY write out_halo=0 tile number = n: %d offset = pos_c: %ld\n", n, pos_c);
fprintf(stderr, "[INFO] XARRAY: n: %d x[0]: %f x[1]: %f x[2]: %f x[3]: %f x[4]: %f x[5]: %f x[10]: %f\n",
n, x[pos_c], x[pos_c+1], x[pos_c+2], x[pos_c+3], x[pos_c+4], x[pos_c+5], x[pos_c+10]);
if (n > 0) fprintf(stderr, "[INFO] XARRAY: n: %d x[0]: %f x[-1]: %f x[-2]: %f x[-3]: %f x[-4]: %f x[-5]: %f x[-10]: %f\n",
Expand Down Expand Up @@ -1259,9 +1259,9 @@ int main(int argc, char* argv[])
nxp = nx + 1;
nyp = ny + 1;

if (verbose) fprintf(stderr, "[INFO] INDEX Before increment n: %d pos_c %d nxp %d nyp %d nxp*nyp %d\n", n, pos_c, nxp, nyp, nxp*nyp);
if (verbose) fprintf(stderr, "[INFO] INDEX Before increment n: %d pos_c %ld nxp %d nyp %d nxp*nyp %d\n", n, pos_c, nxp, nyp, nxp*nyp);
pos_c += nxp*nyp;
if (verbose) fprintf(stderr, "[INFO] INDEX After increment n: %d pos_c %d.\n", n, pos_c);
if (verbose) fprintf(stderr, "[INFO] INDEX After increment n: %d pos_c %ld.\n", n, pos_c);
pos_e += nxp*ny;
pos_n += nx*nyp;
pos_t += nx*ny;
Expand Down

0 comments on commit 82bfcd8

Please sign in to comment.