        subroutine tempfile(ifile,name)
	include 'Online.cmm'
	integer system
	character*40 name
        character*50 fname
	character*80 dname,wname
	character*80 gname
	character*80 string
        dname='/group/atlas/BOL/BOLTEMP/'//name
        wname='/group/atlas/BOL/BOLTEMP/'//'tempfile'
        fname='get '//name
        gname=fname//' tempfile'
         print *,gname
	print *,wname
	open(29,file='gettemp.exe')
	write(29,*)'open paling.nikhef.nl'
        write(29,*)'cd /projects/MDT/Data/BOLtemp/'
        write(29,*)'lcd /group/atlas/BOL/BOLTEMP'
        write(29,*)gname 
        write(29,*)'bye'
	close(29)
C ftp file always on itemploc flag
        if (itemploc.eq.1) then
	  open(ifile,file=dname)
	  read(ifile,'(a)',ERR=99,END=99)string
          rewind(ifile)
          print *,'Temp file available '
          goto 200
	endif
 99	continue
C if not there ftp file
	close(ifile)
	print *,'Temp file not there yet '
        istat = system
     +    ('rm /group/atlas/BOL/BOLTEMP/tempfile')
        istat = system ('ftp < gettemp.exe')
        istat = system 
     +    ('chmod g+w /group/atlas/BOL/BOLTEMP/tempfile')
        print *, 'ftp ended with status ', istat
	open(ifile,file=wname)
	read(ifile,'(a)',ERR=199,END=199)string
        rewind(ifile)
        print *,'Temp file available now'
        goto 200
C if not exist give message
 199	print *,' Temp file does not exist ',dname
 200	continue
        end


