!     last update March 6 2000 add default values for CMAP
      SUBROUTINE FILE(ientry)
!
!  Define input output units
!
      USE BLKMAP
      USE BLK1MOD
!      INCLUDE 'BLK1.COM'
      INCLUDE 'BFILES.I90'
!IPK APR94
      COMMON /RECOD/ IRECD,TSPC
      common /cols/ ibakk,icolr,iblkk 
      COMMON /PAGE/ XL,XH,YL,YH
!
      CHARACTER*80 LIND
!IPK APR94      CHARACTER*40  FNAM,FNAMB
      CHARACTER*40  FNAM,FNAMB,FNAMC
      CHARACTER*3 SUB
      CHARACTER*1 ANS
      LOGICAL*4 EXST,STATM
      data ihere/0/
      if(ihere .eq. 1) return
      mpnam='elt.mpb'
      ibakk=8
      icolr=11
      iblkk= 9
      xl=0.
      yl=0.
      xh=HSIZE
      yh=8.0
	  ielvsw=0
	  if(ientry .eq. 1) then
        ihere=1
!      MAXPL=200000
	  MAXELMP=100000

  	    ALLOCATE (NOPEL(MAXELMP,3),XCEN(MAXELMP),YCEN(MAXELMP)&
        ,RADS(MAXELMP) ,NKEY(MAXELMP),CMAP(MAXPL,2)&
        ,XMAP(MAXPL),YMAP(MAXPL),VAL(MAXPL))

	    ALLOCATE (imap(maxpl),NCRS(MAXPL))
        
        ALLOCATE (VALLIN(MAXLIN),XCOL(MAXLIN),YCOL(MAXLIN))
        RADS=0.
        XCEN=0.
        YCEN=0.
      endif

!ipk jan98
      OPEN(UNIT=90,FILE='messgen.out',STATUS='UNKNOWN', IOSTAT=iost)
	  if(iost .gt. 0) then
        OPEN(UNIT=90,FILE='messgen1.out',STATUS='UNKNOWN', IOSTAT=iost)
        if(iost .gt. 0) then
          OPEN(UNIT=90,FILE='messgen2.out',STATUS='UNKNOWN', IOSTAT=iost)
          if(iost .gt. 0) then
            write(*,*) 'ERROR UNABLE TO OPEN MESSGEN.OUT FILE'
            write(*,*) 'PRESS RETURN TO END'
            read(*,'(I5)') junk
            STOP
		  endif
        endif
      endif
!ipk jan98
      write(lind,6010)
 6010 format('   Compilation limits are')
           call symbl(1.1,1.5,0.20,LIND,0.0,80)
      write(lind,6110) maxe
 6110 FORMAT(      '   Maximum elements =',i8)
           call symbl(1.1,1.2,0.20,LIND,0.0,80)
      write(lind,6111) maxp
 6111 FORMAT(  '   Maximum nodes    =',i8)
           call symbl(1.1,0.9,0.20,LIND,0.0,80)

!
!  Open files
!
      IBAK = 21
      OPEN(IBAK,FILE='ELT.BAK',STATUS='UNKNOWN',FORM='UNFORMATTED',IOSTAT=iost)
	  if(iost .gt. 0) then
        OPEN(IBAK,FILE='ELT1.BAK',STATUS='UNKNOWN',FORM='UNFORMATTED',IOSTAT=iost)
  	    if(iost .gt. 0) then
          OPEN(IBAK,FILE='ELT2.BAK',STATUS='UNKNOWN',FORM='UNFORMATTED',IOSTAT=iost)
          if(iost .gt. 0) then
            write(*,*) 'ERROR UNABLE TO OPEN ELT.BAK FILE'
            write(*,*) 'PRESS RETURN TO END'
            read(*,'(I5)') junk
            STOP
		  endif
        ENDIF
      ENDIF
!      OPEN(IBAK,FILE='ELT.BAK',STATUS='UNKNOWN',FORM='BINARY')
 
      IS11=94
      INQUIRE(FILE='startup.dat',EXIST= EXST)
      IF(EXST) THEN
        OPEN(IS11 ,FILE='startup.dat',STATUS='OLD',FORM='FORMATTED')
      ELSE
        IS11=0
      ENDIF
 
!  Initialize variables
      NCLM=0
 
!ipk may94 add 2 lines below
      XREF=0.
      YREF=0.
      MNP = MAXP
      MEL = MAXE
!!  uncertain       call INITSIZ(0,0,1)
      nmapf=1
      NSIGF=1
      DO I=1,MNP
         XUSR(I) = -1.D20
         YUSR(I) = -1.D20
         CORD(I,1) = -1.D20
         CORD(I,2) = -1.D20
         WD(I) = -9999.
         LAY(I) = -9999
         WIDTH(I) = 0.0
         SS1(I) = 0.0
         SS2(I) = 0.0
         WIDS(I) = 0.0
         WIDBS(I)=0.
         SSO(I)=0.
         INSKP(I) = 1
         INEW(I) = 0
!ipk mar02
         lock(i)=0
         bs1(I)=0.
      ENDDO   
!
      DO I=1,MEL
         DO K=1,8
            NOP(I,K) = 0
         ENDDO   
!
         IEM(I) = 0
         IMAT(I) = 0
         THTA(I)=0.
         XC(I) = -1.E20
         YC(I) = -1.E20
         IESKP(I) = -1
      ENDDO   
!
      MLIN = MAXLIN
      DO I=1,MLIN
         LINTYP(I) = -999
      ENDDO
!IPK OCT96
      DO I=1,10
        ICOLON(I)=1
      ENDDO

!ipk mar00 define default values for CMAP 
      DO J=1,MAXPTS 
        CMAP(J,1) = -1.e20
        CMAP(J,2) = -1.e20
      enddo


      RETURN
      END
