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

record_types.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: 1748 $
00029  * $Date: 2006-03-14 12:18:15 -0800 (Tue, 14 Mar 2006) $
00030  * $Author: dbrown $
00031  * $Id: record_types.cpp 1748 2006-03-14 20:18:15Z dbrown $
00032  * 
00033  * ******** fete: From ENDF To ENDL *********
00034  */
00035 
00036 // Function methods for the different record types
00037 
00038 #include "record_types.hpp"
00039 #include "convert.hpp"
00040 #include "messaging.hpp"
00041 
00042 string toupper(const string& s)
00043 {
00044     string t = s;
00045     int length = t.length();
00046     for (int i = 0; i < length; i++) t[i] = toupper(t[i]);
00047     return t;
00048 }
00049 
00050 void read_ddiiii(string *pS, 
00051          double *pR1, double *pR2, 
00052          int *pI1, int *pI2, int *pI3, int *pI4)
00053 {
00054   *pR1 = stod( pS->substr(  0, 11 ) );
00055   *pR2 = stod( pS->substr( 11, 11 ) );
00056   *pI1 = stoi( pS->substr( 22, 11 ) );
00057   *pI2 = stoi( pS->substr( 33, 11 ) );
00058   *pI3 = stoi( pS->substr( 44, 11 ) );
00059   *pI4 = stoi( pS->substr( 55, 11 ) );
00060 }
00061 
00062 void read_idiiii(string *pS, 
00063          int *pI1, 
00064          double *pR1, 
00065          int *pI2, int *pI3, int *pI4, int *pI5)
00066 {
00067   *pI1 = stoi( pS->substr(  0, 11 ) );
00068   *pR1 = stod( pS->substr( 11, 11 ) );
00069   *pI2 = stoi( pS->substr( 22, 11 ) );
00070   *pI3 = stoi( pS->substr( 33, 11 ) );
00071   *pI4 = stoi( pS->substr( 44, 11 ) );
00072   *pI5 = stoi( pS->substr( 55, 11 ) );
00073 }
00074 
00075 void read_iiidiiddd(string *pS, 
00076             int *pI1, int *pI2, int *pI3,
00077             double *pR1, 
00078             int *pI4, int *pI5, 
00079             double *pR2, double *pR3, double *pR4 )
00080 {
00081   *pI1 = stoi( pS->substr(  0,  6 ) );
00082   *pI2 = stoi( pS->substr(  6,  3 ) );
00083   *pI3 = stoi( pS->substr(  9,  3 ) );
00084   *pR1 = stod( pS->substr( 12, 12 ) );
00085   *pI4 = stoi( pS->substr( 24,  7 ) );
00086   *pI5 = stoi( pS->substr( 31,  3 ) );
00087   *pR2 = stod( pS->substr( 34, 12 ) );
00088   *pR3 = stod( pS->substr( 46, 12 ) );
00089   *pR4 = stod( pS->substr( 58, 12 ) );
00090 }
00091 
00092 void read_iiiddddd(string *pS, 
00093             int *pI1, int *pI2, int *pI3, 
00094             double *pR1, double *pR2,
00095             double *pR3, double *pR4, double *pR5 )
00096 {
00097   *pI1 = stoi( pS->substr(  0,  2 ) );
00098   *pI2 = stoi( pS->substr(  2,  3 ) );
00099   *pI3 = stoi( pS->substr(  5,  3 ) );
00100   *pR1 = stod( pS->substr(  8, 12 ) );
00101   *pR2 = stod( pS->substr( 20, 12 ) );
00102   *pR3 = stod( pS->substr( 32, 12 ) );
00103   *pR4 = stod( pS->substr( 44, 12 ) );
00104   *pR5 = stod( pS->substr( 56, 12 ) );
00105 }
00106 
00107 void read_d(string *pS, 
00108         double *pR )
00109 {
00110   *pR = stod( pS->substr(  0, 11 ) );
00111 }
00112 
00113 void read_dd(string *pS, 
00114          double *pR1, double *pR2 )
00115 {
00116   *pR1 = stod( pS->substr(  0, 11 ) );
00117   *pR2 = stod( pS->substr( 11, 11 ) );
00118 }
00119 
00120 void read_ddd(string *pS, 
00121          double *pR1, double *pR2, double *pR3 )
00122 {
00123   *pR1 = stod( pS->substr(  0, 11 ) );
00124   *pR2 = stod( pS->substr( 11, 11 ) );
00125   *pR3 = stod( pS->substr( 22, 11 ) );
00126 }
00127 
00128 void read_dddddd(string *pS, 
00129          double *pR1, double *pR2, double *pR3,
00130                  double *pR4, double *pR5, double *pR6 )
00131 {
00132   *pR1 = stod( pS->substr(  0, 11 ) );
00133   *pR2 = stod( pS->substr( 11, 11 ) );
00134   *pR3 = stod( pS->substr( 22, 11 ) );
00135   *pR4 = stod( pS->substr( 33, 11 ) );
00136   *pR5 = stod( pS->substr( 44, 11 ) );
00137   *pR6 = stod( pS->substr( 55, 11 ) );
00138 }
00139 
00140 void read_ii(string *pS, 
00141          int *pI1, int *pI2 )
00142 {
00143   *pI1 = stoi( pS->substr(  0, 11 ) );
00144   *pI2 = stoi( pS->substr( 11, 11 ) );
00145 }
00146 
00147 void read_date(string *pS, 
00148          int *pI1 )
00149 {
00150   string smonth;
00151   int year,month,day;
00152 
00153   //get the month and year of the evaluation
00154   smonth = toupper(pS->substr( 27,3 ));
00155   year = stoi( pS->substr(  30, 2 ) );
00156 
00157   //Convert the character month to a string
00158   if( smonth == "JAN" ) 
00159     {
00160       month = 1;
00161     }
00162   else if( smonth == "FEB" ) 
00163     {
00164       month = 2;
00165     }
00166   else if( smonth == "MAR" ) 
00167     {
00168       month = 3;
00169     }
00170   else if( smonth == "APR" ) 
00171     {
00172       month = 4;
00173     }
00174   else if( smonth == "MAY" ) 
00175     {
00176       month = 5;
00177     }
00178   else if( smonth == "JUN" ) 
00179     {
00180       month = 6;
00181     }
00182   else if( smonth == "JUL" ) 
00183     {
00184       month = 7;
00185     }
00186   else if( smonth == "AUG" ) 
00187     {
00188       month = 8;
00189     }
00190   else if( smonth == "SEP" ) 
00191     {
00192       month = 9;
00193     }
00194   else if( smonth == "OCT" ) 
00195     {
00196       month = 10;
00197     }
00198   else if( smonth == "NOV" ) 
00199     {
00200       month = 11;
00201     }
00202   else if( smonth == "DEC" ) 
00203     {
00204       month = 12;
00205     }
00206   else
00207     {
00208       SevereError("read_date",smonth+" is not a recognized month!");
00209     }
00210   
00211   //Since there is no "day" associated with the evaulation date, we use "01"
00212   day=1;
00213 
00214   //ENDL date format is used    
00215   *pI1 = year*10000+month*100+day;
00216 }
00217 // *************** read_yi **********************
00218 int read_yi( string *pS )
00219 {
00220   int yi;
00221 
00222   string upS = toupper(*pS);
00223 
00224   if (upS.find("NEUTR")!=string::npos) yi = 1;
00225 
00226   else if (upS.find("PROTO")!=string::npos) yi = 2;
00227 
00228   else if (upS.find("DEUTE")!=string::npos) yi = 3;
00229 
00230   else if (upS.find("TRITO")!=string::npos) yi = 4;
00231 
00232   else if (upS.find("HELIU")!=string::npos) yi = 5;
00233 
00234   else if (upS.find("ALPHA")!=string::npos) yi = 6;
00235 
00236   else if ( (upS.find("PHOTO")!=string::npos) || (upS.find("GAMMA")!=string::npos) ) yi = 7;
00237 
00238   else
00239   {
00240     SevereError( "read_yi","Cannot identify incident particle" );
00241   }
00242 
00243   return yi;
00244 }

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