00001
00002
00003
00004 #include "cddefines.h"
00005 #include "dense.h"
00006
00007 double dense_tabden(double r0,
00008 double depth)
00009 {
00010 bool lgHit;
00011 long int j;
00012 double frac,
00013 tabden_v,
00014 x;
00015
00016 DEBUG_ENTRY( "dense_tabden()" );
00017
00018
00019
00020
00021 if( r0 <= 0. || depth <= 0. )
00022 {
00023 fprintf( ioQQQ, " dense_tabden called with insane depth, radius, =%10.2e%10.2e\n",
00024 depth, r0 );
00025 }
00026
00027
00028
00029 if( dense.lgDLWDepth )
00030 {
00031
00032 x = log10(depth);
00033 }
00034 else
00035 {
00036
00037 x = log10(r0);
00038 }
00039
00040
00041 tabden_v = -DBL_MAX;
00042
00043 if( x < dense.frad[0] || x >= dense.frad[dense.nvals-1] )
00044 {
00045 fprintf( ioQQQ, " requested radius outside range of dense_tabden\n" );
00046 fprintf( ioQQQ, " radius was%10.2e min, max=%10.2e%10.2e\n",
00047 x, dense.frad[0], dense.frad[dense.nvals-1] );
00048 puts( "[Stop in dense_tabden]" );
00049 cdEXIT(EXIT_FAILURE);
00050 }
00051 else
00052 {
00053 lgHit = false;
00054 j = 1;
00055
00056 while( !lgHit && j <= dense.nvals - 1 )
00057 {
00058 if( dense.frad[j-1] <= (float)x && dense.frad[j] > (float)x )
00059 {
00060 frac = (x - dense.frad[j-1])/(dense.frad[j] -
00061 dense.frad[j-1]);
00062 tabden_v = dense.fhden[j-1] + frac*(dense.fhden[j] -
00063 dense.fhden[j-1]);
00064 lgHit = true;
00065 }
00066 j += 1;
00067 }
00068
00069 if( !lgHit )
00070 {
00071 fprintf( ioQQQ, " radius outran dlaw table scale, requested=%6.2f largest=%6.2f\n",
00072 x, dense.frad[dense.nvals-1] );
00073 puts( "[Stop in dense_tabden]" );
00074 cdEXIT(EXIT_FAILURE);
00075 }
00076 }
00077
00078
00079 tabden_v = pow(10.,tabden_v);
00080
00081 DEBUG_EXIT( "dense_tabden()" );
00082 return( tabden_v );
00083 }
00084