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

Syntax error

Adrian_F_1
Beginner
1,384 Views

Why is the compiler expecting only 2 entries when I have specified length 7?

program ttt
implicit none
CHARACTER(16) :: CCPROP(7) = &
( 'Viscosity', 'Therm Cond', 'Elec Cond', 'Surf Tension', 'Intfacial Tens', 'Self Diff', 'Mutual Diff' )
end

D:\test>ifort char.for /free
Intel(R) Visual Fortran Compiler Professional for applications running on IA-32, Version 11.1    Build 20100414 Package ID: w_cprof_p_11.1.065
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.

char.for(4): error #5082: Syntax error, found ',' when expecting one of: )
( 'Viscosity', 'Therm Cond', 'Elec Cond', 'Surf Tension', 'Intfacial Tens', 'Self Diff', 'Mutual Diff' )
---------------------------^
compilation aborted for char.for (code 1)

I thought this syntax was valid, but changed to DATA and it worked OK.  Is this syntax not valid?

0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,384 Views
You have the wrong syntax for an array constructor. It should be either (/.../) or [...].
0 Kudos
John_B__Walter
Beginner
1,384 Views
What was your intent with this statement? Its complaining about your syntax. the use of the "=" suggests that you were intending it to be a PARAMETER statement, but you've left out that key word. If that was your intent, then change it to CHARACTER(16), PARAMETER :: CCPROP(7) = & [ 'Viscosity', 'Therm Cond', 'Elec Cond', 'Surf Tension', 'Intfacial Tens', 'Self Diff', 'Mutual Diff' ] or CHARACTER(16), PARAMETER :: CCPROP(7) = & (/ 'Viscosity', 'Therm Cond', 'Elec Cond', 'Surf Tension', 'Intfacial Tens', 'Self Diff', 'Mutual Diff' /) and it will declare CCPROP(7) as parameters with the 7 values.
0 Kudos
John_B__Walter
Beginner
1,384 Views
If an array constructor, then what Steve said. Your delimiters were wrong.
0 Kudos
Adrian_F_1
Beginner
1,384 Views
Sorry yes I did originally have PARAMETER there, but removed it trying to figure out syntax. Thanks for the responses.
0 Kudos
Steven_L_Intel1
Employee
1,384 Views
It could be a variable initialization - doesn't have to be PARAMETER.
0 Kudos
Reply