      subroutine lirdata
      use mod_dolo
      IMPLICIT REAL*8(A-H,O-X,Z),logical*1(y)
      character(100000) namel
      logical lex
      common /pr/ nprint
      ifilpr=97
!
!----------------------------------------------
! Initialization
!----------------------------------------------
!
      datlist=' '
      datlist0=' '
! read CurrDir
      call system('echo $CurrDir > CurrDir_name')
      open(99,file='CurrDir_name',status='old')
      read(99,'(a)') Currdir
      close(99,status='delete')
      if(CurrDir==' ') then
         print*,'CurrDir is undefined. Export CurrDir '//
     *   'and WorkDir before running dolo, or give them in data'
         stop
      endif
      l=len_trim(currdir)
      if(currdir(l:l)/='/') currdir(l+1:l+1)='/'
! read workdir
      call system('echo $WorkDir > WorkDir_name')
      open(99,file='WorkDir_name',status='old')
      read(99,'(a)') workdir
      l=len_trim(workdir)
      if(workdir(l:l)/='/') workdir(l+1:l+1)='/'
      close(99,status='delete')
! read prefix
      call system('echo $Project > Prefix_name')
      open(99,file='Prefix_name',status='old')
      read(99,'(a)') prefix
      !close(99,status='delete')
      
!
!-------------------------------------------------
! Run interactive or non interactive dolo?
!-------------------------------------------------
!
      inquire(file=trim(workdir)//'INTERACTIVE_DOLO_ON',exist=lex)
      if(lex) then
         interactive=.true.
         call titre('Interactive run#',40)
         open(99,file=trim(workdir)//'INTERACTIVE_DOLO_ON',status='old')
         close(99,status='delete')
      endif
!
!----------------------------------------------------------
! File DOLOIN exists?
!----------------------------------------------------------
!
      inquire(FILE=trim(currdir)//'/DOLOIN',EXIST=lex)
      if(.not.lex) then
         print*,'file DOLOIN does not exist'
         stop
      endif
!
!----------------------------------------------------------
! Open data file
!----------------------------------------------------------
!

      open(1,form='formatted',status='old',file=trim(currdir)//'DOLOIN')
      call LECNAM('&SMU ',namel,1,ierr,1)
!
!--------------------------------------------
! Is environnement correctly defined?
!--------------------------------------------
!
    
!   WorkDir
      call namela(namel,WORKDIR,'WORKDIR')
      if(WorkDir==' ') then
         print*,'WorkDir is undefined. Export CurrDir '//
     *   'and WorkDir before running dolo'
         stop
      endif
      l=len_trim(workdir)
      if(workdir(l:l)/='/') workdir(l+1:l+1)='/'
!   prefix
      call namela(namel,PREFIX,'PREFIX')
      if(prefix==' ') then
         print*,'Project is undefined. Export Project '//
     *   'before running dolo'
         stop
      endif
      l=len_trim(workdir)
      if(prefix(l:l)/='.') prefix=trim(prefix)//'.'
      call titre('ENVIRONNEMENT#prefix= '//trim(prefix)//
     *'#CurrDir: '//trim(CurrDir(1:65))//
     *'#WorkDir: '//trim(WorkDir(1:65))//'#',
     *70)
!
!----------------------------------------------------------
! Begin read namelist
!----------------------------------------------------------
!
      nprint=0
      yes=.false.
      ychol=.false.
      yopm=.false.
      call namell(namel,YGCAS,'YGCAS',4)
      call namell(namel,YCHOL,'YCHOL',4)
      call namell(namel,YOPM,'YOPM',4)
      call namell(namel,YES,'YES',4)
      call nameli(namel,NPRINT,'NPRINT',4)
      call namela(namel,SCFORB,'ORB')
      call namell(namel,LOC_ACTIVES,'LOC_ACTIVES',4)
      !scforb=trim(workdir)//trim(scforb)
      rewind 1
      return
      end
