From: Frank on
I wanted to work up a facility to deal with floating point exceptions
in fortran. P. 557 of the _Handbook_ has the following source.
Gfortran does not have the modules used. G95 seems to, but I can't
understand the errors I'm getting without thinking that they might not
be complete:

C:\MinGW\source>g95 float1.f90 -Wall -Wextra -o out
In file float1.f90:11

IEEE_SUPPORT_HALTING(IEEE_OVERFLOW)) then
1
Warning (165): Implicit interface 'ieee_support_halting' called at (1)
In file float1.f90:14

call IEEE_SET_HALTING_MODE(IEEE_OVERFLOW, .false. )
1
Error: Too many arguments in call to 'ieee_set_halting_mode' at (1)

C:\MinGW\source>type float1.f90
use IEEE_FEATURES, only : IEEE_DATATYPE
use IEEE_ARITHMETIC, only : IEEE_SUPPORT_DATATYPE
use IEEE_EXCEPTIONS, only: IEEE_OVERFLOW, &
IEEE_GET_FLAG, IEEE_SET_HALTING_MODE
implicit none

real x, y, z
logical :: overflow_flag, IEEE_SUPPORT_HALTING

if(IEEE_SUPPORT_DATATYPE(x) .and. &
IEEE_SUPPORT_HALTING(IEEE_OVERFLOW)) then
read *, x, y

call IEEE_SET_HALTING_MODE(IEEE_OVERFLOW, .false. )

z = x * y
call IEEE_GET_FLAG(IEEE_OVERFLOW, overflow_flag )
if (overflow_flag) then
print "overflow"
else
print *, "no overflow"
print *, x, y, z
endif

else
print *, "no overflow support"
endif


endprogram

! g95 float1.f90 -Wall -Wextra -o out

C:\MinGW\source>

I seem to have at least 2 problems, according to my compiler. I can't
really tell what ieee_support_halting wants to be. P. 540 lists
ieee_set_halting_mode with 2 arguments, so I'm stumped and fishing for
tips.

Thanks for your comment.
From: Ron Shepard on
In article
<e59a6bcb-a79c-4680-8c8b-be20a6542985(a)f20g2000prn.googlegroups.com>,
Frank <merrill(a)lomas-assault.net> wrote:

> use IEEE_FEATURES, only : IEEE_DATATYPE
> use IEEE_ARITHMETIC, only : IEEE_SUPPORT_DATATYPE
> use IEEE_EXCEPTIONS, only: IEEE_OVERFLOW, &
> IEEE_GET_FLAG, IEEE_SET_HALTING_MODE
[...]
> if(IEEE_SUPPORT_DATATYPE(x) .and. &
> IEEE_SUPPORT_HALTING(IEEE_OVERFLOW)) then
[...]

I don't think I can answer your question, but it is clear that the
function IEEE_SUPPORT_HALTING() is not in scope, so that looks like
an error. If it does exist in one of the above modules, it is being
hidden with the ONLY clauses. That function probably needs to be
added to one of the ONLY lists.

$.02 -Ron Shepard
From: Frank on
On Sep 8, 10:29 am, Ron Shepard <ron-shep...(a)NOSPAM.comcast.net>
wrote:
> In article
> <e59a6bcb-a79c-4680-8c8b-be20a6542...(a)f20g2000prn.googlegroups.com>,
>
>  Frank <merr...(a)lomas-assault.net> wrote:
> > use IEEE_FEATURES, only : IEEE_DATATYPE
> > use IEEE_ARITHMETIC, only : IEEE_SUPPORT_DATATYPE
> > use IEEE_EXCEPTIONS, only: IEEE_OVERFLOW, &
> >    IEEE_GET_FLAG, IEEE_SET_HALTING_MODE
> [...]
> > if(IEEE_SUPPORT_DATATYPE(x) .and. &
> >   IEEE_SUPPORT_HALTING(IEEE_OVERFLOW)) then
>
> [...]
>
> I don't think I can answer your question, but it is clear that the
> function IEEE_SUPPORT_HALTING() is not in scope, so that looks like
> an error.  If it does exist in one of the above modules, it is being
> hidden with the ONLY clauses.  That function probably needs to be
> added to one of the ONLY lists.
>
> $.02 -Ron Shepard

