• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gyrokinetics / utils / 2413445047

27 Mar 2026 12:30PM UTC coverage: 6.984% (+7.0%) from 0.0%
2413445047

push

gitlab-ci

David Dickinson
Add missing side and trans arguments

743 of 10639 relevant lines covered (6.98%)

16175.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/runtime_tests.fpp
1
#include "define.inc"
2

3
!>  This module is intended to be used for runtime tests
4
!!  which interrogate what is functional/what compile time
5
!!  options were enabled/disabled, and also any enviroment variables
6
!!  which affect what happens at runtime.
7
module runtime_tests
8

9
  implicit none
10

11
  private
12

13
  public :: runtime_info
14

15
! Functions provided for backwards compatibility
16
  public :: build_identifier
17
  public :: compiler_pgi
18
  public :: get_git_hash
19
  public :: get_git_modified
20
  public :: is_release
21
  public :: release
22
  public :: verbosity
23

24
  !> Type providing information about the code version, compiler, build
25
  !! environment etc
26
  type :: runtime_info_type
27

28
    private
29
    !> Integer determining the verbosity of debugging output, with higher
30
    !! values being more verbose. `verbosity` is read from the
31
    !! GK_VERBOSITY environment variable
32
    integer :: verbosity
33
    !> Whether verbosity has already been read from the environment variable.
34
    !! Reading environment variables is moderately expensive, so this is done
35
    !! once and the value stored in [[verbosity]].
36
    logical :: verbosity_initialized = .false.
37

38
    contains
39
    !> Get the value of [[verbosity]], reading the enviroment variable
40
    !! GK_VERBOSITY if necessary.
41
    procedure :: get_verbosity
42
    !> Returns whether current version is a release
43
    procedure, nopass :: is_release => is_release_runtime_info
44
    !> Returns the release number
45
    procedure, nopass :: release => release_runtime_info
46
    !> Returns whether a PGI compiler was used
47
    procedure, nopass :: compiler_pgi => compiler_pgi_runtime_info
48
    !> Returns the name of the compiler used
49
    procedure, nopass :: get_compiler_name
50
    !> Returns the value of the GK_SYSTEM environment variable
51
    procedure, nopass :: get_gk_system
52
    !> Returns an identifier of the system and build:
53
    !! "system.compiler.githash".
54
    procedure :: build_identifier => build_identifier_runtime_info
55
    !> Returns the git hash
56
    procedure, nopass :: get_git_hash => get_git_hash_runtime_info
57
    !> Returns whether the source code has been modified relative to the
58
    !! repository version
59
    procedure, nopass :: get_git_modified => get_git_modified_runtime_info
60

61
  end type runtime_info_type
62

63
  type(runtime_info_type) runtime_info
64

65
contains
66

67

68
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
69
!  Tests for compilers
70
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
71

72
  !> Returns whether a PGI compiler was used
73
  function compiler_pgi_runtime_info()
×
74
    implicit none
75
    logical :: compiler_pgi_runtime_info
76
    compiler_pgi_runtime_info = .false.
×
77
#if FCOMPILER == _PGI_
78
    compiler_pgi_runtime_info = .true.
79
#endif
80
  end function compiler_pgi_runtime_info
×
81

82
  !> Returns the name of the compiler used
83
  function get_compiler_name()
×
84
    implicit none
85
    character(len=9) :: get_compiler_name
86
    get_compiler_name='unknown'
×
87
#if FCOMPILER == _PGI_
88
    get_compiler_name='pgi'
89
#elif FCOMPILER == _INTEL_
90
    get_compiler_name='intel'
91
#elif FCOMPILER == _IFX_
92
    get_compiler_name='ifx'
93
#elif FCOMPILER == _GFORTRAN_
94
    get_compiler_name='gfortran'
×
95
#elif FCOMPILER == _XL_
96
    get_compiler_name='xl'
97
#elif FCOMPILER == _NAG_
98
    get_compiler_name='nag'
99
#elif FCOMPILER == _CRAY_
100
    get_compiler_name='cray'
101
#elif FCOMPILER == _G95_
102
    get_compiler_name='g95'
103
#elif FCOMPILER == _PATHSCALE_
104
    get_compiler_name='pathscale'
105
#elif FCOMPILER == _LAHEY_
106
    get_compiler_name='lahey'
107
#elif FCOMPILER == _ABSOFT_
108
    get_compiler_name='absoft'
109
#elif FCOMPILER == _ALPHA_
110
    get_compiler_name='alpha'
111
#elif FCOMPILER == _SUN_
112
    get_compiler_name='sun'
113
#elif FCOMPILER == _FUJ_
114
    get_compiler_name='fujitsu'
115
#elif FCOMPILER == _NEC_
116
    get_compiler_name='nec'
117
#endif
118
  end function get_compiler_name
×
119

120
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
121

122

123
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
124
!  Tests for git info
125
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
126

127
  !> Returns the git hash
128
  function get_git_hash_runtime_info(length_in)
×
129
    implicit none
130
    integer, optional, intent(in) :: length_in
131
    integer :: length = 40
132
    character(len=40) :: get_git_hash_runtime_info
133

134
    if( present(length_in) ) then
×
135
      if( length_in <= 40 ) then
×
136
        length = length_in
×
137
      end if
138
    end if
139

140
#ifndef GIT_HASH
141
#define GIT_HASH "unknown"
142
    length=7
143
#endif
144
    get_git_hash_runtime_info=GIT_HASH(1:length)
×
145
  end function get_git_hash_runtime_info
×
146

147
  !> Returns whether the source code has been modified relative to the
148
  !! repository version
149
  function get_git_modified_runtime_info()
×
150
    implicit none
