IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Air Shower Physics
corsika
Commits
2c26a639
Commit
2c26a639
authored
6 months ago
by
Marvin Gottowik
Committed by
Alice Faure
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add counter and limit number of printouts
parent
af4659cd
No related branches found
No related tags found
1 merge request
!647
Resolve "tweak frequency of print outs in StackInspector"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
corsika/detail/modules/StackInspector.inl
+54
-45
54 additions, 45 deletions
corsika/detail/modules/StackInspector.inl
corsika/modules/StackInspector.hpp
+2
-0
2 additions, 0 deletions
corsika/modules/StackInspector.hpp
with
56 additions
and
45 deletions
corsika/detail/modules/StackInspector.inl
+
54
−
45
View file @
2c26a639
...
...
@@ -58,51 +58,60 @@ namespace corsika {
if
((
E0_
-
Etot
)
<
dE_threshold_
)
return
;
std
::
chrono
::
system_clock
::
time_point
const
now
=
std
::
chrono
::
system_clock
::
now
();
std
::
chrono
::
duration
<
double
>
const
elapsed_seconds
=
now
-
StartTime_
;
// seconds
// Select reference times and energies using either the true start
// or the delayed start to avoid counting overhead in ETA
bool
const
usePostVals
=
(
energyPostInit_
!=
HEPEnergyType
::
zero
());
auto
const
dE
=
(
usePostVals
?
energyPostInit_
:
E0_
)
-
Etot
;
std
::
chrono
::
duration
<
double
>
const
usedSeconds
=
now
-
timePostInit_
;
double
const
dT
=
usedSeconds
.
count
();
double
const
progress
=
(
E0_
-
Etot
)
/
E0_
;
// for printout
std
::
time_t
const
now_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
now
);
double
const
ETA_seconds
=
(
1.0
-
progress
)
*
dT
*
(
E0_
/
dE
);
std
::
chrono
::
system_clock
::
time_point
const
ETA
=
now
+
std
::
chrono
::
seconds
((
int
)
ETA_seconds
);
// for printout
std
::
time_t
const
ETA_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
ETA
);
int
const
yday0
=
std
::
localtime
(
&
now_time
)
->
tm_yday
;
int
const
yday1
=
std
::
localtime
(
&
ETA_time
)
->
tm_yday
;
int
const
dyday
=
yday1
-
yday0
;
std
::
stringstream
ETA_string
;
ETA_string
<<
std
::
put_time
(
std
::
localtime
(
&
ETA_time
),
"%T %Z"
);
CORSIKA_LOG_INFO
(
"StackInspector: "
" time={}"
", running={:.1f} seconds"
" ( {:.1f}%)"
", nStep={}"
", stackSize={}"
", Estack={:.1f} GeV"
", ETA={}{}"
,
std
::
put_time
(
std
::
localtime
(
&
now_time
),
"%T %Z"
),
elapsed_seconds
.
count
(),
(
progress
*
100
),
getStep
(),
vS
.
getSize
(),
Etot
/
1
_GeV
,
(
dyday
==
0
?
""
:
fmt
::
format
(
"+{}d "
,
dyday
)),
ETA_string
.
str
());
// Change reference time once the shower has begin (avoid counting overhead time)
if
(
progress
>
0.02
&&
energyPostInit_
==
HEPEnergyType
::
zero
())
{
energyPostInit_
=
Etot
;
timePostInit_
=
std
::
chrono
::
system_clock
::
now
();
// limit number of printouts
if
(
printoutCounter_
<
maxNumberOfPrintouts_
)
{
std
::
chrono
::
system_clock
::
time_point
const
now
=
std
::
chrono
::
system_clock
::
now
();
std
::
chrono
::
duration
<
double
>
const
elapsed_seconds
=
now
-
StartTime_
;
// seconds
// Select reference times and energies using either the true start
// or the delayed start to avoid counting overhead in ETA
bool
const
usePostVals
=
(
energyPostInit_
!=
HEPEnergyType
::
zero
());
auto
const
dE
=
(
usePostVals
?
energyPostInit_
:
E0_
)
-
Etot
;
std
::
chrono
::
duration
<
double
>
const
usedSeconds
=
now
-
timePostInit_
;
double
const
dT
=
usedSeconds
.
count
();
double
const
progress
=
(
E0_
-
Etot
)
/
E0_
;
// for printout
std
::
time_t
const
now_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
now
);
double
const
ETA_seconds
=
(
1.0
-
progress
)
*
dT
*
(
E0_
/
dE
);
std
::
chrono
::
system_clock
::
time_point
const
ETA
=
now
+
std
::
chrono
::
seconds
((
int
)
ETA_seconds
);
std
::
time_t
const
ETA_time
=
std
::
chrono
::
system_clock
::
to_time_t
(
ETA
);
int
const
yday0
=
std
::
localtime
(
&
now_time
)
->
tm_yday
;
int
const
yday1
=
std
::
localtime
(
&
ETA_time
)
->
tm_yday
;
int
const
dyday
=
yday1
-
yday0
;
std
::
stringstream
ETA_string
;
ETA_string
<<
std
::
put_time
(
std
::
localtime
(
&
ETA_time
),
"%T %Z"
);
CORSIKA_LOG_INFO
(
"StackInspector: "
" time={}"
", running={:.1f} seconds"
" ( {:.1f}%)"
", nStep={}"
", stackSize={}"
", Estack={:.1f} GeV"
", ETA={}{}"
,
std
::
put_time
(
std
::
localtime
(
&
now_time
),
"%T %Z"
),
elapsed_seconds
.
count
(),
(
progress
*
100
),
getStep
(),
vS
.
getSize
(),
Etot
/
1
_GeV
,
(
dyday
==
0
?
""
:
fmt
::
format
(
"+{}d "
,
dyday
)),
ETA_string
.
str
());
printoutCounter_
++
;
if
(
printoutCounter_
==
maxNumberOfPrintouts_
)
{
CORSIKA_LOG_INFO
(
"StackInspector reached allowed maximum of {} lines printout"
,
maxNumberOfPrintouts_
);
}
// Change reference time once the shower has begin (avoid counting overhead time)
if
(
progress
>
0.02
&&
energyPostInit_
==
HEPEnergyType
::
zero
())
{
energyPostInit_
=
Etot
;
timePostInit_
=
std
::
chrono
::
system_clock
::
now
();
}
}
}
...
...
This diff is collapsed.
Click to expand it.
corsika/modules/StackInspector.hpp
+
2
−
0
View file @
2c26a639
...
...
@@ -46,6 +46,8 @@ namespace corsika {
private
:
bool
ReportStack_
;
int
printoutCounter_
=
0
;
const
int
maxNumberOfPrintouts_
=
10
;
HEPEnergyType
E0_
;
const
HEPEnergyType
dE_threshold_
=
1
_eV
;
std
::
chrono
::
system_clock
::
time_point
StartTime_
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment