$ fortran/object=z sys$input
      PROGRAM Z
      CALL S1(1,1)
      CALL S1(2,1,2)
      CALL S1(3,1,2,3)
      CALL S2(1)
      CALL S2(1,2)
      CALL S2(1,2,3)
      CALL S3(,,)
      CALL S3(1,,)
      CALL S3(,2,)
      CALL S3(,,3)
      CALL S3(%VAL(0),%VAL(0),%VAL(0))
      CALL S3(1,%VAL(0),%VAL(0))
      CALL S3(%VAL(0),2,%VAL(0))
      CALL S3(%VAL(0),%VAL(0),3)
*      CALL S4(.FALSE.) ! this will fail
      CALL S4(.TRUE.,'ABCD')
      END
C
      SUBROUTINE S1(N,I1,I2,I3)
      INTEGER*4 N
      INTEGER*4 I1,I2,I3 ! any datatype except character
      GOTO (100,200,300,400) N+1
100   WRITE(*,*) N
      RETURN
200   WRITE(*,*) N,I1
      RETURN
300   WRITE(*,*) N,I1,I2
      RETURN
400   WRITE(*,*) N,I1,I2,I3
      RETURN
      END
C
      SUBROUTINE S2(I1,I2,I3)
      INTEGER*4 I1,I2,I3 ! any datatype except character
      INTEGER*4 N
      INTEGER*4 IARGCOUNT ! delete declaration for FORTRAN 6.1+
      N=IARGCOUNT()
      GOTO (100,200,300,400) N+1
100   WRITE(*,*) N
      RETURN
200   WRITE(*,*) N,I1
      RETURN
300   WRITE(*,*) N,I1,I2
      RETURN
400   WRITE(*,*) N,I1,I2,I3
      RETURN
      END
C
      SUBROUTINE S3(I1,I2,I3)
      INTEGER*4 I1,I2,I3 ! any datatype except character
      IF(%LOC(I1).GE.512) WRITE(*,*) I1
      IF(%LOC(I2).GE.512) WRITE(*,*) I2
      IF(%LOC(I3).GE.512) WRITE(*,*) I3
      RETURN
      END
C
      SUBROUTINE S4(FLAG,STR)
      LOGICAL*4 FLAG
      CHARACTER*(*) STR
      IF(FLAG) WRITE(*,*) STR
      RETURN
      END
$
$ if 0 ! FORTRAN 6.1
$ then
$ link z
$ else
$ macro/object=zz sys$input
        .title  zz
        $SFDEF
        .psect  $CODE quad,pic,con,lcl,shr,exe,nowrt
        .entry  iargcount,^m<>
        movl    @SF$L_SAVE_AP(fp),r0
        ret
        .end
$
$ link z+zz
$ endif
$ run z
$ exit
