(git:ec11232)
Loading...
Searching...
No Matches
base_uses.f90
Go to the documentation of this file.
1! Basic use statements and preprocessor macros
2! should be included in the use statements
3
4 USE base_hooks, ONLY: cp__a,&
5 cp__b,&
6 cp__w,&
7 cp__h,&
8 cp__l,&
10 cp_warn,&
11 cp_hint,&
12 timeset,&
14
15#if defined(__OFFLOAD_CUDA) || defined(__OFFLOAD_HIP)
16#define __OFFLOAD
17#endif
18
19! Check for OpenMP early on - ideally before the compiler fails with a cryptic message.
20#if !defined(_OPENMP)
21 "OpenMP is required. Please add the corresponding flag (eg. -fopenmp for GFortran) to your Fortran compiler flags."
22#endif
23
24#if !defined(__SHORT_FILE__)
25 "The preprocessor macro __SHORT_FILE__ is required but has not been defined."
26#endif
27
28#define __LOCATION__ cp__l(__SHORT_FILE__,__LINE__)
29#define CPABORT(MSG) CALL cp__b(__SHORT_FILE__,__LINE__,MSG)
30
31! Issue a warning; warnings are summarized globally.
32! For conditional warnings see CPWARN_IF.
33#define CPWARN(MSG) CALL cp__w(__SHORT_FILE__,__LINE__,MSG)
34
35! Like CPWARN but only if CONDition is true.
36#define CPWARN_IF(COND, MSG) IF(COND)CPWARN(MSG)
37
38! In contrast to CPWARN, the warning counter is not increased
39#define CPHINT(MSG) CALL cp__h(__SHORT_FILE__,__LINE__,MSG)
40
41# define CPASSERT(COND) IF(.NOT.(COND))CALL cp__a(__SHORT_FILE__,__LINE__)
42
43! The MARK_USED macro can be used to mark an argument/variable as used. It is intended to make
44! it possible to switch on -Werror=unused-dummy-argument, but deal elegantly with, e.g.,
45! library wrapper routines that take arguments only used if the library is linked in.
46! This code should be valid for any Fortran variable, is always standard conforming,
47! and will be optimized away completely by the compiler
48#define MARK_USED(FOO) IF(.FALSE.)THEN;DO;IF(SIZE(SHAPE(FOO))==-1) EXIT;ENDDO;ENDIF
49
50! Calculate version number from 2 or 3 components. Can be used for comparison, e.g.,
51! CPVERSION3(4, 9, 0) <= CPVERSION3(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
52! CPVERSION(8, 0) <= CPVERSION(__GNUC__, __GNUC_MINOR__)
53#define CPVERSION2(MAJOR, MINOR) ((MAJOR) * 10000 + (MINOR) * 100)
54#define CPVERSION3(MAJOR, MINOR, UPDATE) (CPVERSION2(MAJOR, MINOR) + (UPDATE))
55#define CPVERSION CPVERSION2
56
57! On top of CPVERSION macro, test if MAJOR_TEST and MINOR_TEST are defined.
58! Usage: #if CPVERSION_CHECK(9, 5, >, __GNUC__, __GNUC_MINOR__)
59! Perform actual comparison according to COMP argument.
60! Note: defined(MAJOR_TEST) and defined(MINOR_TEST) is avoided in macro
61! definition due to issues handling it in certain compilers.
62#define CPVERSION_CHECK(MAJOR_BASE, MINOR_BASE, COMP, MAJOR_TEST, MINOR_TEST) ((MAJOR_TEST) && \
63 (cpversion2(major_base, minor_base) comp cpversion2(major_test, minor_test)))
64
65! Avoid to default initialize type-components (default c'tor)
66#if CPVERSION_CHECK(9, 5, >, __GNUC__, __GNUC_MINOR__) || defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)
67#define FTN_NO_DEFAULT_INIT
68#endif
69
70! gfortran before 8.3 complains about internal symbols not being specified in
71! any data clause when using DEFAULT(NONE) and OOP procedures are called from
72! within the parallel region.
73#if CPVERSION_CHECK(8, 3, >, __GNUC__, __GNUC_MINOR__)
74#define OMP_DEFAULT_NONE_WITH_OOP SHARED
75#else
76#define OMP_DEFAULT_NONE_WITH_OOP NONE
77#endif
78
79#if defined (__MKL)
80! Preprocessing is enabled by default, and below header is not language specific
81! Defines __INTEL_MKL__ (2025), __INTEL_MKL_MINOR__ (0), __INTEL_MKL_UPDATE__ (2),
82! and __INTEL_MKL_PATCH__ (0) as well INTEL_MKL_VERSION, e.g., 20250200.
83#include <mkl_version.h>
84#endif
Central dispatch for basic hooks.
Definition base_hooks.F:12
subroutine, public cp_abort(location, message)
Terminate the program.
Definition base_hooks.F:73
subroutine, public cp__w(filename, linenr, message)
CPWARN handler.
Definition base_hooks.F:193
subroutine, public timeset(routinen, handle)
Start timer.
Definition base_hooks.F:127
subroutine, public cp__a(filename, linenr)
CPASSERT handler.
Definition base_hooks.F:160
character(len=default_string_length) function, public cp__l(filename, linenr)
Helper routine to assemble LOCATION
Definition base_hooks.F:223
subroutine, public cp_hint(location, message)
Issue a hint.
Definition base_hooks.F:110
subroutine, public timestop(handle)
Stop timer.
Definition base_hooks.F:143
subroutine, public cp__h(filename, linenr, message)
CPHINT handler.
Definition base_hooks.F:208
subroutine, public cp_warn(location, message)
Issue a warning.
Definition base_hooks.F:93
subroutine, public cp__b(filename, linenr, message)
CPABORT handler.
Definition base_hooks.F:176