- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have run into a peculiar issue:
I have run into a peculiar issue:
program char_int
integer :: intvalue
intvalue = '123'
write(*,*) 'Intvalue: ', intvalue
end program
Assigning a literal string value to an integer is accepted (I am using Intel Fortran 11.1 here
on Windows). Assigning a string variable to an integer is not.
Is this a bug or is it an extension specific to Intel Fortran? (I suspect the latter as
/stand:f90 etc do flag it as an error)
Regards,
Arjen
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is a rather common extension to the standard, accepted by many compilers. If you are going to use this extension, you may wish to see how the string, which is only 3-bytes long, is padded out to 4 bytes before assignment to the integer variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, I rather want to avoid that this extension causes problems ;). We changed the type of one variable
in our program from a character string to an integer and later I noticed that some character comparisons
and assignments were left. Using the /stand:f03 option catches them though.
Regards,
Arjen
in our program from a character string to an integer and later I noticed that some character comparisons
and assignments were left. Using the /stand:f03 option catches them though.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is indeed an extension and is part of support for Fortran 66 Hollerith constants. In Fortran 66 you could do:
intvalue = 3H123
and many compilers allowed '123' as an alternative. We still support this. Note that intvalue does NOT get the integer value 123 in this case!
intvalue = 3H123
and many compilers allowed '123' as an alternative. We still support this. Note that intvalue does NOT get the integer value 123 in this case!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, I have seen the value - something very large :). I have had to use Hollerith constants, butthat was
a long, long time ago, when I first encountered Fortran ... Never had to deal with them since.
Thanks for the information,
Arjen
a long, long time ago, when I first encountered Fortran ... Never had to deal with them since.
Thanks for the information,
Arjen

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