From c1944d92d83c67ac0871fa2fbe5a9558b81f042f Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Wed, 10 Mar 2021 20:49:12 +0100 Subject: [PATCH] Add ncl-proj8.patch --- ncl-proj8.patch | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ ncl.spec | 5 +++- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 ncl-proj8.patch diff --git a/ncl-proj8.patch b/ncl-proj8.patch new file mode 100644 index 0000000..267e600 --- /dev/null +++ b/ncl-proj8.patch @@ -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 +-#include ++#include + #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); + } + diff --git a/ncl.spec b/ncl.spec index 00dfba5..4314ccd 100644 --- a/ncl.spec +++ b/ncl.spec @@ -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=