commit df905225f1ae87e37154761916e6bbedad739919
parent fb7894528c92bd5687412bfc8eb2daf908cbb3ba
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 18 Jun 2024 09:55:20 +0200
Correction of error handling when resolving a probe list
Realisation is rejected if the returned code is RES_BAD_OP, and
calculations continue. But the result code has not been reset. As a
result, the calculation could return an error if the last realization of
a probe point has been rejected, even if this error is taken into
account.
Diffstat:
2 files changed, 45 insertions(+), 24 deletions(-)
diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h
@@ -155,18 +155,28 @@ XD(solve_one_probe)
res = XD(probe_realisation)(scn, &realis_args, &w);
if(res != RES_OK && res != RES_BAD_OP) goto error;
- if(res == RES_OK) {
- /* Stop time registration */
- time_sub(&t0, time_current(&t1), &t0);
- usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
-
- /* Update MC weights */
- acc_temp->sum += w;
- acc_temp->sum2 += w*w;
- acc_temp->count += 1;
- acc_time->sum += usec;
- acc_time->sum2 += usec*usec;
- acc_time->count += 1;
+ switch(res) {
+ /* Reject the realisation */
+ case RES_BAD_OP:
+ res = RES_OK;
+ break;
+
+ /* Update the accumulators */
+ case RES_OK:
+ /* Stop time registration */
+ time_sub(&t0, time_current(&t1), &t0);
+ usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
+
+ /* Update MC weights */
+ acc_temp->sum += w;
+ acc_temp->sum2 += w*w;
+ acc_temp->count += 1;
+ acc_time->sum += usec;
+ acc_time->sum2 += usec*usec;
+ acc_time->count += 1;
+ break;
+
+ default: FATAL("Unreachable code\n"); break;
}
}
diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h
@@ -197,20 +197,31 @@ XD(solve_one_probe_boundary)
res = XD(boundary_realisation)(scn, &realis_args, &w);
if(res != RES_OK && res != RES_BAD_OP) goto error;
- if(res == RES_OK) {
- /* Stop time registration */
- time_sub(&t0, time_current(&t1), &t0);
- usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
-
- /* Update MC weights */
- acc_temp->sum += w;
- acc_temp->sum2 += w*w;
- acc_temp->count += 1;
- acc_time->sum += usec;
- acc_time->sum2 += usec*usec;
- acc_time->count += 1;
+ switch(res) {
+ /* Reject the realisation */
+ case RES_BAD_OP:
+ res = RES_OK;
+ break;
+
+ /* Update the accumulators */
+ case RES_OK:
+ /* Stop time registration */
+ time_sub(&t0, time_current(&t1), &t0);
+ usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
+
+ /* Update MC weights */
+ acc_temp->sum += w;
+ acc_temp->sum2 += w*w;
+ acc_temp->count += 1;
+ acc_time->sum += usec;
+ acc_time->sum2 += usec*usec;
+ acc_time->count += 1;
+ break;
+
+ default: FATAL("Unreachable code\n"); break;
}
}
+
exit:
return res;
error: