00001
00002
00003
00004 #include "cddefines.h"
00005 #include "dense.h"
00006 #include "parse.h"
00007
00008 void ParseFluc(char *chCard )
00009 {
00010 bool lgEOL;
00011 long int i;
00012 double flmax,
00013 flmin,
00014 period,
00015 temp;
00016
00017 DEBUG_ENTRY( "ParseFluc()" );
00018
00019
00020
00021 if( nMatch("ABUN",chCard) )
00022 {
00023
00024 dense.lgDenFlucOn = false;
00025 }
00026 else
00027 {
00028
00029 dense.lgDenFlucOn = true;
00030 }
00031
00032
00033 if( nMatch("COLU",chCard) )
00034 {
00035
00036 dense.lgDenFlucRadius = false;
00037 }
00038 else
00039 {
00040
00041 dense.lgDenFlucRadius = true;
00042 }
00043
00044 i = 5;
00045
00046 period = pow(10.,FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL));
00047 dense.flong = (realnum)(6.2831853/period);
00048 temp = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00049
00050
00051 if( temp > log10(FLT_MAX) || temp < log10(FLT_MIN) )
00052 {
00053 fprintf(ioQQQ,
00054 " DISASTER - the log of the entered max hydrogen density is %.3f - too extreme for this processor.\n",
00055 temp);
00056 if( temp > 0. )
00057 fprintf(ioQQQ,
00058 " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n",
00059 log10(FLT_MAX) );
00060 else
00061 fprintf(ioQQQ,
00062 " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n",
00063 log10(FLT_MIN) );
00064 fprintf(ioQQQ," Sorry.\n" );
00065 cdEXIT(EXIT_FAILURE);
00066 }
00067
00068
00069 flmax = pow(10.,temp);
00070
00071 temp = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00072
00073
00074 if( temp > log10(FLT_MAX) || temp < log10(FLT_MIN) )
00075 {
00076 fprintf(ioQQQ,
00077 " DISASTER - the log of the entered min hydrogen density is %.3f - too extreme for this processor.\n",
00078 temp);
00079 if( temp > 0. )
00080 fprintf(ioQQQ,
00081 " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n",
00082 log10(FLT_MAX) );
00083 else
00084 fprintf(ioQQQ,
00085 " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n",
00086 log10(FLT_MIN) );
00087 fprintf(ioQQQ," Sorry.\n" );
00088 cdEXIT(EXIT_FAILURE);
00089 }
00090
00091
00092 flmin = pow(10.,temp);
00093
00094 if( flmax/flmin > 100. )
00095 {
00096 fprintf( ioQQQ, "This range of density probably will not work.\n" );
00097 }
00098 if( flmax > 1e15 )
00099 {
00100 fprintf( ioQQQ, "These parameters look funny to me. Please check Hazy.\n" );
00101 }
00102 if( lgEOL || (flmin > flmax) )
00103 {
00104 fprintf( ioQQQ, "There MUST be three numbers on this line.\n" );
00105 fprintf( ioQQQ, "These must be the period(cm), max, min densities, all logs, in that order.\n" );
00106 if( flmin > flmax )
00107 fprintf( ioQQQ, "The max density must be greater or equal than the min density.\n" );
00108 cdEXIT(EXIT_FAILURE);
00109 }
00110
00111
00112 dense.flcPhase = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00113
00114
00115 dense.cfirst = (realnum)((flmax - flmin)/2.);
00116 dense.csecnd = (realnum)((flmax + flmin)/2.);
00117
00118
00119 ASSERT( dense.cfirst < dense.csecnd );
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 if( dense.lgDenFlucOn )
00133 {
00134 strcpy( dense.chDenseLaw, "SINE" );
00135
00136 if( dense.gas_phase[ipHYDROGEN] > 0. )
00137 {
00138 fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" );
00139 cdEXIT(EXIT_FAILURE);
00140 }
00141
00142
00143 dense.gas_phase[ipHYDROGEN] = dense.cfirst*(realnum)cos(dense.flcPhase) + dense.csecnd;
00144
00145 if( dense.gas_phase[ipHYDROGEN] <= 0. )
00146 {
00147 fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density must be > 0.\n" );
00148 cdEXIT(EXIT_FAILURE);
00149 }
00150 }
00151 return;
00152 }