That seems to be right, but I have other problems:

C:\MinGW\source> g95 float2.f90 -Wall -Wextra -o out
In file float2.f90:15

if(IEEE_SUPPORT_HALTING(IEEE_OVERFLOW)) then
1
Error: Too many arguments in call to 'ieee_support_halting' at (1)

C:\MinGW\source>type float2.f90
use IEEE_FEATURES, only : IEEE_DATATYPE
use IEEE_ARITHMETIC, only : IEEE_SUPPORT_DATATYPE, &
IEEE_SUPPORT_HALTING, IEEE_SUPPORT_STANDARD
use IEEE_EXCEPTIONS, only: IEEE_OVERFLOW, &
IEEE_GET_FLAG, IEEE_SET_HALTING_MODE
implicit none

real x, y, z
logical :: overflow_flag

if(IEEE_SUPPORT_DATATYPE(x)) then
print *, "so far so good"
endif

if(IEEE_SUPPORT_HALTING(IEEE_OVERFLOW)) then
print *, "still alright"
endif

endprogram

! g95 float2.f90 -Wall -Wextra -o out

C:\MinGW\source>

How do I find these modules with g95 to read what they actually have
in them?
From: robert.corbett on
On Sep 8, 8:54 am, Frank <merr...(a)lomas-assault.net> wrote:
> I wanted to work up a facility to deal with floating point exceptions
> in fortran. P. 557 of the _Handbook_ has the following source.
> Gfortran does not have the modules used. G95 seems to, but I can't
> understand the errors I'm getting without thinking that they might not
> be complete:
>
> C:\MinGW\source>g95 float1.f90 -Wall -Wextra -o out
> In file float1.f90:11
>
> IEEE_SUPPORT_HALTING(IEEE_OVERFLOW)) then
> 1
> Warning (165): Implicit interface 'ieee_support_halting' called at (1)
> In file float1.f90:14
>
> call IEEE_SET_HALTING_MODE(IEEE_OVERFLOW, .false. )
> 1
> Error: Too many arguments in call to 'ieee_set_halting_mode' at (1)
>
> C:\MinGW\source>type float1.f90
> use IEEE_FEATURES, only : IEEE_DATATYPE
> use IEEE_ARITHMETIC, only : IEEE_SUPPORT_DATATYPE
> use IEEE_EXCEPTIONS, only: IEEE_OVERFLOW, &
> IEEE_GET_FLAG, IEEE_SET_HALTING_MODE
> implicit none
>
> real x, y, z
> logical :: overflow_flag, IEEE_SUPPORT_HALTING
>
> if(IEEE_SUPPORT_DATATYPE(x) .and. &
> IEEE_SUPPORT_HALTING(IEEE_OVERFLOW)) then
> read *, x, y
>
> call IEEE_SET_HALTING_MODE(IEEE_OVERFLOW, .false. )
>
> z = x * y
> call IEEE_GET_FLAG(IEEE_OVERFLOW, overflow_flag )
> if (overflow_flag) then
> print "overflow"
> else
> print *, "no overflow"
> print *, x, y, z
> endif
>
> else
> print *, "no overflow support"
> endif
>
> endprogram
>
> ! g95 float1.f90 -Wall -Wextra -o out
>
> C:\MinGW\source>
>
> I seem to have at least 2 problems, according to my compiler. I can't
> really tell what ieee_support_halting wants to be. P. 540 lists
> ieee_set_halting_mode with 2 arguments, so I'm stumped and fishing for
> tips.
>
> Thanks for your comment.


One of the problems is easily fixed. Add IEEE_SUPPORT_HALTING
to the ONLY list for IEEE_EXCEPTIONS.

Bob Corbett
From: Dan Nagle on
Hello,

On 2009-09-08 14:45:05 -0400, Frank <merrill(a)lomas-assault.net> said:

> How do I find these modules with g95 to read what they actually have
> in them?

Intrinsic modules are magic and need not exist anywhere.
If they do exist, they might be encoded so you can't read them.

There might be several versions, with one selected depending
upon compiler options or other incantations.

You might want to use ieee_selected_real_kind()
to get the right kind value for your reals.

HTH

--
Cheers!

Dan Nagle