/************************************************************************************ * * * Program - pos2.c * * * * AUTHOR: Mandira Mukherjee and Laura Scott * * * * Date: 10/14/94 * * * * PURPOSE/DESCRIPTION: The purpose of the program is to read the BUOY POS dataset. * * * ************************************************************************************/ #include #include #include #include #include #include #include #define RECSIZE 80 #define PARAMS 24 int amount; main (argc,argv) int argc; char *argv[]; { void Print_heading(); int Get_par_type(); 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]; FILE *fptr; /* file pointer */ int i,rec_count,count,param[10],day,hour; int col1,col2,col3,col4,col7; double col5,col6; double Alatval2,Alatmin,Alatmax; double Alonval2,Alonmin,Alonmax; int bnum,yrmx,yrmn,daymx,daymn,locmx,locmn; char name[5]; /*********************************************************************************/ (void) Print_heading(); Get_par_type(tmp,par_type,count,param); if (argc == 1) { printf(" Please enter in the input file name\n\n"); scanf("%s", filename1); } else strcpy(filename1,argv[1]); bnum=atoi(strncpy(name,filename1,5)); printf(" buoy num is %d\n", bnum); printf("DATA FILENAME REQUESTED IS %s\n",filename1); if ((fptr = fopen(filename1,"r"))==NULL) { printf("***************************************************\n"); printf("ERROR-UNABLE TO OPEN DATA FILE. PROGRAM HAS TERMINATED\n"); printf("******************************************************\n"); exit(-1); } rec_count = 0; Alatmin = 300.0; Alatmax = -300.0; Alonmin= 300.0; Alonmax = -300.00; yrmn = 300; daymn = 300; locmn=300; fgets(buf,120,fptr); sscanf(buf,"%d %d %d %d %lf %lf %d ",&col1,&col2,&col3,&col4,&col5,&col6,&col7); /* printf("%d %d %d %d %.3lf %.3lf %d \n",col1,col2,col3,col4,col5,col6,col7);*/ while ((feof(fptr)) ==0) { if (col1 != bnum) printf(" the incorrect buoy information is in this file %d\n",col1); if (col2 > yrmx ) yrmx = col2; if (col2 < yrmn) yrmn = col2; if (col3 > daymx) daymx = col3; if (col3 < daymn) daymn = col3; if (col7 > locmx) locmx = col7; if (col7 < locmn) locmn = col7; Alatval2 = col5; if (Alatval2 < Alatmin) { Alatmin = Alatval2; } if ( Alatval2 > Alatmax) { Alatmax = Alatval2; } /* printf(" Alatmin = %3.2lf \n",Alatmin); printf(" Alatmax = %3.2lf\n",Alatmax);*/ Alonval2 = col6; if (Alonval2 < Alonmin) { Alonmin = Alonval2; } if (Alonval2 > Alonmax) { Alonmax = Alonval2; } /* printf(" Alonmin = %3.2lf \n",Alonmin); printf(" Alonmax = %3.2lf \n",Alonmax);*/ fgets(buf,80,fptr); 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"); } ++rec_count; /*printf ("count = %d",count); printf ("amount = %d",amount);*/ for ( count = 1; count <= amount; count++) { switch (param[count -1]) { case 0: printf(" %d ",col1); break; case 1: printf (" %d",col2); break; case 2: printf (" %d",col3); break; case 3: printf (" %d", col4); break; case 4: printf (" %.3lf",col5); break; case 5: printf (" %.3lf",col6); break; case 6: printf(" %d ",col7); break; } /* End of Switch */ } /*End of for */ printf("\n"); fgets(buf,120,fptr); sscanf(buf,"%d %d %d %d %lf %lf %d ",&col1,&col2,&col3,&col4,&col5,&col6,&col7); /* printf("%d %d %d %d %.3lf %.3lf %d \n",col1,col2,col3,col4,col5,col6,col7);*/ } /* End of while */ /* inspection code section printf(" year min = %d and max %d\n", yrmn,yrmx); printf(" day min %d and max %d\n", daymn, daymx); printf(" loca min %d and max %d\n", locmn, locmx); printf(" Alatmin = %3.2lf \n",Alatmin); printf(" Alatmax = %3.2lf\n",Alatmax); printf(" Alonmin = %3.2lf \n",Alonmin); printf(" Alonmax = %3.2lf \n",Alonmax);*/ 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 and Laura Scott * * * * 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; { char par[15]; /* Temp var to store type */ int pe; printf("\n"); printf("Seven parameters were collected at each event. \n"); printf("These parameters are: \n"); printf("\n"); printf(" NO. Parameter Units \n"); printf(" ----- ----------- ----- \n"); printf(" 1. Buoy id \n"); printf(" 2. Year yy \n"); printf(" 3. Julian Date ddd \n"); printf(" 4. Hour/Minute hhmm \n"); printf(" 5. North Lat deg \n"); printf(" 6. East Long deg \n"); printf(" 7. Location Indicator \n"); printf("\n\n"); 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("\n\n"); printf("*****************NO PARAMETER SELECTED*************\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 24\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); } amount=count-1; } /* end of the get_type function */ /*********************************************************************************/