1module codePrecision_mod
2 ! MODULE codePrecision_mod (prefix='pre' category='8. Low-level utilities and constants')
3 !
4 !:Purpose: A module to specify the precision, mostly for floating
5 ! point variables
6 !
7 use mpi
8 implicit none
9 save
10 public
11
12 !
13 ! Precision for columns in obsSpaceData - default is real8
14 !
15#if !defined(CODEPRECISION_OBS_REAL_SINGLE) && !defined(CODEPRECISION_OBS_REAL_DOUBLE)
16#define CODEPRECISION_OBS_REAL_DOUBLE
17#endif
18
19#ifdef CODEPRECISION_OBS_REAL_DOUBLE
20 integer, parameter :: pre_obsReal = selected_real_kind(15)
21 character(len=20) :: pre_obsMpiReal ="mpi_real8"
22#endif
23
24#ifdef CODEPRECISION_OBS_REAL_SINGLE
25 integer, parameter :: pre_obsReal = selected_real_kind(6)
26 character(len=20) :: pre_obsMpiReal="mpi_real4"
27#endif
28
29 !
30 ! Precision for calculation of analysis increment in variational analysis - default is real8
31 !
32#if !defined(CODEPRECISION_INCR_REAL_SINGLE) && !defined(CODEPRECISION_INCR_REAL_DOUBLE)
33#define CODEPRECISION_INCR_REAL_DOUBLE
34#endif
35
36#ifdef CODEPRECISION_INCR_REAL_DOUBLE
37 integer, parameter :: pre_incrReal = selected_real_kind(15)
38#endif
39
40#ifdef CODEPRECISION_INCR_REAL_SINGLE
41 integer, parameter :: pre_incrReal = selected_real_kind(6)
42#endif
43
44 !
45 ! Precision for mpi transposes in (global) spectral transform - default is real8
46 !
47#if !defined(CODEPRECISION_SPECTRANS_REAL_SINGLE) && !defined(CODEPRECISION_SPECTRANS_REAL_DOUBLE)
48#define CODEPRECISION_SPECTRANS_REAL_DOUBLE
49#endif
50
51#ifdef CODEPRECISION_SPECTRANS_REAL_DOUBLE
52 integer, parameter :: pre_specTransReal = selected_real_kind(15)
53 integer, parameter :: pre_specTransMpiType = MPI_REAL8
54 character(len=20) :: pre_specTransMpiReal ="mpi_real8"
55#endif
56
57#ifdef CODEPRECISION_SPECTRANS_REAL_SINGLE
58 integer, parameter :: pre_specTransReal = selected_real_kind(6)
59 integer, parameter :: pre_specTransMpiType = MPI_REAL4
60 character(len=20) :: pre_specTransMpiReal ="mpi_real4"
61#endif
62
63contains
64
65 subroutine pre_printPrecisions
66 !
67 !:Purpose: To print precision parameters in the listing.
68 !
69 implicit none
70
71 write(*,*)
72 write(*,*) " <<<<<< Code precision parameters >>>>>>"
73 write(*,"(A36, I2)") " pre_obsReal= ", pre_obsReal
74 write(*,"(A36, A20)") " pre_obsMpiReal= ", pre_obsMpiReal
75 write(*,"(A36, I2)") " pre_incrReal= ", pre_incrReal
76 write(*,"(A36, I2)") " pre_specTransReal= ", pre_specTransReal
77 write(*,*) " pre_specTransMpiType= ", pre_specTransMpiType
78 write(*,"(A36, A20)") "pre_specTransMpiReal= ", pre_specTransMpiReal
79 write(*,*)
80
81 end subroutine pre_printPrecisions
82
83end module codePrecision_mod