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

ifort compiler problems with compile-time constants

thedesertwarrior
Beginner
439 Views
Hi,

I had compilation errors on a code that define several kind values


type data_types
integer(kind=int32) :: IntParam1
integer(kind=int16) :: IntParam2
integer(kind=int32) :: IntParam3
real(kind=real32) :: RealParam4
real(kind=real64) :: RealParam5
end type data_types

This is saved as data_types.f90


Then I have the main code (main.f90) that uses the types defined above.

While compiling:

ifort main.f90 data_types.f90 -o output

I had a long list of errors related to the variables defined in the data_types.f90 part.

This name does not have a type, and must an explicit type [IntParam1]
This name does not have a type, and must an explicit type [IntParam2]
This name does not have a type, and must an explicit type [IntParam3]
This name does not have a type, and must an explicit type [RealParam4]
This name does not have a type, and must an explicit type [RealParam5]


I am confused and need help about this. Is there something going wrong with my variable definitions or kind values or can this be supported by adding some options in the line command for compling.

Advance thanks.
0 Kudos
2 Replies
Steven_L_Intel1
Employee
439 Views
You will need to show us more of the code - a complete, small(if possible) example will be helpful.

I am not sure what you intended with the source you have in data_types.f90. You say it "define several kind values" but the code you show declares a single derived type called data_types with five components. If you then tried to use one of the component names by itself, such as:

a = IntParam1

then you would get an error if IMPLICIT NONE was in effect because IntParam1 is not itself a variable or a named constant. Please show us more so we can see what you had in mind.
0 Kudos
jimdempseyatthecove
Honored Contributor III
439 Views
I think you find better luck with

module data_types
...
end module data_types

...

program foo
use data_types
...

Jim Dempsey
0 Kudos
Reply