/* fftest.c -- wrapper for the demo fft function SYNOPSIS fftest [options] OPTIONS -i fin specify an input file name, default fft_in.dat -o fout specify an output file name, default fft_out.dat -s sgn 1 for FFT, -1 for IFFT, default is to do an FFT */ #include #include #include #include #include "fft.h" main (int argc, char *argv[]) { int i, j, k, m, n, c; FTYPE *a1, *a2, *b, t, u, v; FILE *pin, *pout; int nrows, ncols; int sgn = 1; /* default sign is 1 */ int npr = 4; /* default number of threads */ char *fin="fft_in.dat"; /* default input file name */ char *fout="fft_out.dat"; /* default output file name */ /* declarations for getopt */ extern char *optarg; extern int optind, opterr, optopt; /* process command-line parameters (UNIX only) */ while ((c = getopt(argc, argv, "s:p:i:o:")) != EOF) switch (c) { case 's': sgn = atoi(optarg); break; case 'p': npr = atoi(optarg); break; case 'i': fin = malloc(strlen(optarg)); strcpy(fin, optarg); break; case 'o': fout = malloc(strlen(optarg)); strcpy(fout, optarg); break; case '?': fprintf(stderr, "fftest: bad option, exiting...\n"); exit(1); break; } fprintf(stderr, "fftest: sgn=%d, npr=%d, fin=%s fout=%s\n", sgn, npr, fin, fout); /* open input file */ if ((pin=fopen(fin, "r")) == NULL) { fprintf(stderr, "fftest: can't open %s\n", fin); exit(1); } /* read array size */ fread(&nrows, sizeof(int), 1, pin); fread(&ncols, sizeof(int), 1, pin); fprintf(stderr, "fftest: N = %d, K = %d\n", nrows, ncols); /* open output file */ if ((pout=fopen(fout, "w")) == NULL) { fprintf(stderr, "fftest: can't open %s\n", fout); exit(1); } /* write array sizes */ fwrite(&nrows, sizeof(int), 1, pout); fwrite(&ncols, sizeof(int), 1, pout); n = nrows; m = ncols; fprintf(stderr, "fftest: allocating space for %d elements...\n", n); b = (FTYPE *) malloc( 2*n*sizeof(FTYPE) ); a1 = (FTYPE *) malloc( n*sizeof(FTYPE) ); a2 = (FTYPE *) malloc( n*sizeof(FTYPE) ); for (i=0; i