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

possible derived type reordering bug in ifort 19.1.1

may_ka
Beginner
357 Views

Hi all,

the code below implements two versions of a 2D character array, one "normal" with static cell size, and one as an array of derived types. Using an order vector to reshuffle columns in both goes wrong for the derived type array when using ifort 19.1.1. Using gfortran 10.2 and ifort 19.05 works fine. Operation system is linux kernel 5.8.8.

Is this a bug?

 

program test
  implicit none
  type :: ttt
    character(:), allocatable :: v
  end type ttt
  class(ttt), allocatable :: x(:,:)
  character(:), allocatable :: y(:,:)
  character(len=20) :: tmp
  integer :: i,j
  integer, allocatable :: s(:)
  allocate(x(5,9))
  allocate(character(len=10)::y(5,9))
  do i=1,size(x,2)
    do j=1,size(x,1)
      write(tmp,"(I11)") (10**i)/j
      x(j,i)%v=trim(adjustl(tmp))
      y(j,i)=trim(adjustl(tmp))
    end do
  end do
  !!@@@@@@@@@@@@@@@@@
  write(*,*) "y before"
  do i=1,size(y,1)
    write(*,"(*(g0:"",""))") (y(i,j),j=1,size(y,2))
  end do
  write(*,*) "x before"
  do i=1,size(x,1)
    write(*,"(*(g0:"",""))") (x(i,j)%v,j=1,size(x,2))
  end do
  !!@@@@@@@@@@@
  s=(/9,5,8,1,3,7,2,4,6/)
  x=x(:,s)
  y=y(:,s)
  write(*,*) "y after"
  do i=1,size(y,1)
    write(*,"(*(g0:"",""))") (y(i,j),j=1,size(y,2))
  end do
  write(*,*) "x after"
  do i=1,size(x,1)
    write(*,"(*(g0:"",""))") (x(i,j)%v,j=1,size(x,2))
  end do
  !!@@@@@@@@@@@@@@
  do i=1,size(x,2)
    do j=1,size(x,1)
      if(trim(adjustl(x(j,i)%v))/=trim(adjustl(y(j,i)))) then
        write(*,*) "err",j,i
      end if
    end do
  end do
end program test

 

 

0 Kudos
0 Replies
Reply