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 #include "b6stream.hpp"
00037 #include "record_types.hpp"
00038 #include "endl_formats.hpp"
00039 #include "convert.hpp"
00040 #include "global_params.hpp"
00041 #include "messaging.hpp"
00042
00043 extern GlobalParameterClass Global;
00044
00045
00046
00047 void iMF_array_link::print_MF( )
00048 {
00049 cout << " MT: " << MT( );
00050 for( iMF_array_link::iterator this_mf = begin( );
00051 this_mf != end( ); ++this_mf )
00052 {
00053 cout << " " << *this_mf;
00054 }
00055 cout << endl;
00056 }
00057
00058 bool iMF_array_link::angle_cm( )
00059
00060 {
00061 bool CM = true;
00062
00063 for( iMF_array_link::iterator this_mf = begin( );
00064 this_mf != end( ); ++this_mf )
00065 {
00066
00067 if( *this_mf == 5 )
00068 {
00069 CM = false;
00070 break;
00071 }
00072 }
00073 return CM;
00074 }
00075
00076
00077
00078
00079
00080 bool iMF_array_list::at(int x, iMF_array_list::iterator& link)
00081 {
00082 for( link = begin( );
00083 link != end( );
00084 ++link )
00085 {
00086 if ( link->MT( ) == x )
00087 {
00088 return true;
00089 }
00090 }
00091 return false;
00092 }
00093
00094 bool iMF_array_list::found( int mt )
00095 {
00096 bool found_it = false;
00097
00098 for( iMF_array_list::iterator this_mt = begin();
00099 this_mt != end(); ++this_mt)
00100 {
00101 if( mt == this_mt->MT( ) )
00102 {
00103 found_it = true;
00104 break;
00105 }
00106 }
00107 return found_it;
00108 }
00109
00110
00111
00112 b6stream::b6stream(string inputFile)
00113 {
00114
00115 NTAPE=0;MAT=0;MF=0;MT=0;NS=-1;LRP=0;LFI=0;NLIB=0;
00116 NMOD=0;LIS=0;LISO=0;NFOR=0;NSUB=0;NVER=0;LDRV=0;NWD=0;
00117 NXC=0;ZA=0;AWR=0;ELIS=0;STA=0;AWI=0;TEMP=0;
00118 prev_mt = 0;
00119 prev_mf = 0;
00120
00121 SEND=false;FEND=false;MEND=false;TEND=false;DONE=false;lofile=false;
00122
00123 file_top = true;
00124
00125
00126 if (inputFile == "") input_file = "endf.prepro";
00127 else input_file = inputFile;
00128
00129
00130 Efile.open(input_file.c_str(),ios::in);
00131
00132 if ( !Efile.is_open() )
00133 { FatalError("b6stream::b6stream","Cannot find "+input_file+" file",false); }
00134 else
00135 { Info("",input_file+" opened successfully!"); }
00136
00137
00138 for ( int i=0; !DONE; i++ ) { readENDF(); }
00139
00140 Efile.close();
00141
00142 }
00143
00144
00145 b6stream::~b6stream()
00146 {
00147
00148 }
00149
00150 void b6stream::readENDF()
00151 {
00152
00153 if (!getline( Efile, sBuff )) {DONE=true;return;}
00154
00155
00156 if ( ( file_top ) && ( NS == -1 ) )
00157 {
00158 SEND=false;FEND=false;MEND=false;TEND=false;
00159 NTAPE=0; MAT=0;
00160
00161
00162
00163 oFile.open(endf_file_name(1,451).c_str(),ios::out);
00164 if ( !oFile.is_open() )
00165 {
00166 FatalError("b6stream::readENDF",
00167 "File "+endf_file_name(1,451)+" not opened");
00168 }
00169 else
00170 {
00171 Info("","File "+endf_file_name(1,451)+" opened for write...");
00172 oFile << sBuff << endl;
00173 lofile=true;
00174 prev_mf = 1;
00175 prev_mt = 451;
00176 }
00177 }
00178
00179 get_MAT_MF_MT_NS();
00180
00181
00182 if ( MT == 0 && MF != 0 && MAT != 0 ) SEND=true;
00183 if ( MT == 0 && MF == 0 && MAT != 0 ) FEND=true;
00184 if ( MT == 0 && MF == 0 && MAT == 0 ) MEND=true;
00185 if ( MT == 0 && MF == 0 && MAT ==-1 ) TEND=true;
00186
00187
00188 if( file_top )
00189 {
00190 if ( NS == 0 )
00191 {
00192 if ( MF != 0 || MT != 0 )
00193 {
00194 Warning("b6stream::readENDF","MF or MT not zero in first line of input!");
00195 }
00196
00197 NTAPE=MAT; MAT=0;
00198 }
00199
00200 else if ( NS == 1 )
00201 {
00202 check_mf_mt( );
00203 read_idiiii(&sBuff,&ZA,&AWR,&LRP,&LFI,&NLIB,&NMOD);
00204 oFile << sBuff << endl;
00205 }
00206
00207 else if ( NS == 2 )
00208 {
00209 check_mf_mt( );
00210 read_ddiiii(&sBuff,&ELIS,&STA,&LIS,&LISO,&iDummy,&NFOR);
00211 oFile << sBuff << endl;
00212 }
00213
00214 else if ( NS == 3 )
00215 {
00216 check_mf_mt( );
00217 read_ddiiii(&sBuff,&AWI,&dDummy,&iDummy,&iDummy,&NSUB,&NVER);
00218 yi=NSUB_to_yi(NSUB);
00219 oFile << sBuff << endl;
00220 }
00221
00222 else if ( NS == 4 )
00223 {
00224 check_mf_mt( );
00225 read_ddiiii(&sBuff,&TEMP,&dDummy,&LDRV,&iDummy,&NWD,&NXC);
00226 oFile << sBuff << endl;
00227 }
00228
00229 else if ( NS == 5 )
00230 {
00231 check_mf_mt( );
00232 date = 0;
00233 if (Global.Value("skip_date") == 0.) read_date(&sBuff,&date);
00234 else Info("b6stream::readENDF","skipping ENDFB6 evaluation date read.");
00235 oFile << sBuff << endl;
00236
00237
00238 print_summary( );
00239
00240 file_top = false;
00241 }
00242 else
00243 {
00244 check_mf_mt( );
00245 oFile << sBuff << endl;
00246 }
00247 }
00248
00249 else if ( TEND )
00250 {
00251 DONE=true;
00252 }
00253 else if ( MEND )
00254 {
00255 DONE=true;
00256 }
00257 else if ( FEND )
00258 {
00259
00260 if ( lofile )
00261 {
00262 Warning("b6stream::readENDF","Closing file with FEND");
00263 oFile.close();
00264 lofile=false;
00265 }
00266 }
00267 else if ( SEND )
00268 {
00269
00270 if ( lofile )
00271 {
00272 oFile.close();
00273 lofile=false;
00274 Info("b6stream::readENDF","File closed.");
00275 }
00276 }
00277 else if ( !lofile )
00278 {
00279
00280
00281 iMF_array_list::iterator this_mt;
00282 if( MT_MF_list.at( MT, this_mt ) )
00283 {
00284
00285 this_mt->push_back( MF );
00286 }
00287 else
00288 {
00289 iMF_array_link new_link;
00290 new_link.MT( ) = MT;
00291 MT_MF_list.insert( MT_MF_list.end( ), new_link );
00292 this_mt = MT_MF_list.end( );
00293 --this_mt;
00294
00295 this_mt->push_back( MF );
00296 }
00297
00298
00299 oFile.open(endf_file_name(MF,MT).c_str(),ios::out);
00300 if ( !oFile.is_open() )
00301 {
00302 SevereError("b6stream::readENDF",
00303 "File "+endf_file_name(MF,MT)+" not opened.");
00304 }
00305 else
00306 {
00307 Info("b6stream::readENDF","File "+endf_file_name(MF,MT)+
00308 " opened for write...");
00309 oFile << sBuff << endl;
00310 lofile=true;
00311 prev_mf = MF;
00312 prev_mt = MT;
00313 }
00314 }
00315 else
00316 {
00317 check_mf_mt( );
00318 oFile << sBuff << endl;
00319 }
00320
00321
00322 SEND=false;FEND=false;MEND=false;TEND=false;
00323
00324 }
00325
00326 void b6stream::check_mf_mt( )
00327 {
00328 if( ( MF != prev_mf ) || ( MT != prev_mt ) )
00329 {
00330 cout << "MF: " << MF << " prev_mf: " << prev_mf <<
00331 " MT: " << MT << " prev_mt: " << prev_mt << endl;
00332 SevereError( " b6stream::check_mf_mt", " inconsistent mf-mt numbers" );
00333 }
00334 }
00335
00336 void b6stream::get_MAT_MF_MT_NS()
00337 {
00338
00339 MAT=stoi(sBuff.substr(66,4));
00340 MF=stoi(sBuff.substr(70,2));
00341 MT=stoi(sBuff.substr(72,3));
00342 if (sBuff.size()>75) NS=stoi(sBuff.substr(75,5));
00343 else {
00344 if (NS>=0) NS++;
00345 else NS=0;
00346 }
00347 sBuff = sBuff.substr(0,66) ;
00348 }
00349
00350 int b6stream::NSUB_to_yi(int NSUB){
00351 if ( ( NSUB>3 )&&( NSUB<10 ) ) return 0;
00352 if ( ( NSUB>9 )&&( NSUB<13 ) ) return 1;
00353 if ( ( NSUB>10009 )&&( NSUB<10020 ) ) return 2;
00354 if ( ( NSUB>10019 )&&( NSUB<10030 ) ) return 3;
00355 if ( ( NSUB>10029 )&&( NSUB<10040 ) ) return 4;
00356 if ( ( NSUB>20029 )&&( NSUB<20040 ) ) return 5;
00357 if ( ( NSUB>20039 )&&( NSUB<20050 ) ) return 6;
00358 if ( ( NSUB>=0 )&&( NSUB<4 ) ) return 7;
00359 SevereError("b6stream::NSUB_to_yi",
00360 pastenum("Illegal Sublibrary designator NSUB=",NSUB)
00361 +", Cannot compute yi");
00362 return -1;
00363 }
00364
00365 void b6stream::print_summary()
00366 {
00367 if (MESSAGELEVEL_INFO) cout<<"Info : b6stream summary :"<<endl
00368 <<" ENDF Tape number " << NTAPE << endl
00369 <<" Library version "<<NVER<<"; identifier "<<NLIB<<endl
00370 <<" Library format = "<<NFOR<<endl
00371 <<" ZA = "<<ZA<<" AWR = "<<AWR<<endl;
00372 if ( LRP==-1 )
00373 {if (MESSAGELEVEL_INFO) cout<<" No File 2 given and LRP = -1 (we can't use it anyway...)"<<endl;}
00374 else if (LRP==0)
00375 {if (MESSAGELEVEL_INFO) cout<<" File 2 contains effective scattering radius..."<<endl;}
00376 else if (LRP==1)
00377 {}
00378 else if (LRP==2)
00379 {if (MESSAGELEVEL_INFO) cout<<" LRP = 2 :for use with derived files only"<<endl;}
00380 else
00381 {SevereError("b6stream::print_summary","LRP out of range!");}
00382 if (ZA/1000 > 88) {
00383 if (LFI==1) if (MESSAGELEVEL_INFO) cout<<" Material fizzes."<<endl;
00384 else Warning("b6stream::print_summary",
00385 pastenum("LFI = ",LFI)+", but material should fiz.");
00386 } else {
00387 if (LFI==0) if (MESSAGELEVEL_INFO) cout<<" Material does not fizz."<<endl;
00388 else SevereError("b6stream::print_summary",
00389 pastenum("LFI = ",LFI)+", but material cannot fiz!");
00390 }
00391 if (STA==0)
00392 {if (MESSAGELEVEL_INFO) cout<<" Target is stable."<<endl;}
00393 else
00394 {if (MESSAGELEVEL_INFO) cout<<" Target is unstable."<<endl;}
00395 if (MESSAGELEVEL_INFO) cout
00396 <<" Incident particle (yi) = "<<yi<<endl
00397 <<" Excitation energy = "<<ELIS<<endl
00398 <<" Nucleus state number = "<<LIS<<endl
00399 <<" Isomeric state number = "<<LISO<<endl
00400 <<" Temperature = "<<TEMP<<endl;
00401 }
00402
00403 void b6stream::print_MT_MF( )
00404 {
00405 cout << "Info: Data for each reaction:"<<endl;
00406 for( iMF_array_list::iterator this_mt = MT_MF_list.begin();
00407 this_mt != MT_MF_list.end(); ++this_mt)
00408 {
00409 this_mt->print_MF( );
00410 }
00411 }