/*ParseDLaw parse parameters on the dlaw command */ #include #include "cddefines.h" #include "abuntablfac.h" #include "dlaw.h" #include "pressure.h" #include "cap4.h" #include "ffmtread.h" #include "lgmatch.h" #include "readar.h" #include "parse.h" void ParseDLaw(char *chCard ) { char chCAP[5]; int lgEOL, lgEnd; long int i, j; # ifdef DEBUG_FUN fputs( "<+>ParseDLaw()\n", debug_fp ); # endif /* call fcn FABDEN(RADIUS) which uses the ten parameters * N.B.; existing version of FABDEN must be deleted * >>chng 96 nov 29, added table option */ if( lgMatch("TABL",chCard) ) { /* when called, read in densities from input stream */ strcpy( pressure.chCPres, "DLW2" ); if( lgMatch("DEPT",chCard) ) { AbunTablFac.lgDLWDepth = TRUE; } else { AbunTablFac.lgDLWDepth = FALSE; } readar(chCard,&lgEnd); i = 1; AbunTablFac.frad[0] = (float)FFmtRead(chCard,&i,76,&lgEOL); AbunTablFac.fhden[0] = (float)FFmtRead(chCard,&i,76,&lgEOL); if( lgEOL ) { fprintf( ioQQQ, " no pairs entered - cant interpolate\n" ); puts( "[Stop in getdlaw]" ); exit(1); } AbunTablFac.nvals = 2; lgEnd = FALSE; /* read pairs of numbers until we find line starting with END */ while( !lgEnd && AbunTablFac.nvals < LIMTABD ) { readar(chCard,&lgEnd); if( !lgEnd ) { cap4(chCAP , chCard); if( strncmp(chCAP , "END" , 3 ) == 0 ) lgEnd = TRUE; } if( !lgEnd ) { i = 1; AbunTablFac.frad[AbunTablFac.nvals-1] = (float)FFmtRead(chCard ,&i,76,&lgEOL); AbunTablFac.fhden[AbunTablFac.nvals-1] = (float)FFmtRead(chCard ,&i,76,&lgEOL); AbunTablFac.nvals += 1; } } AbunTablFac.nvals -= 1; for( i=1; i < AbunTablFac.nvals; i++ ) { /* the radius values are assumed to be strictly increasing */ if( AbunTablFac.frad[i] <= AbunTablFac.frad[i-1] ) { fprintf( ioQQQ, " density.in radii must be in increasing order\n" ); puts( "[Stop in getdlaw]" ); exit(1); } } } else { /* this is usual case, call fabden to get density */ i = 4; for( j=0; j < 10; j++ ) { dlaw.DensityLaw[j] = FFmtRead(chCard,&i,76,&lgEOL); } /* set flag so we know which law to use later */ strcpy( pressure.chCPres, "DLW1" ); } # ifdef DEBUG_FUN fputs( " <->ParseDLaw()\n", debug_fp ); # endif return; }