ошибка ifort # 8520: фиктивный аргумент массива процедуры BIND (C) должен иметь явную форму

У меня есть два исходных кода f90, и я хочу объединить их для создания динамической библиотеки для последующего использования (возможно, на другом языке). Проблема в том, что когда я компилирую их компилятором Intel Fortran 2015 в Visual Studio, возникают некоторые ошибки. Исходный код: mandel.f90 и mandel_wrap.f90

! Calculates the Mandelbrot set
module mandel
  implicit none

  integer, parameter :: dp=kind(0.d0) ! double precision

contains

  pure function mandel_frac(z, c) result(out)
    ! The Mandelbrot map: z -> z^2 + c
    complex(dp), intent(in):: z, c
    complex(dp):: out  
    out = z**2 + c
  end function mandel_frac

  function calc_num_iter(re, im, itermax, escape) result(out)
    ! Iterates on mandel_frac
    ! Input: 
    !  - re/im: vector of real/imaginary values of grid
    !  - itermax: maximum of iterations done
    !  - escape: stops if abs(z)>escape, for Mandelbrot escape=2
    ! Output:
    !  - number of iterations until abs(z)>escape
    real(dp), intent(in):: re(:), im(:), escape
    integer, intent(in):: itermax
    integer:: out(size(re), size(im))
    integer:: ii, jj, kk, itt
    complex(dp):: zz, cc

    !$OMP PARALLEL  PRIVATE(jj, zz, cc, itt, kk)

    !$OMP DO
    do jj=1,size(im)
       do ii=1,size(re) 
          zz = 0
          cc = cmplx(re(ii), im(jj), dp)
          do kk=1,itermax
             zz = mandel_frac(zz, cc)
             if (abs(zz)>escape) then
                exit
             end if
          end do
          if (kk>=itermax) then
             out(ii,jj) = -1
          else
             out(ii,jj) = kk
          end if
       end do
    end do
    !$OMP END PARALLEL  

  end function calc_num_iter

end module mandel

и

module mandel_wrap
  ! To wrap calc_num_iter for use in C using iso_c_binding

  use iso_c_binding, only: c_double, c_int
  use mandel, only:  calc_num_iter

  implicit none

contains

  ! need to make a subroutine as only scalars can be returned
  subroutine c_calc_num_iter(nre, re, nim, im, itermax, escape, out) bind(c)
    real(c_double), intent(in):: re(nre), im(nim)
    real(c_double), intent(in), value:: escape
    integer(c_int), intent(in), value:: itermax, nre, nim
    integer(c_int), intent(out):: out(nim, nre)  ! note that in C the indices will be reversed!
    out = transpose(calc_num_iter(re, im, itermax, escape))  ! thus the transpose here!
  end subroutine c_calc_num_iter

  subroutine c_calc_num_iter2(re, im, itermax, escape, out) bind(c)
    real(c_double), intent(in):: re(:), im(:)
    real(c_double), intent(in), value:: escape
    integer(c_int), intent(in), value:: itermax
    integer(c_int), intent(out):: out(size(im), size(re))  ! note that in C the indices will be reversed!
    out = transpose(calc_num_iter(re, im, itermax, escape))  ! thus the transpose here!
  end subroutine c_calc_num_iter2

end module mandel_wrap

Сообщение об ошибке

error #8520: An array dummy argument of a BIND(C) procedure must be an explicit shape or assumed size array.   [RE]
error #8520: An array dummy argument of a BIND(C) procedure must be an explicit shape or assumed size array.   [IM]

Более того, когда я попытался скомпилировать их с помощью gfortran, он выдал мне другое сообщение об ошибке.

subroutine c_calc_num_iter2(re,im,itermax,escape,out) bind(c)
                          2  1
Error: Assumed-shape array 're' at (1) cannot be an argument to the procedure 'c_calc_num_iter2' at (2) because the procedure is BIND(C) mandel_wrap.f90

person zlqs1985    schedule 16.09.2016    source источник
comment
См. связанный вопрос и обратите внимание, что существуют более свежие версии компилятора Intel.   -  person francescalus    schedule 16.09.2016
comment
Я пошел дальше и закрыл их как дубликаты. Ваше объяснение очень подробное, и нет смысла повторять все это снова.   -  person Vladimir F    schedule 16.09.2016
comment
Объяснение в этом ответе stackoverflow.com/a/34562270/721644   -  person Vladimir F    schedule 16.09.2016