Skip to content

Commit 2fb5a0d

Browse files
committed
Merge branch 'fix/directory' into 'develop'
Fix/directory See merge request njoy/ENDFtk!15
2 parents 30715df + 0dc6220 commit 2fb5a0d

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

ReleaseNotes.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This update makes the following changes on interface functions:
1111
- Miscellaneous documentation updates were made.
1212

1313
In addition, the following issues were corrected:
14+
- In some ENDF files (such as the JEFF 3.3 decay library files), the directory records in MF1 MT451 sometimes have superfluous zeros in column 1 and 2 (similar to how END records sometimes have supefluous zeros in columns 1 through 6). Previously, ENDFtk flagged these directory records as errors. This has been corrected, although these columns will still be left blank when printing them out (in the same way as END records).
1415
- A minor bug in the rectangular matrix covariance block was corrected. The values for the row and column energies are lifted out of a larger array using the std::ranges::take and std::ranges::drop function. For the column energies, we forgot to properly end the sequence. As a result, the end() iterator of the range did not point to the end of the column energies but to the end of the covariance values, which is now corrected.
1516
- In MF8 MT457 DiscreteSpectrum, NT=8 (which can occur for electrons, i.e. STYP=8), was explicitly disallowed by ENDFtk. This was corrected and a new constructor reflecting this usage was added as well.
1617
- The STA variable in MF1 MT451 was interpreted incorrectly and this has now been fixed. An additional isUnstable() function has been added to the interface.

src/ENDFtk/DirectoryRecord.hpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ namespace ENDFtk {
1818
*
1919
* See ENDF102, section 1.1 for more information.
2020
*/
21-
class DirectoryRecord : protected record::Base< record::Integer< 33 >,
21+
class DirectoryRecord : protected record::Base< record::Real,
22+
record::Real,
23+
record::Integer< 11 >,
2224
record::Integer< 11 >,
2325
record::Integer< 11 >,
2426
record::Integer< 11 > > {
2527

2628
/* type aliases */
2729
using base =
28-
record::Base< record::Integer< 33 >, record::Integer< 11 >,
30+
record::Base< record::Real, record::Real,
31+
record::Integer< 11 >, record::Integer< 11 >,
2932
record::Integer< 11 >, record::Integer< 11 > >;
3033
using tail = record::TailVerifying< record::MAT, record::MF, record::MT >;
3134

@@ -42,7 +45,7 @@ namespace ENDFtk {
4245
* @param[in] mod the modification number
4346
*/
4447
DirectoryRecord( long mf, long mt, long nc, long mod ) :
45-
base( mf, mt, nc, mod ){}
48+
base( 0.0, 0.0, mf, mt, nc, mod ){}
4649

4750
//! @todo pybind11 variant needs default constructor workaround
4851
#ifdef PYBIND11
@@ -86,10 +89,10 @@ namespace ENDFtk {
8689
ImmutableReturnType< index > \
8790
name () const { return std::get< index >( this->fields ); }
8891

89-
DEFINE_GETTER( MF, 0 )
90-
DEFINE_GETTER( MT, 1 )
91-
DEFINE_GETTER( NC, 2 )
92-
DEFINE_GETTER( MOD, 3 )
92+
DEFINE_GETTER( MF, 2 )
93+
DEFINE_GETTER( MT, 3 )
94+
DEFINE_GETTER( NC, 4 )
95+
DEFINE_GETTER( MOD, 5 )
9396

9497
#undef DEFINE_GETTER
9598

src/ENDFtk/DirectoryRecord/test/DirectoryRecord.test.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ using Catch::Matchers::WithinRel;
1212
using namespace njoy::ENDFtk;
1313

1414
std::string chunk();
15+
std::string chunkWithSuperfluousZeros();
1516
void verifyChunk( const DirectoryRecord& );
1617
std::string invalidChunk();
1718

@@ -67,6 +68,30 @@ SCENARIO( "DirectoryRecord" ) {
6768
CHECK( buffer == string );
6869
} // THEN
6970
} // WHEN
71+
72+
WHEN( "the data is read from a string/stream with superfluous zeros" ) {
73+
74+
auto superfluous = chunkWithSuperfluousZeros();
75+
auto begin = superfluous.begin();
76+
auto end = superfluous.end();
77+
long lineNumber = 1;
78+
79+
DirectoryRecord chunk( begin, end, lineNumber, 125, 1, 451 );
80+
81+
THEN( "a DirectoryRecord can be constructed and members can be tested" ) {
82+
83+
verifyChunk( chunk );
84+
} // THEN
85+
86+
THEN( "it can be printed without the superfluous zeros" ) {
87+
88+
std::string buffer;
89+
auto output = std::back_inserter( buffer );
90+
chunk.print( output, 125, 1, 451 );
91+
92+
CHECK( buffer == string );
93+
} // THEN
94+
} // WHEN
7095
} // GIVEN
7196

7297
GIVEN( "invalid data for a DirectoryRecord" ) {
@@ -107,6 +132,12 @@ std::string chunk() {
107132
" 1 451 101 5 125 1451 \n";
108133
}
109134

135+
std::string chunkWithSuperfluousZeros() {
136+
137+
return
138+
" 0.00000+00 0.00000+00 1 451 101 5 125 1451 \n";
139+
}
140+
110141
void verifyChunk( const DirectoryRecord& chunk ) {
111142

112143
CHECK( 1 == chunk.MF() );

0 commit comments

Comments
 (0)