00001
00002
00003
00004 #include "cddefines.h"
00005
00006 #include "physconst.h"
00007 #include "optimize.h"
00008 #include "radius.h"
00009 #include "iterations.h"
00010 #include "input.h"
00011 #include "parse.h"
00012
00013 void ParseRadius(char *chCard,
00014 float *ar1)
00015 {
00016 bool lgEOL,
00017 lgR2set,
00018 lgRLog;
00019 long int i;
00020 double a,
00021 convl;
00022
00023 DEBUG_ENTRY( "ParseRadius()" );
00024
00025
00026
00027
00028 if( nMatch("PARS",chCard) )
00029 {
00030
00031
00032 convl = log10( PARSEC );
00033 }
00034 else
00035 {
00036 convl = 0.;
00037 }
00038
00039
00040 if( nMatch("LINE",chCard) )
00041 {
00042 lgRLog = false;
00043 }
00044 else
00045 {
00046 lgRLog = true;
00047 }
00048
00049 i = 5;
00050 *ar1 = (float)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00051 if( lgEOL )
00052 {
00053 fprintf( ioQQQ, " There should have been a number on this line. Sorry.\n" );
00054 puts( "[Stop in ParseRadius]" );
00055 cdEXIT(EXIT_FAILURE);
00056 }
00057
00058
00059 if( lgRLog )
00060 {
00061 *ar1 += (float)convl;
00062 }
00063 else
00064 {
00065 if( *ar1 > 0. )
00066 {
00067 *ar1 = (float)(log10(*ar1) + convl);
00068 }
00069 else
00070 {
00071 fprintf(ioQQQ,"The first radius is negative and linear radius is set - this is impossible.\n");
00072 puts( "[Stop in ParseRadius]" );
00073 cdEXIT(EXIT_FAILURE);
00074 }
00075 }
00076
00077 if( *ar1 > 37 || *ar1 < -37. )
00078 {
00079 fprintf(ioQQQ,"WARNING - the log of the radius is %e - this is too big and I will soon crash.\n", *ar1 );
00080
00081 fflush( ioQQQ );
00082 }
00083
00084 radius.Radius = pow( 10.f ,*ar1);
00085 radius.lgRadiusKnown = true;
00086
00087
00088 a = (double)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00089 if( lgEOL )
00090 {
00091
00092 lgR2set = false;
00093 }
00094 else
00095 {
00096
00097 lgR2set = true;
00098
00099
00100 if( lgRLog )
00101 {
00102 a += convl;
00103 }
00104
00105 else
00106 {
00107
00108 if( a > 0. )
00109 {
00110 a = log10(a) + convl;
00111 }
00112 else
00113 {
00114 fprintf(ioQQQ,"The second radius is negative and linear radius is set - this is impossible.\n");
00115 puts( "[Stop in ParseRadius]" );
00116 cdEXIT(EXIT_FAILURE);
00117 }
00118 }
00119
00120 if( a > 37 || a < -37. )
00121 {
00122 fprintf(ioQQQ,"WARNING - the log of the outer radius is %e - this is too big and I will soon crash.\n", a );
00123
00124 fflush( ioQQQ );
00125 }
00126 a = pow(10.,a);
00127
00128
00129
00130 if( a > radius.Radius )
00131 {
00132 radius.router[0] = a - radius.Radius;
00133 }
00134
00135 else
00136 {
00137 radius.router[0] = a;
00138 }
00139
00140 for( i=1; i < iterations.iter_malloc; i++ )
00141 {
00142 radius.router[i] = radius.router[0];
00143 }
00144 }
00145
00146
00147 if( optimize.lgVarOn )
00148 {
00149
00150 optimize.nvfpnt[optimize.nparm] = input.nRead;
00151 optimize.vincr[optimize.nparm] = 0.5;
00152
00153
00154 if( lgR2set )
00155 {
00156 strcpy( optimize.chVarFmt[optimize.nparm], "RADIUS %f depth or outer R %f" );
00157 optimize.nvarxt[optimize.nparm] = 2;
00158
00159 optimize.vparm[1][optimize.nparm] = (float)log10(radius.router[0]);
00160 fprintf(ioQQQ,
00161 " WARNING - outer radius or thickness was set with a variable radius.\n");
00162 fprintf(ioQQQ,
00163 " The interpretation of the second number can change from radius to depth as radius changes.\n");
00164 fprintf(ioQQQ,
00165 " Do not use the second parameter unless you are quite certain that you know what you are doing.\n");
00166 fprintf(ioQQQ,
00167 " Consider using the STOP THICKNESS command instead.\n");
00168 }
00169 else
00170 {
00171 strcpy( optimize.chVarFmt[optimize.nparm], "RADIUS= %f" );
00172 optimize.nvarxt[optimize.nparm] = 1;
00173 }
00174
00175
00176 optimize.vparm[0][optimize.nparm] = (float)log10(radius.Radius);
00177 ++optimize.nparm;
00178 }
00179
00180 DEBUG_EXIT( "ParseRadius()" );
00181 return;
00182 }
00183