/************************************************************************************ * * * Program - rd_ax_balln.c * * * * AUTHOR: Mandira Mukherjee * * * * Date: 10/14/94 * * * * PURPOSE/DESCRIPTION: The purpose of the program is to read the Balloon Data for * * FIRE_ASTEX_NAT dataset. The Tethered Balloon data contains * * 9 files from day 11th june 19th June. There are 8 parameters* * in the dataset. * * To test the validity of the different estimates and to * * explain the probable discrepancies , one needs to measure * * temperature, humidity and wind speed gradients: for that * * purpose the tethered balloon will provide the gradients * * and surface layer depth. This directory contains 9 files * * from day 11 to day 19. The granulenames with "a" or "b" * * will indicate first part and the second part. * * * ************************************************************************************/ #include #include #include #include #include #include #include #define RECSIZE 80 #define PARAMS 8 main (argc,argv) int argc; char *argv[]; { void Print_heading(); /* print heading of the data set */ int Get_par_type(); /* displays choice of parameters */ char filename1[MAXPATHLEN+1]; /* name of the file as first argv */ char buf[256]; /* buffer to read strings at a time */ char par_type[10],tmp[10]; /* storage of requested parameters */ FILE *fptr; /* file pointer */ int i,rec_count,count, /* counters */ param[PARAMS]; /* array of requested parameters */ double hour,Z,ta,Pmb,H,V,D,Q; /* variables 1 thru 8 */ /*********************************************************************************/ void Print_heading(); for (count = 0;count < PARAMS; count++) { param[count] = -99; } (void) Print_heading(); if (argc == 1) { printf("Please enter the datafile name: "); scanf("%s",filename1); } else { strcpy (filename1,argv[1]); } printf ("\n\n"); printf("The datafile to be read is %s \n", filename1); Get_par_type(tmp,par_type,count,param); /*************** Read dataset and print the required Heading and the data********/ count = 0; /*Print header of requested Parameters*/ for ( count =1; count <= PARAMS;count++) { switch (param[count - 1]) { case 0: printf(" Hour "); break; case 1: printf (" Z "); break; case 2: printf(" ta "); break; case 3: printf(" Pmb "); break; case 4: printf(" H "); break; case 5: printf(" Vm/s "); break; case 6: printf(" Dir "); break; case 7: printf(" q(g/kg) "); break; default: break; } /* end of case statement */ } /* end of for loop */ printf("\n"); /**************************************************************************/ if ((fptr = fopen(filename1,"r"))==NULL) { printf("***************************************************\n"); printf("ERROR-UNABLE TO OPEN DATA FILE. PROGRAM HAS TERMINATED\n"); printf("******************************************************\n"); exit(-1); } fgets(buf,80,fptr); rec_count = 0; while ((feof(fptr)) ==0) { hour = 0.0; Z = 0.0; ta = 0.0; Pmb = 0.0; H = 0.0; V = 0.0; D = 0.0; Q = 0.0; fgets(buf,80,fptr); sscanf(buf,"%lf%lf%lf%lf%lf%lf%lf%lf",&hour,&Z,&ta,&Pmb,&H,&V,&D,&Q); if ((feof(fptr)!=0)) { printf("\n\n\n"); printf("----------------------------------------------------\n"); printf("*THE END OF FILE HAS BEEN REACHED........ \n"); printf(" THIS IS A NORMAL TERMINATION........... \n"); printf(" THE TOTAL NUMBER OF RECORDS: %d\n", rec_count); printf("-----------------------------------------------------\n"); exit(0); } ++rec_count; for ( count = 1; count <= PARAMS; count++) { switch (param[count -1]) { case 0: printf(" %.3lf",hour); break; case 1: printf (" %.3lf",Z); break; case 2: printf (" %.3lf",ta); break; case 3: printf (" %.3lf", Pmb); break; case 4: printf (" %.3lf",H); break; case 5: printf (" %.3lf",V); break; case 6: printf (" %.3lf",D); break; case 7: printf (" %.3lf",Q); break; } /* End of Switch */ } /*End of for */ printf ("\n"); } /* End of while */ fclose(fptr); } /* End of main */ /******************************************************************************** * * * FILE: Print_heading * * * * AUTHOR: Mandira Mukherjee * * * * PURPOSE/DESCRIPTION: Prints the heading for the FIRE_ASTEX_NAT_SOFIA program. * * * * INVOCATION: * * (void) Print_heading() * * * * INTERNAL ROUTINES: * * NONE. * * * * EXTERNAL ROUTINES: * * NONE * * * *********************************************************************************/ void Print_heading() { printf("\n\n"); printf("***********************************************************\n"); printf("* *\n"); printf("* FIRE_ASTEX_NAT_SOFIA *\n"); printf("* Read Program *\n"); printf("* *\n"); printf("* Version 1.00 September 30, 1994 *\n"); printf("* *\n"); printf("***********************************************************\n"); printf("\n"); } /* End of Printing */ /********************************************************************************* * * * FILE: Get_par_type * * * * AUTHOR: Mandira Mukherjee. * * * * PURPOSE/DESCRIPTION: * * There are eight parameters in FIRE_ASTEX_NAT_SOFIA_BALLOON * * dataset.They are hour,Height in m(z), Atmospheric pressure * * in Pmb(P), Air temperature in degree centigrade(ta), * * Relative humidity in %(H%), Wind speed in m/s (V), Wind * * direction in degree (dir),specific humidity in g/kg (q) . * * * * INVOCATION: * * (void) Get_par_type * * * * INTERNALROUTINES: * * NONE: * *********************************************************************************/ int Get_par_type(tmp,par_type,count,param) int count,param[PARAMS]; char *par_type,*tmp; { int pe; printf("\n"); printf("Eight parameters of information were \n"); printf("collected at each event. These parameters are: \n"); printf("\n"); printf(" NO. Parameter Units \n"); printf(" ----- ----------- ----- \n"); printf(" 1. Time Hour \n"); printf(" 2. Height Meter \n"); printf(" 3. Temperature C \n"); printf(" 4. Pressure hPa \n"); printf(" 5. Humidity percent \n"); printf(" 6. Wind Speed m/s \n"); printf(" 7. Wind Direction degrees \n"); printf(" 8. Specific Humidity g/Kg \n"); printf("\n\n"); /* SELECT PARAMETERS */ par_type[0]= 'q'; while ((par_type[0]!='a') && (par_type[0] != 'A') && (par_type[0] != 's') && (par_type[0]!= 'S') && (par_type[0] != 'X') && (par_type[0] != 'x')) { printf(" Please indicate the number of parameters to be printed \n"); printf(" Please select: a or A for ALL parameters\n"); printf(" S or s for some and X or x to exit the program\n\n\n"); scanf("%s",par_type); strcpy(tmp,par_type); } if ((strcmp(par_type,"a")== 0) || (strcmp(par_type,"A")== 0)) { for (count =0; count <= PARAMS; count++) param[count]= count; } else if ((strcmp(par_type, "s")== 0) || (strcmp(par_type,"S")== 0)) { printf ("**********Parameters selection Requested*************\n"); for (count =1; count <= PARAMS;count++) { printf("Enter q to end selection or X to exit program\n"); printf("Please enter parameter #%d-------->",count); scanf("%s",par_type); printf("%s\n",par_type); strcpy(tmp,par_type); if ((strcmp(par_type,"X")==0) || (strcmp(par_type,"x")== 0)) { printf ("\n\n"); printf("*******EXIT PROGRAM***********\n"); exit(-1); } if(((strcmp(par_type,"q")== 0) || (strcmp(par_type,"Q")== 0))&& (count == 1)) { printf("**********NO SELECTION OF PARAMETERS**********\n"); printf("*********EXIT PROGRAM*************************\n"); exit(-1); } if ((strcmp(par_type,"q")== 0) || (strcmp(par_type,"Q")== 0)) { break; } if ((atoi(tmp) > PARAMS) || (atoi(tmp) <= 0)) { printf("\n"); printf(" THE TOTAL PARAMETERS AVAILABLE ARE 1 THRU 8\n"); printf(" THE REQUESTED PARAMETER IS OUT OF RANGE\n"); strcpy(tmp," "); } pe = atoi(par_type); param[count-1]= pe -1; } /*end of for statement */ } /* end of else if */ else if ((strcmp(par_type,"x")== 0) || (strcmp(par_type,"X")== 0)) { printf ("\n\n"); printf("****************EXIT PROGAM*****************\n"); exit(0); } } /* end of the get_type function */ /*********************************************************************************/