Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 415

assumed rank arrays -> ICE and runtime error

$
0
0

Dear all,

I wrote an example for getting in touch with assumed rank arrays and got two issues. Once an ICE assumed in subroutine bar in line 44 (if un-commented) and in foo in line 22 a run-time error is thrown for i>=2. To get the ICE one have to uncomment lines 21 to 23. The ICE occures in PSXE 2016.3 up to version 2017.2.

Maybe the things I do are not standard conform...

module mod_subs
  implicit none

  contains

  subroutine foo(t)
    implicit none
    real, intent(inout)  :: t(..)

    integer              :: i
    integer              :: i_rank
    integer, allocatable :: i_size_1(:), i_size_2(:)

    i_rank = rank(t)
    allocate(i_size_1(i_rank))
    allocate(i_size_2(i_rank))
    i_size_1=shape(t)
    write(*,'("The rank    of the array is: ",*(i3))') i_rank   ! gives  3
    write(*,'("The shape   of the array is: ",*(i3))') i_size_1 ! gives  2  2  2
    write(*,'("The content of the array is: ",*(f6.2))') t      ! stops at 2.0
    do i = 1, i_rank
      i_size_2(i) = size(t,dim=i)  ! runtime error at i=2: The DIM value 2 must not be greater than 1, the rank of array 'T'.
    end do

    return
  end subroutine foo

  ! --------------------------------------------

  subroutine bar(t)
    implicit none
    real, intent(inout)  :: t(..)

    integer              :: i
    integer              :: i_rank
    integer, allocatable :: i_size(:)

    i_rank = rank(t)
    allocate(i_size(i_rank))
    i_size=shape(t)
    write(*,'("The rank    of the array is: ",*(i3))') i_rank   ! gives  3
    write(*,'("The shape   of the array is: ",*(i3))') i_size   ! gives  2  2  2
    write(*,'("The content of the array is: ",*(f6.2))') t      ! stops at 2.0
    !write(*,*) t(1:i_size(1),1:i_size(2),1:i_size(3)) ! un-commenting throws an ICE (PSXE 2016.3 up to 2017.2)

    return
  end subroutine bar

end module mod_subs


program Assumed_Rank
    use mod_subs
    implicit none

    ! Variables
    integer                :: i, j, k
    real, dimension(2,2,2) :: r_dummy

    ! Body of Assumed_Rank
    r_dummy = reshape([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0],[2,2,2])

    do i = 1, size(r_dummy,dim=3)
      do j = 1, size(r_dummy,dim=2)
        do k = 1, size(r_dummy,dim=1)
          write(*,'(*(f6.2))',advance='no') r_dummy(k,j,i)
        end do
        write(*,'(/)')
      end do
    end do

    call foo(r_dummy)
    call bar(r_dummy)


end program Assumed_Rank
Compiling with Intel(R) Visual Fortran Compiler 17.0.2.187 [Intel(R) 64]...
ifort /nologo /debug:full /Od /warn:interfaces /module:"x64\Debug\\" /object:"x64\Debug\\" /Fd"x64\Debug\vc140.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\\bin\amd64" /Qm64 "D:\02_Fortran\99_test\Assumed_Rank\mod_subs.f90"
ifort /nologo /debug:full /Od /warn:interfaces /module:"x64\Debug\\" /object:"x64\Debug\\" /Fd"x64\Debug\vc140.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\\bin\amd64" /Qm64 "D:\02_Fortran\99_test\Assumed_Rank\Assumed_Rank.f90"
Linking...
Link /OUT:"x64\Debug\Assumed_Rank.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"x64\Debug\Assumed_Rank.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\02_Fortran\99_test\Assumed_Rank\x64\Debug\Assumed_Rank.pdb" /SUBSYSTEM:CONSOLE /IMPLIB:"D:\02_Fortran\99_test\Assumed_Rank\x64\Debug\Assumed_Rank.lib" -qm64 "x64\Debug\mod_subs.obj""x64\Debug\Assumed_Rank.obj"
Embedding manifest...
mt.exe /nologo /outputresource:"D:\02_Fortran\99_test\Assumed_Rank\x64\Debug\Assumed_Rank.exe;#1" /manifest "x64\Debug\Assumed_Rank.exe.intermediate.manifest"

Assumed_Rank - 0 error(s), 0 warning(s)

 

1>------ Rebuild All started: Project: Assumed_Rank, Configuration: Debug x64 ------
1>Deleting intermediate files and output files for project 'Assumed_Rank', configuration 'Debug|x64'.
1>Compiling with Intel(R) Visual Fortran Compiler 17.0.2.187 [Intel(R) 64]...
1>mod_subs.f90
1>fortcom: Fatal: There has been an internal compiler error (C0000005).
1>compilation aborted for D:\02_Fortran\99_test\Assumed_Rank\mod_subs.f90 (code 1)
1>Assumed_Rank.f90
1>
1>Build log written to  "file://D:\02_Fortran\99_test\Assumed_Rank\x64\Debug\BuildLog.htm"
1>Assumed_Rank - 1 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

 

 


Viewing all articles
Browse latest Browse all 415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>