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

Compile-Time Constant?

lklawrie
Beginner
2,875 Views

I'm getting this error message:

Error: A kind type parameter must be a compile-time constant.

I'm setting up Kind in a module:

INTEGER, PARAMETER :: dbl_kind=KIND(1.0D0)
INTEGER, PARAMETER :: default_prec=dbl_kind

this works fine except in INTERFACE statements:

INTERFACE
SUBROUTINE ShowRecurringContinueErrorAtEnd(Message,Index,ReportMaxOf,ReportMinOf,ReportSumOf, &
ReportMaxUnits,ReportMinUnits,ReportSumUnits)
! Use when "continuing" a recurring error messages (shown once at end of simulation)
! over several lines with optional max, min, sum
CHARACTER(len=*) :: Message ! Message automatically written to "error file" at end of simulation
INTEGER, INTENT(INOUT) :: Index ! Recurring message index, if zero, next available index is assigned
REAL(KIND=dbl_kind), INTENT(IN), OPTIONAL :: ReportMaxOf ! Track and report the max of the values passed to this argument
REAL(KIND=dbl_kind), INTENT(IN), OPTIONAL :: ReportMinOf ! Track and report the min of the values passed to this argument
REAL(KIND=dbl_kind), INTENT(IN), OPTIONAL :: ReportSumOf ! Track and report the sum of the values passed to this argument
CHARACTER(len=*), INTENT(IN), OPTIONAL :: ReportMaxUnits ! optional char string (<=15 length) of units for max value
CHARACTER(len=*), INTENT(IN), OPTIONAL :: ReportMinUnits ! optional char string (<=15 length) of units for min value
CHARACTER(len=*), INTENT(IN), OPTIONAL :: ReportSumUnits ! optional char string (<=15 length) of units for sum value
END SUBROUTINE
END INTERFACE

There it doesn't like it and issues the compile error message.

Is there any clean way around this?

Linda

0 Kudos
5 Replies
anthonyrichards
New Contributor III
2,875 Views
Don't you therefore have to USE the module in the INTERFACE block to make the parameter you define in the modulevisible when you need to use it?
0 Kudos
Steven_L_Intel1
Employee
2,875 Views

Linda,

Read my blog post Domestic or Imported?

0 Kudos
lklawrie
Beginner
2,875 Views

Thank you, Steve. Just the answer I was looking for!

Linda

0 Kudos
jerome_hazart
Beginner
2,875 Views
Hi Lina,

i have the same bug with an extremely simple program:

Module toto
integer, parameter :: mykind = 4
Interface
function Myfunction(x)
integer(kind=mykind) :: x
end function Myfunction
end Interface
end Module toto

I think this is a bug from Intel. The only way i found to get rid of it is to declare "mykind" in a dummy separated module:
Module Dummy
integer, parameter :: mykind = 4
end Module Dummy
Module toto
Interface
function Myfunction(x)
use Dummy
integer(kind=mykind) :: x
end function Myfunction
end Interface
end Module toto

It is has if "parameter" was missing.
Jerome

0 Kudos
Steven_L_Intel1
Employee
2,875 Views
Jerome,

This is not a compiler bug. Please read the article I linked to above - it explains this in complete detail.
0 Kudos
Reply