GRIB file version 1 generation library This is a C++ library to generate GRIB version 1 files. It is based on Wesley Ebisuzaki code for wgrib/gribw wrapped into some convenient objects. Relevant objects are #) GRIB_FILE Interface for accessing in Read or Write (+append) a GRIB file on disk. #) GRIB MESSAGE To access or compose and encode a grib message. #) GRIB_FIELD The phisical parameter stored in the message #) GRIB_GRID The grid definition #) GRIB_LEVEL The level of the grid #) GRIB_TIME The time of the grid Every object srore as public data all informations. Example to read a GRIB file from disk and dump contents: [...] GRIB_FILE gf; int ret = gf.OpenRead("grib.grb"); if (ret != 0) return -1; GRIB_MESSAGE m; while ((ret = gf.ReadMessage(m)) == 0) { std::cout << "Message: " << m.field.VarDescription( ) << std::endl; std::cout << "Grid : " << m.grid << std::endl << "Level: " << m.level << std::endl << "Time : " << m.gtime << std::endl << std::endl; // data field is at m.field.vals for (int i = 0; i < field.size; i ++) std::cout << "Value [" << i << "] :" << m.field.vals[i] << std::endl; } ret = gf.Close( ); if (ret != 0) return -1; [...] Example to write a field to disk: [...] GRIB_FILE gn; GRIB_MESSAGE m; GRIB_GRID g; GRIB_LEVEL l; GRIB_TIME t; GRIB_FIELD f; ret = gn.OpenWrite("outtest.grb"); if (ret != 0) return -1; float ff[65160]; // Read temperature values [...] [...] // set time: 12 hour forecast from 2004-07-03 12:00:00 UTC t.set_referencetime(2004, 7, 3, 12, 0); t.set_forecast_hour(12); // set level pressure at 1000 mb l.set_pressure(1000.0); // set grid g.set_size(360, 181); g.set_regular_latlon(90.0, 0.0, -90.0, -1.0, 1.0, 1.0); // set field values of temperature f.set_field(GRIB_PARAMETER_TMP__, ff, 65160, 9.9991e20, 9.9991e20); f.set_scale(-2); m.set_time(t); m.set_grid(g); m.set_level(l); m.set_field(f); // Encode message m.Encode( ); // Write message gn.WriteMessage(m); // Repeat for all times and levels [...] [...] ret = gn.Close( ); if (ret != 0) return -1; [...]