00001       PROGRAM MAIN
00002 
00003       IMPLICIT DOUBLE PRECISION (A-H,O-Z)
00004       COMMON / INOUT  / NINP,NOUT  
00005       DIMENSION  X(400),ER(100)
00006       CHARACTER*20 typop,file1,file2,file3,stop,merge
00007       DATA stop  /'stop'/
00008       DATA merge /'merge'/
00009 
00010       write(6,*) '>>>---------------------------------------<<<'
00011       write(6,*) '>>>        Welcome to   COMBINE           <<<'
00012       write(6,*) '>>>  Program for adding histogram files   <<<'
00013       write(6,*) '>>>---------------------------------------<<<'
00014       CALL GLK_Initialize
00015       NINP=  5           
00016       NOUT= 16           
00017       OPEN( NOUT, file='combine.out') 
00018       CALL GLK_SetNout(nout)
00019 
00020 
00021       write(6,*) '>>> Give name of the TARGET file'
00022       read(5,'(a)') file3
00023 
00024       write(6,*) '>>> add or merge?'
00025       read(5,'(a)') typop
00026 
00027       write(6,*) '>>> Give total number of histos'
00028       read(5,*) Ntot
00029 
00030 
00031       write(6,*) '>>> Give name of the FIRST histogram file on the disk'
00032       read(5,'(a)') file1
00033       NINPH=0 
00034 
00035       OPEN(10+NINPH,file=file1)
00036 
00037       write(6,*) '>>> restoring:: ', file1
00038       CALL GLK_hrfile(10+NINPH,' ',' ')
00039       CALL GLK_hrin(   0,9999,0)
00040 
00041 
00042  600  CONTINUE
00043 
00044       write(6,*) '>>> Give name of the NEXT histogram or type stop'
00045       read(5,'(a)') file2
00046       NINPH=NINPH+1
00047       IF(file2 .EQ. stop) GOTO 900
00048       IF(NINPH .EQ. Ntot) GOTO 900
00049 
00050       OPEN(10+NINPH,file=file2)
00051 
00052       CALL GLK_hrfile(10+NINPH,' ',' ')
00053       IF(typop .EQ. merge) THEN
00054 
00055          write(6,*) '>>> appending::    ', file2 
00056          CALL GLK_hrin(   0,9999,0)
00057       ELSE
00058 
00059          write(6,*) '>>> adding::    ', file2
00060          CALL GLK_hrin2(   0,9999,0)
00061       ENDIF
00062       GOTO 600
00063          
00064 
00065  900  CONTINUE
00066       write(6,*) '>>> Dumping result into::  ',file3
00067       NOUTH=7   
00068 
00069       OPEN(NOUTH,file=file3)
00070       REWIND(NOUTH)
00071 
00072       CALL GLK_hrfile(NOUTH,' ','N') 
00073       CALL GLK_hrout( 0,ICY,' ')       
00074       CALL GLK_hrend(' ')  
00075 
00076       CLOSE(NOUT)              
00077 
00078       END
00079