Neko  0.8.1
A portable framework for high-order spectral element flow simulations
craypat.F90
Go to the documentation of this file.
1 
2 module craypat
3  use, intrinsic :: iso_c_binding
4  use stack, only : stack_i4_t
5  use utils, only : neko_error
6  implicit none
7 
8  type(stack_i4_t), private :: region_depth
9  logical, private :: craypat_on = .false.
10 #ifdef CRAYPAT
11  include 'pat_apif.h'
12 
13 contains
14 
16  subroutine craypat_record_start
17  integer :: ierr
18  call region_depth%init()
19  call pat_record(pat_state_on, ierr)
20  craypat_on = .true.
21  end subroutine craypat_record_start
22 
24  subroutine craypat_record_stop
25  integer :: ierr
26  call pat_record(pat_state_off, ierr)
27  craypat_on = .false.
28  end subroutine craypat_record_stop
29 
31  subroutine craypat_region_begin(name)
32  character(kind=c_char,len=*) :: name
33  integer :: ierr, region_id
34 
35  if (craypat_on) then
37  if (name .eq. 'Time-Step') then
38  region_id = 1
39  else if(name .eq. 'Pressure') then
40  region_id = 2
41  else if (name .eq. 'Velocity') then
42  region_id = 3
43  else if (name .eq. 'gather-scatter') then
44  region_id = 4
45  else ! User defined region
46  region_id = 99
47  end if
48 
49  call region_depth%push(region_id)
50  call pat_region_begin(region_id, name, ierr)
51  end if
52 
53  end subroutine craypat_region_begin
54 
56  subroutine craypat_region_end
57  integer :: ierr
58 
59  if (craypat_on) then
60  if (region_depth%size() .le. 0) then
61  call neko_error('Invalid CrayPat region id')
62  end if
63  call pat_region_end(region_depth%pop(), ierr)
64  end if
65 
66  end subroutine craypat_region_end
67 
68 #endif
69 
70 end module craypat
Interface to CrayPat F77 API.
Definition: craypat.F90:2
type(stack_i4_t), private region_depth
Definition: craypat.F90:8
logical, private craypat_on
Definition: craypat.F90:9
Implements a dynamic stack ADT.
Definition: stack.f90:35
Utilities.
Definition: utils.f90:35
Integer based stack.
Definition: stack.f90:63