(git:d18deda)
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! Dangerous: Full path can be arbitrarily long and might overflow Fortran line.
25#if !defined(__SHORT_FILE__)
26#define __SHORT_FILE__ __FILE__
27#endif
28
29#define __LOCATION__ cp__l(__SHORT_FILE__,__LINE__)
30#define CPABORT(MSG) CALL cp__b(__SHORT_FILE__,__LINE__,MSG)
31
32! Issue a warning; warnings are summarized globally.
33! For conditional warnings see CPWARN_IF.
34#define CPWARN(MSG) CALL cp__w(__SHORT_FILE__,__LINE__,MSG)
35
36! Like CPWARN but only if CONDition is true.
37#define CPWARN_IF(COND, MSG) IF(COND)CPWARN(MSG)
38
39! In contrast to CPWARN, the warning counter is not increased
40#define CPHINT(MSG) CALL cp__h(__SHORT_FILE__,__LINE__,MSG)
41
42# define CPASSERT(COND) IF(.NOT.(COND))CALL cp__a(__SHORT_FILE__,__LINE__)
43
44! The MARK_USED macro can be used to mark an argument/variable as used. It is intended to make
45! it possible to switch on -Werror=unused-dummy-argument, but deal elegantly with, e.g.,
46! library wrapper routines that take arguments only used if the library is linked in.
47! This code should be valid for any Fortran variable, is always standard conforming,
48! and will be optimized away completely by the compiler
49#define MARK_USED(FOO) IF(.FALSE.)THEN;DO;IF(SIZE(SHAPE(FOO))==-1) EXIT;ENDDO;ENDIF
50
51! Calculate version number from 2 or 3 components. Can be used for comparison, e.g.,
52! CPVERSION3(4, 9, 0) <= CPVERSION3(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
53! CPVERSION(8, 0) <= CPVERSION(__GNUC__, __GNUC_MINOR__)
54#define CPVERSION2(MAJOR, MINOR) ((MAJOR) * 10000 + (MINOR) * 100)
55#define CPVERSION3(MAJOR, MINOR, UPDATE) (CPVERSION2(MAJOR, MINOR) + (UPDATE))
56#define CPVERSION CPVERSION2
57
58! On top of CPVERSION macro, test if MAJOR_TEST and MINOR_TEST are defined.
59! Usage: #if CPVERSION_CHECK(9, 5, >, __GNUC__, __GNUC_MINOR__)
60! Perform actual comparison according to COMP argument.
61! Note: defined(MAJOR_TEST) and defined(MINOR_TEST) is avoided in macro
62! definition due to issues handling it in certain compilers.
63#define CPVERSION_CHECK(MAJOR_BASE, MINOR_BASE, COMP, MAJOR_TEST, MINOR_TEST) ((MAJOR_TEST) && \
64 (cpversion2(major_base, minor_base) comp cpversion2(major_test, minor_test)))
65
66! Avoid to default initialize type-components (default c'tor)
67#if CPVERSION_CHECK(9, 5, >, __GNUC__, __GNUC_MINOR__) || defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)
68#define FTN_NO_DEFAULT_INIT
69#endif
70
71! gfortran before 8.3 complains about internal symbols not being specified in
72! any data clause when using DEFAULT(NONE) and OOP procedures are called from
73! within the parallel region.
74#if CPVERSION_CHECK(8, 3, >, __GNUC__, __GNUC_MINOR__)
75#define OMP_DEFAULT_NONE_WITH_OOP SHARED
76#else
77#define OMP_DEFAULT_NONE_WITH_OOP NONE
78#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