(git:34ef472)
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,&
9  cp_abort,&
10  cp_warn,&
11  cp_hint,&
12  timeset,&
13  timestop
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 CPWARN(msg) CALL cp__w(__SHORT_FILE__,__LINE__,msg)
31 #define CPABORT(msg) CALL cp__b(__SHORT_FILE__,__LINE__,msg)
32 ! In contrast to CPWARN, the warning counter is not increased
33 #define CPHINT(msg) CALL cp__h(__SHORT_FILE__,__LINE__,msg)
34 
35 # define CPASSERT(cond) IF(.NOT.(cond))CALL cp__a(__SHORT_FILE__,__LINE__)
36 
37 ! The MARK_USED macro can be used to mark an argument/variable as used. It is intended to make
38 ! it possible to switch on -Werror=unused-dummy-argument, but deal elegantly with, e.g.,
39 ! library wrapper routines that take arguments only used if the library is linked in.
40 ! This code should be valid for any Fortran variable, is always standard conforming,
41 ! and will be optimized away completely by the compiler
42 #define MARK_USED(foo) IF(.FALSE.)THEN; DO ; IF(SIZE(SHAPE(foo))==-1) EXIT ; END DO ; ENDIF
43 
44 ! Calculate version number from 2 or 3 components. Can be used for comparison, e.g.,
45 ! CPVERSION3(4, 9, 0) <= CPVERSION3(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
46 ! CPVERSION(8, 0) <= CPVERSION(__GNUC__, __GNUC_MINOR__)
47 #define CPVERSION2(MAJOR, MINOR) ((MAJOR) * 10000 + (MINOR) * 100)
48 #define CPVERSION3(MAJOR, MINOR, UPDATE) (CPVERSION2(MAJOR, MINOR) + (UPDATE))
49 #define CPVERSION CPVERSION2
50 
51 ! gfortran before 8.3 complains about internal symbols not being specified in
52 ! any data clause when using DEFAULT(NONE) and OOP procedures are called from
53 ! within the parallel region.
54 #if __GNUC__ < 8 || (__GNUC__ == 8 && (__GNUC_MINOR__ < 3))
55 #define OMP_DEFAULT_NONE_WITH_OOP SHARED
56 #else
57 #define OMP_DEFAULT_NONE_WITH_OOP NONE
58 #endif
Central dispatch for basic hooks.
Definition: base_hooks.F:12
subroutine, public cp__a(filename, lineNr)
CPASSERT handler.
Definition: base_hooks.F:160
subroutine, public cp_abort(location, message)
Terminate the program.
Definition: base_hooks.F:73
subroutine, public timeset(routineN, handle)
Start timer.
Definition: base_hooks.F:127
subroutine, public cp__w(filename, lineNr, message)
CPWARN handler.
Definition: base_hooks.F:193
subroutine, public cp__b(filename, lineNr, message)
CPABORT handler.
Definition: base_hooks.F:176
subroutine, public cp_hint(location, message)
Issue a hint.
Definition: base_hooks.F:110
subroutine, public cp__h(filename, lineNr, message)
CPHINT handler.
Definition: base_hooks.F:208
character(len=default_string_length) function, public cp__l(filename, lineNr)
Helper routine to assemble LOCATION
Definition: base_hooks.F:223
subroutine, public timestop(handle)
Stop timer.
Definition: base_hooks.F:143
subroutine, public cp_warn(location, message)
Issue a warning.
Definition: base_hooks.F:93