Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

Static structure (type) placed into common block

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
Highlighted
1 View

what errors are you seeing?  

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
Highlighted
Valued Contributor II
1 View

A common  block automatically

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
Highlighted
Black Belt
1 View

The SAVE of a common block is

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.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos