diff --git a/qpms/qpms_types.h b/qpms/qpms_types.h index 4c1585f..f15d71c 100644 --- a/qpms/qpms_types.h +++ b/qpms/qpms_types.h @@ -79,7 +79,9 @@ typedef unsigned long long qpms_uvswfi_t; typedef enum { QPMS_SUCCESS = 0, ///< Success. QPMS_ERROR = 1, ///< Unspecified error. - QPMS_ENOMEM = 8 ///< Out of memory. + QPMS_ENOMEM = 8, ///< Out of memory. + QPMS_NAN_ENCOUNTERED = 1024 ///< NaN value encountered in data processing. + } qpms_errno_t; diff --git a/qpms/tmatrices.c b/qpms/tmatrices.c index 9ee21f1..baf6ae4 100644 --- a/qpms/tmatrices.c +++ b/qpms/tmatrices.c @@ -454,6 +454,14 @@ qpms_errno_t qpms_load_scuff_tmatrix( "Could not open T-matrix file %s", path); qpms_errno_t retval = qpms_read_scuff_tmatrix(f, bs, n, freqs, freqs_su, tmatrices_array, tmdata); + + for (size_t i = 0; i < *n * bs->n * bs->n; ++i) + if(isnan(creal((*tmdata)[i])) || isnan(cimag((*tmdata)[i]))) { + QPMS_WARN("Encountered NAN in a loaded T-matrix"); + retval |= QPMS_NAN_ENCOUNTERED; + break; + } + if(fclose(f)) qpms_pr_error_at_line(__FILE__, __LINE__, __func__, "Could not close the T-matrix file %s (well, that's weird, " "since it's read only).", path);