Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
octopus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
octopus-code
octopus
Commits
6072f272
Commit
6072f272
authored
4 years ago
by
Sebastian Ohlmann
Browse files
Options
Downloads
Patches
Plain Diff
Fix logic of checking if component in sum is non-zero
Moreover, add some documentation on the algorithm used here.
parent
9ee8145f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Pipeline
#149759788
passed
4 years ago
Stage: external
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/grid/mesh_batch_inc.F90
+44
-19
44 additions, 19 deletions
src/grid/mesh_batch_inc.F90
with
44 additions
and
19 deletions
src/grid/mesh_batch_inc.F90
+
44
−
19
View file @
6072f272
...
...
@@ -923,28 +923,37 @@ subroutine X(priv_mesh_batch_nrm2)(mesh, aa, nrm2)
ithread
=
1
!$ ithread = omp_get_thread_num() + 1
! The algorithm for the squared sum is the same as used, e.g., in openblas.
! The idea is that one wants to avoid an overflow caused by squaring a big
! number by using separate values for the sum of squares and the scale.
! Only at the end, the norm is computed as scal*sqrt(ssq) - in this way
! the largest number which is stored in scal is never squared.
if
(
.not.
mesh
%
use_curvilinear
)
then
do
ip
=
sp
,
sp
+
np
-
1
do
ist
=
1
,
aa
%
nst_linear
! first add real part
a0
=
abs
(
R_REAL
(
aa
%
X
(
ff_pack
)(
ist
,
ip
)))
if
(
a0
<=
M_EPSILON
)
cycle
if
(
scal
(
ist
,
ithread
)
<
a0
)
then
ssq
(
ist
,
ithread
)
=
M_ONE
+
ssq
(
ist
,
ithread
)
*
(
scal
(
ist
,
ithread
)/
a0
)
**
2
scal
(
ist
,
ithread
)
=
a0
else
ssq
(
ist
,
ithread
)
=
ssq
(
ist
,
ithread
)
+
(
a0
/
scal
(
ist
,
ithread
))
**
2
! only add a0 if it is non-zero
if
(
a0
>
M_EPSILON
)
then
if
(
scal
(
ist
,
ithread
)
<
a0
)
then
ssq
(
ist
,
ithread
)
=
M_ONE
+
ssq
(
ist
,
ithread
)
*
(
scal
(
ist
,
ithread
)/
a0
)
**
2
scal
(
ist
,
ithread
)
=
a0
else
ssq
(
ist
,
ithread
)
=
ssq
(
ist
,
ithread
)
+
(
a0
/
scal
(
ist
,
ithread
))
**
2
end
if
end
if
#ifdef R_TCOMPLEX
! then add imaginary part for complex numbers
a0
=
abs
(
R_AIMAG
(
aa
%
X
(
ff_pack
)(
ist
,
ip
)))
if
(
a0
<=
M_EPSILON
)
cycle
if
(
scal
(
ist
,
ithread
)
<
a0
)
then
ssq
(
ist
,
ithread
)
=
M_ONE
+
ssq
(
ist
,
ithread
)
*
(
scal
(
ist
,
ithread
)/
a0
)
**
2
scal
(
ist
,
ithread
)
=
a0
else
ssq
(
ist
,
ithread
)
=
ssq
(
ist
,
ithread
)
+
(
a0
/
scal
(
ist
,
ithread
))
**
2
! only add a0 if it is non-zero
if
(
a0
>
M_EPSILON
)
then
if
(
scal
(
ist
,
ithread
)
<
a0
)
then
ssq
(
ist
,
ithread
)
=
M_ONE
+
ssq
(
ist
,
ithread
)
*
(
scal
(
ist
,
ithread
)/
a0
)
**
2
scal
(
ist
,
ithread
)
=
a0
else
ssq
(
ist
,
ithread
)
=
ssq
(
ist
,
ithread
)
+
(
a0
/
scal
(
ist
,
ithread
))
**
2
end
if
end
if
#endif
end
do
...
...
@@ -954,14 +963,30 @@ subroutine X(priv_mesh_batch_nrm2)(mesh, aa, nrm2)
do
ip
=
sp
,
sp
+
np
-
1
do
ist
=
1
,
aa
%
nst_linear
a0
=
abs
(
aa
%
X
(
ff_pack
)(
ist
,
ip
))
if
(
a0
<
M_EPSILON
)
cycle
if
(
scal
(
ist
,
ithread
)
<
a0
)
then
ssq
(
ist
,
ithread
)
=
mesh
%
vol_pp
(
ip
)
+
ssq
(
ist
,
ithread
)
*
(
scal
(
ist
,
ithread
)/
a0
)
**
2
scal
(
ist
,
ithread
)
=
a0
else
ssq
(
ist
,
ithread
)
=
ssq
(
ist
,
ithread
)
+
mesh
%
vol_pp
(
ip
)
*
(
a0
/
scal
(
ist
,
ithread
))
**
2
! first add real part
a0
=
abs
(
R_REAL
(
aa
%
X
(
ff_pack
)(
ist
,
ip
)))
! only add a0 if it is non-zero
if
(
a0
>
M_EPSILON
)
then
if
(
scal
(
ist
,
ithread
)
<
a0
)
then
ssq
(
ist
,
ithread
)
=
mesh
%
vol_pp
(
ip
)
+
ssq
(
ist
,
ithread
)
*
(
scal
(
ist
,
ithread
)/
a0
)
**
2
scal
(
ist
,
ithread
)
=
a0
else
ssq
(
ist
,
ithread
)
=
ssq
(
ist
,
ithread
)
+
mesh
%
vol_pp
(
ip
)
*
(
a0
/
scal
(
ist
,
ithread
))
**
2
end
if
end
if
#ifdef R_TCOMPLEX
! then add imaginary part for complex numbers
a0
=
abs
(
R_AIMAG
(
aa
%
X
(
ff_pack
)(
ist
,
ip
)))
! only add a0 if it is non-zero
if
(
a0
>
M_EPSILON
)
then
if
(
scal
(
ist
,
ithread
)
<
a0
)
then
ssq
(
ist
,
ithread
)
=
mesh
%
vol_pp
(
ip
)
+
ssq
(
ist
,
ithread
)
*
(
scal
(
ist
,
ithread
)/
a0
)
**
2
scal
(
ist
,
ithread
)
=
a0
else
ssq
(
ist
,
ithread
)
=
ssq
(
ist
,
ithread
)
+
mesh
%
vol_pp
(
ip
)
*
(
a0
/
scal
(
ist
,
ithread
))
**
2
end
if
end
if
#endif
end
do
end
do
...
...
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