dev:error_handling
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
dev:error_handling [2015/09/21 14:37] – created oschuett | dev:error_handling [2025/03/08 13:41] (current) – oschuett | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Error Handling ====== | ====== Error Handling ====== | ||
- | In CP2K there a three convenient macros for error handling. They are defined in [[src>cp2k/src/common/cp_common_uses.f90]], and are therefore always available. However, these macros can only be used for short messages, because of Fortran' | + | In CP2K there exist three convenient macros for error handling. They are defined in [[src> |
<code Fortran> | <code Fortran> | ||
| | ||
| | ||
- | | + | |
</ | </ | ||
- | For longer messages one can call these two routines: | + | For longer messages one can use these two routines: |
<code Fortran> | <code Fortran> | ||
- | CALL cp_warn(routineP, | + | CALL cp_warn(__LOCATION__,"A long warning message "//& |
- | "which can span multiple lines and contains "\\& | + | "which can span multiple lines and contains "//& |
- | "some valuable | + | "some valuable |
- | CALL cp_abort(routineP, | + | CALL cp_abort(__LOCATION__,"A long error message "//& |
- | " | + | " |
</ | </ | ||
+ | |||
+ | <note important> | ||
+ | Messages from '' | ||
+ | </ | ||
+ | |||
+ | ===== Cheat Sheet ===== | ||
+ | If you want to... | ||
+ | * print a **short warning** message, then you should use:< | ||
+ | * print a **longer warning** message, then you should use:< | ||
+ | "which can even span multiple lines" | ||
+ | |||
+ | * **stop** the program with a **short** error message, then you should use:< | ||
+ | * **stop** the program with a **longer** error message, then you should use:< | ||
+ | " | ||
+ | * have a **simple assertion** without a custom error message, then you should use:< | ||
+ | * have a **simple assertion** with a **short** error message, then you should use:< | ||
+ | * have a **complex assertion** with a **short** error message, then you should use:< | ||
+ | CPABORT(" | ||
+ | * have a **lengthy assertion** with a **longer** error message, then you should use:< | ||
+ | CALL cp_abort(__LOCATION__," | ||
+ | "which again can even span multiple lines" | ||
+ |
dev/error_handling.1442846267.txt.gz · Last modified: 2020/08/21 10:14 (external edit)