C Program to show 29 ways Fortran uses the asterisk. This program is valid
C Fortran 2018, but its fixed source form, alternate return, and declarations
C beginning with character* are all obsolescent. Namelist first appeared in
C the F90 Fortran standard, class(*) and namelist with internal access in
C F2003, unlimited format in F2008, and type(*) and rank(*) in F2018. All the
C other uses of * were already in F77. though namelist I/O was an Oracle
C extension to F77 with a slightly different syntax.

      program test29stars
* Comments mark uses of * , as here:! Comment line, * character in it.  (1,2)
      character(2):: c,d='?'
      character(10):: b(4),ch
      integer j,k,n(2)
      data j,k/2*0/                 ! repeated value in data            (3)
      call input(n,'2*4',b,c,d,*666)! repeated value in list-directed input, 
C                                   ! alternate return                  (4,5)
      write(*,'(2i2,1x,4a)') n(1)*j,! default output unit ! multiply    (6,7)
     *      n(2)**k,' '//b          ! continuation line ! exponentiate  (8,9)
      stop
 666  print '(a)', ' * error in n'  ! in non-comment character string   (10)
      print '(*(i4))', n            ! unlimited format item             (11)

      contains

      subroutine input(n,a,b,c,d,*) ! dummy alternate return argument   (12)
      integer,intent(out)::n(*)     ! assumed-size array                (13)
      character,intent(in)::a*(*)   ! length selector ! assumed length
C                                        following variable name        (14,15)
      character*(*),intent(out)::b(:)! length selector ! assumed length
C                                        following character keyword    (16,17)
      type(*),intent(in)::c         ! assumed-type                      (18)
      character(2),intent(in)::d(..)
      integer:: i,nl(6)!!!=42
      integer,parameter:: e(*)=[1,2]! implied-shape array               (19)
      character(18)::nlin='&nlstuff nl=6*666/'! repeat in namelist input(20)
      namelist/nlstuff/nl
      class(*),allocatable:: f(:)   ! polymorphic entity                (21)
      read(nlin, nml=nlstuff)
      write(6, nml=nlstuff)         ! repeat in namelist output         (22)
      select rank(d)
      rank(*)                       ! rank selector                     (23)
      print "(a)",'This should not be printed!'
      end select
      read(a,*,iostat=i) n(1),n(2)  ! list-directed internal read       (24)
      if (i.ne.0) return 1
      print '(a)', 'Enter anything to continue.'
      read(*,'(a)',iostat=i)ch      ! default input unit                (25)
      write(b(1),'(i1)',iostat=i)42 ! integer output * if too big       (26) 
      write(b(2),'(f2.0)',iostat=i)42.0     ! real output * if too big  (27) 
      write(b(3),'(e10.4e1)',iostat=i)42e-20! real output * if too small(28)
      write(b(4),'(e8.4)',iostat=i)42.0     ! real output, bad format   (29)
      end subroutine input
      end program test29stars
 
