ecmwf-ifs / field_api

Apache License 2.0
3 stars 8 forks source link

Print CRC64 code each time a pointer is requested #42

Closed pmarguinaud closed 4 months ago

pmarguinaud commented 4 months ago

This PR adds the following capability : each time a field is accessed with GET accessors functions, Field API prints a checksum. In addition, a backtrace of where the field was accessed from can be printed.

These two features are controlled with the following global variables (field_defaults_module.F90) :

Addresses are printed in hexadecimal, but can be converted to real code locations using addr2line.

An example of listing (taken from an ARPEGE run), after post-processing with addr2line :

F29B6FA62488FFFF FIELD_3RD RDONLY    DEVICE     cpg_gp_parallel.F90:1661 cpg_parallel.F90:358 cpg_drv.F90:370 gp_model.F90:379
F26961A07CFFFFFF FIELD_3RD RDONLY    DEVICE     cpg_gp_parallel.F90:1662 cpg_parallel.F90:358 cpg_drv.F90:370 gp_model.F90:379
B00D273ECD847BE1 FIELD_3RD RDONLY    DEVICE     cpg_gp_parallel.F90:1663 cpg_parallel.F90:358 cpg_drv.F90:370 gp_model.F90:379
128A617186047897 FIELD_3RD RDONLY    DEVICE     cpg_gp_parallel.F90:1664 cpg_parallel.F90:358 cpg_drv.F90:370 gp_model.F90:379

Furthermore, this PR enables the calculation of CRC64 checksums without altering the field status (ie host/device freshness).

Please note that the backtrace feature (field_backtrace.c) is available only on Linux platforms; some help is required here to detect (with cmake) whether we are running on Linux.

You can test CRC/backtrace printing with the test_gang case :

$ export GET_DEBUG_PRINT_CRC=1
$ export GET_DEBUG_PRINT_LOCATION=1
$ ./tests/test_gang.x