00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "global_params.hpp"
00039 #include "convert.hpp"
00040
00041
00042
00043
00044 void ss_link::print()
00045 {
00046 cout << " " << x << " " << y << endl;
00047 }
00048
00049
00050
00051
00052
00053 bool ss_list::at(string x, ss_list::iterator& link)
00054 {
00055 for( link = begin();
00056 link != end();
00057 ++link )
00058 {
00059 if ( link->name( ) == x )
00060 {
00061 return true;
00062 }
00063 }
00064 return false;
00065 }
00066
00067
00068 void ss_list::print()
00069 {
00070 for( ss_list::iterator link = begin();
00071 link != end();
00072 ++link)
00073 {
00074 link->print();
00075 }
00076 cout<<endl;
00077 }
00078
00079
00080
00081
00082
00083 GlobalParameterClass::GlobalParameterClass()
00084 {
00085
00086
00087 set("tol_1d", 0.005);
00088 set("cut_off_1d", 0.001);
00089 set("tol_2d", 0.015);
00090 set("cut_off_2d", 0.003);
00091 set("dE_tol", 0.01);
00092
00093 set("num_mu_3d", 2);
00094 set("num_E_in_3d", 12);
00095 set("log_log_tol", 0.005);
00096
00097 set("num_mf5_bins", 32);
00098 set("mf5_shift", 0.00002);
00099 set("mf5_tol", 0.00001);
00100
00101 set("sum_inelastic", 0);
00102 set("Kalbach_i10", 0);
00103 set("split_gammas", 0);
00104 set("skip_gammas", 0);
00105 set("fission_Q", 1);
00106
00107 set("skip_date", 1);
00108 set("translate_all", 1);
00109 set("skip_logging", 0);
00110 set("message_level",0);
00111
00112
00113
00114 set("endl_datafield_precision",8);
00115 set("max_list_size", 500);
00116 set("Max_n_energy", 20.0);
00117 set("Max_cp_energy", 30.0);
00118 set("Max_g_energy", 30.0);
00119 set("mf5_weight_tol", 0.001);
00120 set("max_coulomb_mu", 0.94);
00121 set("smallest_dE", 1.0e-16);
00122 set("jump_factor", 2.0);
00123 set("Min_n_energy", 1e-11);
00124 }
00125
00126
00127 GlobalParameterClass::~GlobalParameterClass()
00128 {
00129 }
00130
00131
00132 void GlobalParameterClass::set(string gp, double gp_num)
00133 {
00134
00135 gp = tolower( remove_extra_blanks( gp ) );
00136 ostringstream gp_ostr;
00137 gp_ostr << gp_num;
00138 string gp_val = gp_ostr.str();
00139
00140
00141
00142 ss_list::iterator SSlist;
00143
00144 if ( Parameters.at(gp,SSlist) )
00145 {
00146 SSlist->value()=gp_val;
00147 }
00148 else
00149 {
00150 ss_link SSlink;
00151 SSlink.name() = gp;
00152 SSlink.value() = gp_val;
00153 Parameters.insert(Parameters.end(), SSlink);
00154 }
00155 }
00156
00157
00158 void GlobalParameterClass::set(string gp, string gp_val)
00159 {
00160
00161 gp = remove_extra_blanks( gp );
00162 gp_val = remove_extra_blanks( gp_val );
00163
00164
00165
00166
00167 ss_list::iterator SSlist;
00168
00169 if ( Parameters.at(gp,SSlist) )
00170 {
00171 SSlist->value()=gp_val;
00172 }
00173 else
00174 {
00175 ss_link SSlink;
00176 SSlink.name() = gp;
00177 SSlink.value() = gp_val;
00178 Parameters.insert(Parameters.end(), SSlink);
00179 }
00180 }
00181
00182
00183 void GlobalParameterClass::print( )
00184 {
00185 cout<<"Info : List of global parameters used in this translation:"<<endl;
00186 Parameters.print();
00187 }
00188
00189
00190 string GlobalParameterClass::read_command_line(int argc, char* argv[] )
00191 {
00192
00193 string help1("-help"), help2("--help"), help3("-h");
00194 for( int j=1; j<argc; ++j)
00195 {
00196 string sarg(argv[j]);
00197 if( sarg == help1 || sarg == help2 || sarg == help3 )
00198 {
00199 cout << center(40*string("="),42) <<endl;
00200 cout << center("Help for fete.",40)<<endl;
00201 cout << center(40*string("="),42) <<endl;
00202 cout << "Usage: fete [-option1 value]"<<endl<<endl;
00203 cout << "To set the file to translate, use the -f option (e.g. fete -f fred.endf) "<<endl;
00204 cout << "Other options are set by prepending '-' to the options listed below:"<<endl;
00205 Parameters.print();
00206 exit(1);
00207 }
00208 }
00209
00210
00211 for( int j=1; j<argc; j+=2 )
00212 {
00213 if ( argv[j][0] != '-' )
00214 {
00215 cerr<<"fete Fatal Error GlobalParameterClass::read_command_line:"<<endl;
00216 cerr<<" Unable to process command line."<<endl;
00217 cerr<<" "<<argv[j]<<" is not a valid switch!"<<endl;
00218 exit(-10);
00219 }
00220 else
00221 {
00222
00223 spar[j] = argv[j];
00224 if (j+1<argc) spar[j+1]=argv[j+1];
00225 else spar[j+1]="";
00226 }
00227 };
00228
00229
00230
00231 string privateParameterFile("");
00232 for( int j=1; j<argc;j+=2 ) if( spar[j] == "-p" || spar[j] == "-param" ) privateParameterFile=spar[j+1];
00233 if (privateParameterFile!="")
00234 {
00235 cout<<"Info : Private parameter input file: "<<privateParameterFile<<endl;
00236 read_file( privateParameterFile );
00237 }
00238 else
00239 {
00240
00241 read_file("fete_options.inp");
00242 }
00243
00244
00245
00246
00247 for( int j=1; j<argc;j+=2 )
00248 {
00249 if( spar[j] != "-f" && spar[j] != "-file" && spar[j] != "-p" && spar[j] != "-param" )
00250 {
00251 string pval = spar[j+1];
00252 string key = spar[j];
00253 key.erase(0,1);
00254 set(key,pval);
00255 }
00256 }
00257
00258
00259 for( int j=1; j<argc;j+=2 )
00260 {
00261 if( spar[j] == "-f" || spar[j] == "-file" )
00262 {
00263 cout<<"Info : ENDF input file: "<<spar[j+1]<<endl;
00264 string file = spar[j+1];
00265 return file;
00266 }
00267 }
00268 return "";
00269 }
00270
00271
00272 void GlobalParameterClass::read_file(string file)
00273 {
00274 string linebuff, origbuff;
00275
00276 ifstream paramfile( file.c_str() );
00277
00278 if ( !paramfile )
00279 {
00280 cout<<"Info: GlobalParameterClass::read_file: There is no parameter file named: "<<file<<", using internal defaults"<<endl;
00281 }
00282 else
00283 {
00284 cout<<"Info : Reading the parameter file: "<<file<<" ..."<<endl;
00285 while( !paramfile.eof() )
00286 {
00287 getline( paramfile, linebuff );
00288 origbuff=linebuff;
00289 linebuff = remove_extra_blanks( linebuff );
00290 if( linebuff.find('#') <= linebuff.size() )
00291 {
00292 linebuff = linebuff.erase(linebuff.find('#'),linebuff.size());
00293 linebuff=remove_extra_blanks( linebuff );
00294 }
00295
00296 if( linebuff.size() > 0 )
00297 {
00298 int nblanks=0;
00299 for( int i=0;i<linebuff.size();i++ )
00300 {
00301 if ( linebuff.at(i) == ' ' ) ++nblanks;
00302 }
00303 if( nblanks != 1 )
00304 {
00305 cerr
00306 <<"fete Fatal Error GlobalParameterClass::read_file: Could not parse the following line from "
00307 <<"the parameter file, "<<file<<endl;
00308 cerr<<origbuff<<endl;
00309 exit(-10);
00310 }
00311 else
00312 {
00313 string sparam
00314 = linebuff.substr(0,linebuff.find(' '));
00315 string svalue
00316 = linebuff.substr(linebuff.find(' ')+1,linebuff.size());
00317 set(sparam, svalue);
00318 }
00319 }
00320 }
00321 }
00322 }
00323
00324
00325 double GlobalParameterClass::Value( string ParamName )
00326 {
00327 ss_list::iterator XYptr;
00328 string parm = tolower( ParamName );
00329 if( !Parameters.at(parm,XYptr) )
00330 {
00331 cerr<<"fete Fatal Error GlobalParameterClass::Value:"<<
00332 " no parameter called "<<ParamName<<" found!"<<endl;
00333 exit(-50);
00334 }
00335 return( static_cast<double>( stof(XYptr->value()) ) );
00336 }
00337
00338
00339 string GlobalParameterClass::Flag( string ParamName )
00340 {
00341 ss_list::iterator XYptr;
00342 string parm = tolower( ParamName );
00343 if( !Parameters.at(parm,XYptr) )
00344 {
00345 cerr<<"fete Fatal Error GlobalParameterClass::Flag:"<<
00346 " no parameter called "<<ParamName<<" found!"<<endl;
00347 exit(-50);
00348 }
00349 return( XYptr->value() );
00350 }
00351