From c9c431302316b193ba6a1e8fe0214bde5da03194 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 15 Jun 2016 17:03:48 +0100 Subject: [PATCH 01/10] Remove generated Eclipse files --- .cproject | 52 --------------------------------- .settings/language.settings.xml | 12 -------- 2 files changed, 64 deletions(-) delete mode 100644 .cproject delete mode 100644 .settings/language.settings.xml diff --git a/.cproject b/.cproject deleted file mode 100644 index 6756194e9..000000000 --- a/.cproject +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml deleted file mode 100644 index 4e3a7939e..000000000 --- a/.settings/language.settings.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - From 6dba01ecc1d79fe06ffc34dbeefc21a2df598aca Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 15 Jun 2016 18:50:53 +0100 Subject: [PATCH 02/10] GRIB-405: Lambert Projection and jScansPositively=0 --- src/grib_iterator_class_lambert_conformal.c | 277 ++++++++++---------- 1 file changed, 138 insertions(+), 139 deletions(-) diff --git a/src/grib_iterator_class_lambert_conformal.c b/src/grib_iterator_class_lambert_conformal.c index 2a66d6553..f8c52c2dc 100644 --- a/src/grib_iterator_class_lambert_conformal.c +++ b/src/grib_iterator_class_lambert_conformal.c @@ -83,7 +83,6 @@ static void init_class(grib_iterator_class* c) static int next(grib_iterator* i, double *lat, double *lon, double *val) { - grib_iterator_lambert_conformal* self = (grib_iterator_lambert_conformal*)i; if((long)i->e >= (long)(i->nv-1)) @@ -114,161 +113,161 @@ static int next(grib_iterator* i, double *lat, double *lon, double *val) static int init(grib_iterator* iter,grib_handle* h,grib_arguments* args) { - int i, j, ret=0; - double *lats, *lons; /* the lat/lon arrays to be populated */ - long nx,ny,iScansNegatively,jScansPositively,jPointsAreConsecutive,alternativeRowScanning; - double LoVInDegrees,LaDInDegrees,Latin1InDegrees,Latin2InDegrees,latFirstInDegrees, - lonFirstInDegrees, Dx, Dy, radius=0; - double latFirstInRadians, lonFirstInRadians, LoVInRadians, Latin1InRadians, Latin2InRadians, - LaDInRadians, lonDiff, lonDeg, latDeg; - double f, n, rho, rho0, angle, x0, y0, x, y, tmp, tmp2; + int i, j, ret=0; + double *lats, *lons; /* the lat/lon arrays to be populated */ + long nx,ny,iScansNegatively,jScansPositively,jPointsAreConsecutive,alternativeRowScanning; + double LoVInDegrees,LaDInDegrees,Latin1InDegrees,Latin2InDegrees,latFirstInDegrees, + lonFirstInDegrees, Dx, Dy, radius=0; + double latFirstInRadians, lonFirstInRadians, LoVInRadians, Latin1InRadians, Latin2InRadians, + LaDInRadians, lonDiff, lonDeg, latDeg; + double f, n, rho, rho0, angle, x0, y0, x, y, tmp, tmp2; - grib_iterator_lambert_conformal* self = (grib_iterator_lambert_conformal*)iter; + grib_iterator_lambert_conformal* self = (grib_iterator_lambert_conformal*)iter; - const char* sradius = grib_arguments_get_name(h,args,self->carg++); - const char* snx = grib_arguments_get_name(h,args,self->carg++); - const char* sny = grib_arguments_get_name(h,args,self->carg++); - const char* sLoVInDegrees = grib_arguments_get_name(h,args,self->carg++); - const char* sLaDInDegrees = grib_arguments_get_name(h,args,self->carg++); - const char* sLatin1InDegrees = grib_arguments_get_name(h,args,self->carg++); - const char* sLatin2InDegrees = grib_arguments_get_name(h,args,self->carg++); - const char* slatFirstInDegrees = grib_arguments_get_name(h,args,self->carg++); - const char* slonFirstInDegrees = grib_arguments_get_name(h,args,self->carg++); - /* Dx and Dy are in Metres */ - const char* sDx = grib_arguments_get_name(h,args,self->carg++); - const char* sDy = grib_arguments_get_name(h,args,self->carg++); - const char* siScansNegatively = grib_arguments_get_name(h,args,self->carg++); - const char* sjScansPositively = grib_arguments_get_name(h,args,self->carg++); - const char* sjPointsAreConsecutive = grib_arguments_get_name(h,args,self->carg++); - const char* salternativeRowScanning = grib_arguments_get_name(h,args,self->carg++); + const char* sradius = grib_arguments_get_name(h,args,self->carg++); + const char* snx = grib_arguments_get_name(h,args,self->carg++); + const char* sny = grib_arguments_get_name(h,args,self->carg++); + const char* sLoVInDegrees = grib_arguments_get_name(h,args,self->carg++); + const char* sLaDInDegrees = grib_arguments_get_name(h,args,self->carg++); + const char* sLatin1InDegrees = grib_arguments_get_name(h,args,self->carg++); + const char* sLatin2InDegrees = grib_arguments_get_name(h,args,self->carg++); + const char* slatFirstInDegrees = grib_arguments_get_name(h,args,self->carg++); + const char* slonFirstInDegrees = grib_arguments_get_name(h,args,self->carg++); + /* Dx and Dy are in Metres */ + const char* sDx = grib_arguments_get_name(h,args,self->carg++); + const char* sDy = grib_arguments_get_name(h,args,self->carg++); + const char* siScansNegatively = grib_arguments_get_name(h,args,self->carg++); + const char* sjScansPositively = grib_arguments_get_name(h,args,self->carg++); + const char* sjPointsAreConsecutive = grib_arguments_get_name(h,args,self->carg++); + const char* salternativeRowScanning = grib_arguments_get_name(h,args,self->carg++); - if((ret = grib_get_long_internal(h, snx,&nx)) != GRIB_SUCCESS) - return ret; - if((ret = grib_get_long_internal(h, sny,&ny)) != GRIB_SUCCESS) - return ret; + if((ret = grib_get_long_internal(h, snx,&nx)) != GRIB_SUCCESS) + return ret; + if((ret = grib_get_long_internal(h, sny,&ny)) != GRIB_SUCCESS) + return ret; - if (iter->nv!=nx*ny) { - grib_context_log(h->context,GRIB_LOG_ERROR,"Wrong number of points (%ld!=%ldx%ld)",iter->nv,nx,ny); - return GRIB_WRONG_GRID; - } - if((ret = grib_get_double_internal(h, sradius,&radius)) != GRIB_SUCCESS) - return ret; - if((ret = grib_get_double_internal(h, sLoVInDegrees, &LoVInDegrees))!=GRIB_SUCCESS) - return ret; - if((ret = grib_get_double_internal(h, sLaDInDegrees, &LaDInDegrees))!=GRIB_SUCCESS) - return ret; - if((ret = grib_get_double_internal(h, sLatin1InDegrees, &Latin1InDegrees))!=GRIB_SUCCESS) - return ret; - if((ret = grib_get_double_internal(h, sLatin2InDegrees, &Latin2InDegrees))!=GRIB_SUCCESS) - return ret; - if((ret = grib_get_double_internal(h, slatFirstInDegrees,&latFirstInDegrees)) !=GRIB_SUCCESS) - return ret; - if((ret = grib_get_double_internal(h, slonFirstInDegrees,&lonFirstInDegrees)) !=GRIB_SUCCESS) - return ret; - if((ret = grib_get_double_internal(h, sDx,&Dx)) !=GRIB_SUCCESS) - return ret; - if((ret = grib_get_double_internal(h, sDy,&Dy)) !=GRIB_SUCCESS) - return ret; - if((ret = grib_get_long_internal(h, sjPointsAreConsecutive,&jPointsAreConsecutive)) !=GRIB_SUCCESS) - return ret; - if((ret = grib_get_long_internal(h, sjScansPositively,&jScansPositively)) !=GRIB_SUCCESS) - return ret; - if((ret = grib_get_long_internal(h, siScansNegatively,&iScansNegatively)) !=GRIB_SUCCESS) - return ret; - if((ret = grib_get_long_internal(h, salternativeRowScanning,&alternativeRowScanning)) !=GRIB_SUCCESS) - return ret; + if (iter->nv!=nx*ny) { + grib_context_log(h->context,GRIB_LOG_ERROR,"Wrong number of points (%ld!=%ldx%ld)",iter->nv,nx,ny); + return GRIB_WRONG_GRID; + } + if((ret = grib_get_double_internal(h, sradius,&radius)) != GRIB_SUCCESS) + return ret; + if((ret = grib_get_double_internal(h, sLoVInDegrees, &LoVInDegrees))!=GRIB_SUCCESS) + return ret; + if((ret = grib_get_double_internal(h, sLaDInDegrees, &LaDInDegrees))!=GRIB_SUCCESS) + return ret; + if((ret = grib_get_double_internal(h, sLatin1InDegrees, &Latin1InDegrees))!=GRIB_SUCCESS) + return ret; + if((ret = grib_get_double_internal(h, sLatin2InDegrees, &Latin2InDegrees))!=GRIB_SUCCESS) + return ret; + if((ret = grib_get_double_internal(h, slatFirstInDegrees,&latFirstInDegrees)) !=GRIB_SUCCESS) + return ret; + if((ret = grib_get_double_internal(h, slonFirstInDegrees,&lonFirstInDegrees)) !=GRIB_SUCCESS) + return ret; + if((ret = grib_get_double_internal(h, sDx,&Dx)) !=GRIB_SUCCESS) + return ret; + if((ret = grib_get_double_internal(h, sDy,&Dy)) !=GRIB_SUCCESS) + return ret; + if((ret = grib_get_long_internal(h, sjPointsAreConsecutive,&jPointsAreConsecutive)) !=GRIB_SUCCESS) + return ret; + if((ret = grib_get_long_internal(h, sjScansPositively,&jScansPositively)) !=GRIB_SUCCESS) + return ret; + if((ret = grib_get_long_internal(h, siScansNegatively,&iScansNegatively)) !=GRIB_SUCCESS) + return ret; + if((ret = grib_get_long_internal(h, salternativeRowScanning,&alternativeRowScanning)) !=GRIB_SUCCESS) + return ret; - /* See Wolfram MathWorld: http://mathworld.wolfram.com/LambertConformalConicProjection.html */ - latFirstInRadians = latFirstInDegrees * DEG2RAD; - lonFirstInRadians = lonFirstInDegrees * DEG2RAD; - Latin1InRadians = Latin1InDegrees * DEG2RAD; - Latin2InRadians = Latin2InDegrees * DEG2RAD; - LaDInRadians = LaDInDegrees * DEG2RAD; - LoVInRadians = LoVInDegrees * DEG2RAD; + /* See Wolfram MathWorld: http://mathworld.wolfram.com/LambertConformalConicProjection.html */ + latFirstInRadians = latFirstInDegrees * DEG2RAD; + lonFirstInRadians = lonFirstInDegrees * DEG2RAD; + Latin1InRadians = Latin1InDegrees * DEG2RAD; + Latin2InRadians = Latin2InDegrees * DEG2RAD; + LaDInRadians = LaDInDegrees * DEG2RAD; + LoVInRadians = LoVInDegrees * DEG2RAD; - if ( fabs(Latin1InRadians - Latin2InRadians) < 1E-09 ) { - n = sin(Latin1InRadians); - } - else { - n = log(cos(Latin1InRadians)/cos(Latin2InRadians)) / - log(tan(M_PI_4 + Latin2InRadians/2.0) / tan(M_PI_4 + Latin1InRadians/2.0)); - } + if ( fabs(Latin1InRadians - Latin2InRadians) < 1E-09 ) { + n = sin(Latin1InRadians); + } + else { + n = log(cos(Latin1InRadians)/cos(Latin2InRadians)) / + log(tan(M_PI_4 + Latin2InRadians/2.0) / tan(M_PI_4 + Latin1InRadians/2.0)); + } - f = (cos(Latin1InRadians) * pow(tan(M_PI_4 + Latin1InRadians/2.0), n)) / n; - rho = radius * f * pow(tan(M_PI_4 + latFirstInRadians/2.0), -n); - rho0 = radius * f * pow(tan(M_PI_4 + LaDInRadians/2.0), -n); - if ( n < 0 ) /* adjustment for southern hemisphere */ - rho0 = -rho0; - lonDiff = lonFirstInRadians - LoVInRadians; + f = (cos(Latin1InRadians) * pow(tan(M_PI_4 + Latin1InRadians/2.0), n)) / n; + rho = radius * f * pow(tan(M_PI_4 + latFirstInRadians/2.0), -n); + rho0 = radius * f * pow(tan(M_PI_4 + LaDInRadians/2.0), -n); + if ( n < 0 ) /* adjustment for southern hemisphere */ + rho0 = -rho0; + lonDiff = lonFirstInRadians - LoVInRadians; - /* Adjust longitude to range -180 to 180 */ - if (lonDiff > M_PI) lonDiff -= 2*M_PI; - if (lonDiff < -M_PI) lonDiff += 2*M_PI; - angle = n * lonDiff; - x0 = rho * sin(angle); - y0 = rho0 - rho * cos(angle); - Dx = iScansNegatively == 0 ? Dx : -Dx; - Dy = jScansPositively == 1 ? Dy : -Dy; + /* Adjust longitude to range -180 to 180 */ + if (lonDiff > M_PI) lonDiff -= 2*M_PI; + if (lonDiff < -M_PI) lonDiff += 2*M_PI; + angle = n * lonDiff; + x0 = rho * sin(angle); + y0 = rho0 - rho * cos(angle); + Dx = iScansNegatively == 0 ? Dx : -Dx; + /* GRIB-405: Don't change sign of Dy. Latitudes ALWAYS increase from latitudeOfFirstGridPoint */ + /*Dy = jScansPositively == 1 ? Dy : -Dy;*/ - /* No support (yet) for jPointsAreConsecutive */ - if (jPointsAreConsecutive) { - grib_context_log(h->context,GRIB_LOG_ERROR,"No support for: 'Adjacent points in j (y) direction being consecutive'"); - Assert(0); - } + /* No support (yet) for jPointsAreConsecutive */ + if (jPointsAreConsecutive) { + grib_context_log(h->context,GRIB_LOG_ERROR,"No support for: 'Adjacent points in j (y) direction being consecutive'"); + Assert(0); + } - /* Allocate latitude and longitude arrays */ - self->lats = (double*)grib_context_malloc(h->context,iter->nv*sizeof(double)); - if (!self->lats) { - grib_context_log(h->context,GRIB_LOG_ERROR, "unable to allocate %ld bytes",iter->nv*sizeof(double)); - return GRIB_OUT_OF_MEMORY; - } - self->lons = (double*)grib_context_malloc(h->context,iter->nv*sizeof(double)); - if (!self->lats) { - grib_context_log(h->context,GRIB_LOG_ERROR, "unable to allocate %ld bytes",iter->nv*sizeof(double)); - return GRIB_OUT_OF_MEMORY; - } - lats=self->lats; - lons=self->lons; + /* Allocate latitude and longitude arrays */ + self->lats = (double*)grib_context_malloc(h->context,iter->nv*sizeof(double)); + if (!self->lats) { + grib_context_log(h->context,GRIB_LOG_ERROR, "unable to allocate %ld bytes",iter->nv*sizeof(double)); + return GRIB_OUT_OF_MEMORY; + } + self->lons = (double*)grib_context_malloc(h->context,iter->nv*sizeof(double)); + if (!self->lats) { + grib_context_log(h->context,GRIB_LOG_ERROR, "unable to allocate %ld bytes",iter->nv*sizeof(double)); + return GRIB_OUT_OF_MEMORY; + } + lats=self->lats; + lons=self->lons; - /* Populate our arrays */ - for (j = 0; j < ny; j++) { - y = y0 + j*Dy; - if ( n < 0 ) { /* adjustment for southern hemisphere */ - y = -y; - } - tmp = rho0 - y; - tmp2 = tmp*tmp; - for (i = 0; i < nx; i++) { - int index =i+j*nx; - x = x0 + i*Dx; - if ( n < 0 ) { /* adjustment for southern hemisphere */ - x = -x; - } + /* Populate our arrays */ + for (j = 0; j < ny; j++) { + y = y0 + j*Dy; + if ( n < 0 ) { /* adjustment for southern hemisphere */ + y = -y; + } + tmp = rho0 - y; + tmp2 = tmp*tmp; + for (i = 0; i < nx; i++) { + int index =i+j*nx; + x = x0 + i*Dx; + if ( n < 0 ) { /* adjustment for southern hemisphere */ + x = -x; + } - angle = atan(x / tmp); - rho = sqrt(x*x + tmp2); - if (n <= 0) rho = -rho; - lonDeg = LoVInDegrees + (angle/n) * RAD2DEG; - latDeg = (2.0 * atan(pow(radius * f/rho, 1.0/n)) - M_PI_2) * RAD2DEG; - while ( lonDeg >= 360.0) lonDeg -= 360.0; - while ( lonDeg < 0.0) lonDeg += 360.0; - lons[index] = lonDeg; - lats[index] = latDeg; - } - } + angle = atan(x / tmp); + rho = sqrt(x*x + tmp2); + if (n <= 0) rho = -rho; + lonDeg = LoVInDegrees + (angle/n) * RAD2DEG; + latDeg = (2.0 * atan(pow(radius * f/rho, 1.0/n)) - M_PI_2) * RAD2DEG; + while ( lonDeg >= 360.0) lonDeg -= 360.0; + while ( lonDeg < 0.0) lonDeg += 360.0; + lons[index] = lonDeg; + lats[index] = latDeg; + } + } - iter->e = -1; + iter->e = -1; - return ret; + return ret; } static int destroy(grib_iterator* i) { - grib_iterator_lambert_conformal* self = (grib_iterator_lambert_conformal*)i; - const grib_context *c = i->h->context; + grib_iterator_lambert_conformal* self = (grib_iterator_lambert_conformal*)i; + const grib_context *c = i->h->context; - grib_context_free(c,self->lats); - grib_context_free(c,self->lons); - return 1; + grib_context_free(c,self->lats); + grib_context_free(c,self->lons); + return 1; } - From 0a43dcc70d4a3751e7ea564609e7a11dd659e1e6 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 16 Jun 2016 10:42:37 +0100 Subject: [PATCH 03/10] Remove obsolete stuff --- CMakeLists.txt | 2 +- .../definitions/grib1/local.98.35.def | 39 ----- .../definitions/grib1/section.4.def | 160 ------------------ 3 files changed, 1 insertion(+), 200 deletions(-) delete mode 100644 grib_api_for_mars/definitions/grib1/local.98.35.def delete mode 100644 grib_api_for_mars/definitions/grib1/section.4.def diff --git a/CMakeLists.txt b/CMakeLists.txt index e5e6dc08a..999a9c95f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,7 +289,7 @@ add_subdirectory( ifs_samples ) # must come after samples ecbuild_dont_pack( DIRS concepts tests.ecmwf doxygen confluence examples.dev templates parameters java gaussian_experimental gribex examples/F77 - examples/extra bamboo fortran/fortranCtypes tigge/tools share/eccodes grib_api_for_mars + examples/extra bamboo fortran/fortranCtypes tigge/tools share/eccodes src/.deps tests/.deps tools/.deps tigge/.deps examples/C/.deps examples/python/.deps python/.deps fortran/.deps ) diff --git a/grib_api_for_mars/definitions/grib1/local.98.35.def b/grib_api_for_mars/definitions/grib1/local.98.35.def deleted file mode 100644 index 980db3a8b..000000000 --- a/grib_api_for_mars/definitions/grib1/local.98.35.def +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2005-2016 ECMWF. -# -# This software is licensed under the terms of the Apache Licence Version 2.0 -# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -# -# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by -# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. -# -constant GRIBEXSection1Problem = 120 - section1Length ; - -template mars_labeling "grib1/mars_labeling.def"; - -unsigned[1] yearOfReference = yearOfCentury : dump; -unsigned[1] monthOfReference = month : dump; -unsigned[1] dayOfReference = day : dump; -unsigned[1] hourOfReference = hour : dump; -unsigned[1] minuteOfReference = minute : dump; -unsigned[1] centuryOfReference = centuryOfReferenceTimeOfData : dump; -transient secondsOfReference = 0 ; - -unsigned[1] numberOfForcasts=0 : dump; -unsigned[1] numberOfAnalysis=1 : dump; - -if (numberOfForcasts) { - unsigned[3] forecastSteps[numberOfForcasts] : dump; -} -if (numberOfAnalysis) { - signed[3] analysisOffsets[numberOfAnalysis] : dump; -} - -padto padding_local_35(offsetSection1 + 120); - -meta dateOfReference g1date(centuryOfReference,yearOfReference,monthOfReference,dayOfReference) : dump; -meta timeOfReference time(hourOfReference,minuteOfReference,secondsOfReference) : dump; - -if (indicatorOfTypeOfLevel==160) { - alias mars.levelist = level; -} - diff --git a/grib_api_for_mars/definitions/grib1/section.4.def b/grib_api_for_mars/definitions/grib1/section.4.def deleted file mode 100644 index b23f46a26..000000000 --- a/grib_api_for_mars/definitions/grib1/section.4.def +++ /dev/null @@ -1,160 +0,0 @@ -# Copyright 2005-2016 ECMWF. -# -# This software is licensed under the terms of the Apache Licence Version 2.0 -# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -# -# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by -# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. -# -# START grib1::section -# SECTION 4, Binary data section -# Length of section -# (octets) -position offsetSection4; - -# Due to a trick done by GRIBEX to support large GRIBs, we need a special treatment -# of the message length and of the section4 lenth, so instead of -# length[3] section4Length ; -# we get: -g1_section4_length[3] section4Length(totalLength); - -meta section4Pointer section_pointer(offsetSection4,section4Length,4); - -g1_half_byte_codeflag halfByte; -flags[1] dataFlag "grib1/11.table" = 0 : read_only; -signed[2] binaryScaleFactor = 0 : read_only,dump; -ibmfloat referenceValue : read_only,dump; -unsigned[1] bitsPerValue : dump ; -alias numberOfBitsContainingEachPackedValue = bitsPerValue; - -meta referenceValueError reference_value_error(referenceValue,ibm); - -flagbit sphericalHarmonics(dataFlag,7) : dump; -flagbit complexPacking(dataFlag,6) : dump; -flagbit integerPointValues(dataFlag,5) : dump; -flagbit additionalFlagPresent(dataFlag,4) : edition_specific,dump; - -transient hideThis=0; - -concept packingType { -#set uses the last one -#get returns the first match - "grid_simple" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;} - "grid_ieee" = { sphericalHarmonics = 0; complexPacking = 0; - integerPointValues=1; additionalFlagPresent=1;} - "spectral_complex" = { sphericalHarmonics = 1; complexPacking = 1; - additionalFlagPresent = 0; } - "spectral_simple" = { sphericalHarmonics = 1; complexPacking = 0; additionalFlagPresent = 0; - representationMode=1;} - "spectral_ieee" = { sphericalHarmonics = 1; complexPacking = 1; - additionalFlagPresent = 0; hideThis=1; } - "grid_simple_matrix" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 1;} - "grid_second_order" = { sphericalHarmonics = 0; complexPacking = 1; } - "grid_complex" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;} - "grid_complex_spatial_differencing" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;} - "grid_jpeg" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;} - "grid_png" = { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;} - "grid_simple_log_preprocessing"= { sphericalHarmonics = 0; complexPacking = 0; additionalFlagPresent = 0;} -} : dump; - - -alias ls.packingType=packingType; -alias typeOfPacking=packingType; - -if( binaryScaleFactor == -32767) { - constant dataRepresentationTemplateNumber = 0; - constant bitMapIndicator = 0; - # For grib 1 -> 2 - position offsetBeforeData; - transient numberOfCodedValues=numberOfPoints; - meta values data_dummy_field( - section4Length, - offsetBeforeData, - offsetSection4, - unitsFactor, - unitsBias, - changingPrecision, - numberOfCodedValues, - bitsPerValue, - referenceValue, - binaryScaleFactor, - decimalScaleFactor, - halfByte, - packingType, - grid_ieee,precision, - missingValue, - numberOfPoints, - bitmap - ) : dump; -} else { - template dataValues "grib1/data.[packingType:s].def"; -} - -position offsetAfterData; - -transient dataLength=(offsetAfterData-offsetBeforeData)/8; - -if (bitmapPresent==1) { - alias numberOfEffectiveValues=numberOfDataPoints; -} else { - alias numberOfEffectiveValues=numberOfCodedValues; -} - -_if (sphericalHarmonics) { - alias numberOfEffectiveValues=numberOfValues; -} - -#meta setDecimalPrecision suppressed(decimalPrecision,changeDecimalPrecision); -meta changeDecimalPrecision decimal_precision(bitsPerValue,decimalScaleFactor,changingPrecision,values) : edition_specific; -meta decimalPrecision decimal_precision(bitsPerValue,decimalScaleFactor,changingPrecision) : edition_specific; -alias setDecimalPrecision=changeDecimalPrecision; - -meta bitsPerValueAndRepack bits_per_value(values,bitsPerValue) : edition_specific; -alias setBitsPerValue=bitsPerValueAndRepack; - -meta scaleValuesBy scale_values(values,missingValue) : edition_specific; -meta offsetValuesBy offset_values(values,missingValue) : edition_specific; - -concept gridType { -#set uses the last one -#get returns the first match - "regular_ll" = {dataRepresentationType = 0; sphericalHarmonics = 0; PLPresent=0;} - "reduced_ll" = {dataRepresentationType = 0; sphericalHarmonics = 0; PLPresent=1; Ni=missing(); } - "mercator" = {dataRepresentationType = 1; sphericalHarmonics = 0; PLPresent=0; } - "lambert" = {dataRepresentationType = 3; sphericalHarmonics = 0; PLPresent=0; } - "polar_stereographic" = {dataRepresentationType = 5; sphericalHarmonics = 0; PLPresent=0; } - "UTM" = {dataRepresentationType = 6; sphericalHarmonics = 0; PLPresent=0; } - "simple_polyconic" = {dataRepresentationType = 7; sphericalHarmonics = 0; PLPresent=0; } - "albers" = {dataRepresentationType = 8; sphericalHarmonics = 0; PLPresent=0; } - "miller" = {dataRepresentationType = 8; sphericalHarmonics = 0; PLPresent=0; } - "rotated_ll" = {dataRepresentationType = 10; sphericalHarmonics = 0; PLPresent=0; } - "stretched_ll" = {dataRepresentationType = 20; sphericalHarmonics = 0; PLPresent=0; } - "stretched_rotated_ll" = {dataRepresentationType = 30; sphericalHarmonics = 0; PLPresent=0; } - "regular_gg" = {dataRepresentationType = 4; sphericalHarmonics = 0; PLPresent=0; } - "rotated_gg" = {dataRepresentationType = 14; sphericalHarmonics = 0; PLPresent=0; } - "stretched_gg" = {dataRepresentationType = 24; sphericalHarmonics = 0; PLPresent=0; } - "stretched_rotated_gg" = {dataRepresentationType = 34; sphericalHarmonics = 0; PLPresent=0; } - "reduced_gg" = {dataRepresentationType = 4; sphericalHarmonics = 0; - PLPresent=1; numberOfPointsAlongAParallel = missing(); - iDirectionIncrement = missing(); ijDirectionIncrementGiven=0;} - "sh" = {dataRepresentationType = 50; sphericalHarmonics = 1; PLPresent=0; } - "rotated_sh" = {dataRepresentationType = 60; sphericalHarmonics = 1; PLPresent=0; } - "stretched_sh" = {dataRepresentationType = 70; sphericalHarmonics = 1; PLPresent=0; } - "stretched_rotated_sh" = {dataRepresentationType = 80; sphericalHarmonics = 1; PLPresent=0; } - "space_view" = {dataRepresentationType = 90; sphericalHarmonics = 0; PLPresent=0; } - "unknown" = {PLPresent=0;} - "unknown_PLPresent" = {PLPresent=1;} -} : dump; - -alias ls.gridType=gridType; -alias geography.gridType=gridType; -alias typeOfGrid=gridType; - -meta getNumberOfValues size(values) : edition_specific,dump ; - -padtoeven padding_sec4_1(offsetSection4,section4Length) ; - -meta md5Section4 md5(offsetSection4,section4Length); - - - From 916026d682c52289b34b96d9d691e0fdd218162a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 16 Jun 2016 10:44:01 +0100 Subject: [PATCH 04/10] Remove obsolete stuff (mars_tests) --- mars_tests/Makefile.am | 12 --------- mars_tests/include.sh | 50 ----------------------------------- mars_tests/ls.sh | 60 ------------------------------------------ 3 files changed, 122 deletions(-) delete mode 100755 mars_tests/Makefile.am delete mode 100644 mars_tests/include.sh delete mode 100755 mars_tests/ls.sh diff --git a/mars_tests/Makefile.am b/mars_tests/Makefile.am deleted file mode 100755 index 7a8deb091..000000000 --- a/mars_tests/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -if WITH_MARS_TESTS - TESTS = ls.sh - - noinst_PROGRAMS = - - LDADD = $(top_builddir)/src/libgrib_api.a $(EMOS_LIB) - - INCLUDES = -I$(top_builddir)/src - - EXTRA_DIST = $(TESTS) - -endif diff --git a/mars_tests/include.sh b/mars_tests/include.sh deleted file mode 100644 index 426cb7525..000000000 --- a/mars_tests/include.sh +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2005-2016 ECMWF. -# -# This software is licensed under the terms of the Apache Licence Version 2.0 -# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -# -# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by -# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - -set -ea - -echo -echo "TEST: $0" - -data_dir="" - -# save current working dir -save=`pwd` - -if [ -z "${data_dir}" ] -then - cd ../ - cpath=`pwd` - ECCODES_DEFINITION_PATH=$cpath/definitions - export ECCODES_DEFINITION_PATH - ECCODES_SAMPLES_PATH=$cpath/samples - export ECCODES_SAMPLES_PATH - tools_dir=$cpath/tools/ - tigge_dir=$cpath/tigge/ - data_dir=$cpath/data - test_dir=$cpath/tests - def_dir=$cpath/definitions -else - tools_dir="" - tigge_dir="" -fi - -if [ -z "${GRIB_API_INCLUDE}" ] -then - GRIB_API_INCLUDE=`pwd`/src -fi - -if [ -z "${GRIB_API_LIB}" ] -then - GRIB_API_LIB=`pwd`/src -fi - -# go back to current working dir -cd $save - -set -u diff --git a/mars_tests/ls.sh b/mars_tests/ls.sh deleted file mode 100755 index e0ecff630..000000000 --- a/mars_tests/ls.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# Copyright 2005-2016 ECMWF. -# -# This software is licensed under the terms of the Apache Licence Version 2.0 -# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -# -# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by -# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - -. ./include.sh - -rm -f log | true -workdir=`pwd` - -cd ${data_dir} -infile=regular_gaussian_model_level.grib1 - -${tools_dir}grib_ls -P count $infile > log -${tools_dir}grib_ls -p count,step $infile >> log -${tools_dir}grib_ls $infile >> log -${tools_dir}grib_ls -l 0,0,1 $infile >> log -${tools_dir}grib_get -l 0,0,1 $infile >> log -${tools_dir}grib_get -p count,step $infile >> log -${tools_dir}grib_get -P count $infile >> log - -files=" reduced_gaussian_lsm.grib1 -reduced_gaussian_model_level.grib1 -reduced_gaussian_model_level.grib2 -reduced_gaussian_pressure_level.grib1 -reduced_gaussian_pressure_level.grib2 -reduced_gaussian_pressure_level_constant.grib1 -reduced_gaussian_pressure_level_constant.grib2 -reduced_gaussian_sub_area.grib1 -reduced_gaussian_sub_area.grib2 -reduced_gaussian_surface.grib1 -reduced_gaussian_surface.grib2 -reduced_latlon_surface.grib1 -reduced_latlon_surface.grib2 -regular_gaussian_model_level.grib1 -regular_gaussian_model_level.grib2 -regular_gaussian_pressure_level.grib1 -regular_gaussian_pressure_level.grib2 -regular_gaussian_pressure_level_constant.grib1 -regular_gaussian_pressure_level_constant.grib2 -regular_gaussian_surface.grib1 -regular_gaussian_surface.grib2 -regular_latlon_surface.grib1 -regular_latlon_surface.grib2 -" - -for file in $files -do - echo $file >> log - ${tools_dir}grib_ls -l 40,28 $file | grep index | awk '{print $4;}' >> log -done - -diff log ls.log -rm -f log - -cd $workdir From 26a7a59e69d3e71d38239e097c77fea4e2187b87 Mon Sep 17 00:00:00 2001 From: Enrico Fucile Date: Thu, 16 Jun 2016 11:47:16 +0100 Subject: [PATCH 05/10] Added new fortran function codes_get_string_array and example/F90/bufr_get_string_array.f90 ECC-269 --- data/bufr/bufr_ref_files.txt | 1 + examples/F90/CMakeLists.txt | 1 + examples/F90/bufr_get_string_array.f90 | 58 +++++++++++++++++++++++ examples/F90/bufr_get_string_array.sh | 39 +++++++++++++++ fortran/eccodes_f90_int.f90 | 2 +- fortran/eccodes_f90_long_int.f90 | 2 +- fortran/eccodes_f90_tail.f90 | 51 ++++++++++++++++++-- fortran/grib_api_externals.h | 3 +- fortran/grib_fortran.c | 48 +++++++++++++++++++ src/grib_accessor_class_bufr_data_array.c | 1 + 10 files changed, 198 insertions(+), 8 deletions(-) create mode 100644 examples/F90/bufr_get_string_array.f90 create mode 100755 examples/F90/bufr_get_string_array.sh diff --git a/data/bufr/bufr_ref_files.txt b/data/bufr/bufr_ref_files.txt index 8b0e7f75e..cac029f12 100644 --- a/data/bufr/bufr_ref_files.txt +++ b/data/bufr/bufr_ref_files.txt @@ -384,3 +384,4 @@ uegabe.bufr.num.ref syno.bufr.out.ref airep.bufr.out.ref new_replication.bufr.ref +get_string_array.ref diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt index 2bcaf3486..29ba0beb1 100644 --- a/examples/F90/CMakeLists.txt +++ b/examples/F90/CMakeLists.txt @@ -36,6 +36,7 @@ list( APPEND tests bufr_clone bufr_expanded bufr_get_keys + bufr_get_string_array bufr_keys_iterator bufr_read_header bufr_read_scatterometer diff --git a/examples/F90/bufr_get_string_array.f90 b/examples/F90/bufr_get_string_array.f90 new file mode 100644 index 000000000..6b42c997e --- /dev/null +++ b/examples/F90/bufr_get_string_array.f90 @@ -0,0 +1,58 @@ +! +!Copyright 2005-2016 ECMWF. +! +! This software is licensed under the terms of the Apache Licence Version 2.0 +!which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +! +! In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +! +! +! FOTRAN 90 Implementation: bufr_get_string_array +! +! Description: how to get an array of strings from a BUFR message. + +program bufr_get_string_array +use eccodes +implicit none +integer :: ifile +integer :: iret,i,n +integer :: ibufr +integer :: strsize +integer, parameter :: max_strsize = 20 +character(len=max_strsize) , dimension(:),allocatable :: stationOrSiteName + + call codes_open_file(ifile,'../../data/bufr/pgps_110.bufr','r') + + call codes_bufr_new_from_file(ifile,ibufr,iret) + + + ! unpack the data values + call codes_set(ibufr,'unpack',1) + call codes_get(ibufr,'stationOrSiteName->width',strsize) + strsize=strsize/8 + if (strsize > max_strsize) then + print *,'stationOrSiteName array dimension is ',max_strsize,' and should be ',strsize + call exit(1) + end if + + call codes_get_size(ibufr,'stationOrSiteName',n) + allocate(stationOrSiteName(n)) + ! passing an array of strings stationOrSiteName which must be allocated beforehand + call codes_get_string_array(ibufr,'stationOrSiteName',stationOrSiteName) + do i=1,n + write(*,'(A)')trim(stationOrSiteName(i)) + end do + + !remember to deallocate what was allocated by codes_get_string_array + deallocate(stationOrSiteName) + + ! release the bufr message + call codes_release(ibufr) + + ! close file + call codes_close_file(ifile) + + +end program bufr_get_string_array + diff --git a/examples/F90/bufr_get_string_array.sh b/examples/F90/bufr_get_string_array.sh new file mode 100755 index 000000000..0f65ee45d --- /dev/null +++ b/examples/F90/bufr_get_string_array.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Copyright 2005-2016 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + +. ./include.sh +set -x +#Define a common label for all the tmp files +label="bufr_get_string_array_test_f" + +#Prepare tmp file +fTmp=${label}.tmp.txt +rm -f $fTmp | true + +#----------------------------------------------------- +# Test get string array from a BUFR +#---------------------------------------------------- + +fRef=${data_dir}/bufr/get_string_array.ref + +REDIRECT=/dev/null + +#Write the values into a file and compare with reference +${examples_dir}/eccodes_f_bufr_get_string_array $f > $fTmp + +#We compare output to the reference by ignoring the whitespaces +diff -w $fRef $fTmp + +#cat $fRes + +#Clean up +rm -f ${fTmp} | true + + + diff --git a/fortran/eccodes_f90_int.f90 b/fortran/eccodes_f90_int.f90 index 2a63abfc8..4c2a28500 100644 --- a/fortran/eccodes_f90_int.f90 +++ b/fortran/eccodes_f90_int.f90 @@ -96,8 +96,8 @@ codes_get_real4, & codes_get_real8, & codes_get_string, & + codes_get_string_array, & codes_get_int_array, & - codes_get_byte_array, & codes_get_real4_array, & codes_get_real8_array end interface codes_get diff --git a/fortran/eccodes_f90_long_int.f90 b/fortran/eccodes_f90_long_int.f90 index 4c8fdd440..6e737c806 100644 --- a/fortran/eccodes_f90_long_int.f90 +++ b/fortran/eccodes_f90_long_int.f90 @@ -100,8 +100,8 @@ codes_get_real4, & codes_get_real8, & codes_get_string, & + codes_get_string_array, & codes_get_int_array, & - codes_get_byte_array, & codes_get_real4_array, & codes_get_real8_array end interface codes_get diff --git a/fortran/eccodes_f90_tail.f90 b/fortran/eccodes_f90_tail.f90 index cceea7a93..e4efde2ce 100644 --- a/fortran/eccodes_f90_tail.f90 +++ b/fortran/eccodes_f90_tail.f90 @@ -828,6 +828,49 @@ subroutine codes_get_string ( gribid, key, value, status ) call grib_get_string ( gribid, key, value, status ) end subroutine codes_get_string +subroutine codes_get_string_array ( gribid, key, value, status ) + integer(kind=kindOfInt), intent(in) :: gribid + character(len=*), intent(in) :: key + character(len=*), dimension(:),allocatable,intent(inout) :: value + character :: cvalue(size(value)*len(value(0))) + integer(kind=kindOfInt),optional, intent(out) :: status + + integer(kind=kindOfInt) :: iret + integer(kind=kindOfInt) :: nb_values + integer(kind=kindOfInt) :: slen + integer(kind=kindOfInt) :: size_value + integer(kind=kindOfInt) :: i,s,j + + + if (allocated(value) .eqv. .false.) then + iret=CODES_NULL_POINTER + if (present(status)) then + status = iret + else + call grib_check(iret,'grib_get',key) + endif + end if + + nb_values=size(value) + slen=len(value(0)) + iret=grib_f_get_string_array ( gribid, key, cvalue , nb_values, slen ) + value=transfer(cvalue,value) + if (iret==0 .and. nb_values==1 .and. size_value/=1) then + do i=2,size_value + value(i)=value(1) + enddo + endif + if (iret /= 0) then + call grib_f_write_on_fail(gribid) + endif + if (present(status)) then + status = iret + else + call grib_check(iret,'grib_get',key) + endif + +end subroutine codes_get_string_array + ! Note: This function supports the allocatable array attribute ! ------------------------------------------------------------- subroutine codes_get_int_array ( gribid, key, value, status ) @@ -861,9 +904,9 @@ subroutine codes_get_int_array ( gribid, key, value, status ) value(i)=value(1) enddo endif - if (iret /= 0) then - call grib_f_write_on_fail(gribid) - endif + if (iret /= 0) then + call grib_f_write_on_fail(gribid) + endif if (present(status)) then status = iret else @@ -926,7 +969,6 @@ subroutine codes_get_byte_array ( gribid, key, value, length, status ) integer(kind=kindOfInt), optional, intent(out) :: status integer(kind=kindOfInt) :: iret integer(kind=kindOfInt) :: nb_values - character :: bytes(size(value)) call grib_get_byte_array ( gribid, key, value, length, status ) end subroutine codes_get_byte_array @@ -1144,7 +1186,6 @@ subroutine codes_set_byte_array ( gribid, key, value, length, status ) integer(kind=kindOfInt), optional, intent(out) :: status integer(kind=kindOfInt) :: iret integer(kind=kindOfInt) :: nb_values - character :: bytes(size(value)) call grib_set_byte_array ( gribid, key, value, length, status ) end subroutine codes_set_byte_array diff --git a/fortran/grib_api_externals.h b/fortran/grib_api_externals.h index 2bbd91478..7e764553e 100644 --- a/fortran/grib_api_externals.h +++ b/fortran/grib_api_externals.h @@ -32,7 +32,8 @@ integer, external :: grib_f_get_int, grib_f_get_long,grib_f_get_int_array, & grib_f_get_real8, grib_f_get_real8_array, & grib_f_get_real4_element, grib_f_get_real8_element, & grib_f_get_real4_elements, grib_f_get_real8_elements, & - grib_f_get_string,grib_f_is_missing,grib_f_is_defined + grib_f_get_string,grib_f_get_string_array, & + grib_f_is_missing,grib_f_is_defined integer, external :: grib_f_new_from_index, & grib_f_index_new_from_file, & grib_f_index_add_file, & diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index 99d0c2089..ddcb0f40e 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -162,6 +162,16 @@ static void czstr_to_fortran(char* str,int len) *p=' '; } +static void czstr_to_fortran_replace0(char* str,int len) +{ + char *p,*end; + p=str; end=str+len-1; + while (p != end) { + if (*p=='\0') *p=' '; + p++; + } +} + static void fort_char_clean(char* str,int len) { char *p,*end; @@ -2697,6 +2707,44 @@ int grib_f_set_real8_array(int* gid, char* key, double *val, int* size, int len) return grib_f_set_real8_array_( gid, key, val, size, len); } +/*****************************************************************************/ +int grib_f_get_string_array_(int* gid, char* key, unsigned char* val,int* nvals,int* slen,int len,int len2){ + + grib_handle *h = get_handle(*gid); + int err = GRIB_SUCCESS; + size_t i; + char buf[1024]; + size_t lsize = *nvals; + char** cval=0; + char* p=val; + + if(!h) return GRIB_INVALID_GRIB; + + + cval=(char**)grib_context_malloc_clear(h->context,sizeof(char*)*lsize); + err = grib_get_string_array(h, cast_char(buf,key,len), cval, &lsize); + if (err) return err; + + if (strlen(cval[0])>*slen) err=GRIB_ARRAY_TOO_SMALL; + + for (i=0;icontext,cval); + /*remember to deallocate each string*/ + + return err; +} + +int grib_f_get_string_array__(int* gid, char* key, unsigned char* val,int* nvals,int* slen, int len,int len2){ + return grib_f_get_string_array_( gid, key, val,nvals,slen,len,len2); +} +int grib_f_get_string_array(int* gid, char* key, unsigned char* val,int* nvals,int* slen, int len,int len2){ + return grib_f_get_string_array_( gid, key, val, nvals, slen, len,len2); +} + /*****************************************************************************/ int grib_f_get_string_(int* gid, char* key, char* val,int len, int len2){ diff --git a/src/grib_accessor_class_bufr_data_array.c b/src/grib_accessor_class_bufr_data_array.c index 1e1660382..b20b13a24 100644 --- a/src/grib_accessor_class_bufr_data_array.c +++ b/src/grib_accessor_class_bufr_data_array.c @@ -490,6 +490,7 @@ static grib_darray* decode_double_array(grib_context* c,unsigned char* data,long } else { dval=localReference*modifiedFactor; } + grib_context_log(c, GRIB_LOG_DEBUG," modifiedWidth=%ld lval=%ld dval=%g", modifiedWidth,lval,dval); grib_darray_push(c,ret,dval); } From 73248a326061c4f7c63bc062a2ce5c3336a721bb Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 16 Jun 2016 12:56:57 +0100 Subject: [PATCH 06/10] Fix build break --- fortran/eccodes_f90_int.f90 | 2 +- fortran/eccodes_f90_long_int.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fortran/eccodes_f90_int.f90 b/fortran/eccodes_f90_int.f90 index 4c2a28500..1b005c862 100644 --- a/fortran/eccodes_f90_int.f90 +++ b/fortran/eccodes_f90_int.f90 @@ -96,7 +96,7 @@ codes_get_real4, & codes_get_real8, & codes_get_string, & - codes_get_string_array, & + codes_get_byte_array, & codes_get_int_array, & codes_get_real4_array, & codes_get_real8_array diff --git a/fortran/eccodes_f90_long_int.f90 b/fortran/eccodes_f90_long_int.f90 index 6e737c806..960f55fa9 100644 --- a/fortran/eccodes_f90_long_int.f90 +++ b/fortran/eccodes_f90_long_int.f90 @@ -100,7 +100,7 @@ codes_get_real4, & codes_get_real8, & codes_get_string, & - codes_get_string_array, & + codes_get_byte_array, & codes_get_int_array, & codes_get_real4_array, & codes_get_real8_array From 74f0f63e5f63c8d3bb7c98795895c8712f724db5 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 16 Jun 2016 13:57:00 +0100 Subject: [PATCH 07/10] ECC-269: refactoring and eliminate compiler warnings --- fortran/eccodes_f90_tail.f90 | 20 +++++++------------- fortran/grib_fortran.c | 19 +++++++++---------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/fortran/eccodes_f90_tail.f90 b/fortran/eccodes_f90_tail.f90 index e4efde2ce..10adf9d4d 100644 --- a/fortran/eccodes_f90_tail.f90 +++ b/fortran/eccodes_f90_tail.f90 @@ -829,19 +829,17 @@ subroutine codes_get_string ( gribid, key, value, status ) end subroutine codes_get_string subroutine codes_get_string_array ( gribid, key, value, status ) - integer(kind=kindOfInt), intent(in) :: gribid - character(len=*), intent(in) :: key + integer(kind=kindOfInt), intent(in) :: gribid + character(len=*), intent(in) :: key character(len=*), dimension(:),allocatable,intent(inout) :: value - character :: cvalue(size(value)*len(value(0))) - integer(kind=kindOfInt),optional, intent(out) :: status + integer(kind=kindOfInt),optional, intent(out) :: status + character :: cvalue(size(value)*len(value(0))) integer(kind=kindOfInt) :: iret integer(kind=kindOfInt) :: nb_values integer(kind=kindOfInt) :: slen - integer(kind=kindOfInt) :: size_value integer(kind=kindOfInt) :: i,s,j - if (allocated(value) .eqv. .false.) then iret=CODES_NULL_POINTER if (present(status)) then @@ -855,14 +853,10 @@ subroutine codes_get_string_array ( gribid, key, value, status ) slen=len(value(0)) iret=grib_f_get_string_array ( gribid, key, cvalue , nb_values, slen ) value=transfer(cvalue,value) - if (iret==0 .and. nb_values==1 .and. size_value/=1) then - do i=2,size_value - value(i)=value(1) - enddo + + if (iret /= 0) then + call grib_f_write_on_fail(gribid) endif - if (iret /= 0) then - call grib_f_write_on_fail(gribid) - endif if (present(status)) then status = iret else diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index ddcb0f40e..586de735a 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -162,7 +162,7 @@ static void czstr_to_fortran(char* str,int len) *p=' '; } -static void czstr_to_fortran_replace0(char* str,int len) +/*static void czstr_to_fortran_replace0(char* str,int len) { char *p,*end; p=str; end=str+len-1; @@ -170,7 +170,7 @@ static void czstr_to_fortran_replace0(char* str,int len) if (*p=='\0') *p=' '; p++; } -} +}*/ static void fort_char_clean(char* str,int len) { @@ -2708,8 +2708,8 @@ int grib_f_set_real8_array(int* gid, char* key, double *val, int* size, int len) } /*****************************************************************************/ -int grib_f_get_string_array_(int* gid, char* key, unsigned char* val,int* nvals,int* slen,int len,int len2){ - +int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen,int len,int len2) +{ grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; size_t i; @@ -2720,7 +2720,6 @@ int grib_f_get_string_array_(int* gid, char* key, unsigned char* val,int* nvals, if(!h) return GRIB_INVALID_GRIB; - cval=(char**)grib_context_malloc_clear(h->context,sizeof(char*)*lsize); err = grib_get_string_array(h, cast_char(buf,key,len), cval, &lsize); if (err) return err; @@ -2728,9 +2727,9 @@ int grib_f_get_string_array_(int* gid, char* key, unsigned char* val,int* nvals, if (strlen(cval[0])>*slen) err=GRIB_ARRAY_TOO_SMALL; for (i=0;icontext,cval); /*remember to deallocate each string*/ @@ -2738,10 +2737,10 @@ int grib_f_get_string_array_(int* gid, char* key, unsigned char* val,int* nvals, return err; } -int grib_f_get_string_array__(int* gid, char* key, unsigned char* val,int* nvals,int* slen, int len,int len2){ +int grib_f_get_string_array__(int* gid, char* key, char* val,int* nvals,int* slen, int len,int len2){ return grib_f_get_string_array_( gid, key, val,nvals,slen,len,len2); } -int grib_f_get_string_array(int* gid, char* key, unsigned char* val,int* nvals,int* slen, int len,int len2){ +int grib_f_get_string_array(int* gid, char* key, char* val,int* nvals,int* slen, int len,int len2){ return grib_f_get_string_array_( gid, key, val, nvals, slen, len,len2); } From 308944fbf4e15421fb50f2ee6da4354a04f6a28e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 16 Jun 2016 14:30:01 +0100 Subject: [PATCH 08/10] Remove unused argument --- fortran/grib_fortran.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index 586de735a..1cd017608 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -2708,7 +2708,7 @@ int grib_f_set_real8_array(int* gid, char* key, double *val, int* size, int len) } /*****************************************************************************/ -int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen,int len,int len2) +int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen,int len) { grib_handle *h = get_handle(*gid); int err = GRIB_SUCCESS; @@ -2737,11 +2737,11 @@ int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen return err; } -int grib_f_get_string_array__(int* gid, char* key, char* val,int* nvals,int* slen, int len,int len2){ - return grib_f_get_string_array_( gid, key, val,nvals,slen,len,len2); +int grib_f_get_string_array__(int* gid, char* key, char* val,int* nvals,int* slen, int len){ + return grib_f_get_string_array_( gid, key, val,nvals,slen,len); } -int grib_f_get_string_array(int* gid, char* key, char* val,int* nvals,int* slen, int len,int len2){ - return grib_f_get_string_array_( gid, key, val, nvals, slen, len,len2); +int grib_f_get_string_array(int* gid, char* key, char* val,int* nvals,int* slen, int len){ + return grib_f_get_string_array_( gid, key, val, nvals, slen, len); } /*****************************************************************************/ From 0461c32b061d5fa1579272f559a994a3c373f6ec Mon Sep 17 00:00:00 2001 From: Enrico Fucile Date: Thu, 16 Jun 2016 14:55:57 +0100 Subject: [PATCH 09/10] fixed memory error --- fortran/grib_fortran.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index 1cd017608..c2d2b4cf5 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -2727,7 +2727,7 @@ int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen if (strlen(cval[0])>*slen) err=GRIB_ARRAY_TOO_SMALL; for (i=0;i Date: Thu, 16 Jun 2016 18:49:55 +0100 Subject: [PATCH 10/10] Remove references to p4 --- data/ret.sh | 2 -- doxygen/build_gribex.ksh | 4 ---- doxygen/make_dox.sh | 2 +- tools/make_dox.ksh | 14 +++++--------- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/data/ret.sh b/data/ret.sh index 708178957..43cc8d6b7 100755 --- a/data/ret.sh +++ b/data/ret.sh @@ -38,7 +38,6 @@ do tar="full_${files[i]}" EOF - p4 edit ${files[i]} if [[ ${precision[i]} -gt 0 ]] then grib_set -r -s bitsPerValue=0,decimalScaleFactor=${precision[i]} full_${files[i]} ${files[i]} @@ -53,4 +52,3 @@ EOF grib_dump ${grib2} > /dev/null done - diff --git a/doxygen/build_gribex.ksh b/doxygen/build_gribex.ksh index 58cab912c..c9b1289d7 100755 --- a/doxygen/build_gribex.ksh +++ b/doxygen/build_gribex.ksh @@ -4,13 +4,9 @@ prov=$1 dest=$2 mkdir -p $dest -p4 edit $dest/*.html for file in $prov/*.html do f=`basename $file` cat head.html $file tail.html > $dest/$f done - -p4 add $dest/*.html - diff --git a/doxygen/make_dox.sh b/doxygen/make_dox.sh index afeb38be2..745fd05dc 100755 --- a/doxygen/make_dox.sh +++ b/doxygen/make_dox.sh @@ -3,7 +3,7 @@ cd ../tools ./make_dox.ksh cd ../doxygen -p4 edit ../html/* + rm -f ../html/* touch ../html/Makefile.am doxygen grib_api_wiz.cfg diff --git a/tools/make_dox.ksh b/tools/make_dox.ksh index 2add4d4bf..8b543f665 100755 --- a/tools/make_dox.ksh +++ b/tools/make_dox.ksh @@ -3,30 +3,26 @@ set -ex set -A tools grib_dump grib_ls grib_get grib_copy grib_set grib_filter grib_compare grib_get_data grib_keys grib_index_build export DOXYGEN_USAGE=1 -p4 edit tools.dox - cat tools_head.dox > tools.dox for tool in ${tools[@]} do - p4 edit ${tool}.dox - -set +e + set +e ./$tool > ${tool}.dox -set -e + set -e -cat >> ${tool}.dox <> ${tool}.dox <> ${tool}.dox -cat >> ${tool}.dox <> ${tool}.dox <> tools.dox <> tools.dox <