Skip to content

Commit

Permalink
[bug] fix mcx crash when replay is requested without seed file
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Nov 25, 2024
1 parent e8907db commit 51e9970
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/mcx_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,11 @@ void mcx_preprocess(Config* cfg) {
cfg->issavedet = 0;
}

if ((cfg->outputtype == otJacobian || cfg->outputtype == otWP || cfg->outputtype == otDCS || cfg->outputtype == otRF)
&& cfg->seed != SEED_FROM_FILE) {
MCX_ERROR(-6, "Jacobian output is only valid in the reply mode. Please define cfg.seed");
}

// if neither trajectory or polarization is enabled, disable istrajstokes flag
if (!(cfg->debuglevel & (MCX_DEBUG_MOVE | MCX_DEBUG_MOVE_ONLY)) || !((cfg->mediabyte <= 4) && (cfg->polmedianum > 0))) {
cfg->istrajstokes = 0;
Expand Down Expand Up @@ -2852,7 +2857,7 @@ int mcx_loadjson(cJSON* root, Config* cfg) {
MCX_ERROR(-1, "Optode.Source.Pattern JData-annotated array must be in the 'single' format");
}

if (ndim == 3 && dims[2] > 1 && dims[0] > 1 && cfg->srctype == MCX_SRC_PATTERN || cfg->srctype == MCX_SRC_PATTERN3D) {
if (ndim == 3 && dims[2] > 1 && dims[0] > 1 && (cfg->srctype == MCX_SRC_PATTERN || cfg->srctype == MCX_SRC_PATTERN3D)) {
cfg->srcnum = dims[0];
}
} else {
Expand Down Expand Up @@ -3766,11 +3771,6 @@ void mcx_validatecfg(Config* cfg, float* detps, int dimdetps[2], int seedbyte) {
cfg->seed = time(NULL);
}

if ((cfg->outputtype == otJacobian || cfg->outputtype == otWP || cfg->outputtype == otDCS || cfg->outputtype == otRF)
&& cfg->seed != SEED_FROM_FILE) {
MCX_ERROR(-6, "Jacobian output is only valid in the reply mode. Please define cfg.seed");
}

for (i = 0; i < cfg->detnum; i++) {
if (!cfg->issrcfrom0) {
cfg->detpos[i].x--;
Expand Down

0 comments on commit 51e9970

Please sign in to comment.