Line data Source code
1 : ! This file is part of ELPA.
2 : !
3 : ! The ELPA library was originally created by the ELPA consortium,
4 : ! consisting of the following organizations:
5 : !
6 : ! - Max Planck Computing and Data Facility (MPCDF), formerly known as
7 : ! Rechenzentrum Garching der Max-Planck-Gesellschaft (RZG),
8 : ! - Bergische Universität Wuppertal, Lehrstuhl für angewandte
9 : ! Informatik,
10 : ! - Technische Universität München, Lehrstuhl für Informatik mit
11 : ! Schwerpunkt Wissenschaftliches Rechnen ,
12 : ! - Fritz-Haber-Institut, Berlin, Abt. Theorie,
13 : ! - Max-Plack-Institut für Mathematik in den Naturwissenschaften,
14 : ! Leipzig, Abt. Komplexe Strukutren in Biologie und Kognition,
15 : ! and
16 : ! - IBM Deutschland GmbH
17 : !
18 : !
19 : ! More information can be found here:
20 : ! http://elpa.mpcdf.mpg.de/
21 : !
22 : ! ELPA is free software: you can redistribute it and/or modify
23 : ! it under the terms of the version 3 of the license of the
24 : ! GNU Lesser General Public License as published by the Free
25 : ! Software Foundation.
26 : !
27 : ! ELPA is distributed in the hope that it will be useful,
28 : ! but WITHOUT ANY WARRANTY; without even the implied warranty of
29 : ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 : ! GNU Lesser General Public License for more details.
31 : !
32 : ! You should have received a copy of the GNU Lesser General Public License
33 : ! along with ELPA. If not, see <http://www.gnu.org/licenses/>
34 : !
35 : ! ELPA reflects a substantial effort on the part of the original
36 : ! ELPA consortium, and we ask you to respect the spirit of the
37 : ! license that we chose: i.e., please contribute any changes you
38 : ! may have back to the original ELPA library distribution, and keep
39 : ! any derivatives of ELPA under the same license that we chose for
40 : ! the original distribution, the GNU Lesser General Public License.
41 : !
42 : !
43 : #include "config-f90.h"
44 : module test_util
45 : use iso_c_binding
46 : #ifdef WITH_MPI
47 : #ifdef HAVE_MPI_MODULE
48 : use mpi
49 : implicit none
50 : #else
51 : implicit none
52 : include 'mpif.h'
53 : #endif
54 : #else
55 : integer, parameter :: mpi_comm_world = -1
56 : #endif
57 :
58 : integer, parameter :: rk8 = C_DOUBLE
59 : integer, parameter :: rk4 = C_FLOAT
60 : integer, parameter :: ck8 = C_DOUBLE_COMPLEX
61 : integer, parameter :: ck4 = C_FLOAT_COMPLEX
62 : integer, parameter :: ik = C_INT32_T
63 : integer, parameter :: lik = C_INT64_T
64 :
65 : contains
66 : !>
67 : !> This function translates, if ELPA was build with OpenMP support,
68 : !> the found evel of "thread safetiness" from the internal number
69 : !> of the MPI library into a human understandable value
70 : !>
71 : !> \param level thread-saftiness of the MPI library
72 : !> \return str human understandable value of thread saftiness
73 0 : pure function mpi_thread_level_name(level) result(str)
74 : use, intrinsic :: iso_c_binding
75 : implicit none
76 : integer(kind=c_int), intent(in) :: level
77 : character(len=21) :: str
78 : #ifdef WITH_MPI
79 0 : select case(level)
80 : case (MPI_THREAD_SINGLE)
81 0 : str = "MPI_THREAD_SINGLE"
82 : case (MPI_THREAD_FUNNELED)
83 0 : str = "MPI_THREAD_FUNNELED"
84 : case (MPI_THREAD_SERIALIZED)
85 0 : str = "MPI_THREAD_SERIALIZED"
86 : case (MPI_THREAD_MULTIPLE)
87 0 : str = "MPI_THREAD_MULTIPLE"
88 : case default
89 0 : write(str,'(i0,1x,a)') level, "(Unknown level)"
90 : end select
91 : #endif
92 0 : end function
93 :
94 0 : function seconds() result(s)
95 : integer :: ticks, tick_rate
96 : real(kind=c_double) :: s
97 :
98 0 : call system_clock(count=ticks, count_rate=tick_rate)
99 0 : s = real(ticks, kind=c_double) / tick_rate
100 0 : end function
101 :
102 2145473568 : subroutine x_a(condition, condition_string, file, line)
103 : #ifdef HAVE_ISO_FORTRAN_ENV
104 : use iso_fortran_env, only : error_unit
105 : #endif
106 : implicit none
107 : #ifndef HAVE_ISO_FORTRAN_ENV
108 : integer, parameter :: error_unit = 0
109 : #endif
110 : logical, intent(in) :: condition
111 : character(len=*), intent(in) :: condition_string
112 : character(len=*), intent(in) :: file
113 : integer, intent(in) :: line
114 :
115 2145473568 : if (.not. condition) then
116 0 : write(error_unit,'(a,i0)') "Assertion `" // condition_string // "` failed at " // file // ":", line
117 0 : stop 1
118 : end if
119 4290947136 : end subroutine
120 :
121 136848 : subroutine x_ao(error_code, error_code_string, file, line)
122 : use elpa
123 : #ifdef HAVE_ISO_FORTRAN_ENV
124 : use iso_fortran_env, only : error_unit
125 : #endif
126 : implicit none
127 : #ifndef HAVE_ISO_FORTRAN_ENV
128 : integer, parameter :: error_unit = 0
129 : #endif
130 : integer, intent(in) :: error_code
131 : character(len=*), intent(in) :: error_code_string
132 : character(len=*), intent(in) :: file
133 : integer, intent(in) :: line
134 :
135 136848 : if (error_code /= ELPA_OK) then
136 : write(error_unit,'(a,i0)') "Assertion failed: `" // error_code_string // &
137 0 : " is " // elpa_strerr(error_code) // "` at " // file // ":", line
138 0 : stop 1
139 : end if
140 273696 : end subroutine
141 : end module
142 :
|