/************************************************************************************ * * * Program - rd_ax_sofia_rad.c * * * * AUTHOR: Mandira Mukherjee * * * * Date: 10/14/94 * * * *PURPOSE/DESCRIPTION: * * The goals of ASTEX were pursued by combining measurements * * from aircraft, satellites, ships and islands. Surface based * * measurements were made from the island of Santa Maria (in * * the Azores) and Porto Santo (near Madeira) and four research* * vessels- NOAA's Oceanus and Malcolm Baldrige, the German Ship* * Valdivia and the French Ship Le Suroit. Soundings were made * * from Le Suroit and Oceanus. * * * * The above dataset contains seven parameters with following * * informations- * * 1 pressure ( min minima maxima root mean square) * * 2 net radiation ( min minima maxima root mean square) * * 3 Solar radiation ( min minima maxima root mean square)* * 4 Infra_red radiation ( min minima maxima root mean square)* * 5 a resistance of control( min minima maxima root mean square)* * 6 temperature of box ( min minima maxima root mean square) * * 7 temperature box power 4 (min minima maxima root mean square)* * * * Pressure is computed as parameter 1 / 4.54438e-3 in hectopascals* * net radiation as parameter 2* 12.9*1000. in Wm-2 * * solar radiation as parameter 3* 12.9*1000 in Wm-2 * * IR radiation as parameter * * 4/.0000039+(5.67e-8)*parameter7-.026*solar radiation * * data quality can be inferred in computing the albedo : * * data good during day time in general* * * ************************************************************************************/ #include #include #include #include #include #include #include #define RECSIZE 80 #define PARAMS 7 main (argc,argv) int argc; char *argv[]; { void Print_heading(); /* prints the heading of the data set */ int Get_par_type(); /* displays the 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 parameter */ FILE *fptr; /* file pointer */ int i,rec_count,count, /* counter */ param[PARAMS], /* array of requested parameter */ day,hour; int parnum1,parnum2,parnum3,parnum4, parnum5,parnum6,parnum7; /* var 1 thru 7 in integer */ char min1[15],minma1[15],maxma1[15],dev1[15]; char min2[12],minma2[12],maxma2[12],dev2[15]; char min3[12],minma3[12],maxma3[12],dev3[15]; char min4[12],minma4[12],maxma4[12],dev4[15]; char min5[12],minma5[12],maxma5[12],dev5[15]; char min6[12],minma6[12],maxma6[12],dev6[15]; char min7[12],minma7[12],maxma7[12],dev7[15]; /* minima and maxma values 1 thru 7 */ /*********************************************************************************/ 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); /**************************************************************************/ 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; while ((feof(fptr)) ==0) { for (i =0; i< 16;i++) { fgets(buf,80,fptr); { if ( i==0) { printf("%s\n",buf); } else if ( i == 2) { sscanf(buf," %d %s %s %s %s",&parnum1,min1,minma1,maxma1,dev1); } else if ( i == 4) { sscanf(buf," %d %s %s %s %s",&parnum2,min2,minma2,maxma2,dev2); } else if ( i== 6) { sscanf(buf," %d %s %s %s %s",&parnum3,min3,minma3,maxma3,dev3); } else if ( i == 8) { sscanf(buf," %d %s %s %s %s",&parnum4,min4,minma4,maxma4,dev4); } else if ( i == 10) { sscanf(buf," %d %s %s %s %s",&parnum5,min5,minma5,maxma5,dev5); } else if ( i == 12) { sscanf(buf," %d %s %s %s %s",&parnum6,min6,minma6,maxma6,dev6); } else if ( i == 14) { sscanf(buf," %d %s %s %s %s",&parnum7,min7,minma7,maxma7,dev7); } } } /* end of 16 for loops */ printf("\n"); 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(" PRESSURE %d %s %s %s %s\n",parnum1,min1,minma1,maxma1,dev1); break; case 1: printf ("NET RAD %d %s %s %s %s\n",parnum2,min2,minma2,maxma2,dev2); break; case 2: printf ("SOLAR RAD %d %s %s %s %s\n",parnum3,min3,minma3,maxma3,dev3); break; case 3: printf ("INF-RED RAD %d %s %s %s %s\n",parnum4,min4,minma4,maxma4,dev4); break; case 4: printf ("A RES. CONT. %d %s %s %s %s\n",parnum5,min5,minma5,maxma5,dev5); break; case 5: printf ("TEMP BOX %d %s %s %s %s\n",parnum6,min6,minma6,maxma6,dev6); break; case 6: printf ("TEMP BOX4 %d %s %s %s %s\n",parnum7,min7,minma7,maxma7,dev7); 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_PRESSURE_RADIATION *\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 seven parameters in FI_AX_NAT_SOFIA_PRESSURE_RAD * * dataset.They are pressure, Net Radiation, Solar Radiation, * * Infra_red Radiation, A resistance of control, Temperature * * of box, Temperature of box Power 4. * * * * INVOCATION: * * (void) Get_par_type * * * * INTERNALROUTINES: * * NONE: * *********************************************************************************/ int Get_par_type(tmp,par_type,count,param) int count,param[15]; char *par_type,*tmp; { char par[15]; /* Temp var to store type */ int pe; printf("\n"); printf("Seven 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. Pressure hPa \n"); printf(" 2. Net Radiation Wm-2 \n"); printf(" 3. Solar Radiation Wm-2 \n"); printf(" 4. Infra_red Radiation Wm-2 \n"); printf(" 5. A resistance of control \n"); printf(" 6. Temperature of box C \n"); printf(" 7. Temperature of box Power 4 C \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 7\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 */ /*************************************************************************************/