/* ******************************************************************* * * * Copyright (c) L-DGO/MIT/JGOFS * * * * * * File : dyn.c * * * * Purpose : * * * * Version Number : 1.1 * * * * Revision History : * * * * Date Developer * * ---- --------- * * * * Sat Oct 17 1992 10.00 Glenn Flierl * * * * * ******************************************************************* */ #if HP || IBM #define jdbopen_ jdbopen #define jdbreada_ jdbreada #define jdbread_ jdbread #define jdbclose_ jdbclose #define jdbcomments_ jdbcomments #define jdblevel_ jdblevel #define jdbattributes_ jdbattributes #endif #include #include double atof(); #include /* #define DEBUG */ #define TOKEN 40 #define NVAR 150 #define COMMSIZE 2048 int nlevels; int firstvar[10]; char names[NVAR][TOKEN]; int namesize=TOKEN; char values[NVAR][TOKEN]; int valuesize=TOKEN; int lev[NVAR],vpntr[NVAR]; int handle; int minlevelread; char *nm[] = {"sal","temp","press","theta","sigth","svan","dynhgt"}; int nmpt[] = {-1,-1,-1,-1,-1,-1,-1}; float nmvl[7]; int newvarpt[] = {-1,-1,-1,-1,-1,-1,-1}; int newvarmin = 10000; int newvarmax = 10000; float sigma,th; float thref = 0.0; float dyn,p0,del0; float atg(); float theta(); float svan(); char pstrings[10][255]; int npstrings; int ncrit; char comments[COMMSIZE]; docalc() { int i; if(minlevelreadminlevelread) return 0; do { minlevelread=jdbreada_(&handle,values,&valuesize); } while (minlevelread > *level); if(minlevelread<=ncrit) docalc(); if (minlevelread < *level) return 0; else { minlevelread++; return 1; }; } ioclose_() { jdbclose_(&handle); } int ioopen_(s,nparams,ntotal) char *s[]; int *nparams; int *ntotal; { char tmp[255],*sp; int i,j,k,m,maxclev,nread; for (i=0;ifirstvar[nlevels])firstvar[++nlevels]=lev[i]; }; firstvar[nlevels+1]=nread; doinit(nparams,s); k=0; *ntotal=firstvar[nlevels+1]; for(i=0;i<=nlevels;i++) for(j=0;j< *ntotal;j++)if(lev[j]==i)vpntr[k++]=j; minlevelread = nlevels+1; return nlevels; } int iovarlevel_(vn) int *vn; { return lev[vpntr[*vn]]; } ioattrout_(vn,str) int *vn; char *str; { return 0; } iovalreal_(vn,f) int *vn; float *f; { if(strspn(values[vpntr[*vn]],"0123456789.+-")) *f=atof(values[vpntr[*vn]]); else *f= -9999.0; } char *iovalstr_(vn,tmp) int *vn; char *tmp; { char *s; s=values[vpntr[*vn]]; s=s+strspn(s," "); strcpy(tmp,s); } char *ioname_(vn,s) int *vn; char *s; { strcpy(s,names[vpntr[*vn]]); } int iocommout_(s) char *s; { return 0; }