/* * (C) COPYRIGHT International Business Machines Corp. 1994 * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of IBM not be * used in advertising or publicity pertaining to distribution of the * software without specific prior written permission. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE * OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include main(int argc, char *argv[]) { char *xyzfile, *qfile, *ffile; char text[500]; int ni, nj, nk, ndim, ngrid, ngridvars, nf; int composite, extraneous; int field, index, invaliddata, i, j, k, xyz, uvw, grid; int *gbuffer, *ibuffer; int mgrid, iblank, ascii, lt; float datavalue; float *sbuffer, *vbuffer; float fsmach, alpha, re, time; FILE *xyzinput; FILE *qinput; FILE *finput; if (argc == 1) { printf("Usage: %s -xyz xyzfile -q qfile\n", argv[0]); printf(" [-f ffile] [-dim ndim] [-mgrid]\n"); printf(" [-iblank] [-ascii] [-leadtrail]\n",argv[0]); printf("\n"); printf(" xyzfile is the name of the grid positions file\n"); printf(" qfile is the name of the solution file\n"); printf(" ffile is the name of the function file\n"); printf(" ndim is number of dimensions in the data (2 or 3) \n"); printf(" -mgrid if multi-grid; default: single grid\n"); printf(" -iblank if iblank'd; default: no iblanking\n"); printf(" -ascii for ascii output; default: binary output\n"); printf(" -leadtrail if data was written with four byte Fortran\n" " leading and trailing byte counts)\n"); exit(1); } ngridvars = 4; ffile="none"; ndim=3; mgrid=0; iblank=0; ascii=0; composite=0; while (argc > 1) { if (!strcmp("-xyz", argv[1])) { if (argc < 2) { fprintf(stderr, "no filename given for -xyz flag\n"); exit(-1); } xyzfile = argv[2]; argc--; argv++; } else if (!strcmp("-q", argv[1])) { if (argc < 2) { fprintf(stderr, "no filename given for -q flag\n"); exit(-1); } qfile = argv[2]; argc--; argv++; } else if (!strcmp("-f", argv[1])) { if (argc < 2) { fprintf(stderr, "no filename given for -f flag\n"); exit(-1); } ffile = argv[2]; argc--; argv++; } else if (!strcmp("-dim", argv[1])) { if (argc < 2) { fprintf(stderr, "no filename given for -dim flag\n"); exit(-1); } ndim = atoi(argv[2]); argc--; argv++; } else if (!strcmp("-mgrid", argv[1])) { mgrid=1; } else if (!strcmp("-iblank", argv[1])) { iblank=1; } else if (!strcmp("-ascii", argv[1])) { ascii=1; } else if (!strcmp("-leadtrail", argv[1])) { lt=1; } else if (!strcmp("-composite", argv[1])) { composite=1; } else { printf("unrecognized parameter: %s\n", argv[1]); } argc--; argv++; } xyzinput = fopen(xyzfile,"r"); if (xyzinput == NULL){ perror(xyzfile); exit(1); } qinput = fopen(qfile,"r"); if (qinput == NULL){ perror(qfile); exit(1); } if(strcmp("none",ffile)){ finput = fopen(ffile,"r"); if (finput == NULL){ perror(ffile); exit(1); } } /* start reading data from xyz-file (grid positions) */ /* if multi-grid, find out how many grids */ if(mgrid==1){ /* remove leading byte count indicator */ if(lt==1) fread(&extraneous,4,1,xyzinput); fread(&ngrid,4,1,xyzinput); /* remove trailing byte count indicator */ if(lt==1) fread(&extraneous,4,1,xyzinput); } else ngrid=1; gbuffer=(int*)malloc(ngrid*ngridvars*sizeof(int)); /* for each grid, find number of i, j and k (if any) indicies */ /* remove leading byte count indicator */ if(lt==1) fread(&extraneous,4,1,xyzinput); for (grid=0; grid