Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

fete.cpp

Go to the documentation of this file.
00001 /*
00002  * ******** fete: From ENDF To ENDL *********
00003  * 
00004  * Copyright (c) 2006, The Regents of the University of California. 
00005  * All rights reserved.
00006  * 
00007  * Produced at the Lawrence Livermore National Laboratory. 
00008  * Written by David A. Brown, Gerry Hedstrom, Tony Hill
00009  * 
00010  * This file is part of fete v1.0  (UCRL-CODE-218718)
00011  * 
00012  * Please read the COPYING file for "Our Notice and GNU General 
00013  * Public License" in the root of this software distribution.  
00014  * 
00015  * This program is free software; you can redistribute it and/or modify 
00016  * it under the terms of the GNU General Public License (as published by 
00017  * the Free Software Foundation) version 2, dated June 1991. 
00018  * 
00019  * This program is distributed in the hope that it will be useful, 
00020  * but WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 
00022  * and conditions of the GNU General Public License for more details. 
00023  * 
00024  * You should have received a copy of the GNU General Public License along 
00025  * with this program; if not, write to the Free Software Foundation, Inc., 
00026  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
00027  * 
00028  * $Revision: 1890 $
00029  * $Date: 2006-08-29 11:45:16 -0700 (Tue, 29 Aug 2006) $
00030  * $Author: dbrown $
00031  * $Id: fete.cpp 1890 2006-08-29 18:45:16Z dbrown $
00032  * 
00033  * ******** fete: From ENDF To ENDL *********
00034  */
00035 
00036 #include <sstream>
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 #include <stdio.h>
00041 #include <glob.h>
00042 #include "convert.hpp"
00043 #include "version.hpp"
00044 #include "b6stream.hpp"
00045 #include "bdfls_tools.hpp"
00046 #include "endl_formats.hpp"
00047 #include "load_data.hpp"
00048 #include "global_params.hpp"
00049 #include "messaging.hpp"
00050 #include "mf12classes.hpp"
00051 #include "mf13classes.hpp"
00052 #include "logger.hpp"
00053 
00054 #define CLEAN_TEMP_FILES
00055 
00056 using namespace std;
00057 
00058 #ifdef CLEAN_TEMP_FILES
00059 
00060 // --------------- glob ---------------
00061 //! Gizmo to glob for files patching a pattern
00062 vector< string > glob(string pattern){
00063     glob_t globbuf;
00064     glob(pattern.c_str(), GLOB_ERR, NULL, &globbuf);
00065     vector< string > names;
00066     for (int i=0; i<globbuf.gl_pathc; ++i)
00067         names.push_back(static_cast<string>( globbuf.gl_pathv[i]) );
00068     return names;
00069 }
00070 
00071 // --------------- clean_files ---------------
00072 //! Cleans files
00073 bool clean_files( string pattern )
00074 {
00075   bool result=true;
00076   vector<string> filelist = glob(pattern);
00077   for( unsigned int i=0; i<filelist.size(); ++i )
00078   {
00079     result = result && remove(filelist[i].c_str())!=-1;
00080   }
00081   return result;
00082 }
00083 
00084 #endif
00085 
00086 
00087 
00088 // --------------- global data ---------------
00089 // We need the global parameters for the translation available globally
00090 GlobalParameterClass Global;
00091 
00092 // We need the bdfls data to available globally
00093 bdflsClass bdfls;
00094 
00095 // This object holds the reaction details for each MT
00096 // We'll pass members of this map around globally
00097 ENDLClass ENDL;
00098 
00099 // We need an (n,z[i]) storage array for cascades
00100 map< int, cascade > cascade_gammas;
00101 
00102 // We need to hold the C55 gammas to the end
00103 C55_gammas C55;
00104 
00105 // At the end, we write out the evaluation documentation, version info and
00106 // any processing errors.  This holds that data.
00107 MessageLogger messageLog;
00108 
00109 
00110 
00111 // --------------- main ---------------
00112 int main( int argc, char* argv[] )
00113 {
00114   //Pretty banner to set off start of program & print the version information
00115   cout << "+" << 40*string("-") << "+"<<endl;
00116   cout << "|" << center("fete: from ENDF to endl...",40)<< "|"<<endl;
00117   cout << "|" << center("Version "+string(FETE_VERSION),40) << "|" <<endl;
00118   cout << "|" << center("Revision "+string(FETE_REVISION),40) << "|" <<endl;
00119   cout << "|" << center("Last SVN commit "+string(FETE_VERSION_DATE),40) << "|" <<endl;
00120   cout << "+" << 40*string("-") << "+"<<endl;
00121 
00122 #ifdef CLEAN_TEMP_FILES
00123 
00124   if (!clean_files("yo*")) cout<<"\n\nRemoving old yo* files failed"<<endl;
00125 
00126 #endif
00127 
00128   //Read in any user requested settings
00129   string inFile = Global.read_command_line(argc, argv);
00130 
00131   //Print the parameter values used in the translation
00132   Global.print();
00133 
00134   bdfls.read();
00135 
00136   b6stream Eval(inFile);
00137 
00138   // print out the data for each reaction
00139   if ( MESSAGELEVEL_INFO )
00140   {
00141     Eval.print_MT_MF( );
00142   }
00143 
00144   // Here is where we loop over the all the reaction files
00145   for( iMF_array_list::iterator this_mt = Eval.MT_MF_list.begin();
00146       this_mt != Eval.MT_MF_list.end(); ++this_mt)
00147   {
00148     if ( ( this_mt->MT() != 151 ) && ( ( this_mt->MT() < 450 ) || ( this_mt->MT() > 461 ) ) )
00149         cout << endl << " ------ Processing MT = " << this_mt->MT() << " ------ " << endl;
00150     
00151     int mt = this_mt->MT();
00152     bool skip_mt = false;
00153     bool skip_xs = false;
00154 
00155     // check for more detailed particle data
00156     if( 
00157         ( mt ==   4  && ( Eval.MT_MF_list.found(  50 ) || Eval.MT_MF_list.found(  91 ) ) )  ||
00158         ( mt == 103  && ( Eval.MT_MF_list.found( 600 ) || Eval.MT_MF_list.found( 649 ) ) )  ||
00159         ( mt == 104  && ( Eval.MT_MF_list.found( 650 ) || Eval.MT_MF_list.found( 699 ) ) )  ||
00160         ( mt == 105  && ( Eval.MT_MF_list.found( 700 ) || Eval.MT_MF_list.found( 749 ) ) )  ||
00161         ( mt == 106  && ( Eval.MT_MF_list.found( 750 ) || Eval.MT_MF_list.found( 799 ) ) )  ||
00162         ( mt == 107  && ( Eval.MT_MF_list.found( 800 ) || Eval.MT_MF_list.found( 849 ) ) ) 
00163       )
00164     {
00165       if ( Global.Value( "translate_all" ) == 0 )
00166       {
00167         Info( "main", pastenum("Skipping  mt: ", mt) + ".  Use detailed reaction data");
00168         skip_xs = true;
00169         skip_mt = true;
00170       }
00171     }
00172     if( !skip_mt )
00173     {
00174       ENDL.global( Eval.ZA, Eval.AWR, Eval.TEMP, Eval.ELIS, Eval.yi, Eval.date );
00175       ENDL.T  = mt;
00176       ENDL.C  = 0;
00177       ENDL.S  = 0;
00178       ENDL.LR = 0;
00179       ENDL.write_file = true;
00180       ENDL.append = false;   // the default is to start a new file
00181       bool xs_exist = false; // no cross section data yet
00182       
00183       for( iMF_array_link::iterator this_mf = this_mt->begin( ); 
00184            this_mf != this_mt->end( ); ++this_mf )
00185       {
00186         int mf = *this_mf;
00187         // We can accept mf13 files for mt = 3 or mt = 4.
00188         // For all other cases we also need the cross sections (mf3).
00189         if( ( mf == 3 ) || ( ( mf <= 13 ) && ( ( mt >= 3 ) && ( mt <= 4 ) ) ) ) xs_exist = true;
00190         // In ENDL some angular distributions are in CM and some in lab frame
00191         if( mf == 4 ) ENDL.angles_CM = this_mt->angle_cm( );
00192         if( xs_exist && Global.Value( "translate_all" ) > 0 )
00193         { 
00194           ENDL.F = mf;
00195           if( !( mf==3 && skip_xs ) ) LoadData( mf, mt );
00196         }
00197         else if ( mt < 151 ) Info("main",pastenum("Skipping mt: ",mt)+
00198             pastenum(" mf: ",mf)+".  No cross section data");
00199       }
00200     }
00201   }
00202   if( ( C55.has_MT3 ) || ( C55.has_MT4 ) )
00203   {
00204     C55.write_endl( );
00205   }
00206   messageLog.write();
00207 
00208 #ifdef CLEAN_TEMP_FILES
00209 
00210   if (!clean_files("mf??mt???")) cout<<"\n\nRemoving temporary mf*mt* files failed"<<endl;
00211 
00212 #endif
00213 
00214 }

Generated on Thu Sep 7 10:30:04 2006 for fete -- From ENDFB6 To ENDL by doxygen 1.3.4