#include #include "grib_api_internal.h" #include "netcdf.h" #include "test.h" void handle_error(int err,const char* caller); void preproc(double* values,double bias,int length,int mode); int main(int argc, char *argv[]) { FILE *f; FILE *fl; int i,ii,jj; grib_context* gc; grib_handle* gh; double* grib_values; double* nc_values; size_t *pstart,*pcount; int dimids[NC_MAX_VAR_DIMS]; int varid,ndims; char varname[NC_MAX_NAME+1]; int dimlen,length; int* dimlens; int err,ncid,natts; nc_type vartype; double nc_vmax,nc_vmin,val; int nc_imax,nc_imin; double grib_vmax,grib_vmin; int grib_imax,grib_imin; int latid,lonid; size_t size = 0; const void* buffer = NULL; int ret=0; double max_error=0; int id_max_error=0; #if 0 double R,xscale,scaled_vmax; int D; #endif int numberOfFigures; double referenceValue; long decimalScaleFactor,numberOfBitsContainingEachPackedValue,binaryScaleFactor; long typeOfPreProcessing; double preProcessingParameter; /* ---------- Variables ------------*/ varid=5; latid=2; lonid=3; numberOfFigures=4; /*---------------------------------*/ gc = grib_context_get_default(); gh=grib_handle_new_from_samples(NULL,"GRIB1"); if (!gh) { printf("Error: unable to create grib_handle\n"); exit(1); } grib_set_long(gh,"editionNumber",2); grib_set_long(gh,"gridDefinitionTemplateNumber",61); err = nc_open("nc_data", NC_NOWRITE, &ncid); handle_error(err,"nc_open"); err=nc_inq_var(ncid,varid,varname,&vartype,&ndims,dimids,&natts); handle_error(err,"nc_inq_var"); pstart=(size_t*)malloc(ndims*sizeof(size_t)); pcount=(size_t*)malloc(ndims*sizeof(size_t)); dimlens=(int*)malloc(ndims*sizeof(int)); length=1; for (i=0;inc_vmax) { nc_vmax=val; nc_imax=i; } if (valgrib_vmax) { grib_vmax=val; grib_imax=i; } if (val