C Collection of code snippets by Arne Vajhøj 
C (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
      program p2
      implicit none
      integer*4 fc2s,fs2c
      character*6 c2smbx,s2cmbx
      parameter (fc2s=11,
     +           fs2c=12,
     +           c2smbx='C2SMBX',
     +           s2cmbx='S2CMBX')
      integer*4 msglen
      character*100 outmsg
      character*1000 inmsg
c  silly hack to avoid breaking lines over 80 characters
      open(unit=6,file='sys$output',status='new',
     +  recl=132,carriagecontrol='list')
c  open mailboxes
      open(unit=fc2s,file=c2smbx//':',status='new')
      open(unit=fs2c,file=s2cmbx//':',status='old')
c  write
      outmsg='Hi from Fortran!'
      msglen=len('Hi from Fortran!')
      write(unit=fc2s,fmt='(a)') outmsg(1:msglen)
c  read
100   read(unit=fs2c,fmt='(q,a)',end=200) msglen,inmsg
      if(inmsg(1:msglen).eq.'*') goto 200
      write(unit=6,fmt='(a)') '|'//inmsg(1:msglen)//'|'
      goto 100
c  close mailboxes
200   close(unit=fc2s)
      close(unit=fs2c)
c
      end
