mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-11-19 12:32:40 +01:00
26ca2d3907
Now, probes witth absolute check and relative checks perform the verification with the expected/actual value as expected and returns a boolean to indicate the result.
106 lines
1.9 KiB
C
106 lines
1.9 KiB
C
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
#ifdef VFC_CI
|
|
#include <vfc_probes.h>
|
|
vfc_probes probes;
|
|
#endif
|
|
|
|
|
|
// Wrappers to Verificarlo functions
|
|
|
|
#ifdef VFC_CI
|
|
void __attribute__((constructor)) qmckl_init_probes(){
|
|
probes = vfc_init_probes();
|
|
}
|
|
#endif
|
|
|
|
|
|
bool qmckl_probe(
|
|
char * testName,
|
|
char * varName,
|
|
double value
|
|
) {
|
|
#ifdef VFC_CI
|
|
return vfc_probe(&probes, testName, varName, value);
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
|
|
bool qmckl_probe_check(
|
|
char * testName,
|
|
char * varName,
|
|
double value,
|
|
double expectedValue,
|
|
double accuracyTarget
|
|
) {
|
|
#ifdef VFC_CI
|
|
return vfc_probe_check(&probes, testName, varName, value, accuracyTarget);
|
|
#else
|
|
return !(abs(value - expectedValue) < accuracyTarget);
|
|
#endif
|
|
}
|
|
|
|
|
|
bool qmckl_probe_check_relative (
|
|
char * testName,
|
|
char * varName,
|
|
double value,
|
|
double expectedValue,
|
|
double accuracyTarget
|
|
) {
|
|
#ifdef VFC_CI
|
|
return vfc_probe_check_relative(&probes, testName, varName, value, accuracyTarget);
|
|
#else
|
|
return !(abs(value - expectedValue) / abs(expectedValue) < accuracyTarget);
|
|
#endif
|
|
}
|
|
|
|
#ifdef VFC_CI
|
|
void __attribute__((destructor)) qmckl_dump_probes(){
|
|
vfc_dump_probes(&probes);
|
|
}
|
|
#endif
|
|
|
|
|
|
// Fortran wrappers
|
|
|
|
bool qmckl_probe_f(
|
|
char * testName,
|
|
char * varName,
|
|
double * value
|
|
) {
|
|
return qmckl_probe(testName, varName, *value);
|
|
}
|
|
|
|
|
|
bool qmckl_probe_check_f(
|
|
char * testName,
|
|
char * varName,
|
|
double * value,
|
|
double * expectedValue,
|
|
double * accuracyTarget
|
|
) {
|
|
return qmckl_probe_check(
|
|
testName, varName,
|
|
*value, *expectedValue, *accuracyTarget
|
|
);
|
|
}
|
|
|
|
|
|
bool qmckl_probe_check_relative_f(
|
|
char * testName,
|
|
char * varName,
|
|
double * value,
|
|
double * expectedValue,
|
|
double * accuracyTarget
|
|
) {
|
|
return qmckl_probe_check_relative(
|
|
testName, varName,
|
|
*value, *expectedValue, *accuracyTarget
|
|
);
|
|
}
|