- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
program main
real(8) :: a
character(*),parameter :: gf1 = '(I0)', gf2='(I10)'
character(30) :: gbuf
A = 1200.0_8
write(gbuf,gf1, iostat = istat ) a
write(*,*) istat,' a = ',trim(gbuf)
write(gbuf,gf2, iostat = istat ) a
write(*,*) istat,' a = ',trim(gbuf)
end program
>ifx fmt_issue.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.2.0 Build 20240602
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.30.30709.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:fmt_issue.exe
-subsystem:console
fmt_issue.obj
>fmt_issue
0 a = 4652992471259676672
0 a = **********
Neither give an iostat error but the result with I0 compared to I10 seems wrong, surely both should be ****** ? Is this wrong?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>ifx /check:format "2024-10-19 format.f90" && "2024-10-19 format.exe"
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.2.1 Build 20240711
...
61 a =
61 a =
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suppose if I had made format gf2 say I30 I would get a more consistent output:
0 a = 4652992471259676672
0 a = 4652992471259676672
But the question of why no error and why take the binary representation of a real64 and interpret it as a int64?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>ifx /check:format "2024-10-19 format.f90" && "2024-10-19 format.exe"
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.2.1 Build 20240711
...
61 a =
61 a =
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting thanks. I did look to see if there was and option but clearly failed!! In windows it seems that option lives under the heading "Check Edit Descriptor Data Type" which didn't jump out at me. That gives a more satisfactory result. It is one of those cases where the default is to accept questionable code and you need to set and option to have it throw an 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