Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Reference manuals
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NEMO Workspace
Documentation
Reference manuals
Commits
426fb9cc
Commit
426fb9cc
authored
1 year ago
by
sparonuz
Browse files
Options
Downloads
Patches
Plain Diff
Added key_single to coding rules
parent
a3db1f32
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
Added key_single to coding rules
Pipeline
#1394
passed with stage
Stage:
in 6 minutes and 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
latex/global/coding_rules.tex
+40
-0
40 additions, 0 deletions
latex/global/coding_rules.tex
with
40 additions
and
0 deletions
latex/global/coding_rules.tex
+
40
−
0
View file @
426fb9cc
...
...
@@ -612,6 +612,46 @@ definitions" to obtain the required numerical precision and range as well as the
REAL(wp), DIMENSION(jpi,jpj,jpk) :: zpc ! power consumption
\end{forlines}
\subsubsection
{
The
\key
{
single
}}
In the
\path
{
./src/OCE/par
_
kind.F90
}
module the working precision
for
\forcode
{
REAL
}
variables is declared as follows:
\begin{forlines}
# if defined key
_
single
INTEGER, PUBLIC, PARAMETER :: wp = sp !: working precision
# else
INTEGER, PUBLIC, PARAMETER :: wp = dp !: working precision
# endif
\end{forlines}
The default is
\forcode
{
dp
}
, so that all the real variables declared
\forcode
{
wp
}
are assigned to be double precision.
The
\key
{
single
}
is available to switch the precision of the
\forcode
{
wp
}
parameter
to single precision. This does not mean that the code will be fully single precision,
which can lead to instabilities in the model. In facts, the declaration of a set of variables
has been hardcoded to
\forcode
{
dp
}
and the key
\key
{
single
}
enables to run in mixed-precision.
Variables that need to stay double precision, no matter the value of the working precision are declared as:
\begin{forlines}
REAL(dp), DIMENSION(jpi,jpj,jpk) :: arr
_
name
\end{forlines}
This set of variables has been highlighted using the methodology described in Tinto et al. 2019. and this mixed-precision
version of
\NEMO
is tested for the official configuration
\forcode
{
ORCA2
}
compiled without the
\forcode
{
ICE
}
module.
Apart from changing the value of the
\forcode
{
wp
}
parameter another macro will be activated by the usage of the
\key
{
single
}
. Inside the
\path
{
./src/OCE/single
_
precision
_
substitute.h90
}
two macros are defined:
\begin{forlines}
#if defined key
_
single
# define CASTSP(x) REAL(x,sp)
# define CASTDP(x) REAL(x,dp)
#else
# define CASTSP(x) x
# define CASTDP(x) x
#endif
\end{forlines}
When the
\key
{
single
}
is used at compilation time all the variable
to which this macro is applied will be put inside a cast, to double or single precision depending on the macro used.
This is done to ensure coherence at compilation time between variables and dummy arguments in some function and subroutine calls.
When the
\key
{
single
}
is omitted the cast is no longer needed and the macro evaluates to the variable itself.
\subsection
{
Structures
}
The
\forcode
{
TYPE
}
structure allowing to declare some variables is more often used in
\NEMO
,
...
...
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