Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.

using integer in place of logical

DataScientist
Valued Contributor I
287 Views

Is this code, standard-complying:

integer :: i = 1
if (i) Print *, "Hello World!"
end

If not, why does Intel ifort happily compile and execute the code with no error? This seems too obvious to be a compiler bug. So, it is there likely for a reason. But this code does not compile with Gfortran.

0 Kudos
1 Solution
IanH
Black Belt
280 Views

A. King wrote:

Is there any plans to change this default behavior (for example, by allowing the compiler to keep the significant digits even when no kind is specified for the constant)?

There have been proposals to allow the default kind in a program unit (or other scoping unit) to be specified for the relevant intrinsic types.

But that aside, the implied proposal above is impractical.  Depending on exactly what is being proposed there are multiple problems, but tos start consider the real literal `0.1` as an example in this alternative world - what kind is it?

I expect that a "physical chemist with background in [many things]" understood the limits of precision of floating point representation, so I suspect the underlying issue was simply that they thought that the default kind in Fortran was akin to double precision kind.  There's no need to make literal resolution inscrutably opaque, confusing or incompatible in order to remedy that.

In terms of the issue with the large array constructor, Fortran has excellent support for "compile time" constant expression evaluation, which includes the ability to build up large arrays from smaller arrays, amongst many other things.  I'd not expect issues with things like code bloat - compilers are pretty good at not including things in the executable that aren't required and/or loaders only load the pages from executables that are required.

View solution in original post

22 Replies
DataScientist
Valued Contributor I
10 Views

Vautier, Gilles wrote:

In a obj file, I think it's possible to set the memory block readonly.

You can also integrate a binary file in ressources. It may be readonly in this case.

Thanks again. Do you have any reference suggestions on how to it? I have never done this in the past.

 

GVautier
New Contributor II
10 Views

A. King wrote:

Quote:

Vautier, Gilles wrote:

 

In a obj file, I think it's possible to set the memory block readonly.

You can also integrate a binary file in ressources. It may be readonly in this case.

 

 

Thanks again. Do you have any reference suggestions on how to it? I have never done this in the past.

 

For obj files, search for coff format but it's not easy to implement.

For ressources look here https://blog.kowalczyk.info/article/zy/Embedding-binary-resources-on-Windows.html

 

Reply