/************************************************************************ * * * PROGRAM: read_lase.c * * * * VERSION: 2.0 DATE: 17 February 2000 * * * * PURPOSE: The purpose of this code is to demonstrate reading * * LASE data files. It is intended as a starting point * * from which a program can be developed to process LASE * * data. In its distributed form, it reads in the file * * header and profile data and writes it to the screen. * * * * ALGORITHM: None. * * * * INVOCATION: read_lase * * WHERE: * * - optional * * name of (including path if not in current * * directory) LASE file to be read * * * * * * EXTERNAL ROUTINES: * * #include * * #include * * #include * * * * INTERNAL ROUTINES: None. * * * * NOTES: None. * * * * MODIFICATION HISTORY: * * 2/17/2000 - Modified to work with new format for LASE_CAMEX3 * * data set, including change to floating point for * * lat/lon and profile values; with these changes, * * program will still work with files in original LASE * * format * * * * ************************************************************************/ #include #include #include #define DATBUF 600 #define MAXBUF 80 #define MAX_FILENAME 51 #define MAX_NUM_VAR 9 void banner(int x); main (argc,argv) int argc; char *argv[]; { char filename[MAX_FILENAME], dataname[30], investigator[60], species[60], mission[30], temp[MAXBUF], varname[MAX_NUM_VAR][30], units[9][30], contkey; int i, line_count, num_hdr_lines, syr, smon, sday, ryr, rmon, rday, flight_num, num_var, num_comment_lines, data_type, avg_period, freq, jday, time, alt, balt, alt_inc, num_pts, pcount; float scale[MAX_NUM_VAR], offset[MAX_NUM_VAR], min[MAX_NUM_VAR], max[MAX_NUM_VAR], missing[MAX_NUM_VAR], lod[MAX_NUM_VAR], lat, lon, profile[DATBUF]; FILE *f1, *fout; banner(argc); if (argc ==1) { printf("\nPlease enter the LASE data file name\n\n"); gets(filename); } else strcpy(filename,argv[1]); if ((f1 = fopen(filename,"r")) == NULL) { printf("Can't open LASE data file %s\n",filename); exit(-1); } line_count = 0; fscanf(f1,"%d", &num_hdr_lines); fgets(temp,79,f1); /* read to end of previous line */ line_count +=1; fgets(dataname,29,f1); /* original file name */ line_count +=1; fgets(investigator,59,f1); printf("\nInvestigator: %s",investigator); line_count +=1; fgets(species,59,f1); printf("Data: %s",species); line_count +=1; fgets(mission,29,f1); printf("Mission: %s",mission); line_count +=1; fscanf(f1,"%d %d %d %d %d %d",&syr,&smon,&sday,&ryr,&rmon,&rday); printf("Start date: %d/%d/%d \n",smon,sday,syr); printf("Date processed: %d/%d/%d \n",rmon,rday,ryr); line_count +=1; fscanf(f1,"%d",&flight_num); line_count +=1; printf("Flight Number: %d\n",flight_num); fscanf(f1,"%d",&num_var); line_count +=1; fscanf(f1,"%d",&num_comment_lines); line_count +=1; fscanf(f1,"%d",&data_type); line_count +=1; fscanf(f1,"%d",&avg_period); line_count +=1; fscanf(f1,"%d",&freq); line_count +=1; printf("\nNum Variable Units Scale Offset Min Max Missing\n"); printf("--------------------------------------------------------------------------------\n"); for (i=0;i