Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions mccode/src/cogen.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,11 @@ int cogen_raytrace(struct instr_def *instr)
coutf("/* loop to generate events and call raytrace() propagate them */");
coutf("void raytrace_all(unsigned long long ncount, unsigned long seed) {");
coutf("");

coutf(" // if on GPU and mcdotrace just exit");
coutf(" #ifdef OPENACC");
coutf(" if (!mcdotrace) {");
coutf(" #endif");
coutf("");
coutf(" /* CPU-loop */");
coutf(" unsigned long long loops;");
coutf(" loops = ceil((double)ncount/gpu_innerloop);");
Expand Down Expand Up @@ -2072,6 +2076,12 @@ int cogen_raytrace(struct instr_def *instr)
coutf(" MPI_MASTER(");
coutf(" printf(\"*** TRACE end *** \\n\");");
coutf(" );");
coutf("");
coutf(" // if on GPU and mcdotrace just exit");
coutf(" #ifdef OPENACC");
coutf(" }");
coutf(" #endif");
coutf("");
coutf("} /* raytrace_all */");
coutf("");
coutf("#endif //no-FUNNEL");
Expand Down Expand Up @@ -2116,6 +2126,10 @@ int cogen_rt_funnel(struct instr_def *instr)

coutf("void raytrace_all_funnel(unsigned long long ncount, unsigned long seed) {");
coutf("");
coutf(" // if on GPU and mcdotrace just exit");
coutf(" #ifdef OPENACC");
coutf(" if (!mcdotrace) {");
coutf(" #endif");
coutf(" // set up outer (CPU) loop / particle batches");
coutf(" unsigned long long loops;");
coutf("");
Expand Down Expand Up @@ -2301,7 +2315,10 @@ int cogen_rt_funnel(struct instr_def *instr)
coutf(" free(pbuffer);");
cout( "");
coutf(" printf(\"\\n\");");

coutf(" // if on GPU and mcdotrace just exit");
coutf(" #ifdef OPENACC");
coutf(" }");
coutf(" #endif");
coutf("} /* raytrace_all_funnel */");
coutf("#endif // FUNNEL");
coutf("");
Expand Down
18 changes: 12 additions & 6 deletions tools/Python/mcdisplay/pyqtgraph/mcdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,10 @@ def run_ui(self, instr, rays):
''' '''
self._init_2dmode()
self._set_and_plot_instr(instr)
self._set_rays(rays)
self._unzoom()
self._display_nextray()
if not rays==[]:
self._set_rays(rays)
self._unzoom()
self._display_nextray()
return self.app.exec_()

def run_ui_tof(self, instr, rays):
Expand Down Expand Up @@ -535,6 +536,11 @@ def main(instr=None, dirname=None, invcanvas=None, tof=None, **kwds):
reader = McDisplayReader(instr=instr, dir=dirname, **kwds)
instrument = reader.read_instrument()
raybundle = reader.read_particles()

if raybundle is None:
rays=[]
else:
rays=raybundle.rays

if invcanvas is not None and invcanvas:
## Switch to using white background and black foreground
Expand All @@ -544,11 +550,11 @@ def main(instr=None, dirname=None, invcanvas=None, tof=None, **kwds):
gui = McDisplay2DGui(title=dirname+" - Press 'h' for comp list")
try:
if tof is None or not tof:
sys.exit(gui.run_ui(instrument, raybundle.rays))
sys.exit(gui.run_ui(instrument, rays))
else:
sys.exit(gui.run_ui_tof(instrument, raybundle.rays))
sys.exit(gui.run_ui_tof(instrument, rays))
except:
sys.exit(gui.run_ui(instrument, raybundle.rays))
sys.exit(gui.run_ui(instrument, rays))


if __name__ == '__main__':
Expand Down
10 changes: 7 additions & 3 deletions tools/Python/mcdisplay/webgl-classic/mcdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ def copy(a, b):
# write instrument
json_instr = 'MCDATA_instrdata = %s;' % json.dumps(instrument.jsonize(), indent=0)
file_save(json_instr, dest.joinpath('_instr.js'))

# write particles
json_particles = 'MCDATA_particledata = %s;' % json.dumps(raybundle.jsonize(), indent=0)

if raybundle is not None:
# write particles
json_particles = 'MCDATA_particledata = %s;' % json.dumps(raybundle.jsonize(), indent=0)
else:
# write empty list
json_particles = 'MCDATA_particledata = [];'
file_save(json_particles, dest.joinpath('_particles.js'))

# Workaround for allowing non-relative paths to instrname
Expand Down
8 changes: 6 additions & 2 deletions tools/Python/mcdisplay/webgl/mcdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ def copy(a, b):
json_instr = '%s' % json.dumps(instrument.jsonize(), indent=2)
file_save(json_instr, dest.joinpath('instrument.json'))

# Write particles
json_particles = '%s' % json.dumps(raybundle.jsonize(), indent=2)
if raybundle is not None:
# Write particles
json_particles = '%s' % json.dumps(raybundle.jsonize(), indent=2)
else:
# write empty list
json_particles = '[]'
file_save(json_particles, dest.joinpath('particles.json'))

# Exit if nobrowse flag has been set
Expand Down
4 changes: 2 additions & 2 deletions tools/Python/mctest/mctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ def mccode_test(branchdir, testdir, limitinstrs=None, instrfilter=None, compfilt
logging.info(formatstr % test.get_display_name())
# Run mcdisplay (single particle only)
if test.testnb>0:
cmd = mccode_config.configuration["MCDISPLAY"]+'-classic --nobrowse %s %s -n1 -d display > displaylog.txt 2>&1' % (test.instrname+'.instr', test.parvals)
cmd = mccode_config.configuration["MCDISPLAY"]+'-classic --nobrowse %s %s -n0 -d display > displaylog.txt 2>&1' % (test.instrname+'.instr', test.parvals)
else:
cmd = mccode_config.configuration["MCDISPLAY"]+'-classic --nobrowse %s -y -n1 -d display > displaylog.txt 2>&1' % (test.instrname+'.instr')
cmd = mccode_config.configuration["MCDISPLAY"]+'-classic --nobrowse %s -y -n0 -d display > displaylog.txt 2>&1' % (test.instrname+'.instr')
retcode = utils.run_subtool_noread(cmd, cwd=join(testdir, test.instrname), timeout=compilemax)
if retcode[0]==0:
test.displayed = True
Expand Down
Loading