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

Issues with User-Defined Derived-Type I/O

han190
Novice
1,127 Views

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.

Labels (2)
6 Replies
Steve_Lionel
Honored Contributor III
1,086 Views

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.

0 Kudos
han190
Novice
1,057 Views

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.

0 Kudos
Barbara_P_Intel
Employee
1,062 Views

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.



0 Kudos
han190
Novice
1,057 Views

Thank you, I am looking forward to a bug-fix release!

0 Kudos
Barbara_P_Intel
Employee
1,056 Views

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.


0 Kudos
Barbara_P_Intel
Employee
400 Views

The incorrect error message that you reported is fixed in the Fortran compilers that were released last week. Please give them a try!



0 Kudos
Reply