Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28658 Discussions

ifc 7.1 - parameter(x,char(y)) is wrong for y between 127 and 256?

vsbabu
Beginner
212 Views
Hi,

A quick question from a Fortran newbie. CHAR intrinsic works fine for 0-255 range; but when given inside a PARAMETER() declaration, it supports only till 127.

Any workarounds for this?

Cheers!
Satheesh
------------------------------------------
C Print CHARs using intrinsics
PROGRAM char_intrinsic
CHARACTER x, y
C Upto 127 is no problem inside PARAMETER() specs
PARAMETER ( x = CHAR(127) )
C Uncomment out the next line and it fails compilation
C with an error: "The value of this intrinsic procedure argument is incorrect"
C PARAMETER ( y = CHAR(130) )
DO 100 n=0, 255, 1
C If the value is incorrect, how come CHAR(n), where n>127 works here?
y = CHAR(n)
PRINT *, 'Character value for', n, ' is ', y
100 CONTINUE
END PROGRAM
0 Kudos
1 Reply
TimP
Honored Contributor III
212 Views
With ifort 8.1, the compilation fails when you un-comment that line, not because of the CHAR(130), but because you attempt to assign new values to the PARAMETER constant in the DO loop.

I suppose 7.1 rejected CHAR(130) on account of possible portability issues. The default range of 8-bit integers on IA processors would be [-256..127]. Evidently, the compiler people agreed with you that this should not be fatal, and so the current compiler accepts it, as does CVF, which is the usual arbiter for behavior of extensions.

I found the mixture of pre-f90 style with free format somewhat confusing; maybe that had something to do with the syntax error.
0 Kudos
Reply