This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / giopa / grfile.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:21:17  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.20  by  S.Giani
11 *-- Author :
12       SUBROUTINE GRFILE(LUN,CHFILE,CHOPTT)
13 C.
14 C.    ******************************************************************
15 C.    *                                                                *
16 C.    *       Routine to open a GEANT/RZ data base.                    *
17 C.    *                                                                *
18 C.    *       LUN logical unit number associated to the file           *
19 C.    *                                                                *
20 C.    *       CHFILE RZ file name                                      *
21 C.    *                                                                *
22 C.    *       CHOPT is a character string which may be                 *
23 C.    *          'N' To create a new file                              *
24 C.    *          'U' to open an existing file for update               *
25 C.    *          ' ' to open an existing file for read only            *
26 C.    *          'Q' The initial allocation (default 1000 records)     *
27 C.    *              is given in IQUEST(10)                            *
28 C.    *          'X' Open the file in exchange format                  *
29 C.    *          'I' Read all data structures from file to memory      *
30 C.    *          'O' Write all data structures from memory to file     *
31 C.    *                                                                *
32 C.    *    Note:                                                       *
33 C.    *         If options 'I' or 'O' all data structures are read or  *
34 C.    *            written from/to file and the file is closed.        *
35 C.    *         See routine GRMDIR to create subdirectories            *
36 C.    *         See routines GROUT,GRIN to write,read objects          *
37 C.    *                                                                *
38 C.    *    ==>Called by : <USER>                                       *
39 C.    *       Author    R.Brun  *********                              *
40 C.    *                                                                *
41 C.    ******************************************************************
42 C.
43 #include "geant321/gcbank.inc"
44       COMMON/QUEST/IQUEST(100)
45       CHARACTER*(*) CHFILE,CHOPTT
46       CHARACTER*8 CHOPT,CHTOP,CHTAGS(2)
47       CHARACTER*10 CHOPT1,CHOPT2
48       SAVE CHTAGS,CHTOP
49       DATA CHTAGS,CHTOP/'Object','Version','        '/
50 C.
51 C.    ------------------------------------------------------------------
52 C.
53 *
54       CHOPT=CHOPTT
55       CALL CLTOU(CHOPT)
56       IOPTN=INDEX(CHOPT,'N')
57       IOPTU=INDEX(CHOPT,'U')
58       IOPTQ=INDEX(CHOPT,'Q')
59       IOPTI=INDEX(CHOPT,'I')
60       IOPTO=INDEX(CHOPT,'O')
61       IF(IOPTN.EQ.0.AND.IOPTU.EQ.0)IOPTO=0
62       IF(IOPTN.NE.0)IOPTI=0
63 *
64 *          Open file
65 *
66       CHOPT2 = CHOPT//'XW'
67       CHOPT1 = CHOPT//'X'
68       CALL RZOPEN(LUN,CHTOP,CHFILE,CHOPT2,1024,ISTAT)
69       IF(ISTAT.NE.0)GO TO 99
70 *
71       IF(IOPTN.NE.0)THEN
72          IF(IOPTQ.NE.0)THEN
73             NQUOT=IQUEST(10)
74             IF(NQUOT.LT.100.OR.NQUOT.GT.100000)NQUOT=1000
75          ELSE
76             NQUOT=1000
77          ENDIF
78          CALL RZMAKE(LUN,CHTOP,2,'HI',CHTAGS,NQUOT,CHOPT1)
79       ELSE
80          CALL RZFILE(LUN,CHTOP,CHOPT1)
81       ENDIF
82 *
83 *           Read/write initialisation structures
84 *
85       IF(IOPTI.NE.0)THEN
86          CALL GRIN('INIT',0,' ')
87       ENDIF
88       IF(IOPTO.NE.0)THEN
89          CALL GROUT('INIT',1,' ')
90       ENDIF
91       IF(IOPTI.NE.0.OR.IOPTO.NE.0)THEN
92          CALL RZEND(CHTOP)
93          CLOSE(LUN)
94       ENDIF
95 *
96   99  END