[J3] branch based on ieee class ?
Bill Long
longb at cray.com
Thu Nov 7 14:49:19 EST 2019
I tried Vipul’s example code with all 4 compilers I have, and every one compiles it with no error and executes as expected.
It seems your main problem is a poor choice of compiler.
Cheers,
Bill
> On Nov 7, 2019, at 10:46 AM, Dan Nagle via J3 <j3 at mailman.j3-fortran.org> wrote:
>
> Hi,
>
> Yes, I didn't read far enough.
>
> But neither of the compilers I'm targeting support == and /= :-(
>
>
>> On Nov 7, 2019, at 09:42 , Vipul Parekh via J3 <j3 at mailman.j3-fortran.org> wrote:
>>
>> Hello Dan,
>>
>> See section 17.2 Derived types, constants, and operators defined in
>> the modules in 18-007r1.pdf, p3 on IEEE_ARITHMETIC module,
>> particularly lines 27 thru' 30 which state,
>>
>> 27 * The pure elemental operator == for two values of one of these
>> types to return true if the values are the
>> 28 same and false otherwise.
>> 29 * The pure elemental operator /= for two values of one of these
>> types to return true if the values differ and
>> 30 false otherwise.
>>
>> From what I understand, you will have to construct your case using
>> either of the above-mentioned operators e.g.,
>>
>> use, intrinsic :: ieee_arithmetic, only : ieee_class,
>> ieee_negative_normal, operator(==)
>> real :: x
>> x = -1.0
>> if ( ieee_class(x) == ieee_negative_normal ) then
>> print *, "x is IEEE_NEGATIVE_NORMAL"
>> else
>> print *, "The IEEE class of x is not as expected!"
>> end if
>> end
>>
>> Upon execution, the program output is expected as:
>> x is IEEE_NEGATIVE_NORMAL
>>
>> Regards,
>> Vipul Parekh
>>
>> On Thu, Nov 7, 2019 at 10:38 AM Dan Nagle via J3
>> <j3 at mailman.j3-fortran.org> wrote:
>>>
>>> Hi,
>>>
>>> How to?
>>>
>>> C1145 removes the select case option (my first choice), and
>>> Table 10.2 eliminates if-blocks by not listing ieee_class_type
>>> among the allowed operands for == and /= (or .eqv. and .neqv.).
>>>
>>> I'm writing a workshop on ieee 754 and I would like to write
>>> a diagnostic routine that can print "this is an X" where
>>> X is one of the ieee_class_type values. So I want to branch
>>> to select the correct label per class.
>>>
>>> (With the select case, a range of values does not seem to make sense.
>>> But I want to case each one singly, so that's no matter to the task at hand.)
>>>
>>>
>>> --
>>>
>>> Cheers!
>>> Dan Nagle
>>>
>>>
>
>
> --
>
> Cheers!
> Dan Nagle
>
>
Bill Long longb at cray.com
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray, a Hewlett Packard Enterprise company/ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
More information about the J3
mailing list