Update master to aliroot
[u/mrichter/AliRoot.git] / DPMJET / openfile.f
index 2dbd952..585033c 100644 (file)
 *----------------------------------------------------------------------*
 *
       IMPLICIT NONE
+      LOGICAL EXISTS
+      INTEGER LNROOT
+      INTEGER LNBLNK
+      CHARACTER*1000 FILNAM
+      CHARACTER*1000 CHROOT
+      CHROOT=' '
+      CALL GETENVF('ALICE_ROOT',CHROOT)
+      LNROOT = LNBLNK(CHROOT)
+      IF(LNROOT.LE.0) THEN
+         FILNAM='dpmjet.dat'
+      ELSE
+         FILNAM=CHROOT(1:LNROOT)//'/DPMJET/dpmjet.dat'
+      ENDIF
+      INQUIRE(FILE=FILNAM,EXIST=EXISTS)
+      IF(.NOT.EXISTS) THEN
+         PRINT*,'***********************************'
+         PRINT*,'*           openfile              *'
+         PRINT*,'*        ---------------          *'
+         PRINT*,'*   File dpmjet.dat not found     *'
+         PRINT*,'*         Program STOP            *'
+         PRINT*,'*   Check ALICE_ROOT environment  *'
+         PRINT*,'*           variable              *'
+         PRINT*,'***********************************'
+         STOP
+      ENDIF
       OPEN (10, FILE="dpmjet.inp", STATUS="OLD")
-      OPEN (23, FILE="dpmjet.dat", STATUS="OLD")
+      OPEN (23, FILE=FILNAM, STATUS="OLD")
       RETURN
       END