      SUBROUTINE MASKCODE(filename,mskcd)

C     MASKCODE TAKES A MASK FILE NAME AND ASSIGNS A MASK CODE
C     ACCORDING TO THE SUFFIX:
C
c                1 - (.s,index,.p) sequential mask
c                2 - (.d, .2, .l) two integer mask
c                3 - (.3) three integer
c                4 - (.4) four integer
c                5 - (.c) one integer,one string (15 char)
c                6 - (.c2) two string
c                7 - (2ri) two reals, one integer
c                8 - (2r2i) two reals, two integers
c                9 - (c2i) one string, two integers
c               10 - (c1) one string
c               11 - (.i, .a) ASCII
c               12 - (ci) one integer, one string (80 char)

      character*80 filename

c****************************************************
c
c     Find beginning of suffix (after '.')
c
c****************************************************

      nspace = 0

      do 50 n=1,80
       if ( filename(n:n).eq. '.' ) nspace=n
50    continue
      n=nspace

      call findlastchar(ll,filename,80) !- fixed (15-may-01 TOB)

c****************************************************
c
c    Set mask code number
c
c****************************************************

      if ( n .eq. 0 .or. filename(n+1:n+1) .eq. 's'
     *    .or. filename(n+1:n+1) .eq. 'p' ) then
       mskcd=1
      elseif ( filename(n+1:n+1) .eq. 'd' ) then
       mskcd=2
      elseif ( filename(n+1:n+1) .eq. 'l' ) then
       mskcd=2
      elseif ( filename(n+1:n+1) .eq. '2'.and.
     * ll .eq. n+1 ) then
       mskcd=2 
      elseif ( filename(n+1:n+1) .eq. '3' ) then
       mskcd=3
      elseif ( filename(n+1:n+1) .eq. '4' ) then
       mskcd=4
      elseif ( filename(n+1:n+2) .eq. 'c2' ) then
       mskcd=6
      elseif ( filename(n+1:n+3) .eq. 'c2i' ) then
       mskcd=9
      elseif ( filename(n+1:n+2) .eq. 'c1' ) then
       mskcd=10
      elseif ( filename(n+1:n+2) .eq. 'ci' ) then
       mskcd=12
      elseif ( filename(n+1:n+1) .eq. 'c') then
       mskcd=5
      elseif ( filename(n+1:n+3) .eq. '2ri' ) then
       mskcd=7
      elseif ( filename(n+1:n+4) .eq. '2r2i' ) then
       mskcd=8
      elseif ( filename(n+1:n+1) .eq. 'i' .or. 
     *         filename(n+1:n+1) .eq. 'a' ) then
       mskcd=10
      else
       mskcd=1
      endif

      return
      end
