- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I asked a question on the Fortran Discourse and get suggestions that I should probably repost it here. Here is the link to the original post: https://fortran-lang.discourse.group/t/issues-with-user-defined-derived-type-i-o/6016/1
(The original post)
The question is pretty long so I would really appreciate it if you can read it through. Let’s say I have two modules module_a and module_b, each containing a derived type a_type and b_type. Also, I used the User-Defined Derived-Type I/O (UDDTIO) for each type, so there exists a write(formatted) for each module. The minimal code that generates error is shown below (io.f90),
module module_a
implicit none
public :: a_type
public :: write(formatted)
private
type :: a_type
integer :: value
end type a_type
interface write(formatted)
module procedure :: write_formatted_a
end interface write(formatted)
contains
subroutine write_formatted_a(self, unit, iotype, v_list, iostat, iomsg)
class(a_type), intent(in) :: self
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list (:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
if (iotype == 'DT') then
write (unit, fmt="(i0)", iostat=iostat, iomsg=iomsg) self%value
end if
end subroutine write_formatted_a
end module module_a
module module_b
implicit none
public :: b_type
public :: write(formatted)
private
type :: b_type
integer :: value
end type b_type
interface write(formatted)
module procedure :: write_formatted_b
end interface write(formatted)
contains
subroutine write_formatted_b(self, unit, iotype, v_list, iostat, iomsg)
class(b_type), intent(in) :: self
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list (:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
if (iotype == 'DT') then
write (unit, fmt="(i0)", iostat=iostat, iomsg=iomsg) self%value
end if
end subroutine write_formatted_b
end module module_b
program main
use module_a
use module_b
implicit none
type(a_type) :: a = a_type(1)
type(b_type) :: b = b_type(2)
print "(a, dt)", "A = ", a
print "(a, dt)", "B = ", b
end program main
gfortran compiles and runs the code with no complains
> gfortran io.f90
> ./a.out
A = 1
B = 2
but intel compiler tells me
> ifx io.f90
io.f90: error #8638: The type/rank signature for arguments
of this specific subroutine is identical to another specific subroutine
that shares the same defined I/O. [MODULE_A^WRITE_FORMATTED_A]
io.f90: error #8638: The type/rank signature for arguments
of this specific subroutine is identical to another specific subroutine
that shares the same defined I/O. [MODULE_B^WRITE_FORMATTED_B]
compilation aborted for io.f90 (code 1)
Is this complain standard-compliant? write_formatted_a clearly has a different argument with write_formatted_b.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your code is fine, and NAG Fortran also likes it. It baffles me that the Intel compiler is even comparing the two routines, given that they are UDIO procedures for distinct types.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the confirmation! Given my limited understanding of the compiler, it seems I will have to wait for the Intel developers to provide a bug fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for reporting this with a small reproducer!
I filed a bug report, CMPLRLLVM-48883. We will let you know when it's fixed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, I am looking forward to a bug-fix release!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is correct. Updated compilers are released regularly. I don't know when this particular issue will be fixed and available. When I know, I'll post it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The incorrect error message that you reported is fixed in the Fortran compilers that were released last week. Please give them a try!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page