Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Quote:
Hello recently I am using ECMWF library to read GRIB file and everything is ok when I built the program but it could not read the GRIB file so it gives me "End of resource reached when reading message" this error even though i am using different GRIB file. thank you for answering.

C++
#include <stdio.h>
#include <stdlib.h>

extern "C"{
#include <grib_api.h>
}

#include <qdebug.h>
#include <QtCore/QCoreApplication>

int main(int argc, char *argv[])
{
	QCoreApplication a(argc, argv);

	int err = 0,i;
	double *values = NULL;
	double max,min,average;
	size_t values_len= 0;

	//FILE* in = NULL;
	 
	grib_handle *h = NULL;

	const char* path = "exmaple.grb";

	FILE* in = fopen( path,"r" );

	if(!in) 
	{
		printf("ERROR: unable to open file %s\n",path);
		return 1;
    }

	h = grib_handle_new_from_file(0,in,&err); "problem is here err = -44 it means" 
                                       "End of resource reached when reading message"

	if (h == NULL)
	{
       printf("Error: unable to create handle from file %s\n",path);
    }

	GRIB_CHECK(grib_get_size(h,"values",&values_len),0);

	return a.exec();
} 
Posted
Updated 18-Nov-15 15:25pm
v2
Comments
Richard MacCutchan 19-Nov-15 4:06am    
Sounds as if the file contents are not valid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900