- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page