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

Error #6005

alanlodge
Beginner
1,543 Views
I'm compiling existing code on IVF 11.1, and I'm getting lots of #6005 errors (A derived type object in a COMMON block shall not have default initialization) which I don't understand. The relevant structure is STRUCTURE /LOCAL_POINT/
CHARACTER*(16) TAG
INTEGER*4 BASEADD(3) /0,0,0/
BYTE TYPE /14/
END STRUCTURE

Is this because TAG doesn't have an initialiser? What should such an initialiser look like? Sorry - it's been years since I did any serious FORTRAN...
0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,543 Views
There are two fields of the structure that are initialized - given initial values. BASEADD has /0,0,0/ and TYPE has /14/. The problem is caused by the initialization and putting a record with initialized structure in a COMMON. The Fortran standard prohibits this, but I think that old DEC compilers allowed it. Of course, the standard doesn't have STRUCTURE/RECORD, but we generally try to keep STRUCTURE/RECORD and derived types as equivalent as we can. Any initialization of COMMON should be in a BLOCK DATA subprogram, however.

The following works:

[plain]BLOCK DATA
STRUCTURE /LOCAL_POINT/
CHARACTER*(16) TAG
INTEGER*4 BASEADD(3)
BYTE TYPE
END STRUCTURE

RECORD /LOCAL_POINT/ eN2B15S23

COMMON /MYC/ eN2B15S23
data eN2B15S23 /LOCAL_POINT('',[0,0,0],14)/
end[/plain]
Ideally, the STRUCTURE, variable and COMMON declarations would come from an INCLUDE file. Elsewhere in the program you'd just use the INCLUDE.

I will admit that I am a bit puzzled by this error and perhaps this should be a standards warning rather than an error. I will investigate.

View solution in original post

0 Kudos
8 Replies
rogcar
Beginner
1,543 Views
Hello there

Could give some more info? Using only this piece of code, I couldn't reproduce your error, as it worked flawlessly. Also, the inicializationis just fine. Is your structure inside any type definition, module, or whatever?

Roger
0 Kudos
alanlodge
Beginner
1,543 Views
Quoting - rogcar
Hello there

Could give some more info? Using only this piece of code, I couldn't reproduce your error, as it worked flawlessly. Also, the inicializationis just fine. Is your structure inside any type definition, module, or whatever?

Roger
Hi!

The variable I create appears in a common block, which is giving the problem. Here's all I need to reproduce the error:

PROGRAM TEST

STRUCTURE /LOCAL_POINT/
CHARACTER*(16) TAG
INTEGER*4 BASEADD(3) /0,0,0/
BYTE TYPE /14/
END STRUCTURE

RECORD /LOCAL_POINT/ eN2B15S23

COMMON /MYC/ eN2B15S23

END PROGRAM

Any help would be appreciated!
0 Kudos
Steven_L_Intel1
Employee
1,544 Views
There are two fields of the structure that are initialized - given initial values. BASEADD has /0,0,0/ and TYPE has /14/. The problem is caused by the initialization and putting a record with initialized structure in a COMMON. The Fortran standard prohibits this, but I think that old DEC compilers allowed it. Of course, the standard doesn't have STRUCTURE/RECORD, but we generally try to keep STRUCTURE/RECORD and derived types as equivalent as we can. Any initialization of COMMON should be in a BLOCK DATA subprogram, however.

The following works:

[plain]BLOCK DATA
STRUCTURE /LOCAL_POINT/
CHARACTER*(16) TAG
INTEGER*4 BASEADD(3)
BYTE TYPE
END STRUCTURE

RECORD /LOCAL_POINT/ eN2B15S23

COMMON /MYC/ eN2B15S23
data eN2B15S23 /LOCAL_POINT('',[0,0,0],14)/
end[/plain]
Ideally, the STRUCTURE, variable and COMMON declarations would come from an INCLUDE file. Elsewhere in the program you'd just use the INCLUDE.

I will admit that I am a bit puzzled by this error and perhaps this should be a standards warning rather than an error. I will investigate.
0 Kudos
alanlodge
Beginner
1,543 Views
Steve, that's what I needed! Thank you!

0 Kudos
Eric_Luth
Beginner
1,543 Views

I'm running into this same problem in Intel Parallel Sutdio XE 2011 (version 12.0). The workaround suggested does work, but I'm not excited about fixing the 1000+ places were our legacy code has used this incorrect definition. You said "I will admit that I am a bit puzzled by this error and perhaps this should be a standards warning rather than an error. I will investigate." Is there a way to reduce this error to a warning?

0 Kudos
Steven_L_Intel1
Employee
1,543 Views
Are there really 1000+ places where this is written, or do you use INCLUDE files to declare the type and/or the COMMON? If INCLUDE is not used, maintaining this application would seem to be a nightmare even without this issue. I'd hope that INCLUDE was used in which case it should be straightforward to move the initialization to a BLOCK DATA subprogram.

There is no way to prevent this diagnostic from aborting the compilation.
0 Kudos
Valentin_P_2
Beginner
1,543 Views

I am migrating Compaq Visual Fortran code to Intel Visual Fortran.

The code has a derived-type array pointer in COMMON block and that creates the same problem.

Error #6005: A derived type object in a COMMON block shall not have default initialization [ XYplots ]:

is given for the following code:

MODULE test 

TYPE Axis
     SEQUENCE
       integer:: parm = 1
END TYPE Axis

TYPE XYplotsData

     SEQUENCE

      real, pointer:: plot(:)

     TYPE (Axis):: X_axis

END TYPE XYplotsData

TYPE (XYplotsData), pointer::    XYplots (: )
COMMON /data1/  XYplots

END MODULE

There are no compilation errors if default initialization parm = 1 is taken off.

In the real (not simplified) code structure 'Axis' has many elements that have default initializations and I would like to keep it that way.

How do I define correctly this common block while keeping default initialization in Axis definition?

 

 

 

0 Kudos
Steven_L_Intel1
Employee
1,543 Views

Take out the COMMON declaration. You don't need it for module variables.

0 Kudos
Reply