/************************************************************/ /* */ /* This program reads the TARFOX uwc131a_bag data file. */ /* */ /************************************************************/ #include #include #include FILE *fp; FILE *tp; char *store[14]; char line[512]; char buf5[512]; char buf6[512]; char buf7[512]; char buf8[512]; char buf9[512]; char buf10[512]; char buf11[512]; char buf12[512]; char buf13[512]; char buf14[512]; char buf15[512]; char buf16[512]; char buf17[512]; char buf18[512]; char buf19[512]; char buf20[512]; char buf21[512]; char buf22[512]; int nlhead; int ffi; char buf1[80]; char buf2[512]; char buf3[512]; char buf4[512]; int ivol; int nvol; int dx; int npv; int nauxv; int nscoml; int ncoml; int y1; int y2; int m1; int m2; int d1; int d2; int iv[20000]; int auxv[20000][6]; int pv[20000][6]; int ans; int store1[20000]; int store2[20000][6]; int store3[20000][6]; int x,y; int select[6]; int num; int num_recs; int num_sel; int i,j,k,n; char data_file[30]; char out_file[30]; char instring[80]; char *currentpos, *lastpos; int ans; float scale[6]; float pv_scales[6]; float auxv_scales[6]; char pv_parms[6][180]; char auxv_parms[6][180]; void get_file(); void read_file(); void print_file(); void custom_menu(); void set_pv_parms(); void set_auxv_parms(); void print_pv(); void print_auxv(); void get_file() { printf("Please enter name of data file: "); scanf("%s",data_file); printf("%s\n",data_file); fp=fopen(data_file,"r"); strcat(data_file,".rpt"); strcpy(out_file,data_file); printf("%s %s\n","Name of report file: ",out_file); tp=fopen(out_file,"w"); } void set_pv_parms() { strcpy(pv_parms[0],"PRIMARY VARIABLES:"); strcpy(pv_parms[1],"1. LIGHT SCATTERING AT 450 NM "); strcpy(pv_parms[2],"2. LIGHT SCATTERING AT 550 NM "); strcpy(pv_parms[3],"3. LIGHT SCATTERING AT 750 NM "); strcpy(pv_parms[4],"4. BACKSCATTERING AT 450 NM "); strcpy(pv_parms[5],"5. BACKSCATTERING AT 550 NM "); strcpy(pv_parms[6],"6. BACKSCATTERING AT 750 NM "); } void print_pv() { int m; m=0; set_pv_parms(); for (m=0;m<7;m++) { printf("%s\n",pv_parms[m]); } } void set_auxv_parms() { strcpy(auxv_parms[0],"AUXILIARY VARIABLES:"); strcpy(auxv_parms[1],"1. TIME IN HHMMSS FORMAT [UTC]"); strcpy(auxv_parms[2],"2. GPS LATITUDE (TRIMBLE TNL-3000) [decimal degrees]"); strcpy(auxv_parms[3],"3. GPS LONGITUDE (TRIMPLE TNL-3000) [decimal degrees]"); strcpy(auxv_parms[4],"4. STATIC PRESSURE (ROSEMOUNT MODEL 830BA VARIABLE CAPACITANCE) [millibars]"); strcpy(auxv_parms[5],"5. RELATIVE HUMIDITY OF SAMPLE STREAM FOR MS ELECTRON INTEGRATING 3-WAVELENGTH NEPHELOMTER) [percent]"); strcpy(auxv_parms[6],"6. BAG SWITCH [1 means valve-open/bag-filling; 0 means valve-closed]"); } void print_auxv() { int m; m=0; set_auxv_parms(); for (m=0;m<7;m++) { printf("%s\n",auxv_parms[m]); } } void read_file() { int i; printf("Reading file...\n"); fscanf(fp,"%d",&nlhead); fscanf(fp,"%d\n",&ffi); fgets(buf1,80,fp); fgets(buf2,80,fp); fgets(buf3,80,fp); fgets(buf4,80,fp); fscanf(fp,"%d",&ivol); fscanf(fp,"%d\n",&nvol); fscanf(fp,"%d",&y1); fscanf(fp,"%d",&m1); fscanf(fp,"%d",&d1); fscanf(fp,"%d",&y2); fscanf(fp,"%d",&m2); fscanf(fp,"%d\n",&d2); fscanf(fp,"%d\n",&dx); fgets(buf5,180,fp); fscanf(fp,"%d\n",&npv); for (i=0;i<6;i++) fscanf(fp,"%e",&pv_scales[i]); fscanf(fp,"\n"); /* fgets(buf6,180,fp); */ fgets(buf7,180,fp); fgets(buf8,180,fp); fgets(buf9,180,fp); fgets(buf10,180,fp); fgets(buf11,180,fp); fgets(buf12,180,fp); fgets(buf13,180,fp); fscanf(fp,"%d\n",&nauxv); fgets(buf14,180,fp); fgets(buf15,180,fp); fgets(buf16,180,fp); fgets(buf17,180,fp); fgets(buf18,180,fp); fgets(buf19,180,fp); fgets(buf20,180,fp); fgets(buf21,180,fp); fscanf(fp,"%d\n",&nscoml); fscanf(fp,"%d\n",&ncoml); for (i=0;i<14;i++) { fgets(line, sizeof(line), fp); store[i] = (char *)malloc(sizeof(line)); strcpy(store[i], line); } /* reading data*/ while (!feof(fp)) { fscanf(fp,"%d",&iv[num_recs]); store1[num_recs]=iv[num_recs]; for (i=0;i<6;i++) { fscanf(fp,"%d",&auxv[num_recs][i]); store2[num_recs][i]=auxv[num_recs][i]; } for (i=0;i<6;i++) { fscanf(fp,"%d",&pv[num_recs][i]); store3[num_recs][i]=pv[num_recs][i]; } num_recs++; } printf("Finished reading\n"); printf("%s %d\n\n","Number of records: ",num_recs); } void custom_menu() { int i,j,k; int sel_num; ans=0; sel_num=0; printf("If you want all the data written to output file, enter 1\n"); printf("To select primary variables enter 2\n"); printf("To select auxiliary variables enter 3\n"); scanf("%d",&ans); /*printf("%d\n",ans);*/ if (ans == 1) { print_file(); } if (ans == 2) { i=0; read_file(); print_auxv(); printf("Output of each selection is written to output file in the same order.\n"); printf("Enter the number(s) of the auxiliary variable(s) to view: \n"); printf("Enter -1 when selection is done: \n"); while (sel_num != -1) { scanf("%d",&sel_num); /*printf("%d",sel_num);*/ select[i]=sel_num; i++; } num_sel=i-1; /* for (j=0;j