- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
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 Solución
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
>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 =
Enlace copiado
3 Respuestas
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
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?
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
>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 =
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
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.
Responder
Opciones de temas
- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla