/* Simple method This is a method developed for the workshop May 24-25, 1995 to show a very simple case. It requires two parameters - the name of the file containing the variable names - the name of the file containing the table of data It assumes that there is only one level of data (level 0) compile with build contrib test with methods/sm contrib/head contrib/s3dat list test: list "sm(contrib/head,contrib/s3dat,press<200)" put in objects/.objects: smtest=sm(fullpath/contrib/head,fullpath/contrib/s3dat) test with list /smtest */ #include #include double atof(); /* #define DEBUG */ #define TOKEN 40 #define NVAR 50 char names[NVAR][TOKEN]; char values[NVAR][TOKEN]; int ndata; FILE *fl; int ioopen_(s,nparams,ntotal) char *s[]; int *nparams,*ntotal; { /* get the variable names */ fl=fopen(s[0],"r"); if(fl==NULL){ printf("&x error - header file %s missing\n",s[0]); exit(1); }; ndata=0; while(!feof(fl)){ if(fscanf(fl,"%s",names[ndata]) == EOF) break; ndata++; }; fclose(fl); /* tell the outer routine that this param is taken care of */ s[0][0]=0; *ntotal=ndata; /* open data file */ fl=fopen(s[1],"r"); if(fl==NULL){ printf("&x error - data file %s missing\n",s[0]); exit(1); }; /* tell the outer routine that this param is taken care of */ s[1][0]=0; /* only zero level in data */ return 0; } ioname_(vn,s) int *vn; char *s; { strcpy(s,names[*vn]); } int iovarlevel_(vn) int *vn; { return 0; } ioattrout_(vn,str) int *vn; char *str; { return 0; } int iocommout_(str) char *str; { return 0; } iovalreal_(vn,f) int *vn; float *f; { int i; i= *vn; if(strspn(values[i],"0123456789.+-")) *f=atof(values[i]); else *f = -9999.0; } iovalstr_(vn,tmp) int *vn; char *tmp; { static char *s; int i; i= *vn; s=values[i]; s=s+strspn(s," "); strcpy(tmp,s); } int ioreadrec_(level) int *level; { int i; if(feof(fl))return 0; for (i=0;i