I have legacy code that I need to compile in Ubuntu 22.04. I have compiled the code with Intel Fortran 11 way back, now with the latest Oneapi I get an error. The following is a snippet of the code, the code is do matrix manipulation.
module MatranUtil_m
implicit none
! Kind for double precision.
#ifdef sngl
integer, parameter :: wp = kind(1.0e0)
#endif
#ifdef dbl
integer, parameter :: wp = kind(1.0d0)
#endif
…
subroutine ReshapeAryR1(Ary, n)
! SJB added to avoid error
! SJB import :: wp
real(wp), pointer :: Ary(:)
integer, intent(in) :: n
if (associated(Ary)) then
if (size(Ary)<n) then
deallocate(Ary)
allocate(Ary(n))
end if
else
allocate(Ary(n))
end if
Ary = 0.0
end subroutine ReshapeAryR1
…
The following is my compile command following the make file of the legacy package
steph@sjb-pc: ifort -c -fpp MatranUtil.f90 MatranUtil.f90(123): error #6683: A kind type parameter must be a compile-time constant. [WP] real(wp), pointer :: Ary(:) -----------^ MatranUtil.f90(140): error #6683: A kind type parameter must be a compile-time constant. [WP] real(wp), pointer :: Ary(:,:) -----------^ MatranUtil.f90(160): error #6683: A kind type parameter must be a compile-time constant. [WP] complex(wp), pointer :: Ary(:) --------------^ MatranUtil.f90(177): error #6683: A kind type parameter must be a compile-time constant. [WP] complex(wp), pointer :: Ary(:, :) --------------^ compilation aborted for MatranUtil.f90 (code 1) steph@sjb-pc:
I have search Google and saw a recommendation to import the parameter explicitly, see Re: Couldn't use a integer parameter in submodules - Intel Community
I have tried this proposed solution (see import function commented out - this is where I tried it) with the following results.
steph@sjb-pc:$ ifort -c -fpp MatranUtil.f90
MatranUtil.f90(119): error #6483: IMPORT-name must be the name of an entity in the host scoping unit. [WP]
import :: wp
----------------^
MatranUtil.f90(121): error #6683: A kind type parameter must be a compile-time constant. [WP]
real(wp), pointer :: Ary(
-----------^
MatranUtil.f90(138): error #6683: A kind type parameter must be a compile-time constant. [WP]
real(wp), pointer :: Ary(:,
-----------^
MatranUtil.f90(158): error #6683: A kind type parameter must be a compile-time constant. [WP]
complex(wp), pointer :: Ary(
--------------^
MatranUtil.f90(175): error #6683: A kind type parameter must be a compile-time constant. [WP]
complex(wp), pointer :: Ary(:,
--------------^
compilation aborted for MatranUtil.f90 (code 1)
I’ll appreciate some guidance, this is the first time that I encounter this approach.