151
    logical :: get_git_modified_runtime_info
152
#ifndef GIT_HASH
153
#define GIT_HASH "unknown"
154
#endif
155
    if(GIT_STATE.eq."clean")then
×
156
       get_git_modified_runtime_info=.false.
157
    else
158
       get_git_modified_runtime_info=.true.
159
    endif
160
  end function get_git_modified_runtime_info
×
161
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
162

163
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
164
!! System info
165
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
166

167
  !> Returns the value of the GK_SYSTEM environment variable
168
  function get_gk_system()
×
169
    implicit none
170
    character(len=20) :: get_gk_system
171
#ifndef GK_SYSTEM
172
#define GK_SYSTEM "unknown"
173
#endif
174
    get_gk_system=GK_SYSTEM
×
175
  end function get_gk_system
×
176

177
  !> Returns an identifier of the system and build:
178
  !! "system.compiler.githash".
179
  function build_identifier_runtime_info(self)
×
180
    implicit none
181
    class(runtime_info_type), intent(inout) :: self
182
    character(len=50) :: build_identifier_runtime_info
183
    character(len=:), allocatable :: git_hash
×
184

185
    git_hash = self%get_git_hash(7)
×
186
    build_identifier_runtime_info = trim(self%get_gk_system())&
187
         //"."//trim(self%get_compiler_name())&
188
         //'.'//git_hash(1:7)
×
189

190
    if(self%get_git_modified()) then
×
191
      build_identifier_runtime_info = trim(build_identifier_runtime_info(1:41))//'.modified'
×
192
    end if
193

194
  end function build_identifier_runtime_info
×
195

196
  !> Returns whether current version is a release
197
  function is_release_runtime_info()
×
198
    implicit none
199
    logical :: is_release_runtime_info
200
#ifdef IS_RELEASE
201
    is_release_runtime_info = .true.
202
#else
203
    is_release_runtime_info = .false.
×
204
#endif
205
  end function is_release_runtime_info
×
206

207
  !> Returns the release number
208
  function release_runtime_info()
×
209
    implicit none
210
    character(len=30) :: release_runtime_info
211
#ifdef RELEASE
212
    release_runtime_info = RELEASE
×
213
#else
214
    release_runtime_info = 'no known release'
215
#endif
216
  end function release_runtime_info
×
217

218
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
219
!! Testing the runtime environment
220
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
221

222
  !> This function interrogates the environment variable
223
  !! GK_VERBOSITY and returns its integer value. This is used
224
  !! to control the level of debug output (not diagnostic/physics output).
225
  !! Normal levels range from 0 to 5, with output getting 
226
  !! heavier as the value increases. Values higher than 5 can be used for 
227
  !! specialised/very heavy output.
228
  function get_verbosity(self)
×
229
    implicit none
230
    class(runtime_info_type), intent(inout) :: self
231
    integer :: get_verbosity
232
    character(len=10) :: verbosity_char
233

234
    if( self%verbosity_initialized ) then
×
235
      get_verbosity = self%verbosity
×
236
    else
237
      verbosity_char = ''
×
238
      call get_environment_variable("GK_VERBOSITY", verbosity_char)
×
239
      read (verbosity_char,'(I10)') get_verbosity
×
240
      self%verbosity = get_verbosity
×
241
      self%verbosity_initialized = .true.
×
242
    end if
243
  end function get_verbosity
×
244

245
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
246
! Functions provided for backwards compatibility !
247
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
248

249
  !> This function is just a call of [[get_verbosity]] and is provided for
250
  !! backwards compatibility.
251
  function verbosity()
×
252
    implicit none
253
    integer :: verbosity
254

255
    verbosity = runtime_info%get_verbosity()
×
256

257
  end function verbosity
×
258

259
  !> This function is just a call of [[is_release_runtime_info]] and is provided for
260
  !! backwards compatibility.
261
  function is_release()
×
262
    implicit none
263
    logical :: is_release
264

265
    is_release = runtime_info%is_release()
×
266

267
  end function is_release
×
268

269
  !> This function is just a call of [[release_runtime_info]] and is provided for
270
  !! backwards compatibility.
271
  function release()
×
272
    implicit none
273
    character(len=30) :: release
274

275
    release = runtime_info%release()
×
276

277
  end function release
×
278

279
  !> This function is just a call of [[get_git_hash_runtime_info]] and is provided for
280
  !! backwards compatibility.
281
  function get_git_hash(length_in)
×
282
    implicit none
283
    integer, optional, intent(in) :: length_in
284
    character(len=40) :: get_git_hash
285

286
    get_git_hash = runtime_info%get_git_hash(length_in)
×
287

288
  end function get_git_hash
×
289

290
  !> This function is just a call of [[get_git_modified_runtime_info]] and is provided for
291
  !! backwards compatibility.
292
  function get_git_modified()
×
293
    implicit none
294
    logical :: get_git_modified
295

296
    get_git_modified = runtime_info%get_git_modified()
×
297

298
  end function get_git_modified
×
299

300
  !> This function is just a call of [[build_identifier_runtime_info]] and is provided for
301
  !! backwards compatibility.
302
  function build_identifier()
×
303
    implicit none
304
    character(len=50) :: build_identifier
305

306
    build_identifier = runtime_info%build_identifier()
×
307

308
  end function build_identifier
×
309

310
  !> This function is just a call of [[compiler_pgi_runtime_info]] and is provided for
311
  !! backwards compatibility.
312
  function compiler_pgi()
×
313
    implicit none
314
    logical :: compiler_pgi
315

316
    compiler_pgi = runtime_info%compiler_pgi()
×
317

318
  end function compiler_pgi
×
319

320
end module runtime_tests
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc