Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Problem with large integer constant

iev
Beginner
617 Views
Hello,

First of all, I would like to mention that I don't know much about Fortran, but I have to compile a program written in it with the Intel compiler. In the source code there is a definiton:

INTEGER *8 mask

and later in the code the assignment:

mask = 15815322240

When I try to compile the code with the command line:

ifc -c -O2 code.f

I get the error:

mask = 15815322240
^
Error 18 at (:code.f> : invalid integer constant

I replaced the assignment with:

mask = Z'3AEAAAA80'

and now the program compiles correctly (The hexadecimal equivalent of 15815322240 is 3AEAAAA80).My questions are:

1) Is the change I made correct?
2) If it is correct, why does it compile in one case and doesn't in the other?
3) I noticed that the above value needs 5 bytes to be saved. How many bytes are allocated for an INTEGER *8 on an IA-32 system?

Executing an ifc -V gives:
Intel Fortran Compiler for 32-bit applications, Version 7.1 Build 20030922Z
Copyright (C) 1985-2003 Intel Corporation. All rights reserved.
FOR NON-COMMERCIAL USE ONLY

GNU ld version 2.14.90.0.4 20030523
Supported emulations:
elf_i386
i386linux

Thank you in advance for your help.
0 Kudos
1 Reply
TimP
Honored Contributor III
617 Views
Your untyped integer constant is a default integer, thus it must fit in 4 bytes with the Intel compilers. INTEGER*8 is a non-standard but well entrenched notation for an integer stored in 8 bytes.
Ideally, you would use the standard (since f90) notation such as
INTEGER,PARAMETER :: LONG = SELECTED_INT_KIND(11)
! integer kind big enough for 11 decimal digits
INTEGER(LONG) :: mask
mask = 15815322240_LONG

With the Intel compilers, the value of LONG happens to be 8, but assuming that makes your code non-portable.
0 Kudos
Reply