problem with derived type I/O on internal file

problem with derived type I/O on internal file

johnyb's picture

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:

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

The output is :

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

 

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.

Johny
3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Steve Lionel (Intel)'s picture
Best Reply

This is our bug. It is fixed for a release later this year.

Steve
johnyb's picture

Thanks Steve,

So i'll have to wait a bit before playing with that new feature

Johny

Login to leave a comment.