#include #include #include #define SWORD 32 #define MASK ( (unsigned) 0xffffffff) #define G1BYTE(p,q,b) ((unsigned) p << q >> (SWORD - b)) /* right justify b bits, located qbits from left of p. */ void main() { void dmphdr(); /* function to dump header record */ void scnscl(); void nscscl(); void datchr(); void julcal(); void yymmdd(); void stuff(); void spread(); void gbytes(); void gbyte(); void sbytes(); void sbyte(); void sesprd(); void scninit(); void nscinit(); void scnfil(); void nscfil(); void scnrec(); void scnnam(); void nscnam(); void nscrec(); unsigned short buf[80]; char ans; char *base_ptr; char file_name[80]; char file_out[80]; char filename[80]; char file1[80]; /* header file */ char file2[80]; /* scanner scale factors */ char file3[80]; /* nonscanner scale factors */ char file4[80]; /* nfov input data */ char file5[80]; /* nfov 5.0 deg. nested data */ char file6[80]; /* nfov 10.0 deg. nested data */ char file7[80]; /* nfov 2.5 deg. zonal data */ char file8[80]; /* nfov 5.0 deg. zonal data */ char file9[80]; /* nfov 10.0 deg. zonal data */ char file10[80]; /* nfov global data */ char file11[80]; /* mfov-nf input data */ char file12[80]; /* mfov-nf 10.0 deg. nested data */ char file13[80]; /* mfov-nf 5.0 deg. zonal data */ char file14[80]; /* mfov-nf 10.0 deg. zonal data */ char file15[80]; /* mfov-nf global data */ char file16[80]; /* wfov-nf input data */ char file17[80]; /* wfov-nf 10.0 deg. nested data */ char file18[80]; /* wfov-nf 5.0 deg. zonal data */ char file19[80]; /* wfov-nf 10.0 deg. zonal data */ char file20[80]; /* wfov-nf global data */ char file21[80]; /* mfov-sf input data */ char file22[80]; /* mfov-sf 10.0 deg. zonal data */ char file23[80]; /* mfov-sf global data */ char file24[80]; /* wfov-sf input data */ char file25[80]; /* wfov-sf 10.0 deg. zonal data */ char file26[80]; /* wfov-sf global data */ /**************************************************************/ FILE *fp; FILE *fpo; FILE *fd; FILE *fp1; FILE *fp2; FILE *fp3; FILE *fp4; FILE *fp5; FILE *fp6; FILE *fp7; FILE *fp8; FILE *fp9; FILE *fp10; FILE *fp11; FILE *fp12; FILE *fp13; FILE *fp14; FILE *fp15; FILE *fp16; FILE *fp17; FILE *fp18; FILE *fp19; FILE *fp20; FILE *fp21; FILE *fp22; FILE *fp23; FILE *fp24; FILE *fp25; FILE *fp26; FILE *npks4; /***********************************************************/ int i; int ni = 30; int nfile; int iray[4]; int idata[9]; int dfalt[3]; int res; int nr; int inst; int ires; int imf; int icovrg; int irecf; int irecl; int iscitm; int insitm; int iscflno[3][3]; int iscray[4][9]; int iscrayc[4][9]; int insray[9][4]; int inffilm[3][2]; int inffilw[3][2]; int isffil[3][2]; int iscndx[49]; int nsindx[29]; int iscrec[7]; int insrec[16]; int lnsrec[16]; int lscrec[7]; int insfil[16]; int iscfil[7]; int istpos[3][2]; int lstpos[3][2]; int iscfac[1290]; int insfac[360]; int nscbeg[29]; int nscend[29]; int iscbeg[49]; int iscend[49]; int inspck[720]; float rnsdat[360]; int num[5]; int loc[5]; loc[0] = 0; loc[1] = 1; loc[2] = 91; loc[3] = 436; loc[4] = 0; num[0] = 0; num[1] = 90; num[2] = 345; num[3] = 240; num[4] = 0; dfalt[0] = 2147483647; dfalt[1] = 32767; dfalt[2] = 127; iscflno [0][0] = 1; iscflno [0][1] = 2; iscflno [0][2] = 3; iscflno [1][0] = 4; iscflno [1][1] = 5; iscflno [1][2] = 6; iscflno [2][0] = 7; iscflno [2][1] = 7; iscflno [2][2] = 7; iscray [0][0] = 17; iscray [0][1] = 18; iscray [0][2] = 3; iscray [0][3] = 2; iscray [0][4] = 19; iscray [0][5] = 0; iscray [0][6] = 0; iscray [0][7] = 0; iscray [0][8] = 0; iscray [1][0] = 23; iscray [1][1] = 24; iscray [1][2] = 6; iscray [1][3] = 7; iscray [1][4] = 25; iscray [1][5] = 0; iscray [1][6] = 0; iscray [1][7] = 0; iscray [1][8] = 0; iscray [2][0] = 29; iscray [2][1] = 30; iscray [2][2] = 0; iscray [2][3] = 10; iscray [2][4] = 31; iscray [2][5] = 42; iscray [2][6] = 41; iscray [2][7] = 0; iscray [2][8] = 0; iscray [3][0] = 35; iscray [3][1] = 36; iscray [3][2] = 0; iscray [3][3] = 11; iscray [3][4] = 37; iscray [3][5] = 0; iscray [3][6] = 0; iscray [3][7] = 46; iscray [3][8] = 45; iscrayc [0][0] = 20; iscrayc [0][1] = 21; iscrayc [0][2] = 4; iscrayc [0][3] = 5; iscrayc [0][4] = 22; iscrayc [0][5] = 0; iscrayc [0][6] = 0; iscrayc [0][7] = 0; iscrayc [0][8] = 0; iscrayc [1][0] = 26; iscrayc [1][1] = 27; iscrayc [1][2] = 8; iscrayc [1][3] = 9; iscrayc [1][4] = 28; iscrayc [1][5] = 0; iscrayc [1][6] = 0; iscrayc [1][7] = 0; iscrayc [1][8] = 0; iscrayc [2][0] = 32; iscrayc [2][1] = 33; iscrayc [2][2] = 0; iscrayc [2][3] = 10; iscrayc [2][4] = 34; iscrayc [2][5] = 44; iscrayc [2][6] = 43; iscrayc [2][7] = 0; iscrayc [2][8] = 0; iscrayc [3][0] = 38; iscrayc [3][1] = 39; iscrayc [3][2] = 0; iscrayc [3][3] = 12; iscrayc [3][4] = 40; iscrayc [3][5] = 0; iscrayc [3][6] = 0; iscrayc [3][7] = 48; iscrayc [3][8] = 47; inffilm [0][0] = 1; inffilm [1][0] = 3; inffilm [2][0] = 5; inffilm [0][1] = 2; inffilm [1][1] = 4; inffilm [2][1] = 5; inffilw [0][0] = 6; inffilw [1][0] = 8; inffilw [2][0] = 10; inffilw [0][1] = 7; inffilw [1][1] = 9; inffilw [2][1] = 10; isffil [0][0] = 11; isffil [1][0] = 12; isffil [2][0] = 13; isffil [0][1] = 14; isffil [1][1] = 15; isffil [2][1] = 16; insray[0][0] = 11; insray[1][0] = 12; insray[2][0] = 3; insray[3][0] = 2; insray[4][0] = 13; insray[5][0] = 0; insray[6][0] = 0; insray[7][0] = 0; insray[8][0] = 0; insray[0][1] = 14; insray[1][1] = 15; insray[2][1] = 4; insray[3][1] = 5; insray[4][1] = 16; insray[5][1] = 0; insray[6][1] = 0; insray[7][1] = 0; insray[8][1] = 0; insray[0][2] = 17; insray[1][2] = 18; insray[2][2] = 0; insray[3][2] = 6; insray[4][2] = 19; insray[5][2] = 25; insray[6][2] = 24; insray[7][2] = 0; insray[8][2] = 0; insray[0][3] = 20; insray[1][3] = 21; insray[2][3] = 0; insray[3][3] = 7; insray[4][3] = 22; insray[5][3] = 0; insray[6][3] = 0; insray[7][3] = 27; insray[8][3] = 26; istpos [0][0] = 1; istpos [1][0] = 91; istpos [2][0] = 436; istpos [0][1] = 1; istpos [1][1] = 61; istpos [2][1] = 241; lstpos [0][0] = 90; lstpos [1][0] = 435; lstpos [2][0] = 675; lstpos [0][1] = 60; lstpos [1][1] = 240; lstpos [2][1] = 360; nscbeg [0] = 1; nscbeg [1] = 2; nscbeg [2] = 3; nscbeg [3] = 4; nscbeg [4] = 5; nscbeg [5] = 6; nscbeg [6] = 37; nscbeg [7] = 61; nscbeg [8] = 62; nscbeg [9] = 63; nscbeg [10] = 64; nscbeg [11] = 65; nscbeg [12] = 66; nscbeg [13] = 67; nscbeg [14] = 68; nscbeg [15] = 69; nscbeg [16] = 70; nscbeg [17] = 101; nscbeg [18] = 132; nscbeg [19] = 163; nscbeg [20] = 187; nscbeg [21] = 211; nscbeg [22] = 235; nscbeg [23] = 241; nscbeg [24] = 272; nscbeg [25] = 303; nscbeg [26] = 327; nscbeg [27] = 351; nscbeg [28] = 354; nscend[0] = 1; nscend[1] = 2; nscend[2] = 3; nscend[3] = 4; nscend[4] = 5; nscend[5] = 36; nscend[6] = 60; nscend[7] = 61; nscend[8] = 62; nscend[9] = 63; nscend[10] = 64; nscend[11] = 65; nscend[12] = 66; nscend[13] = 67; nscend[14] = 68; nscend[15] = 69; nscend[16] = 100; nscend[17] = 131; nscend[18] = 162; nscend[19] = 186; nscend[20] = 210; nscend[21] = 234; nscend[22] = 235; nscend[23] = 271; nscend[24] = 302; nscend[25] = 326; nscend[26] = 350; nscend[27] = 353; nscend[28] = 360; iscbeg[0] = 1; iscbeg[1] = 2; iscbeg[2] = 3; iscbeg[3] = 4; iscbeg[4] = 5; iscbeg[5] = 6; iscbeg[6] = 7; iscbeg[7] = 8; iscbeg[8] = 9; iscbeg[9] = 10; iscbeg[10] = 41; iscbeg[11] = 65; iscbeg[12] = 89; iscbeg[13] = 91; iscbeg[14] = 92; iscbeg[15] = 93; iscbeg[16] = 94; iscbeg[17] = 95; iscbeg[18] = 96; iscbeg[19] = 97; iscbeg[20] = 98; iscbeg[21] = 99; iscbeg[22] = 100; iscbeg[23] = 101; iscbeg[24] = 102; iscbeg[25] = 103; iscbeg[26] = 104; iscbeg[27] = 105; iscbeg[28] = 106; iscbeg[29] = 137; iscbeg[30] = 168; iscbeg[31] = 199; iscbeg[32] = 230; iscbeg[33] = 261; iscbeg[34] = 292; iscbeg[35] = 316; iscbeg[36] = 340; iscbeg[37] = 364; iscbeg[38] = 388; iscbeg[39] = 412; iscbeg[40] = 436; iscbeg[41] = 467; iscbeg[42] = 498; iscbeg[43] = 529; iscbeg[44] = 560; iscbeg[45] = 584; iscbeg[46] = 608; iscbeg[47] = 632; iscbeg[48] = 656; iscend[0] = 1; iscend[1] = 2; iscend[2] = 3; iscend[3] = 4; iscend[4] = 5; iscend[5] = 6; iscend[6] = 7; iscend[7] = 8; iscend[8] = 9; iscend[9] = 40; iscend[10] = 64; iscend[11] = 88; iscend[12] = 90; iscend[13] = 91; iscend[14] = 92; iscend[15] = 93; iscend[16] = 94; iscend[17] = 95; iscend[18] = 96; iscend[19] = 97; iscend[20] = 98; iscend[21] = 99; iscend[22] = 100; iscend[23] = 101; iscend[24] = 102; iscend[25] = 103; iscend[26] = 104; iscend[27] = 105; iscend[28] = 136; iscend[29] = 167; iscend[30] = 198; iscend[31] = 229; iscend[32] = 260; iscend[33] = 291; iscend[34] = 315; iscend[35] = 339; iscend[36] = 363; iscend[37] = 387; iscend[38] = 411; iscend[39] = 435; iscend[40] = 466; iscend[41] = 497; iscend[42] = 528; iscend[43] = 559; iscend[44] = 583; iscend[45] = 607; iscend[46] = 631; iscend[47] = 655; iscend[48] = 656; /*************************************************************************************/ /* */ /* The S-4 contains 26 separate files. This program is designed to read the header, */ /* the scale factors, and one of the data files per run. Before using this program, */ /* the S-4 product is separated into 26 files with the above file names. */ /* */ /*************************************************************************************/ printf("\n\n"); printf("\n\n"); printf("\n\n"); printf("\n\n"); printf("\n\n"); printf("\n\n"); printf("\n\n"); printf("\n\n"); printf("\n\n"); printf("Please enter the name of the INPUT file you wish to read : \n"); printf("\n \n"); scanf("%s",file_name); fp = fopen(file_name, "r"); if (fp == NULL) { printf("***************************************************************************\n"); printf("* ERROR - Unable to open the data file for this filename --> %s\n",file_name); printf("* Program has terminated. *\n"); printf("***************************************************************************\n"); } /***************************************************************/ getname: printf("Please enter the name of the OUTPUT file you wish to write OUTPUT to : \n"); scanf("%s",file_out); fpo = fopen(file_out, "r"); if (fpo != NULL) { printf("***************************************************************************\n"); printf("* WARNING: This fillename exist --> %s\n",file_out); printf("* Do you wish to overwrite it? 'y' yes 'n' no *\n"); printf("***************************************************************************\n"); scanf("%s",&ans); if((ans == 'n') || (ans == 'N')) { goto getname; } } fpo = fopen(file_out, "w"); printf("\n\n"); printf("\n\n"); printf("\n\n"); printf("\n\n"); printf("*******************************************************************\n"); printf("* ERBE S4N *\n"); printf("* Options MENU *\n"); printf("-------------------------------------------------------------------\n"); printf("This program will only process Nonscanner data\n"); printf("The following default options will be selected for you\n"); printf("Instrument = 2\n"); printf("Field-of-view = 2\n"); printf("Please enter a value for each option from the following MENU\n"); printf("------------------------------------------------------------\n"); printf("\n"); wrong_val: printf("Enter a value for 'resolution' 2 or 3\n"); printf("\n"); scanf("%s",&ans); ires = atoi(&ans); if ((ires > 3) || (ires < 2)) { printf("There are only two values for you to select\n"); printf("Please try again\n"); goto wrong_val; } wrong_cov: printf("Enter a value for 'coverage' 1,2 or 3\n"); scanf("%s",&ans); icovrg = atoi(&ans); if ((icovrg > 3) || (icovrg < 1)) { printf("There are only three values for you to select\n"); printf("Please try again!\n"); goto wrong_cov; } printf("Enter a value for 'first record to process' \n"); scanf("%s",&ans); irecf = atoi(&ans); printf("Enter a value for 'last record to process' \n"); scanf("%s",&ans); irecl = atoi(&ans); printf("\n\n"); printf("***********************************************************\n"); printf(" no yes \n"); printf(" 1) dgma data values. 0 1 \n"); printf(" 2) hgma data values. 0 1 \n"); printf(" 3) daily data values. 0 1 \n"); printf(" 4) hourly data values. 0 1 \n"); printf("************************************************************\n"); printf("\n"); printf("Enter a value of '1' to turn on this flag for dgma data \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { iray[0] = res; } printf("Enter a value of '1' to turn on this flag for hgma data \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { iray[1] = res; } printf("Enter a value of '1' to turn on this flag for daily data \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { iray[2] = res; } printf("Enter a value of '1' to tunr on this flag for hourly data \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { iray[3] = res; } printf("You have selected these options\n"); printf("iray[0] %d\n",iray[0]); printf("iray[1] %d\n",iray[1]); printf("iray[2] %d\n",iray[2]); printf("iray[3] %d\n",iray[3]); printf("************************************************************\n"); printf(" no yes \n"); printf(" 1) longwave data values. 0 1 \n"); printf(" 2) shortwave data values. 0 1 \n"); printf(" 3) net values. 0 1 \n"); printf(" 4) solar incidence. 0 1 \n"); printf(" 5) albedo values. 0 1 \n"); printf(" 6) no. of days of sw. 0 1 \n"); printf(" 7) no. of days of lw. 0 1 \n"); printf(" 8) no. of hours of sw. 0 1 \n"); printf(" 9) no. of hours of lw. 0 1 \n"); printf("***********************************************************\n"); /******************************************************************/ printf("Enter a value of '1' to turn on this flag for longwave data \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { idata[0] = res; } printf("Enter a value of '1' to turn on this flag for shortwave data \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { idata[1] = res; } printf("Enter a value of '1' to turn on this flag for net value \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { idata[2] = res; } printf("Enter a value of '1' to turn on this flag for solar incidence \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { idata[3] = res; } printf("Enter a value of '1' to turn on this flag for albedo values \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { idata[4] = res; } printf("Enter a value of '1' to turn on this flag for no. of days of sw \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { idata[5] = res; } printf("Enter a value of '1' to turn on this flag for no. of days of lw \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { idata[6] = res; } printf("Enter a value of '1' to turn on this flag for no. of hours of sw \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { idata[7] = res; } printf("Enter a value of '1' to turn on this flag for no. of hours of lw \n"); scanf("%s",&ans); res=atoi(&ans); if (res == 1) { idata[8] = res; } printf("You have selected these options\n"); printf("iray[0] %d\n",iray[0]); printf("iray[1] %d\n",iray[1]); printf("iray[2] %d\n",iray[2]); printf("iray[3] %d\n",iray[3]); printf("\n"); printf("You have selected these options\n"); printf("idata[0] %d\n",idata[0]); printf("idata[1] %d\n",idata[1]); printf("idata[2] %d\n",idata[2]); printf("idata[3] %d\n",idata[3]); printf("idata[4] %d\n",idata[4]); printf("idata[5] %d\n",idata[5]); printf("idata[6] %d\n",idata[6]); printf("idata[7] %d\n",idata[7]); printf("idata[8] %d\n",idata[8]); printf("YOU HAVE REQUESTED THE FOLLOWING OPTIONS TO PROCESS: \n\n"); printf("Instrument = 2\n"); printf("Field-of-view = 2\n"); printf("Resolution = %d\n",ires); printf("Coverage = %d\n",icovrg); printf("First record = %d\n",irecf); printf("Last record = %d\n",irecl); /***********************************************************/ inst = 2; imf = 2; printf("\n"); printf("\n\n"); while ((feof(fp)) == 0) { fscanf(fp,"%s\n",&filename); base_ptr = strrchr(filename,'/'); if(base_ptr != NULL) { strcpy(filename,base_ptr+1); } if ((strncmp(filename,"s4n01",5)) == 0) { strcpy(file1,filename); fp1 = fopen(file1,"r"); if (fp1 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file1); printf("*************************************\n"); exit(0); } fread ((char *)buf,1,ni,fp1); (void) dmphdr (fpo,buf); } else if ((strncmp(filename,"s4n02",5)) == 0) { strcpy(file2,filename); fp2 = fopen(file2,"r"); if (fp2 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file2); printf("*************************************\n"); exit(0); } } else if ((strncmp(filename,"s4n03",5)) == 0) { strcpy(file3,filename); fp3 = fopen(file3,"r"); if (fp3 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file3); printf("*************************************\n"); exit(0); } (void) nscscl (fpo,fp3 ,&insfac[0] ,&dfalt[0] ,&loc[0] ,&num[0]); if (inst == 2) { (void) nscinit(fpo,&insray[0][0] ,&inffilm[0][0] ,&inffilw[0][0] ,&isffil[0][0] ,&idata[0] ,&nsindx[0] ,&insrec[0] ,&lnsrec[0] ,&insfil ,&iray[0] ,&icovrg ,&ires ,&irecf ,&irecl ,&imf ,&insitm); } } else if ((strncmp(filename,"s4n04",5)) == 0) { strcpy(file4,filename); fp4 = fopen(file4,"r"); if (fp4 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file4); printf("*************************************\n"); exit(0); } } else if ((strncmp(filename,"s4n05",5)) == 0) { strcpy(file5,filename); fp5 = fopen(file5,"r"); if (fp5 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file5); printf("*************************************\n"); exit(0); } } else if ((strncmp(filename,"s4n06",5)) == 0) { strcpy(file6,filename); fp6 = fopen(file6,"r"); if (fp6 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file6); printf("*************************************\n"); exit(0); } } else if ((strncmp(filename,"s4n07",5)) == 0) { strcpy(file7,filename); fp7 = fopen(file7,"r"); if (fp7 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file7); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n08",5) == 0) { strcpy(file8,filename); fp8 = fopen(file8,"r"); if (fp8 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file8); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n09",5) == 0) { strcpy(file9,filename); fp9 = fopen(file9,"r"); if (fp9 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file9); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n10",5) == 0) { strcpy(file10,filename); fp10 = fopen(file10,"r"); if (fp10 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file10); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n11",5) == 0) { strcpy(file11,filename); fp11 = fopen(file11,"r"); if (fp11 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file11); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n12",5) == 0) { strcpy(file12,filename); fp12 = fopen(file12,"r"); if (fp12 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file12); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n13",5) == 0) { strcpy(file13,filename); fp13 = fopen(file13,"r"); if (fp13 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file13); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n14",5) == 0) { strcpy(file14,filename); fp14 = fopen(file14,"r"); if (fp14 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file14); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n15",5) == 0) { strcpy(file15,filename); fp15 = fopen(file15,"r"); if (fp15 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file15); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n16",5) == 0) { strcpy(file16,filename); fp16 = fopen(file16,"r"); if (fp16 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file16); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n17",5) == 0) { strcpy(file17,filename); fp17 = fopen(file17,"r"); if (fp17 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file17); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n18",5) == 0) { strcpy(file18,filename); fp18 = fopen(file18,"r"); if (fp18 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file18); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n19",5) == 0) { strcpy(file19,filename); fp19 = fopen(file19,"r"); if (fp19 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file19); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n20",5) == 0) { strcpy(file20,filename); fp20 = fopen(file20,"r"); if (fp20 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file20); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n21",5) == 0) { strcpy(file21,filename); fp21 = fopen(file21,"r"); if (fp21 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file21); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n22",5) == 0) { strcpy(file22,filename); fp22 = fopen(file22,"r"); if (fp22 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file22); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n23",5) == 0) { strcpy(file23,filename); fp23 = fopen(file23,"r"); if (fp23 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file23); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n24",5) == 0) { strcpy(file24,filename); fp24 = fopen(file24,"r"); if (fp24 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file24); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n25",5) == 0) { strcpy(file25,filename); fp25 = fopen(file25,"r"); if (fp25 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file25); printf("*************************************\n"); exit(0); } } else if (strncmp(filename,"s4n26",5) == 0) { strcpy(file26,filename); fp26 = fopen(file26,"r"); if (fp26 == NULL) { printf("*************************************\n"); printf("* ERROR - Unable to open %s\n",file26); printf("*************************************\n"); exit(0); } } } /*** End of the while loop ***/ /*** NOW PROCESS TAPES ***/ /** process the nonscanner files **/ nfile = 0; for(i = 0; i <= 16; i++) { if (insfil[i] == 1) { nfile = nfile + i; (void) nscfil(fpo,fp11 ,fp12 ,fp13 ,fp14 ,fp15 ,fp16 ,fp17 ,fp18 ,fp19 ,fp20 ,fp21 ,fp22 ,fp23 ,fp24 ,fp25 ,fp26 ,&nfile ,&rnsdat[0] ,&nsindx[0] ,&nscbeg[0] ,&nscend[0] ,&insrec[0] ,&lscrec[0] ,&lnsrec[0] ,&dfalt[0] ,&inspck[0] ,&istpos[0][0] ,&lstpos[0][0] ,&insfac[0] ,&insitm); } /**End of if loop **/ nfile = 0; } /**End of the for loop for nonscanner **/ } /*** END OF MAIN ***/ /*******************************************************************/ /* */ /* (void) dmphdr (fpo,buf) */ /* */ /*******************************************************************/ void dmphdr (fpo,ihead) FILE *fpo; unsigned short ihead [30]; { char productid[13]; char granuleid[20]; char ireslt[30]; char pdate[9]; char temp[3]; int temp_val [30]; char hold[1]; int iprod; int icraft; float wjd; float fjd; int j; *pdate = '\0'; *ireslt = '\0'; /*** write processing date ***/ for (j = 0; j <= 30; j++) { temp_val[j] = ihead[j]; } temp_val[j] = '\n'; if (ihead[8] < 10) { j=temp_val[8]; sprintf(temp,"%d",j); strcpy(pdate,temp,2); strcat(pdate,"/"); } else { j=temp_val[8]; sprintf(temp,"%d",j); strcpy(pdate,temp,3); strcat(pdate,"/"); } if (ihead[9] > 10) { j=temp_val[9]; sprintf(temp,"%d",j); strcat(pdate,temp); strcat(pdate,"/"); } else { j=temp_val[9]; sprintf(temp,"%d",j); strcat(pdate,temp); strcat(pdate,"/"); } if (ihead[7] > 10) { j=temp_val[7]; if(j != 0) { sprintf(temp,"%d",j); strcat(pdate,"19"); strcat(pdate,temp); } } else { /** add code for the year 2000 **/ } /*** define product code ***/ if (ihead[2] == 19) { iprod = 1; } else if (ihead[2] == 0) { iprod = 2; } else if (ihead[1] == 2) { iprod = 3; } else if (ihead[2] == 8) { iprod = 4; } else if (ihead[2] == 4) { iprod = 5; strcpy(productid,"s8_"); } else if (ihead[2] == 60) { iprod = 6; strcpy(productid,"s9_"); } else if (ihead[2] == 62) { iprod = 7; strcpy(productid,"s10_mfov_nf_"); } else if (ihead[2] == 64) { iprod = 8; strcpy(productid,"s10_wfov_nf_"); } else if (ihead[2] == 66) { iprod = 9; strcpy(productid,"s10_mfov_sf_"); } else if (ihead[2] == 68) { iprod = 10; strcpy(productid,"s10_wfov_sf_"); } else if (ihead[2] == 84) { iprod = 11; strcpy(productid,"s10n_wfov_nf_"); } else if (ihead[2] == 88) { iprod = 12; strcpy(productid,"s10n_wfov_sf_"); } else if (ihead[2] == 3) { iprod = 13; strcpy(productid,"ivt_"); } else { iprod = 13; strcpy(productid,"?????"); } fprintf(fpo,"\n\n"); fprintf(fpo,"PHYSICAL HEADER CONTENTS:\n"); fprintf(fpo," (0) subsystem indicator : %d\n",ihead[1]); fprintf(fpo," (1) product code : %d\n",ihead[2]); fprintf(fpo," (2) spacecraft indicator : %d\n",ihead[3]); fprintf(fpo," (3) whole julian date - high : %d\n",ihead[4]); fprintf(fpo," (4) whole julian date - low : %d\n",ihead[5]); fprintf(fpo," (5) fractional julian date : %d\n",ihead[6]); fprintf(fpo," (6) processed version counter : %d\n",ihead[7]); fprintf(fpo," (7) year processed : %d\n",ihead[8]); fprintf(fpo," (8) month processed : %d\n",ihead[9]); fprintf(fpo," (9) day processed : %d\n",ihead[10]); fprintf(fpo," (10) hour processed : %d\n",ihead[11]); fprintf(fpo," (11) minute processed : %d\n",ihead[12]); fprintf(fpo," (12) second processed : %d\n",ihead[13]); /*** obtain temporal span ***/ wjd = (ihead[3] * 10000 + ihead[4]); fjd = (ihead[5] / 10000.); (void) datchr (wjd ,fjd ,ireslt); /*** set spacecraft ***/ icraft = ihead[2]; if (iprod == 5) { strcpy(granuleid,productid,3); } /*** print out tape specifications ***/ /** for erbeid based upon iprod ***/ switch (iprod) { case 1: fprintf(fpo,"ERBE Product : S-2"); break; case 2: fprintf(fpo,"ERBE Product : S-4"); break; case 3: fprintf(fpo,"\n\n\n"); fprintf(fpo,"\n\n\n"); fprintf(fpo,"\n\n\n"); fprintf(fpo,"\n\n\n"); fprintf(fpo,"ERBE Product : S-4N"); break; case 4: fprintf(fpo,"ERBE Product : S-7"); break; case 5: fprintf(fpo,"ERBE Product : S-8"); break; case 6: fprintf(fpo,"ERBE Product : S-9"); break; case 7: fprintf(fpo,"ERBE Product : S-10_MFOV_NF"); break; case 8: fprintf(fpo,"ERBE Product : S-10_WFOV_NF"); break; case 9: fprintf(fpo,"ERBE Product : S-10_MFOV_SF"); break; case 10: fprintf(fpo,"ERBE Product : S-10_WFOV_SF"); break; case 11: fprintf(fpo,"ERBE Product : S_10N_WFOV_NF"); break; case 12: fprintf(fpo,"ERBE Product : S-10N_WFOV_SF"); break; case 13: fprintf(fpo,"ERBE Product : ERBE IVT"); break; case 14: fprintf(fpo,"ERBE Product : ???"); break; } /**End switch **/ fprintf(fpo,"\n"); /** for iscnam based upon icraft ***/ switch (icraft) { case 1: fprintf(fpo,"Spacecraft : NOAA-9"); break; case 2: fprintf(fpo,"Spacecraft : ERBS"); break; case 3: fprintf(fpo,"Spacecraft : NOAA-10"); break; case 4: fprintf(fpo,"Spacecraft : NOAA-9 & NOAA-10 Processing date : %s",pdate); break; case 5: fprintf(fpo,"Spacecraft : ERBS & NOAA-9"); break; case 6: fprintf(fpo,"Spacecraft : ERBS & NOAA-10"); break; case 7: fprintf(fpo,"Spacecraft : ERBS, NOAA-9, & NOAA-10 Processing date : %s",pdate); break; } /**End switch **/ fprintf(fpo,"\n"); fprintf(fpo,"Data Date : %s",ireslt); fprintf(fpo," Processing version: %d\n",ihead[6]); fprintf(fpo,"\n"); } /*End of function dmphdr */ /********************************************************/ /* Function DATCHR */ /* */ /* input : wjd ,fjd */ /* output: ireslt */ /********************************************************/ void datchr (wjd ,fjd ,ireslt) float wjd; float fjd; char ireslt[30]; { float date[7]; int ind = 0; int iyear; int imon; int lday; char temp[3]; (void) julcal(wjd ,fjd ,ind ,date); iyear = date[0]; imon = date[1]; lday = date[2]; sprintf(temp,"%d",iyear); strcpy(ireslt,temp,2); strcat(ireslt,"/"); if (imon < 10) { strcat(ireslt,"0"); } sprintf(temp,"%d",imon); strcat(ireslt,temp,2); strcat(ireslt,"/"); if (lday < 10) { strcat(ireslt,"0"); } sprintf(temp,"%d",lday); strcat(ireslt,temp,2); } /*** End of function datchr ***/ /********************************/ /* Fuction JULCAL */ /********************************/ void julcal (wholjd ,fracjd ,ind ,dat) float wholjd; float fracjd; int ind; float dat[7]; { int iyr; int iday; int iyymmd; int intday; int iymd; int ianal = 1; int morday; float moryr; int idayyr; int iyr49; int iyrmo; int isec; int ihr; int imin; int ncalls[60]; float fraday; float leapcy; if (ianal == 1) { /*** This should be a common block ***/ ncalls[23] = ncalls[23] + 1; /*** ***/ /*** the program does not combine whole and fractional parts, but ***/ /*** works with each part separately. this is done to maintain the ***/ /*** maximum number of significant digits for each value. ***/ } if (ind == 0) { if (fracjd >= 0.5) { intday = (wholjd - 2432917.); fraday = fracjd - 0.5; } else { fraday = fracjd + 0.5; intday = (wholjd - 2432918.); } } else { intday = (wholjd + 365. ); fraday = fracjd; } leapcy = intday / 1461; morday = intday - (leapcy * 1461); iyr49 = leapcy * 4; /*** If the elasped time is a multiple number of 4-year cycles with ***/ /*** less than one year of additional time, these values are now ***/ /*** valid. If a year or more remains in addition, however, the number ***/ /*** of years must be accounted for. Because leap year is the fourth ***/ /*** year of each 4-year cycle since 01january 1949, each whole elapsed year ***/ /*** is 365 days in length. ***/ if (morday >= 365) { moryr = morday / 365; if (moryr == 4) { moryr = 3; iyr49 = iyr49 + moryr; morday = morday - (moryr * 365); } } iyr = iyr49 + 49; dat[0] = iyr; /*** Morday indicates how many additional days into the year must be ***/ /*** accounted for. If it is the first day of the year, no additional ***/ /*** days need be accounted for, because 01 january is an exact number ***/ /*** of elapsed years. On january 2, 1 more day must be accounted for. ***/ /*** In general, to account for x more days, we need the x+1 day of the year. ***/ idayyr = morday + 1; /*** The function yymmdd will return the day of the year based on ***/ /*** a number of days elapsed. ***/ (void) yymmdd (iyr ,idayyr ,&iymd); /*** From iymd, the month and day must be separated. ***/ dat[2] = (iymd%100) ; iyrmo = iymd/100; dat[1] = (iyrmo%100); /*** The fractional part of the day will be converted into seconds by ***/ /*** multiplying by total seconds per day (86400). The excess will ***/ /*** be truncated from seconds and captured into dat[6]. ***/ isec = ( 86400. * fraday); dat[5] = 86400. * fraday - isec; ihr = isec / 3600; dat[3] = ihr; isec = isec - (ihr * 3600); imin = isec / 60; dat[4] = imin; dat[5] = (isec - (imin * 60)) + dat[5]; } /*End of function julcal */ /*********************************/ /* Function YYMMDD */ /*********************************/ void yymmdd (iyr ,iday ,iyymmd) int iyr; int iday; int *iyymmd; { int jday; int leap; int imon1; int ianal = 1; int irow; int i; int idymon[13][2]; idymon[0][0] = 0; idymon[1][0] = 31; idymon[2][0] = 59; idymon[3][0] = 90; idymon[4][0] = 120; idymon[5][0] = 151; idymon[6][0] = 181; idymon[7][0] = 212; idymon[8][0] = 243; idymon[9][0] = 273; idymon[10][0] = 304; idymon[11][0] = 334; idymon[12][0] = 365; idymon[0][1] = 0; idymon[1][1] = 31; idymon[2][1] = 60; idymon[3][1] = 91; idymon[4][1] = 121; idymon[5][1] = 152; idymon[6][1] = 182; idymon[7][1] = 213; idymon[8][1] = 244; idymon[9][1] = 274; idymon[10][1] = 305; idymon[11][1] = 335; idymon[12][1] = 366; jday = iday; leap = iyr - (iyr/4) * 4; if (leap == 0) { irow = 1; } else { irow = 0; } /*** Locate the proper month of the year by stepping backwards ***/ /*** and checking total days elapsed. ***/ imon1 = 13; /*** do until idymon < jday ***/ for (i=1; i<=13; i++) { if (idymon[imon1-i][irow] < jday) { imon1 = imon1 - i; goto done; } } done: jday = jday - idymon[imon1][irow]; imon1 = imon1 + 1; *iyymmd = (iyr*10000) + (imon1*100) + jday; } /*** End of yymmdd function */ /********************************************************/ /* */ /* (void) scnscl (fp2) */ /* */ /* To unpack and print out the scanner scale factors */ /* and make them ready for use with the scanner data. */ /********************************************************/ void scnscl (fp2 ,iscfac ,dfalt ,num ,loc) FILE *fp2; int *iscfac; int *dfalt; int *num; int *loc; { unsigned int buf[1050]; int iopt; int iscpck[1290]; int itemp[1050]; int insfac[360]; int ntot; int ni; int nb; int i; int nr; int k; int ii; k=0; iopt = 0; ni=1050; nb =1; /***************************************/ /* this was in a common block in the */ /* fortran program. */ /* array dfalt[3] */ /***************************************/ fread ((char *)buf,1,ni,fp2); nr=262; for (i=0; i<=nr; i++) { *(iscpck+i) = buf[i]; } ni = 240; fread ((char *)buf,1,ni,fp2); nr = 323; for (i=263; i<=nr; i++) { k = k + 1; *(iscpck+i) = buf[k]; } /*** unpack the scale factor record ***/ (void) stuff(&dfalt[0] ,&iopt ,&iscpck[0] ,&loc[0] ,&num[0] ,&iscfac[0] ,&ntot); /*** write out the scale factors ***/ k=0; printf(" SCANNNER SCALE FACTORS\n\n"); for(i=1;i<=360;i++) { k++; printf("%5d ",*(iscfac+i)); if(k > 12) { printf("\n"); k=0; } } /**End of for loop **/ printf("end of scnscl\n"); } /*** End of function scnscl ***/ /*************************************************************/ /* */ /* Function nscscl */ /* */ /* This function will unpack and print out the nonscanner */ /* scale factors and make them ready for use with the */ /* nonscanner data. */ /*************************************************************/ void nscscl (fpo,fp3 ,insfac ,dfalt ,loc ,num) FILE *fpo; int *insfac; int *dfalt; int *loc; int *num; { unsigned int buf[1050]; int iopt; int ni; int inspck[720]; int ntot; int i; int k; ni=720; iopt = 0; num[1] = 60; num[2] = 180; num[3] = 120; num[4] = 0; loc[1] = 1; loc[2] = 61; loc[3] = 241; loc[4] = 0; /*******************************************/ /* this was in a common block in the */ /* fortran program. */ /* array dfalt[3] */ /*******************************************/ fread ((char *)buf,1,ni,fp3); /*** unpack the scale factors ***/ for(i=0;i<=719;i++) { inspck[i] = buf[i]; } (void) stuff(&dfalt[0] ,&iopt ,&inspck[0] ,&loc[0] ,&num[0] ,&insfac[0] ,&ntot); /*** write out scale factors ***/ fprintf(fpo,"\n\n\n"); fprintf(fpo," NONSCANNER SCALE FACTORS\n"); k=0; for(i=1;i<=360;i++) { k++; fprintf(fpo,"%5d ",*(insfac+i)); if(k > 9) { fprintf(fpo,"\n"); k=0; } } /**End of for loop **/ fprintf(fpo,"\n\n"); } /* End of function nscscl */ /*************************************************************/ /* Function stuff */ /* */ /* To pack or unpack an integer array into an output integer */ /* array according to user-specified word sizes (any combo */ /* of 32-,16-,8-,and/or 4-bit words) and convert between */ /* subsystem-defined default values and word-size-dependent */ /* (2**(n-1)-1, where n=number of bits per word) defaults. */ /*************************************************************/ void stuff(dfalt ,iopt ,idata ,loc ,num ,ldata ,ntot) int *dfalt; int *idata; int *ldata; int *iopt; int *loc; int *num; int *ntot; { /*** initialize ***/ int dfault; int iexp; int istrt; int iretck; int nwords; int iret; int i; int j; int k; int itwo; int nbits; int npad; int itest; int jstop; int ix1; ix1 = 32; iexp=6; istrt=0; iretck=0; for (i=1; i<=3; i++) { nwords = 0; iret = 0; /*** check for usage of this word-size -- if so, continue; ***/ /*** if not, increment loop ***/ if (*(num+i) > 0) { /*** calculate word-size (itwo), and number of 60-bit words ***/ /*** needed for the pack or unpack of (nwords). ***/ itwo=1; for(j=1;j<=iexp-i;j++) { itwo = itwo * 2; } nbits = *(num+i); nbits = nbits * itwo; nwords = nbits/32; npad = nbits-nwords*32; if (npad > 0) { nwords = nwords + 1; } k = *(loc+i); /*** calculate word-size-dependent default (itest) ***/ itest=1; for(j=1;j<=itwo-1;j++) { itest = itest * 2; } itest = itest - 1; if (*iopt == 1) { *ntot = *ntot + nwords; /*** convert defaults (except 4-bit) ***/ if (i < 4) { jstop = k+*(num+i)-1; for (j=k; j 0) { if (*inbts > 0 && *inbts < 33) { if (*iotbts > 0 && *iotbts < 33) { if (((*iotbts == 32) && (*numpck < 134217727)) || (*inbts == 32 && *numpck < 268435455)) { *numdon = (*numpck * *iotbts) / *inbts; /*** determine if we are doing an unpack or a pack ***/ if (*iotbts == 32) /*** we are doing an unpack ***/ { (void) gbytes(isrc ,idest ,&ix1 ,inbts ,&ixy ,numdon); } else { /*** There is potential for a problem here. ***/ ix1 = 0; ixy = 0; (void) sbytes(idest ,isrc ,&ix1 ,&iotbts ,&ixy ,&numpck); } } /*End of if iotbts == 32 */ } /* End of if iotbts */ } /*End of if inbts > 0 */ else /* For some reason we had errors in the input. */ { *numdon = 0; } } /*End of if numpck */ } /*** End of function spread ***/ /****************************************************/ /* */ /* Function gbytes */ /* */ /* Purpose to unpack n b bit bytes from p into u */ /* starting by skipping q bits in p then skipping */ /* s bits between bytes. */ /****************************************************/ void gbytes(p ,u ,q ,b ,s ,n) long *p, *u, *q, *b, *s, *n; { register long i = 0, jp = 0; long jq = *q; if (*n > 0) { while (1) { (void) gbyte (p + jp, u + i, &jq, b); if (++i == *n) { break; } jq += *b + *s; jp += jq / SWORD; jq %= SWORD; } } }/*** End of function gbytes***/ /****************************************************/ /* */ /* Function sbytes */ /* */ /* Purpose to pack n b bit bytes from u into p */ /* starting by skipping q bits in p then skipping */ /* s bits between bytes. */ /****************************************************/ void sbytes(p ,u ,q ,b ,s ,n) long *p, *u, *q, *b, *s, *n; { register long i = 0, jp = 0; long jq = *q; if (*n > 0) { while (1) { (void) sbyte(p + jp,u + i,&jq ,b); if (++i == *n) { break; } jq += *b + *s; jp += jq / SWORD; jq %= SWORD; } } }/*** End of function sbytes ***/ /****************************************************/ /* */ /* Function sbyte */ /* Purpose to pack one byte. */ /****************************************************/ void sbyte(p, u, q, b) long *p, *u, *q, *b; { register long *t, jq = *q, jb = *b, qb; if (jq < SWORD) { t = p; } else { t = p + jq / SWORD; jq %= SWORD; } if ((jq + jb) > SWORD) { qb = SWORD - jq; jq = SWORD - jb; jb -= qb; *t = ((*t >> qb) << qb) + (G1BYTE(*u, jq ,qb)); jq = 0; t++; /* point to next word */ } *t = (*t & ~(MASK << (SWORD - jb) >> jq)) + ((~(MASK << jb) & *u) << SWORD-(jb+jq)); *t = (*t & ~(MASK << (SWORD - jb) >> jq)) + (((unsigned) *u) << (SWORD - jb) >> jq); }/*** End of function sbyte ***/ /******************************************************/ /* */ /* Function gbyte */ /* */ /* Purpose to unpack one byte. */ /******************************************************/ void gbyte(p ,u ,q ,b) long *p, *u ,*q ,*b; { register long j, jq = *q, jb = *b, lb, qb; if (jq < SWORD) { j = 0; } else { j = jq / SWORD; /* number of words offset */ jq %= SWORD; /* odd bits of offset */ } if ((jq + jb) > SWORD) { qb = SWORD - jq; jb -= qb; lb = ((~(MASK << qb)) & (*(p + j))) << jb; jq = 0; j++; /* increment to next word */ *u = lb + (G1BYTE(*(p + j), jq, jb)); } else { *u = (G1BYTE(*(p + j), jq, jb)); } } /* End of function gbyte */ /*******************************************************/ /* Function sesprd */ /* */ /* Takes bit string data from the input array (in) */ /* does sign extend for unpack operations */ /* and places it in the output array (iout). */ /*******************************************************/ void sesprd(in ,iout ,inbits ,itbits ,inwrds ,itwrds) int *in; int *iout; int *inbits; int *inwrds; int *itwrds; int *itbits; { int ianal; int lbit; int n; int i; /* Use spread to do bit manipulation */ (void) spread(in ,iout ,inbits ,itbits ,inwrds ,itwrds); /* check for an unpack operation */ if (*itbits == 32) { lbit = 32 - *inbits; n = (*itbits * *inwrds) / *inbits; for (i = 1;i <= n;i++) { /* iout[i]=shift(shift(iout[i],lbit),-(lbit)); */ } /* End for loop */ } /* End if itbits */ } /* End of sesprd */ /**********************************************************/ /* Function scninit */ /* */ /* Purpose of this subroutine is to initialize all arrays */ /* and variables to be used to dump scanner data record. */ /**********************************************************/ void scninit(idata ,iscflno ,iscray ,iscrayc ,iscndx ,iscrec ,lscrec ,icovrg ,ires ,irecf ,irecl ,imf ,iray ,iscfil ,iscitm) int *idata[]; int *iscflno[][3]; int *iscray[][9]; int *iscrayc[][9]; int *iscndx[]; int *iscrec[]; int *lscrec[]; int *iray[]; int *iscfil[]; int *icovrg; int *ires; int *irecf; int *irecl; int *imf; int *iscitm; { int isub; int k; int j; int i; isub = *iscflno[*icovrg-1][*ires-1]; *iscfil[isub] = 1; *iscndx[1] = 1; *iscndx[2] = 14; *iscndx[3] = 49; k=3; if((imf == 1) || (imf == 3)) { for (i=0;i<=4;i++) { if (*iray[i] == 1) { for (j=0;j<=9;j++) { if (*idata[j] == 1) { if (*iscray[i][j] != 0) { k = k + 1; *iscndx[k] = *iscray[i][j]; } /* End of if iscray */ } /* End if idata */ } /* End of for j loop */ } /* End if iray */ } /* End of for loop */ } /* End if imf */ if((imf == 2) || (imf ==3)) { for (i=0;i<=4;i++) { if (iray[i] == 1) { for (j = 0;j <= 9; j++) { if (idata[j] == 1 ) { if (iscrayc[i][j] != 0) { k = k + 1; iscndx[k] = iscrayc[i][j]; } /* End of if iscrayc */ } /* End of if idata */ } /* End of for j loop */ } /* End of if iray */ } /* End of for loop */ } /* End of if imf = 2 */ *iscitm = k; iscrec[isub] = *irecf; lscrec[isub] = *irecl; } /*** End of function scninit ***/ /*******************************************************************/ /* */ /* Function nscinit */ /* */ /* Purpose of this routine is to initialize the arrays and */ /* variables used to dump nonscanner data. */ /*******************************************************************/ void nscinit(fpo,insray ,inffilm ,inffilw ,isffil ,idata ,nsindx ,insrec ,lnsrec ,insfil ,iray ,icovrg ,ires ,irecf ,irecl ,imf ,insitm) FILE *fpo; int *insray[][4]; int *inffilm[][2]; int *inffilw[][2]; int *isffil [][2]; int *idata[]; int *nsindx[]; int *insrec[]; int *lnsrec[]; int *insfil[]; int *iray[]; int *icovrg; int *ires; int *irecf; int *irecl; int *imf; int *insitm; { int isub; int i; int j; int k; if ((*imf == 1) && (*ires != 3)) { isub = inffilm[*icovrg-1][*ires-2]; } if ((*imf == 2) && (*ires != 3)) { isub = inffilw[*icovrg-1][*ires-2]; } if (*ires == 3) { isub = isffil[*icovrg-1][*imf-1]; } insfil[isub] = 1; nsindx[0] = 1; nsindx[1] = 8; nsindx[2] = 23; nsindx[3] = 28; k = 3; for (i=0; i<=3;i++) { if (iray[i] == 1) { for (j=0; j<= 8; j++) { if (idata[j] == 1) { if (insray[j][i] != 0) { k = k + 1; nsindx[k] = insray[j][i]; } /* End of if insray */ } /* End of if iray */ } /* End of for loop */ } /* End of if iray */ } /* End of for loop */ *insitm = k; insrec[isub] = *irecf; lnsrec[isub] = *irecl; } /* End of the function nscinit */ /***************************************************************/ /* */ /* Purpose to process the desired records of any */ /* given scanner file. */ /**************************************************************/ void scnfil(fp4 ,fp5 ,fp6 ,fp7 ,fp8 ,fp9 ,fp10 ,nfile ,iscrec ,lscrec ,istpos ,lstpos ,iscndx ,iscfac ,iscbeg ,iscend ,iscitm ,dfalt) FILE *fp4, *fp5, *fp6, *fp7, *fp8, *fp9, *fp10; int *nfile; int *iscrec[]; int *lscrec[]; int *istpos[][2]; int *lstpos[][2]; int *iscfac[]; int *iscndx[]; int *iscbeg[]; int *iscend[]; int *dfalt[]; int *iscitm; { float rscdat[1290]; int rsndat[360]; int ifrec; int ifile; int ilrec; int icnt; int indx; int item; int jbeg; int jend; int i; int nb; /* determine range of records to be looked at. */ nb = 1; switch (*nfile) { case 4: printf("case 4\n"); printf(" SCANNER FILE %d\n",*nfile-3); ifrec = *(iscrec+*nfile-3); ilrec = *(lscrec+*nfile-3); for (icnt=ifrec;icnt<=ilrec;icnt++) { loop: (void) scnrec(fp4 ,&istpos[0] ,&lstpos[0] ,&iscfac[0] ,&rscdat[0] ,&dfalt[0]); if (ilrec < rscdat[91]) { printf("****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit; } else if (*(rscdat+91) < ifrec) { goto loop; } else if ((*(rscdat+91)>= ifrec) && (*(rscdat+91) <= ilrec)) { for (indx=1; indx<= *iscitm;indx++) { item = *(iscndx+indx); jbeg = *(iscbeg+item); jend = *(iscend+item); (void) scnnam(&item ,&jbeg ,&jend ,&rscdat[0]); }/** End of for **/ } /** End of if **/ }/**End of for loop **/ endit: break; case 5: for (icnt=ifrec;icnt<=ilrec;icnt++) { ifrec = *iscrec+*nfile-4; ilrec = *lscrec+*nfile-4; (void) scnrec(fp5 ,&istpos[0][0] ,&lstpos[0][0] ,&iscfac[0] ,&rscdat[0] ,&dfalt[0]); } break; case 6: for (icnt=ifrec;icnt<=ilrec;icnt++) { ifrec = *iscrec+*nfile-4; ilrec = *lscrec+*nfile-4; (void) scnrec(fp6 ,&istpos[0][0] ,&lstpos[0][0] ,&iscfac[0] ,&rscdat[0] ,&dfalt[0]); } break; case 7: for (icnt=ifrec;icnt<=ilrec;icnt++) { ifrec = *iscrec+*nfile-4; ilrec = *lscrec+*nfile-4; (void) scnrec(fp7 ,&istpos[0][0] ,&lstpos[0][0] ,&iscfac[0] ,&rscdat[0] ,&dfalt[0]); } break; case 8: for (icnt=ifrec;icnt<=ilrec;icnt++) { ifrec = *iscrec+*nfile-4; ilrec = *lscrec+*nfile-4; (void) scnrec(fp8 ,&istpos[0][0] ,&lstpos[0][0] ,&iscfac[0] ,&rscdat[0] ,&dfalt[0]); } break; case 9: for (icnt=ifrec;icnt<=ilrec;icnt++) { ifrec = *iscrec+*nfile-4; ilrec = *lscrec+*nfile-4; (void) scnrec(fp9 ,&istpos[0][0] ,&lstpos[0][0] ,&iscfac[0] ,&rscdat[0] ,&dfalt[0]); } break; case 10: for (icnt=ifrec;icnt<=ilrec;icnt++) { ifrec = *iscrec+*nfile-4; ilrec = *lscrec+*nfile-4; (void) scnrec(fp10 ,&istpos[0][0] ,&lstpos[0][0] ,&iscfac[0] ,&rscdat[0] ,&dfalt[0]); } } /** End of switch **/ } /* End of function scnfil */ /***********************************************************/ /* */ /* Function scnrec */ /* */ /* Purpose to unpack a scanner data record */ /* and scale the values. */ /***********************************************************/ void scnrec(fpn ,istpos ,lstpos ,iscfac ,rscdat ,dfalt) FILE *fpn; int *istpos[][2]; int *lstpos[][2]; int *iscfac[]; float *rscdat[]; int *dfalt[]; { unsigned int buf[1050]; float xyz; int iopt; int loc[4]; int num[4]; int iscpck[1290]; int iscdat[675]; int ni; int nb; int i; int j; int k; int ifst; int ilst; int ntot; int numbtyp; nb = 1; loc[1] = 1; loc[2] = 91; loc[3] = 436; loc[4] = 0; /* begin scanner processing. */ num[1] = 90; num[2] = 345; num[3] = 240; num[4] = 0; numbtyp = 3; ni=1050; k=0; fread((char *)buf,1,ni,fpn); for(i=0;i<=262;i++) { iscpck[i] = buf[i]; } ni=240; fread((char *)buf,1,ni,fpn); for(i=263;i<=322;i++) { k = k + 1; iscpck[i] = buf[k]; } for(i=0;i<=674;i++) { rscdat[i] = iscdat[i]; } /* calculate scaled values */ for (i=0;i<=numbtyp;i++) { ifst = istpos[i][0]; ilst = lstpos[i][0]; for (j=ifst;j<=ilst;j++) { if (rscdat[j] != dfalt[i]) { xyz = *iscfac[j]; if (xyz != 0) *rscdat[j] = *rscdat[j] / xyz; } /* end of if rscdat */ } /* End of for loop */ } /* End of for i loop */ }/* End of function scnrec */ shift (idata ,ifactor) /**********************************************************************/ /* */ /* Function shift */ /* */ /* Purpose - */ /* shift(a1,a2) is a specific function that returns a shifted result. */ /* The argument a1 is the data to be shifted. Argument a2 is the */ /* number of binary positions a1 will be shifted and the direction */ /* of the shift. If a2 is greater than zero, the shift will be left */ /* circular. If a2 is less than zero, the shift will be right with */ /* sign extension and end drop off. If a2 is zero, no shift will */ /* be accomplished. */ /**********************************************************************/ #define MINO(a,b) (((a) < (b)) ? (a) : (b)); int idata; int ifactor; { int ishift; int icount; int loop; int ix1; int ifac; int ibit31; int shiftbits; ifac=ifactor; /* need to load the value */ shiftbits = idata; /* make sure the user wants to do something */ if (ifactor != 0) { /* adjust the magnitude of the shift */ /* find the absolute value of ifac */ if (ifac < 0) { ifac = ifac * -1; } /* find the minimum value */ ifac = MINO(ifac,32); /* determine correct sign */ if(ifactor >= 0) { ifactor = ifac; } else { ifactor = ifac * -1; } /* get the number of bit to shift the data */ /* find the absolute value of ifactor */ icount = ifactor; if (ifactor < 0) { icount = ifactor * -1; } /* determine direction of shift */ if (ifactor > 0) { /* do the left circular shift */ for (loop = 1;loop <= icount; loop++) { ibit31 = shiftbits << 31; /* save most significant bit */ /* do the shift */ shiftbits = shiftbits << 1; /* perform the end-carry of most-significant bit */ /* to the least significant bit position. */ /* For the right arithmatic shift, with sign extension */ /* and end drop off, we do not need to work black magic, */ } /* End of for loop */ } /* End of if ifactor > 0*/ } /* End if ifactor != 0*/ } /* End of function shift */ /************************************************************/ /* Function scnnam */ /* */ /************************************************************/ void scnnam (item ,jbeg ,jend ,rscdat) int *item; int *jbeg; int *jend; float rscdat[675]; { int i; if (*item == 1) { printf("FILE ID "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 2) { printf("TSOLRD-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 3) { printf("NET-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 4) { printf("NETCS-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 5) { printf("TSOLRDCS-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 6) { printf("NET-MONTHLY(HR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 7) { printf("TSOLRH-MONTHLY(HR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 8) { printf("NETCS-MONTHLY(HR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 9) { printf("TSOLRHCS-MONTHLY(HR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 10) { printf("SOLARD-DAILY "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 11) { printf("SOLARH-MONTHLY HOURLY "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 12) { printf("SOLARHCS-MONTHLY HOURLY "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 13) { printf("SPARES "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 14) { printf("REGION NUMBER "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 15) { printf("DATE: YYMM "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 16) { printf("SPACECRAFT ID "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 17) { printf("LW-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 18) { printf("SW-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 19) { printf("ALBEDO-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 20) { printf("LWCS-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 21) { printf("SWCS-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 22) { printf("ALBEDOCS-MONTHLY(DAY) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 23) { printf("LW-MONTHLY(HOUR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 24) { printf("SW-MONTHLY(HOUR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 25) { printf("ALBEDO-MONTHLY(HOUR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 26) { printf("LWCS-MONTHLY(HOUR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 27) { printf("SWCS-MONTHLY(HOUR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 28) { printf("ALBEDOCS-MONTHLY(HOUR) "); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 29) { printf("LW-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 30) { printf("SW-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 31) { printf("ALBEDO-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 32) { printf("LWCS-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 33) { printf("SWCS-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 34) { printf("ALBEDOCS-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 35) { printf("LW-MONTHLY HOURLY \n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 36) { printf("SW-MONTHLY HOURLY \n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 37) { printf("ALBEDO-MONTHLY HOURLY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 38) { printf("LWCS-MONTHLY HOURLY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 39) { printf("SWCS-MONTHLY HOURLY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 40) { printf("ALBEDOCS-MONTHLY HOURLY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 41) { printf("NDLW-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 42) { printf("NDSW-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 43) { printf("NDLWCS-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 44) { printf("NDSWCS-DAILY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 45) { printf("NHLW-MONTHLY HOURLY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 46) { printf("NHSW-MONTHLY HOURLY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 47) { printf("NHLWCS-MONTHLY HOURLY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 48) { printf("NHSWCS-MONTHLY HOURLY\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } else if(*item == 49) { printf("SCANNER GEOGRAPHIC SCENE TYPE\n"); for(i=*jbeg;i<=*jend;i++) { printf("%lf\n",rscdat[i]); } } } /* End of scnnam */ /*****************************************************/ /* */ /* Function nscfil */ /*****************************************************/ void nscfil(fpo,fp11 ,fp12 ,fp13 ,fp14 ,fp15 ,fp16 ,fp17 ,fp18 ,fp19 ,fp20 ,fp21 ,fp22 ,fp23 ,fp24 ,fp25 ,fp26 ,nfile ,rnsdat ,nsindx ,nscbeg ,nscend ,insrec ,lscrec ,lnsrec ,dfalt ,inspck ,istpos ,lstpos ,insfac ,insitm) FILE *fpo; FILE *fp11, *fp12, *fp13, *fp14, *fp15, *fp16, *fp17, *fp18, *fp19, *fp20, *fp21, *fp22, *fp23, *fp24, *fp25, *fp26; int *nfile; int *lnsrec; int *nsindx; int *nscbeg; int *nscend; int *insrec; int *dfalt; int *inspck; int *istpos; int *lstpos; int *insfac; int *insitm; float *rnsdat; { unsigned int buf[1050]; int icnt; int indx; int ifrec; int ilrec; int item; int jbeg; int jend; int ni; int j; int ifile; int count; int read_size; *nfile=*nfile+10; ifile=0; switch (*nfile) { case 11: ifrec = *insrec+*nfile-10; ilrec = *lnsrec+*nfile-10; for (icnt = ifrec; icnt <= ilrec; icnt++) { loop0: (void) nscrec(fpo,fp11,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit; } else if(*(rnsdat+61) < ifrec) { goto loop0; } else if (((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec))) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE = %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } } } } /** End of for loop **/ endit: break; case 12: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop1: (void) nscrec(fpo,fp12,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit1; } else if(*(rnsdat+61) < ifrec) { goto loop1; } else if (((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec))) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item); jend = *(nscend+item); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,*rnsdat); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit1: break; case 13: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop2: (void) nscrec(fpo,fp13 ,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit2; } else if(*(rnsdat+61) < ifrec) { goto loop2; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit2: break; case 14: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop3: (void) nscrec(fpo,fp14 ,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit3; } else if(*(rnsdat+61) < ifrec) { goto loop3; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat=j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit3: case 15: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop4: (void) nscrec(fpo,fp15,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit4; } else if(*(rnsdat+61) < ifrec) { goto loop4; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit4: break; case 16: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop5: (void) nscrec(fpo,fp16,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit5; } else if(*(rnsdat+61) < ifrec) { goto loop5; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit5: break; case 17: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); printf("ifrec = %d\n",ifrec); printf("ilrec = %d\n",ilrec); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop6: (void) nscrec(fpo,fp17,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit6; } else if(*(rnsdat+61) < ifrec) { goto loop6; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit6: break; case 18: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop7: (void) nscrec(fpo,fp18,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit7; } else if(*(rnsdat+61) < ifrec) { goto loop7; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit7: break; case 19: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop8: (void) nscrec(fpo,fp19,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit8; } else if(*(rnsdat+61) < ifrec) { goto loop8; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit8: case 20: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop9: (void) nscrec(fpo,fp20,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit9; } else if(*(rnsdat+61) < ifrec) { goto loop9; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit9: break; case 21: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop10: (void) nscrec(fpo,fp11,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit10; } else if(*(rnsdat+61) < ifrec) { goto loop10; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit10: break; case 22: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop11: (void) nscrec(fpo,fp11,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit11; } else if(*(rnsdat+61) < ifrec) { goto loop11; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit11: break; case 23: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop12: (void) nscrec(fpo,fp11,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit12; } else if(*(rnsdat+61) < ifrec) { goto loop12; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit12: break; case 24: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop13: (void) nscrec(fpo,fp24 ,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit13; } else if(*(rnsdat+61) < ifrec) { goto loop13; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); }/* End of for indx */ } } /** End of for loop **/ endit13: break; case 25: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop14: (void) nscrec(fpo,fp25,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit14; } else if(*(rnsdat+61) < ifrec) { goto loop14; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit14: break; case 26: ifrec = *(insrec+*nfile-10); ilrec = *(lnsrec+*nfile-10); for (icnt = ifrec; icnt <= ilrec; icnt++) { loop15: (void) nscrec(fpo,fp26,&dfalt[0] ,&inspck[0] ,&istpos[0] ,&lstpos[0] ,&rnsdat[0] ,&insfac[0],&read_size); if (ilrec < *(rnsdat+61)) { fprintf(fpo,"****** REGION READ IS PAST REGION DESIRED ******\n"); goto endit15; } else if(*(rnsdat+61) < ifrec) { goto loop15; } else if ((*(rnsdat+61) >= ifrec) && (*(rnsdat+61) <= ilrec)) { fprintf(fpo,"\n"); fprintf(fpo,"DATA DATE = %6.3lf",*(rnsdat+62)); fprintf(fpo," SATELLITE= %6.3lf\n",*(rnsdat+63)); count=0; fprintf(fpo,"\n"); for (indx = 0; indx <= *insitm;indx++) { item = *(nsindx+indx); jbeg = *(nscbeg+item-1); jend = *(nscend+item-1); fprintf(fpo,"\n"); (void) nscnam(fpo,&item ,&jbeg ,&jend ,&rnsdat[0]); fprintf(fpo,"\n"); for(j=jbeg;j<=jend;j++) { count++; fprintf(fpo,"%10.3lf ",*(rnsdat+j)); if((count > 7) || (j == jend)) { fprintf(fpo,"\n"); count=0; } } fprintf(fpo,"\n"); } } } /** End of for loop **/ endit15: break; } /** End of switch **/ } /**End of nscfil **/ /**********************************************************/ /* */ /* Function nscrec */ /**********************************************************/ void nscrec(fpo,fpn ,dfalt ,inspck ,istpos ,lstpos ,rnsdat ,insfac,read_size) FILE *fpn; FILE *fpo; int *inspck; int *dfalt; int *istpos; int *lstpos; int *insfac; float *rnsdat; int *read_size; { unsigned int buf[1050]; float a; float b; int c; int d; int ni; int nb; int iopt; int loc[4]; int num[4]; int insdat[370]; int numbtyp; int j; int i; int k; int ifst; int ilst; int ntot; int nr; nr=0; ni = 720; nb=1; numbtyp=3; loc[1] = 1; loc[2] = 61; loc[3] = 241; loc[4] = 0; num[1] = 60; num[2] = 180; num[3] = 120; num[4] = 0; *read_size=fread((char *)buf,1,ni,fpn); if (*read_size != ni) { printf("HIT END OF FILE ON DATA RECORD READ\n"); printf("read_size = %d\n",*read_size); printf("size = %d\n",ni); exit(0); } for(i=0;i<=719;i++) { inspck[i] = buf[i]; } (void) stuff (&dfalt[0] ,&iopt ,&inspck[0] ,&loc[0] ,&num[0] ,&insdat[0] ,&ntot); for (i=0;i<360;i++) { *(rnsdat+i) = *(insdat+i); }/**End of for loop **/ /**calculate scaled values **/ for(i=0;i