Add ncl-proj8.patch

This commit is contained in:
Sandro Mani 2021-03-10 20:49:12 +01:00
parent fc26304593
commit c1944d92d8
2 changed files with 73 additions and 1 deletions

69
ncl-proj8.patch Normal file
View File

@ -0,0 +1,69 @@
diff -rupN --no-dereference ncl-6.6.2/ni/src/lib/nfp/TransformCoordinate.c ncl-6.6.2-new/ni/src/lib/nfp/TransformCoordinate.c
--- ncl-6.6.2/ni/src/lib/nfp/TransformCoordinate.c 2019-02-28 00:44:39.000000000 +0100
+++ ncl-6.6.2-new/ni/src/lib/nfp/TransformCoordinate.c 2021-03-10 19:16:04.100897315 +0100
@@ -1,48 +1,39 @@
#include <stdio.h>
-#include <proj_api.h>
+#include <proj.h>
#include "TransformCoordinate.h"
int TransformCoordinate(char * SrcProjStr, char * DstProjStr,
double * x, double * y, double * z,
unsigned int nPoint) {
- projPJ SrcProj, DstProj;
+ PJ *proj;
int Err, i;
+ PJ_COORD* c = (PJ_COORD*)malloc(nPoint * sizeof(PJ_COORD));
/* Constructing the projections */
- if (!(SrcProj = pj_init_plus(SrcProjStr))) {
- printf("FATAL ERROR: Can not make a projection out of <%s>\n", SrcProjStr);
+ if (!(proj = proj_create_crs_to_crs(PJ_DEFAULT_CTX, SrcProjStr, DstProjStr, NULL))) {
+ printf("FATAL ERROR: Can not create transform from <%s> to <%s>\n", SrcProjStr, DstProjStr);
return (1);
}
- if (!(DstProj = pj_init_plus(DstProjStr))) {
- printf("FATAL ERROR: Can not make a projection out of <%s>\n", DstProjStr);
- return (2);
- }
- /* Converting to radian if needed */
- if (pj_is_latlong(SrcProj)) {
- for (i = 0; i < nPoint; i++) {
- x[i] *= DEG_TO_RAD;
- y[i] *= DEG_TO_RAD;
- }
+ for (i = 0; i < nPoint; ++i) {
+ c[i].xyz.x = x[i];
+ c[i].xyz.y = y[i];
+ c[i].xyz.z = z[i];
}
/* Transforming the coordinates */
- if ((Err = pj_transform(SrcProj, DstProj, nPoint, 1, x, y, z)) != 0) {
- printf("FATAL ERROR: %s\n", pj_strerrno(Err));
- return (3);
- }
+ proj_trans_array(proj, PJ_FWD, nPoint, c);
- /* converting to degree if needed */
- if (pj_is_latlong(DstProj)) {
- for (i = 0; i < nPoint; i++) {
- x[i] *= RAD_TO_DEG;
- y[i] *= RAD_TO_DEG;
- }
+ for (i = 0; i < nPoint; ++i) {
+ x[i] = c[i].xyz.x;
+ y[i] = c[i].xyz.y;
+ z[i] = c[i].xyz.z;
}
/* freeing the projection */
- pj_free(DstProj);
- pj_free(SrcProj);
+ proj_destroy(proj);
+ free(c);
+
return (0);
}

View File

@ -60,6 +60,8 @@ Patch12: ncl-5.1.0-netcdff.patch
Patch13: ncl-5.1.0-includes.patch
# Add Fedora secondary arches
Patch16: ncl-5.2.1-secondary.patch
# Fix build with proj8
Patch17: ncl-proj8.patch
BuildRequires: make
BuildRequires: /bin/csh
@ -139,6 +141,7 @@ Example programs and data using NCL.
%patch12 -p1 -b .netcdff
%patch13 -p1 -b .includes
%patch16 -p1 -b .secondary
%patch17 -p1 -b .proj
sed -ri -e 's,-lblas_ncl,-l%{blaslib},' \
-e 's,-llapack_ncl,-l%{blaslib},' config/Project
@ -187,7 +190,7 @@ FCOPTIONS="$RPM_OPT_FLAGS -fPIC -fno-second-underscore -fno-range-check -fopenmp
%if 0%{?fedora} >= 32 || 0%{?rhel} >= 9
FCOPTIONS="$FCOPTIONS -fallow-argument-mismatch -fcommon"
%endif
make Build CCOPTIONS="$RPM_OPT_FLAGS -std=c99 -fPIC -fno-strict-aliasing -fopenmp -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H -fcommon" \
make Build CCOPTIONS="$RPM_OPT_FLAGS -std=c99 -fPIC -fno-strict-aliasing -fopenmp -fcommon" \
F77=gfortran F77_LD=gfortran CTOFLIBS="-lgfortran" FCOPTIONS="$FCOPTIONS" COPT= FOPT=