Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29597 ディスカッション

Inconsistent format handling??

andrew_4619
名誉コントリビューター III
1,789件の閲覧回数
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?

 

0 件の賞賛
1 解決策
IanH
名誉コントリビューター III
1,648件の閲覧回数
>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 =

元の投稿で解決策を見る

3 返答(返信)
andrew_4619
名誉コントリビューター III
1,718件の閲覧回数

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?

IanH
名誉コントリビューター III
1,649件の閲覧回数
>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 =
andrew_4619
名誉コントリビューター III
1,627件の閲覧回数

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. 

返信