#From glenn@lake.mit.edu Fri Jul 7 11:37 EDT 1995 #Date: Fri, 7 Jul 95 11:38:02 EDT #From: Glenn Flierl #To: jmanning@whsun1.wh.whoi.edu, rgroman@whoi.edu #Subject: Matlab method #include #include #include #include "/usr/local/matlab/extern/include/mat.h" double atof(); #define MAXVAR 20 MATFile *fl; char **names; static int nn; static int lev[MAXVAR],ptr[MAXVAR]; static int maxlev=0; static float oldval[20]; double *mp[MAXVAR]; static int index= -1; static int maxindex=0; /* flags for controlling reading sequence */ #define OK0 -999 #define ERR1 -9999 /* error reporting */ err(s,t) char *s,*t; { printf("&x error - &s &s\n",s,t); exit(1); } /* open subroutine */ int ioopen_(s,nparams,ntotal) char *s[]; int *nparams,*ntotal; { char tmp[80]; FILE *fh; int i,j,k; double *mpi; /* open file named in first parameter */ strcpy(tmp,s[0]); strcat(tmp,".mat"); fl=matOpen(tmp,"r"); if(fl==NULL)err("MATLAB file name ",s[0]); names=matGetDir(fl,&nn); if(names==NULL)err("No Variables in MATLAB FILE",""); *ntotal=nn; for(i=0;imaxlev)maxlev=i; }; fclose(fh); }; s[0][0] = 0; if(maxlev){ k=0; for(i=maxlev;i>=0;i--){ for(j=0;j=maxindex-1)return 0; index++; return 1; } /* close file */ ioclose_() { } /* comments */ int iocommout_() { return 0; }