HP OpenVMS Systems

ask the wizard
Content starts here

Program Sections (PSECTs) and COMMONs?

» close window

The Question is:

Dear Wizard,
We have something called a SYSTEL application - the backend is written
in FORTRAN, and the frontend in SYSTEL (3rd party).  The FORTRAN image is ran
 detached by a SYSTEL process, and it's multithreaded.
After migrating to Alpha,  we notice the common block values are global
and shareable between the threads, whereas on the VAX they are not.
Is this because of usage differences for the common block between VAX and
 Alpha?  We are  not linking with any .opt for these psects on the VAX, so we
didn't do any on the Alpha - are we missing on some attributes?
And of course, we would rather the common block values not globally shareable,
 the values are getting clobbered. I appreciate  any help/
suggestions for I'm a FORTRAn novice.

The Answer is :

  On OpenVMS, COMMON blocks are implemented as Program Sections
  (PSECTs) with the Overlay (OVR) PSECT attribute set.
  On OpenVMS VAX, Fortran gives COMMON blocks the Shared (SHR)
  attribute, which allows COMMON blocks to be linked into a
  shareable image and INSTALLed with the /SHARE and /WRITEABLE
  attributes.  This permits the data to be shared among multiple
  processes. However, the presence of the SHR attribute also prevents
  COMMON blocks from being linked into shareable images that are NOT
  also installed /WRITEABLE, where the data is meant to be accessed
  only within a single process, making it necessary to change the
  attribute to NOSHR in the majority of applications.
  The OpenVMS Alpha language compilers will generally default to NOSHR
  for the COMMON blocks.
  These (expected) SHR settings differences appear to be the direct
  opposite of what was reported, however.
  On both platforms, the PSECT attributes of COMMON blocks can be
  changed by means of the CDEC$ PSECT directive (in Fortran) or via
  the #pragma extern_model mechanism (in C), or via the PSECT_ATTR
  linker options file statement.
  You will want to contact the Compaq Customer Support Center, as
  particular details of the multithreading environment involved here
  will be required.  Additionally, details of the Fortran source and
  of any associated installed writeable images (COMMONs) will be of
  interest.  A reproducer would be quite useful.
  Also please see topic (2486).

answer written or last revised on ( 4-OCT-2001 )

» close window