#include #include main() { FILE *inf, *opf, *fopen(); int i,j,k,order=0; int nlat,nlon,nband; int datatype; static char *grid1; static short *grid2; static long *grid3; static float *grid4; static char *buff1 ; /* Byte data buffer */ static short *buff2 ; /* Short data buffer */ static long *buff3 ; /* Long data buffer */ static float *buff4 ; /* Float data buffer */ char s[20],infile[60],outfile[60]; printf("Please enter the input file name: "); gets(infile); printf("Enter the first dimension of the input file (b->band,s->sample)"); gets(s); if (s[0] == 'B' || s[0] == 'b') order=1; else order=0; printf("Enter the number of lines in the file: "); gets(s); nlat=atoi(s); printf("Enter the number of samples in the file: "); gets(s); nlon=atoi(s); printf("Enter the number of bands in the file: "); gets(s); nband=atoi(s); printf ("Enter the input data type (b=byte, s=short, l=long, f=float):"); gets (s); if ( ! strcmp ( s, "b") || ! strcmp ( s, "B" ) ) { datatype = 1 ; buff1 = ( char * ) malloc ( nband * nlon * sizeof ( char ) ) ; grid1 = ( char * ) malloc ( nlat * nlon * sizeof ( char ) ) ; } else if ( ! strcmp ( s, "s") || ! strcmp ( s, "S" ) ) { datatype = 2 ; buff2 = ( short * ) malloc ( nband * nlon * sizeof ( short ) ) ; grid2 = ( short * ) malloc ( nlat * nlon * sizeof ( short ) ) ; } else if ( ! strcmp ( s, "l") || ! strcmp ( s, "L" ) ) { datatype = 3 ; buff3 = ( long * ) malloc ( nband * nlon * sizeof ( long ) ) ; grid3 = ( long * ) malloc ( nlat * nlon * sizeof ( long ) ) ; } else if ( ! strcmp ( s, "f") || ! strcmp ( s, "F" ) ) { datatype = 4 ; buff4 = ( float * ) malloc ( nband * nlon * sizeof ( float ) ) ; grid4 = ( float * ) malloc ( nlat * nlon * sizeof ( float ) ) ; } else { printf (" Invalid data type option! ") ; exit (1) ; } printf("Please enter the output file name: "); gets(outfile); while ((opf=fopen(outfile,"w")) == NULL) { printf("Please enter the output file name: "); gets(outfile); } /* Read in input file */ if (order == 0) { for (j=0; j