Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Crash on entering subroutine in context with MODULE-statement

$
0
0

Hello all,

in my code I am using MODULEs in order to organize and store my data.
With one of this MODULEs I faced some crashes that I cannot explain.
Fortunately I could also reproduce these crashes in a small program:

    module mod1
    implicit none
    type :: modstruct
      integer :: n1, n2
      double precision, allocatable, dimension(:,:,:) :: arr
    end type modstruct
    integer :: n1, n2
    type(modstruct), allocatable, dimension(:) :: bear

    contains
    subroutine alloc()
      allocate(bear(1:3))
      bear(1)%n1 = 1001
      bear(1)%n2 = 201
      allocate(bear(1)%arr(1:bear(1)%n1,1:bear(1)%n2,1:3))
    end subroutine alloc

    end module mod1

    program module_test
    use mod1
    implicit none
    ! Variables

    ! Body of module_test
    call alloc()
    print *, allocated(bear)
    print *, allocated(bear(1)%arr)
    print *, shape(bear(1)%arr)
    n1 = bear(1)%n1
    n2 = bear(1)%n2
    call dosome(bear(1)%n1,bear(1)%n2,bear(1)%arr) ! WORKS
    call dosome(bear(1)%n1, bear(1)%n2, bear(1)%arr(1:n1,1:n2,1:3) ) ! WORKS
    call dosome(bear(1)%n1, bear(1)%n2, bear(1)%arr(1:bear(1)%n1,1:bear(1)%n2,1:3) ) ! FAILS

    end program module_test

    subroutine dosome(m1,m2,arrin)
      integer, intent(in) :: m1, m2
      double precision, intent(in), dimension(1:m1,1:m2,1:3) :: arrin

      print *, 'inside '
      print *, shape(arrin)
    end subroutine dosome

The issue arises in calling the "dosome"-subroutine. In line 38-40 I tried three different ways in calling this subroutine.
The first two works while the third one crashes on entering the subroutine.
Can somebody tell me, where my error is?

BTW: The issue arises only when I compile this piece of code with ifort on Windows.
I also tested the same piece of code with ifort and gfortran under Linux and here everything went fine.

Any hints and comment is welcome!

BR,
Arthur


Viewing all articles
Browse latest Browse all 5691

Trending Articles



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