/*************************************************************************/ /* name - isccp_d2_read.c * * Purpose - This program reads ISCCP D2 HDF formatted data files * * Inputs - HDF file name, output file name, subsetting information * Output - Report file * * Key Local Parameters - maxrank - max rank of HDF SDS * hdfname - name of HDF file * begin1 - beginning cell number * end1 - ending cell number * dataitems - data items to be read * status - input ok or not * * Functions Called - * getinput - gets data date and file type * readhdf - reads file id and description, etc. * getdata - gets parameters to subset * readdata - reads data, max, mins, etc *************************************************************************/ #include #include #include #include "hdf.h" #define MAXRANK 2 #define LISTSIZE 55 #define FIRST 1 #define MAXLEN 256 #define MAXLNG 132 #define STARTPOS 1 int main(argc,argv) int argc; char **argv; { char hdfname[MAXLEN], outfile[MAXLEN]; char subset_ans[MAXLEN]; char param_ans[MAXLEN]; int32 begin1, end1, begin2, end2; uint16 dataitems[LISTSIZE]; FILE *out; /* function prototypes */ char *getinput(); /* gets name of input file */ void readhdf(); /* reads 5 different files from HDF file */ void getparam(); /* get user selected parameter(s) to read */ void getarea(); /* gets area based on cell number */ void getdata(); /* retrieves data based on cell number */ void readdata(); /* reads data applying conversion values */ /* Try to extract date and file type from command line */ if (argc == 3){ strcpy(hdfname,argv[1]); if (strcmp(argv[2],"-") == 0) { strcpy(outfile,"stdout"); } else { strcpy(outfile,argv[2]); } } else /* prompt for info if necessary */ { printf("This program reads the ISCCP D2 HDF formatted data files \n "); getinput(hdfname,outfile); } printf("Input file is %s\n\n",hdfname); printf("Output file is %s\n\n",outfile); /* open output file */ if (strcmp(outfile,"stdout") == 0) { out = stdout; } else { if ((out=fopen(outfile,"wt")) == NULL) { printf("Cannot open output file %s\n\n",outfile); exit(1); } } /* call function to read file id */ readhdf(out,hdfname); /* call funtion to select parameter */ getparam(param_ans,&begin2,&end2); /* call function to subset area */ getarea(subset_ans,&begin1,&end1); /* call function to get parameters */ getdata(out,hdfname,dataitems); /* call function to read data */ printf("\n\nGetting data, Please wait ...\n"); readdata(out,hdfname,dataitems,subset_ans,begin1,end1,begin2,end2); fprintf(stderr, "\n***************************************************************\n"); fprintf(stderr, "* *\n"); fprintf(stderr, "* Program has completed processing *\n"); fprintf(stderr, "* *\n"); fprintf(stderr, "***************************************************************\n"); } /***********************************************************************/ /* name - getinput * * Purpose - This subroutine accepts user input for the input & output * file names * * Input parameters - none * Output parameters - hdfname - input file name * outfile - output file name. If = '-' then prints * to standard output (stdout) * * Key Local Parameters - NONE * Functions Called - NONE ************************************************************************/ char *getinput(hdfname,outfile) char *hdfname,*outfile; { int out_control; do { printf("Please enter file name to read: "); scanf("%s",hdfname); printf("\n\n"); } while (strlen(hdfname) == 0); do { printf("Please enter report file name (use `-' to print to screen): "); scanf("%s",outfile); if (*outfile == '-') { strcpy(outfile,"stdout"); } else { if (access(outfile,2) == 0) { printf( "******************************************************************\n"); printf( "* *\n"); printf( "* WARNING FILE EXISTS - PLEASE CHOOSE OPTION BELOW *\n"); printf( "* *\n"); printf( "* 1 - stop now *\n"); printf( "* 2 - overwrite file %s *\n", outfile); printf( "* *\n"); printf( "******************************************************************\n"); out_control = 0; while ((out_control <1) || (out_control > 2)) { printf("\n\t Please enter number of action to take (1-2): "); scanf("%d",&out_control); } if (out_control == 1) { fprintf(stderr,"EXITING PROGRAM\n"); exit(0); } } /* end of access */ printf("\n\n"); } /* end of else */ } while (strlen(outfile) == 0); printf("\n"); printf("************************************************************************\n"); printf("ISCCP_D2 HDF formatted files include five file descriptions - they are:\n"); printf("1) README SECTION - including information the contributing satellites,\n"); printf(" processing centers, file format description, etc.\n"); printf("2) TABLE OF CONTENTS - Lists the date and spatial coverage of each \n"); printf("data object in the HDF file\nin ASCII text tabular form and cell stats\n"); printf("3) FORTRAN READ SOFTWARE\n"); printf("4) ANCILLARY DATA TABLE - Lists characteristics of each ISCCP grid \n"); printf("box in tabular form\n"); printf("5) CALIBRATION - Calibration correction factor\n"); printf("***********************************************************************\n\n"); printf("\n\n This program can write these descriptors into a set of files\n"); return 0; } /* end of get input */ /************************************************************************ * name - readhdf * * Purpose - This subroutine reads the file id and file description * * Input - hdfname - the name of the HDF input file * * Key Local Parameters : iret - return code from HDF routines * dfile - pointer to HDF file * id - file id * filedesc - file description * * Functions Called : HDF functions to get file id, file description *******************************************************************/ void readhdf(out,hdfname) char *hdfname; FILE *out; { int32 iret,dfile,idlen,deslen,out_control; int vdata_ref=-1, vdata_id, i, iref; float32 buf1[6596],buf2[6596],buf3[6596],buf4[6596],buf5[6596],buf6[6596],buf7[6596],buf8[6596],buf9[6596], buf10[6596],buf11[6596]; char str[7]; char *fileid, /*pointer for file identifier */ *filedes; /*pointer for file description */ char kind[MAXLEN], /* input kind */ name1[MAXLEN], /* name for Read me */ name2[MAXLEN], /* name for table of contents */ name3[MAXLEN], /* name for FORTRAN READ SOFTWARE */ name4[MAXLEN], /* name for ancillary file */ name5[MAXLEN]; /* name for calibration correction factor */ FILE *des1, *des2, *des3, *des4,*des5; /* five pointers for 5 HDF files */ dfile = Hopen(hdfname,DFACC_READ,0); if (dfile == -1){ fprintf(out,"%s %s\n\n","Error in opening HDF file",hdfname); exit(1); } /* get file id */ idlen = DFANgetfidlen(dfile,FIRST); if (idlen == (int32) -1) { printf("File doesn't have a file identifier\n"); } else { fileid = malloc(idlen+1); *(fileid+idlen) = NULL; iret = DFANgetfid(dfile,fileid,idlen+1,(intn)FIRST); if (iret == -1){ fprintf(out,"%s%d\n\n","Error in getting file id: id = ",dfile); exit(1); } else { fprintf(out,"%s %s\n\n","File ID: ",fileid); idlen = DFANgetfidlen(dfile,(int32) 0); while (idlen != (int32) -1) { free (fileid); fileid = malloc(idlen); iret = DFANgetfid(dfile,fileid,idlen,(intn)0); if (iret == -1){ fprintf(out,"%s%d\n\n","Error in getting file id: id = ",dfile); free(fileid); exit(1); } fprintf(out,"%s %s\n\n","File ID: ",fileid); idlen = DFANgetfidlen(dfile,(intn) 0); } /* end while */ free(fileid); } /* end else process file ids */ } /* end else we have a file id */ /* PROCESS FILE DESCRIPTIONS */ printf("Would you like to have the README SECTION, TABLE OF CONTENTS,\n"); printf("FORTRAN READ software and ANCILLARY FILE written to local files? (Y or N): "); scanf("%s",kind); printf("\n"); kind[0] = toupper(kind[0]); if (kind[0] == 'N') { iret = Hclose(dfile); return; } else { /* kind[0] != 'N' so Generate FILES */ do { printf("\nPlease enter file name to write the README data into: "); scanf("%s",&name1[0]); printf("\n"); if (access(&name1[0],2) == 0) { printf( "******************************************************************\n"); printf( "* *\n"); printf( "* WARNING FILE EXISTS - PLEASE CHOOSE OPTION BELOW *\n"); printf( "* *\n"); printf( "* 1 - stop now *\n"); printf( "* 2 - overwrite file %s *\n", &name1[0]); printf( "* *\n"); printf( "******************************************************************\n"); out_control = 0; while ((out_control <1) || (out_control > 2)) { printf("\n\t Please enter number of action to take (1-2): "); scanf("%d",&out_control); } if (out_control == 1) { fprintf(stderr,"EXITING PROGRAM\n"); exit(0); } printf("\n"); } /*end access */ } while (strlen(&name1[0]) == 0); if ((des1=fopen(&name1[0],"wt")) == NULL) { fprintf(stderr,"Cannot open output file %s\n\n",&name1[0]); iret = Hclose(dfile); exit(1); } deslen = DFANgetfdslen(dfile,(intn)FIRST); if (deslen == (int32) -1) { fprintf(stderr, "ERROR - no length for file description 1 - trying next section\n"); } else { filedes = malloc(deslen); iret = DFANgetfds(dfile,filedes,deslen,(intn)FIRST); if (iret == -1) { fprintf(stderr, "ERROR - read for file description failed - trying next section\n"); free(filedes); } else { fprintf(des1,"%s",filedes); fprintf(des1,"\n"); free(filedes); fclose(des1); } } /* end des1 processing */ /* GET NAME FOR Table Of Contents FILE */ do { printf("Please enter file name to write the Table Of Contents data into: "); scanf("%s",&name2[0]); printf("\n"); if (access(&name2[0],2) == 0) { printf( "******************************************************************\n"); printf( "* *\n"); printf( "* WARNING FILE EXISTS - PLEASE CHOOSE OPTION BELOW *\n"); printf( "* *\n"); printf( "* 1 - stop now *\n"); printf( "* 2 - overwrite file %s *\n", &name2[0]); printf( "* *\n"); printf( "******************************************************************\n"); out_control = 0; while ((out_control <1) || (out_control > 2)) { printf("\n\t Please enter number of action to take (1-2): "); scanf("%d",&out_control); } if (out_control == 1) { fprintf(stderr,"EXITING PROGRAM\n"); exit(0); } printf("\n"); } /*end access */ } while (strlen(&name2[0]) == 0); if ((des2=fopen(&name2[0],"wt")) == NULL) { fprintf(stderr,"Cannot open output file %s\n\n",&name2[0]); iret = Hclose(dfile); exit(1); } deslen = DFANgetfdslen(dfile,(intn)0); if (deslen != (int32) -1) { filedes = malloc(deslen); DFANgetfds(dfile,filedes,deslen,(intn)0); fprintf(des2,"%s",filedes); fprintf(des2,"\n"); free(filedes); fclose(des2); } else { fprintf(stderr, "ERROR - could not read file descriptor 2 - trying next one\n"); } /*end des2 processing */ /******************************************************************************/ do { printf("Please enter file name to write the FORTRAN READ SOFTWARE into: "); scanf("%s",&name3[0]); printf("\n"); if (access(&name3[0],2) == 0) { printf( "******************************************************************\n"); printf( "* *\n"); printf( "* WARNING FILE EXISTS - PLEASE CHOOSE OPTION BELOW *\n"); printf( "* *\n"); printf( "* 1 - stop now *\n"); printf( "* 2 - overwrite file %s *\n", &name3[0]); printf( "* *\n"); printf( "******************************************************************\n"); out_control = 0; while ((out_control <1) || (out_control > 2)) { printf("\n\t Please enter number of action to take (1-2): "); scanf("%d",&out_control); } if (out_control == 1) { fprintf(stderr,"EXITING PROGRAM\n"); exit(0); } printf("\n"); } /*end access */ } while (strlen(&name3[0]) == 0); if ((des3=fopen(&name3[0],"wt")) == NULL) { fprintf(stderr,"Cannot open output file FORTRAN READ SOFTWARE file\n\n"); iret = Hclose(dfile); exit(1); } deslen = DFANgetfdslen(dfile,(intn)0); if (deslen != (int32) -1) { filedes = malloc(deslen); DFANgetfds(dfile,filedes,deslen,(intn)0); fprintf(des3,"%s",filedes); fprintf(des3,"\n"); free(filedes); fclose(des3); } else { fprintf(stderr, "ERROR - could not read file descriptor 3 - trying next one\n"); } /************************************************************************* PROCESS ANN DATA FILE ANYWAY *************************************************************************/ do { printf("Please enter file name to write the Ancillary file into: "); scanf("%s",&name4[0]); printf("\n"); if (access(&name4[0],2) == 0) { printf( "******************************************************************\n"); printf( "* *\n"); printf( "* WARNING FILE EXISTS - PLEASE CHOOSE OPTION BELOW *\n"); printf( "* *\n"); printf( "* 1 - stop now *\n"); printf( "* 2 - overwrite file %s *\n", &name4[0]); printf( "* *\n"); printf( "******************************************************************\n"); out_control = 0; while ((out_control <1) || (out_control > 2)) { printf("\n\t Please enter number of action to take (1-2): "); scanf("%d",&out_control); } if (out_control == 1) { fprintf(stderr,"EXITING PROGRAM\n"); exit(0); } printf("\n"); } /*end access */ } while (strlen(&name4[0]) == 0); if ((des4=fopen(&name4[0],"wt")) == NULL) { fprintf(stderr,"Cannot open ancillary data file %s - job aborted\n\n",&name4[0]); iret = Hclose(dfile); exit(3); } /* find out if this is a VData record or not */ deslen = DFANgetfdslen(dfile,(intn)0); if (deslen != (int32) -1) { filedes = malloc(deslen); DFANgetfds(dfile,filedes,deslen,(intn)0); printf("%s",filedes); printf("\n"); fprintf(des4,"%s",filedes); fprintf(des4,"\n"); free(filedes); if(deslen < 100) { printf("The VData records will now be read!\n"); printf("\n"); Vstart(dfile); iref = VSgetid(dfile,vdata_ref); /* THIS ROUTINE DECODES 11 FIELDS FROM THE HDF VDATA RECORD. THESE ARE THE ANCILLARY FILE FIELD NAMES. GRD BOX */ strcpy(str,"IBOX"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf1); /* LAT IND */ strcpy(str,"J"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf2); /* LON IND*/ strcpy(str,"I"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf3); /* SQ1 IND*/ strcpy(str,"LONBEG"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf4); /* SQ2 IND*/ strcpy(str,"LONEND"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf5); /* LAT CENTER*/ strcpy(str,"CENLAT"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf6); /* LON CENTER*/ strcpy(str,"CENLON"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf7); /* BOX AREA*/ strcpy(str,"IAREA"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf8); /* PER LAND*/ strcpy(str,"LANDFR"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf9); /* TOPOG HEIGHT*/ strcpy(str,"ITOPOG"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf10); /* VEG TYPE*/ strcpy(str,"IVEG"); vdata_id = VSattach(dfile, iref, "r"); next_vd_field(hdfname,vdata_id,str,buf11); /* These are the only VData records that are used at this time. */ fprintf(des4,"***************************************************************\n"); fprintf(des4," Vdata values from file\n"); fprintf(des4,"***************************************************************\n"); for (i=0; i<6596; i++) { if(i == 0) { fprintf(des4," GRD LAT LON SQ1 SQ2 LAT LON BOX PERC TOPOG VEG\n"); fprintf(des4," BOX IND IND IND IND CENTER CENTER AREA LAND HEIGHT TYPE\n"); fprintf(des4,"%4d %2d %1d %3d %3d %4.2f %7.2f %6d %3d %4d %1d\n",(int)buf1[i],(int)buf2[i], (int)buf3[i],(int)buf4[i],(int)buf5[i],buf6[i],buf7[i],(int)buf8[i],(int)buf9[i],(int)buf10[i], (int)buf11[i]); } else { fprintf(des4,"%4d %2d %1d %3d %3d %4.2f %7.2f %6d %3d %4d %1d\n",(int)buf1[i],(int)buf2[i], (int)buf3[i],(int)buf4[i],(int)buf5[i],buf6[i],buf7[i],(int)buf8[i],(int)buf9[i],(int)buf10[i], (int)buf11[i]); } } fclose(des4); } } else { fprintf(stderr,"ERROR - could not read file descriptor 4 - ANNCILLARY"); fprintf(stderr," DATA \n This data is required to calculate cloud height"); fprintf(stderr,"\n\t- data file may be corrupted - job aborted\n"); exit(3); } /* end processing description 4 */ /*****************************************************************************/ do { printf("Please enter file name to write the Calibration Factor into: "); scanf("%s",&name5[0]); printf("\n"); if (access(&name5[0],2) == 0) { printf( "******************************************************************\n"); printf( "* *\n"); printf( "* WARNING FILE EXISTS - PLEASE CHOOSE OPTION BELOW *\n"); printf( "* *\n"); printf( "* 1 - stop now *\n"); printf( "* 2 - overwrite file %s *\n", &name5[0]); printf( "* *\n"); printf( "******************************************************************\n"); out_control = 0; while ((out_control <1) || (out_control > 2)) { printf("\n\t Please enter number of action to take (1-2): "); scanf("%d",&out_control); } if (out_control == 1) { fprintf(stderr,"EXITING PROGRAM\n"); exit(0); } printf("\n"); } /*end access */ } while (strlen(&name5[0]) == 0); if ((des5=fopen(&name5[0],"wt")) == NULL) { printf("Cannot open output file CALIBRATION CORRECTION FACTOR\n\n"); iret = Hclose(dfile); exit(1); } deslen = DFANgetfdslen(dfile,(intn)0); if (deslen != (int32) -1) { filedes = malloc(deslen); DFANgetfds(dfile,filedes,deslen,(intn)0); fprintf(des5,"%s",filedes); fprintf(des5,"\n"); free(filedes); fclose(des5); } else { printf("ERROR - could not read file descriptor 5 - continuing processing\n"); } /* end processing description 5 */ } /* end of writting out files */ /************************************************************************* DONE PROCESSING ANN DATA FILE *************************************************************************/ iret = Hclose(dfile); return; } next_vd_field(hdfname,vdata_id,str,buffer) int vdata_id; char str[7], hdfname[256]; float32 buffer[6596]; { int nrec, status, vsize, interlace; char fields[80], vclass[7], vdata_name[7]; status = VSinquire(vdata_id,&nrec,&interlace,fields,&vsize,vdata_name); if(status == -1) { printf("Inquire failed will stop.\n"); exit(0); } status = VSelts(vdata_id); status = VSgetclass(vdata_id,vclass); status = VSsetfields(vdata_id,str); status = DFSDndatasets(hdfname); status = VSread(vdata_id,(uint8 *)buffer,nrec,interlace); VSdetach(vdata_id); return(0); } /********************************************************************/ /* Name - getparam type - function * * Purpose - This functions asks the user to enter the parameter * number(s) to subset data * * Input Parameters - NONE * Output Parameters -param_ans - enter parameter number(P) or none * begin2-beginning parameter number * end2 - ending parameter number * * Key Local Parameters -NONE * * Functions Called - NONE *****************************************************************/ void getparam(param_ans,begin2,end2) char *param_ans; int32 *begin2, *end2; { char kind[MAXLEN]; printf("Enter whether you would like to select a particular parameter?\n"); printf("yes (Y) or no subsetting (N): "); scanf("%s",kind); *param_ans = toupper(kind[0]); if (param_ans[0] == 'N'){ *begin2 = 1; *end2 = 130; } else { printf("\n\nEnter beginning and end parameter numbers separated by a space\n) "); printf(" ( 1 <= parameter number <= 130): "); printf("\n\nYou may enter just one parameter (e.g., 8 8) "); printf("\n or a first and last parameter (e.g., 32 40)"); scanf("%d %d",begin2,end2); while ((*begin2<1) || (*begin2 > 130) || (*end2 > 130) || (*end2 < 1) || (*end2<*begin2)) { printf(" Incorreect entry - please try again.\n"); printf("\n\nEnter beginning and end parameter numbers (e.g., 8 9) "); scanf("%d %d",begin2,end2); } } } /********************************************************************/ /* Name - getarea type - function * * Purpose - This functions asks the user to enter the cell * numbers to subset data * * Input Parameters - NONE * Output Parameters -subset_ans - enter cell number(C) or none * begin1-beginning cell number * end1 - ending cell number * * Key Local Parameters -NONE * * Functions Called - NONE *****************************************************************/ void getarea(subset_ans,begin1,end1) char *subset_ans; int32 *begin1, *end1; { char kind[MAXLEN]; printf("Enter whether you would like to further subset based on lat/lon?\n"); printf("yes (Y) or no subsetting (N): "); scanf("%s",kind); *subset_ans = toupper(kind[0]); if (subset_ans[0] == 'N') { *begin1 = 1; *end1 = 6596; } else { printf("\n\nEnter beginning and end cell numbers separated by a space\n) "); printf(" (1 <= cell no. <= 6596): "); scanf("%d %d",begin1,end1); while ((*begin1<1) || (*begin1 > 6596) || (*end1 > 6596) || (*end1 < 1) || (*end1<*begin1)) { printf(" Incorreect entry - please try again.\n"); printf("\n\nEnter beginning and end cell numbers (e.g., 1250 3649) "); scanf("%d %d",begin1,end1); } } } /*********************************************************************/ /* Name - getdata * * Purpose - This subroutine allows the user to choose from the annotation * labels, which data parameters to dump * * Input - hdfname - the number of HDF file * Output - dataitems - list of reference numbers of data to dump * * Key Local Parameters - nlabels - number of reference labels * i,j - counters * k - index to dataitems * itemnum - number for user to choose * startpos - starting position in HDF file * reflist - list of reference numbers * labellist - list of annotation labels * * Functions called - annotation label routines from HDF *********************************************************************/ void getdata(out,hdfname,dataitems) char *hdfname; uint16 dataitems[LISTSIZE]; FILE *out; { int32 i,j,k,itemnum,nlabels,iret; char labellist[LISTSIZE*MAXLNG]; uint16 reflist[LISTSIZE]; char dataunt[25], datafmt[10], coordsys[25]; int32 dimsize[MAXRANK], numdims; /* initialize dataitems array */ for (i=0; i15 || (i == nlabels - 1)) { printf("\n"); printf("Please choose the numbers of the data items to dump "); printf("separated by a space.\n"); printf("Enter 0 to quit "); printf("entering parameters\n\n"); while (itemnum >0) { scanf("%d",&itemnum); if (itemnum == -1) break; if (itemnum == 0) { dataitems[k] = 0; return; } dataitems[k] = reflist[itemnum-1]; k++; } /* itemnum > 0 */ j = 1; } } /* end for i= (float32)0.0)*/ { fprintf(out,"%8.2f",PRETAB[*(c+(j-1))]); } break; case 34: case 37: case 40: { fprintf(out,"%8.2f",TMPTAB[*(c+(j-1))]); } break; case 41: case 46: case 51: case 56: case 61: case 66: case 71: case 76: case 81: case 86: case 91: case 96: case 101: case 106: case 111: { if (*(c+(j-1)) == UNDEF_INT) { fprintf (out,"%8.2f",UNDEF_FLOAT); } else { fprintf(out,"%8.2f",(((float32)*(c+(j-1))) *0.5)); } } break; case 42: case 47: case 52: case 57: case 62: case 67: case 72: case 77: case 82: case 87: case 92: case 97: case 102: case 107: case 112: case 120: case 125: if ( j == 120) { param_120 = PRETAB[*(c+(j-1))]; } if ( j == 125) { param_125 = PRETAB[*(c+(j-1))]; } { fprintf(out,"%8.2f",PRETAB[*(c+(j-1))]); } break; case 43: case 48: case 53: case 58: case 63: case 68: case 73: case 78: case 83: case 88: case 93: case 98: case 103: case 108: case 113: { fprintf(out,"%8.2f",TMPTAB[*(c+(j-1))]); } break; case 44: case 49: case 54: case 59: case 64: case 69: case 74: case 79: case 84: case 89: case 94: case 99: case 104: case 109: case 114: { fprintf(out,"%8.2f",TAUTAB[*(c+(j-1))]); } break; case 45: case 50: case 55: case 75: case 80: case 85: if (TAUTAB[*(c+(j-1))] >= (float32)0.0) { /* CONDITION CHANGED TO ONLY APPLY TO LIQUID -CHANGED 12/99*/ fprintf(out,"%8.2f",(TAUTAB[*(c+(j-1))] * PATHW)); } else{ fprintf(out,"%8.2f",(TAUTAB[*(c+(j-1))])); } break; case 60: case 65: case 70:case 90: case 95: case 100: case 105: case 110: case 115: if (TAUTAB[*(c+(j-1))] >= (float32)0.0) { fprintf(out,"%8.2f",(TAUTAB[*(c+(j-1))] * PATHI)); } else{ fprintf(out,"%8.2f",(TAUTAB[*(c+(j-1))])); } break; case 118: { fprintf(out,"%8.2f",RFLTAB[*(c+(j-1))]); } break; case 128: case 129: { fprintf(out,"%8.2f",PRWTAB[*(c+(j-1))]); } break; case 130: { fprintf(out,"%8.2f",OZNTAB[*(c+(j-1))]); } break; } /* with switch j*/ if ((j%10) == 0){ fprintf(out,"\n(%3d)",j+1); } } /*end of for j loop */ fprintf(out,"\n\n"); c += winend[1]; /* move buffer pointer to start of next cell data */ /* print out cell unique info as detailed below */ fprintf(out," CENTER: CENTER LON/LAT %5.2f %5.2f\n\n", (float32)(((float32)lon-(float32)1) * ((float32)360.0/(float32)ICELLS[lat-1]) + (((float32)360.0/(float32)ICELLS[lat-1])/(float32)2.0)), (float32)((((float32)lat-(float32)1)*(float32)2.5) + ((float32)2.5/ (float32)2.0) - (float32)90.0)); /*************************************************************************** * PRESSURE LAYER MIDPOINT CALCULATION AS DERIVED FROM FORTRAN CODE AS * * PROVIDED BY DATA PRODUCER * ***************************************************************************/ PTROP = param_125; if(PTROP == 0) { } LYSRF = 0; LYRTRP = NUM_LAYERS; for ( ii = 1; ii <= NUM_LAYERS; ii++) { if (param_120 <= PBOUND[ii]) { LYSRF = ii; } if (param_125 > PBOUND[ii]) { LYRTRP = ii - 1; } } /* end of for statement */ fprintf(out," MIDPRS: ACTUAL PRESSURE LAYER MID-POINTS (MB)"); for ( ii = 0; ii < NUM_LAYERS; ii++) { if (( ii < LYSRF ) || ( ii > LYRTRP)) { fprintf(out,"%8.2f",UNDEF_FLOAT); } else { if ( ii == LYSRF) { fprintf(out,"%8.2f",((param_120 + PBOUND[ii+1]) * (float32) 0.5)); } else { if ( ii == LYRTRP) { fprintf(out,"%8.2f",((param_125 + PBOUND[ii]) * (float32) 0.5)); } else { fprintf(out,"%8.2f", ((PBOUND[ii] + PBOUND[ii+1]) * (float32)0.5)); } /* end of last else */ } /* end of second last else */ } /* end of else first */ } /* end of for loop */ fprintf (out,"\n\n"); /************************************************************************* * CLOUD TOP HEIGHT CALCULATED AS CODE PROVIDED BY DATA PRODUCER * *************************************************************************/ /* print out cloud height */ TS = param_116; TC = param_23; HGT = ( TS - TC)/ RLAPSE * 1000.0; fprintf(out," CLDHGT: CLOUD TOP HEIGHT (M) %9.0f\n\n",HGT); } k++; } /* while (dataitems[k] != 0) */ } /* end readdata */ /*****************************************************************************/