Search code examples
initializationfortranfortran77openvms

OpenVMS initialization of record types


I have some legacy code that I am trying to improve... one approach I like to take is using structures to organize data rather than equivalence operations.... shudder. This is on OpenVMS Fortran 6.4 which I understand to be Fortran77 plus some stuff (might be wrong).

I want to initialize a record variable like so:

structure /my_data/
  integer*2   var1
  integer*2   var2
  character*5 NameTag
end structure

record /my_data/ OrganizedData

data OrganizedData /1, 2, 'Fred '/

I know the data statement is an error, the compiler told me so. Checking in the help files, it appears that DATA does not support record variables in this version. Can anyone confirm? Any suggestions to initialize something like this other than direct assignments?


Solution

  • I have only the Oracle (Sun) manual here, not from OpenVMS, but it implements the same VAX extension (completely non-standard!). There is no structure constructor described there, that you could use for creating values of structure in single expression.

    It also says:

    Record fields are not allowed in COMMON statements.

    Records and record fields are not allowed in DATA,EQUIVALENCE, or NAMELISTstatements.

    Record fields are not allowed in SAVE statement.

    If you can use a compiler which accepts Fortran 90 you could use

    type my_data
      integer*2   var1
      integer*2   var2
      character*5 NameTag
    end type
    
    type(my_data) :: OrganizedData
    
    OrganizedData  = my_data(1, 2, 'Fred')
    

    (I left the also non-standard * notation there.)