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

Inconsistent format handling??

andrew_4619
Honored Contributor III
745 Views
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 Kudos
1 Solution
IanH
Honored Contributor III
604 Views
>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 =

View solution in original post

3 Replies
andrew_4619
Honored Contributor III
674 Views

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?

0 Kudos
IanH
Honored Contributor III
605 Views
>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
Honored Contributor III
583 Views

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. 

0 Kudos
Reply