Skip to content

Commit

Permalink
[bug] fix mcxlab crash when using issave2pt=0 with photonsharing
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Nov 10, 2024
1 parent 8c69db3 commit f17dcc6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/mcx_core.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3916,7 +3916,7 @@ is more than what your have specified (%d), please use the -H option to specify
((cfg->issavedet == FILL_MAXDETPHOTON) ? cfg->energytot : ((double)cfg->nphoton * ((cfg->respin > 1) ? (cfg->respin) : 1))) / max(1, cfg->runtime));
fflush(cfg->flog);

if (cfg->srctype == MCX_SRC_PATTERN && cfg->srcnum > 1) {
if (cfg->issave2pt && cfg->srctype == MCX_SRC_PATTERN && cfg->srcnum > 1) {
for (i = 0; i < (int)cfg->srcnum; i++) {
MCX_FPRINTF(cfg->flog, "source #%d total simulated energy: %.2f\tabsorbed: " S_BOLD "" S_BLUE "%5.5f%%" S_RESET"\n(loss due to initial specular reflection is excluded in the total)\n",
i + 1, energytot[i], energyabs[i] / energytot[i] * 100.f);
Expand Down Expand Up @@ -4000,6 +4000,13 @@ is more than what your have specified (%d), please use the -H option to specify
free(energy);
free(field);
free(srcpw);
free(energytot);
free(energyabs);

if (energytot) {
free(energytot);
}

if (energyabs) {
free(energyabs);
}

}

0 comments on commit f17dcc6

Please sign in to comment.