- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying out the derived type i/o available since version 14 of the compiler and running into problems when reading from an internal file. With the following code:
[fortran]module m_prb_dtio_1
type t
integer :: a
contains
procedure :: fmtread => t_read_formatted
generic :: read(formatted) => fmtread
end type t
contains
subroutine t_read_formatted(dtv, unit, iotype, vlist, iostat, iomsg)
class(t), intent(inout) :: dtv
integer, intent(in) :: unit
character(len=*), intent(in) :: iotype
integer, intent(in) :: vlist(:)
integer, intent(out) :: iostat
character(len=*), intent(inout) :: iomsg
read(unit, fmt="(i2)", iostat=iostat, iomsg=iomsg) dtv%a
end subroutine
end module m_prb_dtio_1
program test
use m_prb_dtio_1
character(len=100) :: str
integer ios
type(t) :: t1, t2
str = "42"
open (10, file="test.input")
write(10, fmt="(A)") str
rewind(10)
read (10, fmt="(DT)", iostat=ios) t1
print *, "ios:", ios, ", t1 :", t1
read (unit=str, fmt="(DT)", iostat=ios) t2
print *, "ios:", ios, ", t2 :", t2
end program[/fortran]
The output is :
[plain]C:\>ifort prb_dtio_1.f90
Intel(R) Visual Fortran Compiler XE for applications running on IA-32, Version 14.0.2.176 Build 20140130
Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
-out:prb_dtio_1.exe
-subsystem:console
prb_dtio_1.obj
C:\>prb_dtio_1
ios: 0 , t1 : 42
ios: 48 , t2 : 0[/plain]
As far as I understand the standard, derived type I/O should work for internal files as well. As I have no other compiler that supports this at hand, I can not be certain if the error is in my code or a bug in ifort
Johny
P.S. I posted this already once a few hours ago, but the post did not appear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is our bug. It is fixed for a release later this year.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve,
So i'll have to wait a bit before playing with that new feature

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page