diff --git a/mccode/src/cogen.c.in b/mccode/src/cogen.c.in index bc15aa1b12..a10c1b7c6a 100644 --- a/mccode/src/cogen.c.in +++ b/mccode/src/cogen.c.in @@ -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);"); @@ -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"); @@ -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(""); @@ -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(""); diff --git a/tools/Python/mcdisplay/pyqtgraph/mcdisplay.py b/tools/Python/mcdisplay/pyqtgraph/mcdisplay.py index 449b8e7bff..f095a8d697 100755 --- a/tools/Python/mcdisplay/pyqtgraph/mcdisplay.py +++ b/tools/Python/mcdisplay/pyqtgraph/mcdisplay.py @@ -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): @@ -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 @@ -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__': diff --git a/tools/Python/mcdisplay/webgl-classic/mcdisplay.py b/tools/Python/mcdisplay/webgl-classic/mcdisplay.py index f499c3db70..6f86b45945 100755 --- a/tools/Python/mcdisplay/webgl-classic/mcdisplay.py +++ b/tools/Python/mcdisplay/webgl-classic/mcdisplay.py @@ -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 diff --git a/tools/Python/mcdisplay/webgl/mcdisplay.py b/tools/Python/mcdisplay/webgl/mcdisplay.py index 108b7d8b85..af993bfecf 100755 --- a/tools/Python/mcdisplay/webgl/mcdisplay.py +++ b/tools/Python/mcdisplay/webgl/mcdisplay.py @@ -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 diff --git a/tools/Python/mctest/mctest.py b/tools/Python/mctest/mctest.py index 099021400c..9618d056ad 100644 --- a/tools/Python/mctest/mctest.py +++ b/tools/Python/mctest/mctest.py @@ -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