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
Principiante
3.069 Visualizações

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 Respostas
Steven_L_Intel1
Funcionário
3.069 Visualizações
You have the wrong syntax for an array constructor. It should be either (/.../) or [...].
John_B__Walter
Principiante
3.069 Visualizações
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.
John_B__Walter
Principiante
3.069 Visualizações
If an array constructor, then what Steve said. Your delimiters were wrong.
Adrian_F_1
Principiante
3.069 Visualizações
Sorry yes I did originally have PARAMETER there, but removed it trying to figure out syntax. Thanks for the responses.
Steven_L_Intel1
Funcionário
3.069 Visualizações
It could be a variable initialization - doesn't have to be PARAMETER.
Responder