Skip to content

Commit

Permalink
Fix arrays and latch in iaea_phsp_source (#323)
Browse files Browse the repository at this point in the history
Initialize "extra" arrays with a fixed dimension MAXEXTRAS. Arrays
extrafloat_type, extralong_types, extrainttemp, and extrafloattemp were
initialized with zero dimension when the IAEA phsp did not store
additional integers (e.g., latch) or floats (e.g., zlast) for each
particle.

Set latch to 0, similar to what is done in egs_phsp_source. Source had
the temerity to actually assign any latch value read from the phsp file
to the incident particle, not realizing that, at least in the case of
egs_chamber, this variable is used for setting the splitting number.
This partially fixes Issue #314 reported by @ojalaj.
  • Loading branch information
blakewalters authored and ftessier committed Aug 18, 2017
1 parent 35f098e commit bab2e86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions HEN_HOUSE/egs++/sources/iaea_phsp_source/iaea_phsp_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void IAEA_PhspSource::openFile(const string &phsp_file) {
return;
}
//determine if Zlast is stored in the file and, if so, its array index, i_zlast
int extrafloat_types[n_extra_floats], extralong_types[n_extra_longs];
int extrafloat_types[MAXEXTRAS], extralong_types[MAXEXTRAS];
iaea_get_type_extra_variables(&iaea_fileid,&iaea_iostat,extralong_types,extrafloat_types);
if (iaea_iostat==-1) {
egsWarning("IAEA_PhspSource::openFile: failed to get Mode of data %s.IAEAheader\n",phsp_file.c_str());
Expand Down Expand Up @@ -288,8 +288,8 @@ EGS_I64 IAEA_PhspSource::getNextParticle(EGS_RandomGenerator *, int &q,
do { readParticle(); } while ( rejectParticle() );
}
*/
int nstat,extrainttemp[n_extra_longs];
float extrafloattemp[n_extra_floats];
int nstat,extrainttemp[MAXEXTRAS];
float extrafloattemp[MAXEXTRAS];
if (Nuse >= Nreuse) { //get a new particle
if ((++Npos) > Nlast) {
egsWarning("IAEA_PhspSource::getNextParticle(): reached the end of the "
Expand All @@ -306,9 +306,12 @@ EGS_I64 IAEA_PhspSource::getNextParticle(EGS_RandomGenerator *, int &q,
}
iaea_get_particle(&iaea_fileid,&nstat,&p.q,&p.E,&p.wt,&p.x,&p.y,&p.z,&p.u,&p.v,&p.w,extrafloattemp,extrainttemp);
++Nread;
p.latch=0; //important if we are using latch to do vr
/*
if (latch_stored) {
p.latch = extrainttemp[i_latch];
}
*/
if (mode2) {
p.zlast = extrafloattemp[i_zlast];
}
Expand Down Expand Up @@ -343,9 +346,6 @@ EGS_I64 IAEA_PhspSource::getNextParticle(EGS_RandomGenerator *, int &q,
else {
egsFatal("IAEA_PhspSource::getNextParticle: unknown charge on particle\n");
}
if (!latch_stored) {
p.latch = 0; //need some non-nonsense value in case there is a LATCH filter
}
//note: we don't have to convert to p.E to K.E. because that's what IAEA format stores
if (first || nstat>0) {
count++; //increment primary history counter
Expand Down
2 changes: 2 additions & 0 deletions HEN_HOUSE/egs++/sources/iaea_phsp_source/iaea_phsp_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#ifndef IAEA_PHSP_SOURCE_
#define IAEA_PHSP_SOURCE_

#define MAXEXTRAS 10

#include "egs_vector.h"
#include "egs_base_source.h"
#include "egs_rndm.h"
Expand Down

0 comments on commit bab2e86

Please sign in to comment.