/* * C Implementation: eps_wind_rose * * Description: * * Author: Enrico Fucile , (C) 2006 * * Copyright: See COPYING file that comes with this distribution * */ #include #include #include #include #include "grib_api.h" void usage(char* prog) { printf("\nUsage: %s direction_grib_file intensity_grib_file",prog); exit(1); } int get_wind_rose_index(double v); int get_sea_state_index(double v); int main(int argc, char** argv) { FILE* fdir = NULL; FILE* fint = NULL; int i,j,k; grib_context* c=NULL; char* fintname = NULL; char* fdirname = NULL; grib_handle *hdir = NULL; grib_handle *hint = NULL; grib_handle *hold = NULL; const void *buffer=0; size_t size=0; double* values_dir=0; double* values_int=0; size_t size=0; char* ofile[100]={0,}; size_t values_count=0; char* wind_rose[8]={"nord","nord_east", "east","south_east", "south","south_west", "west","nord_west"}; size_t wind_rose_count=sizeof(wind_rose); char* sea_state[9]={"calm","smooth","slight", "moderate","rough","very_rough", "high","very_high","phenomenal"}; double* values[72]={0,}; size_t sea_state_count=sizeof(sea_state); int eps_members=0,steps=0; long member=0,step=0,ltmp=0; int new_step=0; int handle_count=0; char short_name_dir[10]={0,}; char short_name_int[10]={0,}; char tmp[10]={0,}; size_t len=0; int err1=0,err2=0; if (argc != 3) usage(argv[0]); /* direction file */ fdirname=argv[1]; fdir = fopen(fdirname,"r"); if (!fdir) { printf("ERROR: unable to open file %s\n",fdirname); return 1; } /* intensity file */ fintname=argv[2]; fint = fopen(fintname,"r"); if(!fint) { printf("ERROR: unable to open file %s\n",fintname); fclose(fdir); return 1; } k=0; for (i=0;i