/************************************************************************ * * * PROGRAM: faxrad_read.c * * * * VERSION: 1.0 DATE: July 28, 1995 * * * * PURPOSE: The purpose of this code is to provide a sample read * * program for users who order the FIRE ASTEX Radiosonde data * * which is able to read all six sites: LE Suroit, * * Malcolm Baldrige, Oceanus, Porto Santo, Santa Maria, and * * Valdivia. * * * * CONTACT: If you have any questions, please contact the Langley DAAC.* * * * Langley DAAC User and Data Services Office * * NASA Langley Research Center * * Mail Stop 157B * * Hampton, VA 23681-0001 * * USA * * * * Phone: (804)864-8656 * * FAX: (804)864-8807 * * E-Mail: userserv@eosdis.larc.nasa.gov * * * * * * ALGORITHM: None. * * * * INVOCATION: faxrad_read datafile * * WHERE: * * - optional * * input ASCII data file * * * * FILE/RECORD REFERENCES: * * Currently, this program will produce no output files. ALL * * output will be printed to the screen. * * * * EXTERNAL ROUTINES: None. * * * * INTERNAL ROUTINES: * * #include * * #include * * #include * * * * NOTES: This program has been set up to read the FIRE ASTEX * * Radiosonde data set files. * * The first line expects the location of the experiment. * * The second line expects the latitude and longitude location * * for that particular data file. * * The third line contains data of the begin date of the data * * file in YYMMDDHHmm format where YY is the year, MM is the * * month, DD is the day, HH is the hour, and mm is the minutes * * of when this data file begins it's collection of data. * * The forth line contains the parameter names of the data * * values where it's data is located in that column. * * The fifth line represents the units of each parameter. * * The sixth line and down is the actual data. * * * * **There are two data sets that have a blank line separating * * each line. These two locations are Santa Maria and * * Valdivia. This read software has been modified to read * * these two data sets. * * * ************************************************************************/ #include #include #include #define SIZE 81 /* Number of characters on a line */ main(argc,argv) int argc; char *argv[]; { char buf[SIZE], /* String used to read in data */ filename[30], /* Input file name */ temp_name[30], /* Input temporary name */ location[SIZE]; /* Location of experiment */ FILE *fptr; /* Input file pointer */ int amount, /* Number of parameters user dumps */ count, /* Loop counter */ dir, /* Direction in deg */ hgt_msl, /* Hgt/MSL in m */ min, /* Minutes */ param[10], /* Array which stores parameter choices */ rec_count, /* Stores number of records read in from input file */ sec; /* Seconds */ double asc_rate, /* AscRate in m/s */ dewp, /* Dewp in degC */ mixr, /* Mix R. in g/kg */ pres, /* Pressure in hPa */ rh, /* RH in % */ speed, /* Speed in m/s */ temp; /* Temp in degC */ void Print_greeting (), /* Print banner page on screen */ Note_to_User (); /* Print messages from data producer on screen */ /*************************************/ /* */ /* Begin Read Program */ /* */ /*************************************/ for (count = 0; count < 10; count++) param[count] = -1; (void) Print_greeting(); (void) Note_to_User(); if (argc == 1) /* Interactive Mode */ { printf("Please enter the input data file name --> "); scanf("%s",temp_name); strcpy(filename,temp_name); } else if (argc != 0) { strcpy(filename,argv[1]); } printf("\n\n"); fptr = fopen(filename,"r"); if (fptr == NULL) { printf("*****************************************\n"); printf("* ERROR - Unable to open the data file. *\n"); printf("* Program has terminated. *\n"); printf("*****************************************\n"); printf("\n"); exit ( -1 ); } /* Reads the first three lines of data file and prints to screen */ fgets((char *) &buf[0], SIZE, fptr); printf("The location of this data collection: %s",buf); strcpy(location,buf); if (strncmp(" STA MARIA",location,10) == 0) fgets((char *) &buf[0], SIZE, fptr); else if (strncmp(" VALDIVIA",location,9) == 0) fgets((char *) &buf[0], SIZE, fptr); fgets((char *) &buf[0], SIZE, fptr); printf("The beginning latitude and longitude values: %s",buf); if (strncmp(" STA MARIA",location,10) == 0) fgets((char *) &buf[0], SIZE, fptr); else if (strncmp(" VALDIVIA",location,9) == 0) fgets((char *) &buf[0], SIZE, fptr); fgets((char *) &buf[0], SIZE, fptr); printf("The beginning date of data collection: %s",buf); if (strncmp(" STA MARIA",location,10) == 0) fgets((char *) &buf[0], SIZE, fptr); else if (strncmp(" VALDIVIA",location,9) == 0) fgets((char *) &buf[0], SIZE, fptr); /* Reads next two lines of data file and continues */ fgets((char *) &buf[0], SIZE, fptr); if (strncmp(" STA MARIA",location,10) == 0) fgets((char *) &buf[0], SIZE, fptr); else if (strncmp(" VALDIVIA",location,9) == 0) fgets((char *) &buf[0], SIZE, fptr); fgets((char *) &buf[0], SIZE, fptr); if (strncmp(" STA MARIA",location,10) == 0) fgets((char *) &buf[0], SIZE, fptr); else if (strncmp(" VALDIVIA",location,9) == 0) fgets((char *) &buf[0], SIZE, fptr); printf("\n\n"); printf("There are ten parameters of information\n"); printf("for each event. These parameters are:\n"); printf("\n"); printf(" No. Parameter Units\n"); printf(" --- --------- -----\n"); printf(" 1. Minutes & Seconds min s\n"); printf(" Past Launch\n"); printf(" 2. Ascent Rate m/s\n"); printf(" 3. Height m\n"); printf(" 4. Pressure hPa\n"); printf(" 5. Temperature degC\n"); printf(" 6. Relative Humidity percent\n"); printf(" 7. Dewpoint degC\n"); printf(" 8. Mix Ratio g/kg\n"); printf(" 9. Wind Direction deg\n"); printf(" 10. Wind Speed m/s\n"); printf("\n\n"); printf("How many parameters would you like to have printed out\n"); printf("with each event/record? "); scanf("%s",temp_name); amount = atoi(temp_name); printf("\n"); if (amount == 10) { for (count = 0; count < 10; count++) param[count] = count; } else if (amount < 10) { for (count = 1; count <= amount; count++) { printf("Enter parameter #%d --> ",count); scanf("%s",temp_name); param[count-1] = atoi(temp_name) - 1; printf("\n"); } } /* Prints Parameter Names */ for (count = 1; count <= amount; count++) { switch (param[count-1]) { case 0: printf(" Time ",min,sec); break; case 1: printf("AscRate ",asc_rate); break; case 2: printf("Height ",hgt_msl); break; case 3: printf("Pressure ",pres); break; case 4: printf("Temp ",temp); break; case 5: printf(" RH ",rh); break; case 6: printf(" Dewp ",dewp); break; case 7: printf("Mix R. ",mixr); break; case 8: printf("Dir ",dir); break; case 9: printf("Speed ",speed); break; default: break; } /* End of switch */ } printf("\n"); rec_count = 0; while ((feof(fptr)) == 0) { min = 0; sec = 0; asc_rate = 0.0; hgt_msl = 0; pres = 0.0; temp = 0.0; rh = 0.0; dewp = 0.0; mixr = 0.0; dir = 0; speed = 0.0; fscanf(fptr,"%3d%2d%lf%5d%lf%lf%lf%lf%lf%3d%lf",&min,&sec,&asc_rate, &hgt_msl,&pres,&temp,&rh,&dewp,&mixr,&dir,&speed); if (feof(fptr) != 0) { printf("\n\n"); printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); printf("~ End of file has been reached. ~\n"); printf("~ There are a total of %d records in ~\n",rec_count); printf("~ this file. ~\n"); printf("~ Program has completed successfully! ~\n"); printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); exit ( 0 ); } ++rec_count; /* Prints Data Values to the standard output - the screen. */ for (count = 1; count <= amount; count++) { switch (param[count-1]) { case 0: printf(" %d %d",min,sec); break; case 1: printf(" %.1lf",asc_rate); break; case 2: printf(" %d",hgt_msl); break; case 3: printf(" %.1lf",pres); break; case 4: printf(" %.1lf",temp); break; case 5: printf(" %.1lf",rh); break; case 6: printf(" %.1lf",dewp); break; case 7: printf(" %.3lf",mixr); break; case 8: printf(" %d",dir); break; case 9: printf(" %.1lf",speed); break; default: break; } /* End of switch */ } /* End of for */ printf("\n"); } /* End of while */ } /* End of main function */ void Print_greeting() { printf("*****************************************************\n"); printf("* *\n"); printf("* FIRE ASTEX Radiosonde Read Program *\n"); printf("* for the location(s) of *\n"); printf("* *\n"); printf("* LE Suroit *\n"); printf("* Malcolm Baldrige *\n"); printf("* Oceanus *\n"); printf("* Porto Santo *\n"); printf("* Santa Maria *\n"); printf("* Valdivia *\n"); printf("* *\n"); printf("* Version 1.0 July 28, 1995 *\n"); printf("*****************************************************\n"); printf("\n\n"); } /* End of Print_greeting function */ void Note_to_User() { printf("****************************************************************\n"); printf("* *\n"); printf("* NOTE TO USER FROM THE DATA PRODUCER!!! *\n"); printf("* *\n"); printf("* When working with the FIRE ASTEX Radiosonde data, please *\n"); printf("* READ the summary files for each location. These files *\n"); printf("* include information concerning the data when collected. *\n"); printf("* *\n"); printf("* Notes for each location: *\n"); printf("* LE Suroit: All of the wind speed values are bad from the *\n"); printf("* data file, LJN2092P.12Z (as named at the *\n"); printf("* Langley DAAC. In fact, all wind data from *\n"); printf("* that time are bad. *\n"); printf("* ALL Locations: All wind speeds greater than 100.0 are BAD. *\n"); printf("* When working with the data files, any wind speed *\n"); printf("* value >100.0 should be changed to -99.9 and then *\n"); printf("* the wind direction should be changed to -99. *\n"); printf("* *\n"); printf("* Version 1.0 July 28, 1995 *\n"); printf("****************************************************************\n"); printf("\n\n"); } /* End of Print_greeting function */