C Collection of code snippets by Arne Vajhøj 
C (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
      program p2z
      implicit none
      include '($secdef)'
      character*1 name
      parameter (name='M')
      integer*4 range(2),stat
      integer*4 sys$mgblsc
      external sys$mgblsc
c  map global section
      range(1)=0
      range(2)=0
      stat=sys$mgblsc(%ref(range),%ref(range),,
     +                %val(SEC$M_EXPREG+SEC$M_WRT),%descr(name),,)
      if((stat.and.1).eq.0) write(*,*) 'sys$mgblsc stat=',stat
      call action(%val(range(1)))
      end
c
      subroutine action(shrmem)
      implicit none
      integer*4 blocksize,blocks,shrmemsiz,maxmsgsiz,maxmsgs
      parameter (blocksize=8192,
     +           blocks=10,
     +           shrmemsiz=blocks*blocksize,
     +           maxmsgsiz=100,
     +           maxmsgs=shrmemsiz/maxmsgsiz)
      structure /shrmemtyp/
        character*100 msg(maxmsgs)
      end structure
      record /shrmemtyp/shrmem
      integer*4 i,msglen
c  write to global section
      i=0
100   i=i+1
      if(shrmem.msg(i)(1:1).ne.char(0)) goto 100
      shrmem.msg(i)='Hi from Fortran (alt)!'//char(0)
c  dump global section
      do 200 i=1,maxmsgs
        if(shrmem.msg(i)(1:1).ne.char(0)) then
          msglen=index(shrmem.msg(i),char(0))
          write(*,*) '|'//shrmem.msg(i)(1:msglen)//'|'
        endif
200   continue
      end
