4
4
!
5
5
! JSON-Fortran kind definitions.
6
6
!
7
- ! ## License
7
+ ! ### License
8
8
! * JSON-Fortran is released under a BSD-style license.
9
9
! See the [LICENSE](https://github.com/jacobwilliams/json-fortran/blob/master/LICENSE)
10
10
! file for details.
34
34
! character arguments of the default (```CDK```) kind. If you find a procedure which does
35
35
! not accept an ```intent(in)``` literal string argument of default kind, please
36
36
! [file an issue](https://github.com/jacobwilliams/json-fortran/issues/new) on GitHub.
37
+ !
38
+ ! @note The default real kind (`RK`) and the default integer kind (`IK`) can be
39
+ ! changed using optional preprocessor flags. This library was built with kinds:
40
+ #ifdef REAL32
41
+ ! real(kind=real32) [4 bytes]
42
+ #elif REAL64
43
+ ! real(kind=real64) [8 bytes]
44
+ #elif REAL128
45
+ ! real(kind=real128) [16 bytes]
46
+ #else
47
+ ! real(kind=real64) [8 bytes]
48
+ #endif
49
+ ! and
50
+ #ifdef INT8
51
+ ! integer(kind=int8) [1 byte]
52
+ #elif INT16
53
+ ! integer(kind=int16) [2 bytes]
54
+ #elif INT32
55
+ ! integer(kind=int32) [4 bytes]
56
+ #elif INT64
57
+ ! integer(kind=int64) [8 bytes]
58
+ #else
59
+ ! integer(kind=int32) [4 bytes]
60
+ #endif
61
+ ! .
37
62
38
63
module json_kinds
39
64
40
- use ,intrinsic :: iso_fortran_env, only: real64,int32,logical_kinds
65
+ use ,intrinsic :: iso_fortran_env
41
66
42
67
implicit none
43
68
44
69
private
45
70
46
- integer ,parameter ,public :: RK = real64 ! ! Default real kind [8 bytes]
71
+ #ifdef REAL32
72
+ integer ,parameter ,public :: RK = real32 ! ! Default real kind [4 bytes]
73
+ #elif REAL64
74
+ integer ,parameter ,public :: RK = real64 ! ! Default real kind [8 bytes]
75
+ #elif REAL128
76
+ integer ,parameter ,public :: RK = real128 ! ! Default real kind [16 bytes]
77
+ #else
78
+ integer ,parameter ,public :: RK = real64 ! ! Default real kind if not specified [8 bytes]
79
+ #endif
47
80
48
- integer ,parameter ,public :: IK = int32 ! ! Default integer kind [4 bytes].
81
+ #ifdef INT8
82
+ integer ,parameter ,public :: IK = int8 ! ! Default integer kind [1 byte]
83
+ #elif INT16
84
+ integer ,parameter ,public :: IK = int16 ! ! Default integer kind [2 bytes]
85
+ #elif INT32
86
+ integer ,parameter ,public :: IK = int32 ! ! Default integer kind [4 bytes]
87
+ #elif INT64
88
+ integer ,parameter ,public :: IK = int64 ! ! Default integer kind [8 bytes]
89
+ #else
90
+ integer ,parameter ,public :: IK = int32 ! ! Default integer kind if not specified [4 bytes]
91
+ #endif
49
92
50
93
! *********************************************************
51
94
! >
52
95
! Processor dependendant 'DEFAULT' character kind.
53
96
! This is 1 byte for the Intel and Gfortran compilers.
54
-
55
97
integer ,parameter ,public :: CDK = selected_char_kind(' DEFAULT' )
56
98
! *********************************************************
57
99
@@ -62,14 +104,12 @@ module json_kinds
62
104
! (and perhaps others).
63
105
! The declaration ensures a valid kind
64
106
! if the compiler doesn't have a logical_kinds(3).
65
- !
66
107
integer ,parameter ,public :: LK = logical_kinds(min (3 ,size (logical_kinds)))
67
108
! *********************************************************
68
109
69
110
! *********************************************************
70
111
! >
71
112
! String kind preprocessor macro.
72
- !
73
113
#if defined __GFORTRAN__ && defined USE_UCS4
74
114
! gfortran compiler AND UCS4 support requested:
75
115
character (kind= CDK,len=* ),parameter :: json_fortran_string_kind = ' ISO_10646'
0 commit comments