- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Is there a proper define for infinity? We get the following compilation errors under IFort v17 on Windows 10:

C:\Dashboards\EMsoft\EMsoftPublic\Source\EMsoftLib/constants.f90(103): error #7995: DEC$ ATTRIBUTES DLLIMPORT or DLLEXPORT data may not be equivalenced. [INFTY] REAL,public :: infty ---------------^ C:\Dashboards\EMsoft\EMsoftPublic\Source\EMsoftLib/constants.f90(108): error #7995: DEC$ ATTRIBUTES DLLIMPORT or DLLEXPORT data may not be equivalenced. [INFTYD] REAL(kind=dbl),public :: inftyd -------------------------^ compilation aborted for C:\Dashboards\EMsoft\EMsoftPublic\Source\EMsoftLib\constants.f90 (code 1)

This code compiles find under GFortran v6.2.

Thanks for any help.

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

It seems the compiler is complaining about a !DEC$ ATTRIBUTES directive, not the declarations you show. You cut off the error message so we can't know what the problem is.

Please post a small but complete code sample, not just pieces of the error messages.

A standard-conforming way of obtaining an Infinity value is:

IEEE_VALUE (X,IEEE_POSITIVE_INF) ! or IEEE_NEGATIVE_INF

where X is a value or variable of the real kind you want an Infinity for and you have done a USE IEEE_ARITHMETIC to make the function available. This isn't allowed in a constant expression in Fortran 2008 - it will be in the next standard revision.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

I think we would need a complete working example of your problem, if you don't care to change the code.

I suppose that use of the Fortran HUGE() and ieee_arithmetic infinity constants would be recommended, as both gfortran and ifort have supported them for years now.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Ok - now you have posted enough for us to see the issue. The complaint is:

DEC$ ATTRIBUTES DLLIMPORT or DLLEXPORT data may not be equivalenced.

It has nothing to do with "defining infinity"

This is a restriction of the Intel compiler - what you are doing (DLLEXPORT) is nonstandard and compilers can apply their own rules to it.

You don't need to use EQUIVALENCE, though. The following works and is even standard (other than the DLLEXPORT):

module foo integer, parameter :: dbl = 8 REAL,public :: infty DATA infty/z'7f800000'/ !Hex for +Infinity REAL(kind=dbl),public :: inftyd DATA inftyd/z'7FF0000000000000'/ !Hex for +Infinity !DEC$ ATTRIBUTES DLLEXPORT :: infty !DEC$ ATTRIBUTES DLLEXPORT :: inftyd end

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page