FV3 Bundle
ncd_kinds.F90
Go to the documentation of this file.
1 module ncd_kinds
2 !$$$ module documentation block
3 ! . . . .
4 ! module: kinds
5 ! prgmmr: treadon org: np23 date: 2004-08-15
6 !
7 ! abstract: Module to hold specification kinds for variable declaration.
8 ! This module is based on (copied from) Paul vanDelst's
9 ! type_kinds module found in the community radiative transfer
10 ! model
11 !
12 ! module history log:
13 ! 2004-08-15 treadon
14 ! 2011-07-04 todling - define main precision during compilation
15 !
16 ! Subroutines Included:
17 !
18 ! Functions Included:
19 !
20 ! remarks:
21 ! The numerical data types defined in this module are:
22 ! i_byte - specification kind for byte (1-byte) integer variable
23 ! i_short - specification kind for short (2-byte) integer variable
24 ! i_long - specification kind for long (4-byte) integer variable
25 ! i_llong - specification kind for double long (8-byte) integer variable
26 ! r_single - specification kind for single precision (4-byte) real variable
27 ! r_double - specification kind for double precision (8-byte) real variable
28 ! r_quad - specification kind for quad precision (16-byte) real variable
29 !
30 ! i_kind - generic specification kind for default integer
31 ! r_kind - generic specification kind for default floating point
32 !
33 !
34 ! attributes:
35 ! language: f90
36 ! machine: ibm RS/6000 SP
37 !
38 !$$$ end documentation block
39  implicit none
40  private
41 
42 ! Integer type definitions below
43 
44 ! Integer types
45  integer, parameter, public :: i_byte = selected_int_kind(1) ! byte integer
46  integer, parameter, public :: i_short = selected_int_kind(4) ! short integer
47  integer, parameter, public :: i_long = selected_int_kind(8) ! long integer
48  integer, parameter, private :: llong_t = selected_int_kind(16) ! llong integer
49  integer, parameter, public :: i_llong = max( llong_t, i_long )
50 
51 ! Expected 8-bit byte sizes of the integer kinds
52  integer, parameter, public :: num_bytes_for_i_byte = 1
53  integer, parameter, public :: num_bytes_for_i_short = 2
54  integer, parameter, public :: num_bytes_for_i_long = 4
55  integer, parameter, public :: num_bytes_for_i_llong = 8
56 
57 ! Define arrays for default definition
58  integer, parameter, private :: num_i_kinds = 4
59  integer, parameter, dimension( num_i_kinds ), private :: integer_types = (/ &
61  integer, parameter, dimension( num_i_kinds ), private :: integer_byte_sizes = (/ &
64 
65 ! Default values
66 ! **** CHANGE THE FOLLOWING TO CHANGE THE DEFAULT INTEGER TYPE KIND ***
67  integer, parameter, private :: default_integer = 3 ! 1=byte,
68  ! 2=short,
69  ! 3=long,
70  ! 4=llong
71  integer, parameter, public :: i_kind = integer_types( default_integer )
72  integer, parameter, public :: num_bytes_for_i_kind = &
74 
75 
76 ! Real definitions below
77 
78 ! Real types
79  integer, parameter, public :: r_single = selected_real_kind(6) ! single precision
80  integer, parameter, public :: r_double = selected_real_kind(15) ! double precision
81  integer, parameter, private :: quad_t = selected_real_kind(20) ! quad precision
82  integer, parameter, public :: r_quad = max( quad_t, r_double )
83 
84 ! Expected 8-bit byte sizes of the real kinds
85  integer, parameter, public :: num_bytes_for_r_single = 4
86  integer, parameter, public :: num_bytes_for_r_double = 8
87  integer, parameter, public :: num_bytes_for_r_quad = 16
88 
89 ! Define arrays for default definition
90  integer, parameter, private :: num_r_kinds = 3
91  integer, parameter, dimension( num_r_kinds ), private :: real_kinds = (/ &
93  integer, parameter, dimension( num_r_kinds ), private :: real_byte_sizes = (/ &
96 
97 ! Default values
98 ! **** CHANGE THE FOLLOWING TO CHANGE THE DEFAULT REAL TYPE KIND ***
99 #ifdef _REAL4_
100  integer, parameter, private :: default_real = 1 ! 1=single,
101 #endif
102 #ifdef _REAL8_
103  integer, parameter, private :: default_real = 2 ! 2=double,
104 #endif
105 #ifdef _REAL16_
106  integer, parameter, private :: default_real = 3 ! 3=quad
107 #endif
108  integer, parameter, public :: r_kind = real_kinds( default_real )
109  integer, parameter, public :: num_bytes_for_r_kind = &
111 
112 end module ncd_kinds
integer, parameter, private num_r_kinds
Definition: ncd_kinds.F90:90
integer, parameter, public i_byte
Definition: ncd_kinds.F90:45
integer, dimension(num_r_kinds), parameter, private real_kinds
Definition: ncd_kinds.F90:91
integer, parameter, public num_bytes_for_i_kind
Definition: ncd_kinds.F90:72
integer, parameter, public i_kind
Definition: ncd_kinds.F90:71
integer, parameter, private num_i_kinds
Definition: ncd_kinds.F90:58
integer, parameter, public i_long
Definition: ncd_kinds.F90:47
integer, parameter, public num_bytes_for_i_short
Definition: ncd_kinds.F90:53
integer, parameter, public num_bytes_for_r_double
Definition: ncd_kinds.F90:86
integer, parameter, public num_bytes_for_i_long
Definition: ncd_kinds.F90:54
integer, parameter, private default_real
Definition: ncd_kinds.F90:100
integer, parameter, private quad_t
Definition: ncd_kinds.F90:81
integer, parameter, private llong_t
Definition: ncd_kinds.F90:48
integer, parameter, private default_integer
Definition: ncd_kinds.F90:67
integer, parameter, public r_quad
Definition: ncd_kinds.F90:82
integer, parameter, public num_bytes_for_r_quad
Definition: ncd_kinds.F90:87
integer, parameter, public i_short
Definition: ncd_kinds.F90:46
integer, dimension(num_r_kinds), parameter, private real_byte_sizes
Definition: ncd_kinds.F90:93
#define max(a, b)
Definition: mosaic_util.h:33
integer, dimension(num_i_kinds), parameter, private integer_byte_sizes
Definition: ncd_kinds.F90:61
integer, parameter, public num_bytes_for_i_byte
Definition: ncd_kinds.F90:52
integer, parameter, public num_bytes_for_r_single
Definition: ncd_kinds.F90:85
integer, parameter, public r_double
Definition: ncd_kinds.F90:80
integer, dimension(num_i_kinds), parameter, private integer_types
Definition: ncd_kinds.F90:59
integer, parameter, public num_bytes_for_i_llong
Definition: ncd_kinds.F90:55
integer, parameter, public r_single
Definition: ncd_kinds.F90:79
integer, parameter, public num_bytes_for_r_kind
Definition: ncd_kinds.F90:109
integer, parameter, public i_llong
Definition: ncd_kinds.F90:49
integer, parameter, public r_kind
Definition: ncd_kinds.F90:108