66!
77! ===------------------------------------------------------------------------===!
88
9- ! See Fortran 2018, clause 16.10.2
10- ! TODO: These are placeholder values so that some tests can be run.
9+ ! See Fortran 2023, subclause 16.10.2
1110
1211include ' ../include/flang/Runtime/magic-numbers.h'
1312
@@ -24,27 +23,20 @@ module iso_fortran_env
2423 compiler_version = > __builtin_compiler_version
2524
2625 implicit none
27-
28- ! Set PRIVATE by default to explicitly only export what is meant
29- ! to be exported by this MODULE.
3026 private
3127
3228 public :: event_type, notify_type, lock_type, team_type, &
3329 atomic_int_kind, atomic_logical_kind, compiler_options, &
3430 compiler_version
3531
36-
37- ! TODO: Use PACK([x],test) in place of the array constructor idiom
38- ! [(x, integer::j=1,COUNT([test]))] below once PACK() can be folded.
39-
4032 integer , parameter :: &
4133 selectedASCII = selected_char_kind(' ASCII' ), &
4234 selectedUCS_2 = selected_char_kind(' UCS-2' ), &
4335 selectedUnicode = selected_char_kind(' ISO_10646' )
4436 integer , parameter , public :: character_kinds(* ) = [ &
45- [( selectedASCII, integer :: j = 1 , count ([ selectedASCII >= 0 ]))] , &
46- [( selectedUCS_2, integer :: j = 1 , count ([ selectedUCS_2 >= 0 ]))] , &
47- [( selectedUnicode, integer :: j = 1 , count ([ selectedUnicode >= 0 ]))] ]
37+ pack ([ selectedASCII], selectedASCII >= 0 ) , &
38+ pack ([ selectedUCS_2], selectedUCS_2 >= 0 ) , &
39+ pack ([ selectedUnicode], selectedUnicode >= 0 ) ]
4840
4941 integer , parameter :: &
5042 selectedInt8 = selected_int_kind (2 ), &
@@ -76,19 +68,18 @@ module iso_fortran_env
7668
7769 integer , parameter , public :: integer_kinds(* ) = [ &
7870 selected_int_kind (0 ), &
79- ((selected_int_kind (k), &
80- integer :: j= 1 , count ([selected_int_kind (k) >= 0 .and. &
81- selected_int_kind (k) /= &
82- selected_int_kind (k-1 )])), &
83- integer :: k= 1 , 39 )]
71+ [(pack ([selected_int_kind (k)], &
72+ selected_int_kind (k) >= 0 .and. &
73+ selected_int_kind (k) /= selected_int_kind (k-1 )), &
74+ integer :: k= 1 , 39 )]]
8475
8576 integer , parameter , public :: &
8677 logical8 = int8, logical16 = int16, logical32 = int32, logical64 = int64
8778 integer , parameter , public :: logical_kinds(* ) = [ &
88- [( logical8, integer :: j = 1 , count ([ logical8 >= 0 ]))] , &
89- [( logical16, integer :: j = 1 , count ([ logical16 >= 0 ]))] , &
90- [( logical32, integer :: j = 1 , count ([ logical32 >= 0 ]))] , &
91- [( logical64, integer :: j = 1 , count ([ logical64 >= 0 ]))] ]
79+ pack ([ logical8], logical8 >= 0 ) , &
80+ pack ([ logical16], logical16 >= 0 ) , &
81+ pack ([ logical32], logical32 >= 0 ) , &
82+ pack ([ logical64], logical64 >= 0 ) ]
9283
9384 integer , parameter :: &
9485 selectedReal16 = selected_real_kind (3 , 4 ), & ! IEEE half
@@ -129,35 +120,40 @@ module iso_fortran_env
129120 digits (real (0 ,kind= safeReal128)) == 113 )
130121
131122 integer , parameter , public :: real_kinds(* ) = [ &
132- [(real16, integer :: j= 1 , count ([real16 >= 0 ]))], &
133- [(bfloat16, integer :: j= 1 , count ([bfloat16 >= 0 ]))], &
134- [(real32, integer :: j= 1 , count ([real32 >= 0 ]))], &
135- [(real64, integer :: j= 1 , count ([real64 >= 0 ]))], &
136- [(real80, integer :: j= 1 , count ([real80 >= 0 ]))], &
137- [(real64x2, integer :: j= 1 , count ([real64x2 >= 0 ]))], &
138- [(real128, integer :: j= 1 , count ([real128 >= 0 ]))]]
139-
140- integer , parameter , public :: current_team = - 1 , initial_team = - 2 , parent_team = - 3
141-
142- integer , parameter , public :: output_unit = FORTRAN_DEFAULT_OUTPUT_UNIT
143- integer , parameter , public :: input_unit = FORTRAN_DEFAULT_INPUT_UNIT
144- integer , parameter , public :: error_unit = FORTRAN_ERROR_UNIT
145- integer , parameter , public :: iostat_end = FORTRAN_RUNTIME_IOSTAT_END
146- integer , parameter , public :: iostat_eor = FORTRAN_RUNTIME_IOSTAT_EOR
147- integer , parameter , public :: iostat_inquire_internal_unit = &
148- FORTRAN_RUNTIME_IOSTAT_INQUIRE_INTERNAL_UNIT
123+ pack ([real16], real16 >= 0 ), &
124+ pack ([bfloat16], bfloat16 >= 0 ), &
125+ pack ([real32], real32 >= 0 ), &
126+ pack ([real64], real64 >= 0 ), &
127+ pack ([real80], real80 >= 0 ), &
128+ pack ([real64x2], real64x2 >= 0 ), &
129+ pack ([real128], real128 >= 0 )]
130+
131+ integer , parameter , public :: current_team = - 1 , &
132+ initial_team = - 2 , &
133+ parent_team = - 3
149134
150135 integer , parameter , public :: character_storage_size = 8
151136 integer , parameter , public :: file_storage_size = 8
152- integer , parameter , public :: numeric_storage_size = 32
153137
154- integer , parameter , public :: stat_failed_image = FORTRAN_RUNTIME_STAT_FAILED_IMAGE
155- integer , parameter , public :: stat_locked = FORTRAN_RUNTIME_STAT_LOCKED
156- integer , parameter , public :: &
157- stat_locked_other_image = FORTRAN_RUNTIME_STAT_LOCKED_OTHER_IMAGE
158- integer , parameter , public :: stat_stopped_image = FORTRAN_RUNTIME_STAT_STOPPED_IMAGE
159- integer , parameter , public :: stat_unlocked = FORTRAN_RUNTIME_STAT_UNLOCKED
138+ intrinsic :: __builtin_numeric_storage_size
139+ ! This value depends on any -fdefault-integer-N and -fdefault-real-N
140+ ! compiler options that are active when the module file is read.
141+ integer , parameter , public :: numeric_storage_size = &
142+ __builtin_numeric_storage_size()
143+
144+ ! From Runtime/magic-numbers.h:
160145 integer , parameter , public :: &
146+ output_unit = FORTRAN_DEFAULT_OUTPUT_UNIT, &
147+ input_unit = FORTRAN_DEFAULT_INPUT_UNIT, &
148+ error_unit = FORTRAN_ERROR_UNIT, &
149+ iostat_end = FORTRAN_RUNTIME_IOSTAT_END, &
150+ iostat_eor = FORTRAN_RUNTIME_IOSTAT_EOR, &
151+ iostat_inquire_internal_unit = FORTRAN_RUNTIME_IOSTAT_INQUIRE_INTERNAL_UNIT, &
152+ stat_failed_image = FORTRAN_RUNTIME_STAT_FAILED_IMAGE, &
153+ stat_locked = FORTRAN_RUNTIME_STAT_LOCKED, &
154+ stat_locked_other_image = FORTRAN_RUNTIME_STAT_LOCKED_OTHER_IMAGE, &
155+ stat_stopped_image = FORTRAN_RUNTIME_STAT_STOPPED_IMAGE, &
156+ stat_unlocked = FORTRAN_RUNTIME_STAT_UNLOCKED, &
161157 stat_unlocked_failed_image = FORTRAN_RUNTIME_STAT_UNLOCKED_FAILED_IMAGE
162158
163159end module iso_fortran_env
0 commit comments