character*(FileNameLength) cFileName
链接已复制
Perhaps you are including several header files some of which may declare the same common block but with different/different allocations of variables?
Also your given declaration for cFileName is not in a COMMON.
Jim Dempsey
The problem is that I have FileNameLength defined in a common block AND in the program.
The program has
include 'fnames.gcb'
integer,parameter:: FileNameLength=250
character*(FileNameLength) cFileName
etc...
The common block is in file 'Fnames.gcb'
integer,parameter:: FileNameLength=250
character*(FileNameLength) cgbf,CCOD
common/fnames/ cgbf,CCOD
The error message is:
This name has already been assigned a data type. [FILENAMELENGTH]
I want to use the variable 'FileNameLength' in several Common blocks.
I have tried removing them, to leave only one, but get the error messages:
'A COMMON block data object must not be an automatic object.'
and
'This name has not been given an explicit type. [FILENAMELENGTH]'
I'm getting confused,
David
Jugoslav
I'm not sure if I follow you.
I have made a new common block called fnl.gcb:
integer:: FileNameLength=250
common/FNL/FileNameLength
It wouldn't compile with 'Parameter'.
Then in each program that needs this variable or has an include file that needs this variable I have added include 'fnl.gcb'.
When I compile, I get an error on the first program which containsa common block.
Error: A COMMON block data object must not be an automatic object.
I don't know what that error messagemeans.
I don't think I have any spelling problems.
Your original problem was that you defined FileNameLength twice, once in .gcb file and other time again in code (.for file) (that's what I meant by "spelled"). The solution was just to remove the re-declarations.
Jugoslav
David,
If you can, why not dispense with COMMON. You can do this by creating a module containing the arrays, variables and constant parameters. I've done this on a Solution with 11 project files and ~700 source modules. It is a bit of work but you can do it incrimentaly. You could start with
-----------------------------
character*(FileNameLength) cFileName
! file name length
integer,parameter:: FileNameLength=250
end module