-
Notifications
You must be signed in to change notification settings - Fork 2
/
countersmod.f
131 lines (131 loc) · 5.35 KB
/
countersmod.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
* © 2023. Triad National Security, LLC. All rights reserved.
* This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos National
* Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. Department of
* Energy/National Nuclear Security Administration. All rights in the program are reserved by Triad
* National Security, LLC, and the U.S. Department of Energy/National Nuclear Security Administration.
* The Government is granted for itself and others acting on its behalf a nonexclusive, paid-up,
* irrevocable worldwide license in this material to reproduce, prepare. derivative works, distribute
* copies to the public, perform publicly and display publicly, and to permit others to do so.
*This file is part of SuperNu. SuperNu is released under the terms of the GNU GPLv3, see COPYING.
*Copyright (c) 2013-2022 Ryan T. Wollaeger and Daniel R. van Rossum. All rights reserved.
module countersmod
c ------------------
implicit none
************************************************************************
* Collection of runtime counters for different parts of the code.
* This is an integer clone of timingmod.
************************************************************************
integer,private,parameter :: mreg = 11
integer*8,private,target :: iregisters(4,mreg)
c
integer*8,pointer :: ct_nnonvacant(:) !non-vacant particle slots
integer*8,pointer :: ct_npcreate(:) !newly created particles
integer*8,pointer :: ct_npactive(:) !transported particles
integer*8,pointer :: ct_npflux(:) !flux particles
integer*8,pointer :: ct_npfluxbuf(:) !flux particles remaining in buffer
integer*8,pointer :: ct_npcensimc(:) !censussed IMC particles
integer*8,pointer :: ct_npcensddmc(:) !censussed DDMC particles
integer*8,pointer :: ct_npstepimc(:) !IMC interactions (steps)
integer*8,pointer :: ct_npstepddmc(:) !DDMC interactions (steps)
integer*8,pointer :: ct_npstepmax(:) !interactions (steps)
c-- transport method swaps
integer*8,pointer :: ct_npmethswap(:)
c
save
c
contains
c
subroutine countersmod_init
c ---------------------------
implicit none
ct_nnonvacant => iregisters(:,1)
ct_npcreate => iregisters(:,2)
ct_npactive => iregisters(:,3)
ct_npflux => iregisters(:,4)
ct_npfluxbuf => iregisters(:,5)
ct_npcensimc => iregisters(:,6)
ct_npcensddmc => iregisters(:,7)
ct_npstepimc => iregisters(:,8)
ct_npstepddmc => iregisters(:,9)
ct_npstepmax => iregisters(:,10)
ct_npmethswap => iregisters(:,11)
end subroutine countersmod_init
c
c
subroutine counterreg(ireg,n)
c -----------------------------!{{{
implicit none
integer*8,intent(inout) :: ireg(4)
integer,intent(in) :: n
************************************************************************
* Put the counter c in the register reg. The first position in reg stores
* the last value of n, the second position stores the sum.
************************************************************************
ireg(1) = n
ireg(2) = ireg(2) + n!}}}
end subroutine counterreg
c
c
subroutine counters_cycle(impi,ldummystep)
c --------------------------------------------
implicit none
integer,intent(in) :: impi
logical,intent(in) :: ldummystep
************************************************************************
* reset timestep timers and dump timing output (on master rank only).
************************************************************************
logical :: lexist
integer :: istat,i
c
c-- add to total
iregisters(3,:) = iregisters(3,:) + iregisters(2,:)
c-- update max
iregisters(4,:) = max(iregisters(4,:),iregisters(2,:))
c
c-- write output on master rank only
if(impi==0) then
inquire(file='output.counters',exist=lexist)
open(4,file='output.counters',position='append',iostat=istat)
if(istat/=0) stop 'counters_timestep: file open error'
c-- header
if(.not.lexist) then
write(4,'("#",30a12)') 'nonvacant','create','transport',
& 'flux','fluxbuffer','censusimc','censusddmc','stepimc',
& 'stepddmc','stepmax','methswap'
endif
c-- body
if(ldummystep) then
write(4,'("#",1p,30g12.4)') (iregisters(2,i),i=1,mreg)
else
write(4,'(1x,1p,30g12.4)') (iregisters(2,i),i=1,mreg)
endif
close(4)
endif
c
c-- reset timers
iregisters(:2,:) = 0
end subroutine counters_cycle
c
c
subroutine print_counters
c -------------------------
implicit none
************************************************************************
* Print the timing totals
************************************************************************
integer,parameter :: i=3 !total runtime timing
c
write(6,*)
write(6,*) 'counters (on master rank):'
write(6,*) '============================'
write(6,1) 'pckt transport :',ct_npactive(i)/1000
write(6,1) ' steps (imc|ddmc) :',ct_npstepimc(i)/1000,
& ct_npstepddmc(i)/1000
write(6,2) ' max steps :',ct_npstepmax(4)
write(6,1) ' method swaps :',ct_npmethswap(i)/1000
1 format(1x,a,10(i10,"k"))
2 format(1x,a,10i10)
end subroutine print_counters
c
end module countersmod
c vim: fdm=marker