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

Static structure (type) placed into common block

Ilgis_I_
Beginner
303 Views

Hello,

I am porting legacy code that have

      structure aaa
      integer a1
      real      a2
C    ...
      end structure
      structure /aaa/ bbb(100)
      common /ccc/ bbb

so an array bbb of structures aaa is placed into a common block ccc and wish this portable across Win/UX main fortran compilers.

I used
 

      type aaa
      integer a1
      real a2
C     ...
      end type
      type (aaa) bbb(100)
      common /ccc/ bbb
      save /ccc/

however I cannot compile common and save statements on this code. Please, advice how to place said array of structures into common block and be sure that it is statically allocated and remain in memory?

Thank you!

0 Kudos
3 Replies
Lorri_M_Intel
Employee
303 Views

what errors are you seeing?    This compiled for me on Windows.

By the way, the SAVE is redundant; COMMON is already SAVE by definition.

                 --Lorri

0 Kudos
andrew_4619
Honored Contributor II
303 Views

A common  block automatically has "save" status I do not think your SAVE is valid Fortran. If you are modernising why not share the data using a module rather than a common block. 

 

0 Kudos
Steve_Lionel
Honored Contributor III
303 Views

The SAVE of a common block is perfectly standard, though as noted, unnecessary. In some earlier Fortran standards you might have needed it if there were no active procedures that declared that common.

0 Kudos
Reply