commit eaa9194d11c094b4c0dfaea078a3a25cc9ce1cf7
parent 5b9d37c3ea929b10a1ea1107cebe47c6c1399310
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 29 Mar 2016 11:00:31 +0200
Adjust the return code of some estimator getters
Return a RES_BAD_OP code if the [cumulative] phase function couldn't be
retrieved.
Diffstat:
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/sschiff.h b/src/sschiff.h
@@ -190,7 +190,8 @@ sschiff_estimator_get_cross_sections
/* Retrieve a pointer onto the estimated phase function for the scattering
* angles of the estimator. Use the sschiff_estimator_get_scattering_angles
- * function to retrieve these scattering angles. */
+ * function to retrieve these scattering angles. Return RES_BAD_OP if the phase
+ * function couldn't be estimated for this wavelength */
SSCHIFF_API res_T
sschiff_estimator_get_phase_function
(const struct sschiff_estimator* estimator,
@@ -200,7 +201,8 @@ sschiff_estimator_get_phase_function
/* Retrieve a pointer onto the estimated phase function cumulative for the
* scattering angles of the estimator. Use the
* sschiff_estimator_get_scattering_angles function to retrieve these
- * scattering angles */
+ * scattering angles. Return RES_BAD_OP if the phase function couldn't be
+ * estimated for this wavelength */
SSCHIFF_API res_T
sschiff_estimator_get_phase_function_cumulative
(const struct sschiff_estimator* estimator,
@@ -211,7 +213,8 @@ sschiff_estimator_get_phase_function_cumulative
* cumulative is computed for a set of `nthetas' values distributed in [0, 1]
* as [0, 1*S, 2*S, ..., i*S, ..., (nthetas-1)*S] with S=1/(nthetas-1). The
* ouput array `thetas' stored the angles corresponding to these cumulative
- * values. Its length must be at least equal to `nthetas'. */
+ * values. Its length must be at least equal to `nthetas'. Return RES_BAD_OP of
+ * the cumulative phase function cannot be inverted. */
SSCHIFF_API res_T
sschiff_estimator_inverse_cumulative_phase_function
(const struct sschiff_estimator* estimator,
diff --git a/src/sschiff_estimator.c b/src/sschiff_estimator.c
@@ -1693,7 +1693,7 @@ sschiff_estimator_get_phase_function
return RES_BAD_ARG;
/* No phase function was computed */
if(estimator->limit_angles[iwlen] == INVALID_LIMIT_ANGLE)
- return RES_OK;
+ return RES_BAD_OP;
*states = estimator->phase_functions[iwlen].values;
return RES_OK;
}
@@ -1709,7 +1709,7 @@ sschiff_estimator_get_phase_function_cumulative
return RES_BAD_ARG;
/* No phase function cumulative was computed */
if(estimator->limit_angles[iwlen] == INVALID_LIMIT_ANGLE)
- return RES_OK;
+ return RES_BAD_OP;
*states = estimator->phase_functions[iwlen].cumulative;
return RES_OK;
}
@@ -1738,8 +1738,10 @@ sschiff_estimator_inverse_cumulative_phase_function
}
/* No phase function cumulative is computed => nothing to inverse */
- if(estimator->limit_angles[iwlen] == INVALID_LIMIT_ANGLE)
- goto exit;
+ if(estimator->limit_angles[iwlen] == INVALID_LIMIT_ANGLE) {
+ res = RES_BAD_OP;
+ goto error;
+ }
/* Allocate the "filtered" phase function cumulative of small angles, i.e.
* the increasing cumulative defined from the Monte-Carlo estimation. */