***
*     s3code.f
***

*+DECK,S3MATE.
*CMZ :  2.05/14 20/05/95  06.11.49  by  Hal Kalechofsky
*CMZ :  2.05/12 16/05/95  22.11.16  by  Hal Kalechofsky
*CMZ :  2.05/06 23/04/95  11.05.13  by  Aris Angelis
*CMZ :  1.01/00 14/07/94  17.43.14  by  Hal Kalechofsky
*CMZ :  1.00/00 30/11/90  15.16.25  by  Nick van Eijndhoven (CERN)
*-- Author :    Nick van Eijndhoven (CERN)   30/11/90
      SUBROUTINE S3MATE

C
C ***********************************************************************
C *                                                                     *
C *              Definition of Material for MSAC Code                   *
C *                                                                     *
C ***********************************************************************
C *                                                                     *
C *  CALLED BY     : SXMATE                                             *
C *  CONTACT       :                                                    *
C *                                                                     *
C *  ORIGIN        : NICK VAN EIJNDHOVEN                                *
C *  REWRITTEN     :                                                    *
C *  MODIFICATIONS :                                                    *
C *                                                                     *
C ***********************************************************************
C

      IMPLICIT NONE
      REAL AM(3),ZM(3),WM(3),DM
      REAL AP(2),ZP(2),WP(2),DP


* --- Mylar windows and mirrors (C5H4O2) ---
      DATA AM /12.,1.,16./,ZM /6.,1.,8./,WM /5.,4.,2./,DM /1.39/

* --- Polystyrene WLS plate (CH)
      DATA AP /12.,1./, ZP /6.,1./, WP /1.,1./, DP /1.032/
*
* ----------------------------------------------------------------------
*

* --- Define the various materials for GEANT ---

* --- This is really Argon. Commented is Ne.
      CALL GSMATE(301,'Ar $', 39.95,18.,1.782E-3,20027.,999.,0,0)
C     CALL GSMATE(301,'Ne $', 20.18,10.,9.005E-4,32155.,999.,0,0)

      CALL GSMATE(302,'Fe $', 55.85,26.,7.870, 1.76,17.1,0,0)
      CALL GSMATE(303,'G10$', 20.00,10.,1.700,19.40,999.,0,0)

      CALL GSMATE(398,'Vac$',1.E-16,1.E-16,1.E-16,1.E16,1.E16,0,0)
      CALL GSMATE(399,'Air$',14.61,7.3,0.001205,30420.,67500.,0,0)

* --- Define the various mixtures for GEANT ---

      CALL GSMIXT(300,'Mylar$',AM,ZM,DM,-3,WM)
      CALL GSMIXT(304,'Polystyrene $',AP,ZP,DP,-2,WP)
C
      RETURN
      END


*+DECK,S3TMED.
*CMZ :  2.06/20 23/08/95  16.17.41  by  H. Kalechofsky/Y. Foka
*CMZ :  2.05/14 20/05/95  06.11.49  by  Hal Kalechofsky
*CMZ :  2.05/12 16/05/95  22.11.16  by  Hal Kalechofsky
*CMZ :  2.05/06 19/04/95  11.04.04  by  Aris Angelis
*CMZ :  1.01/00 14/07/94  17.34.15  by  Hal Kalechofsky
*CMZ :  1.00/00 30/11/90  15.16.25  by  Nick van Eijndhoven (CERN)
*-- Author :    Nick van Eijndhoven (CERN)   30/11/90
      SUBROUTINE S3TMED

C
C ***********************************************************************
C *                                                                     *
C *              Definition of Media  for MSAC Code                     *
C *                                                                     *
C ***********************************************************************
C *                                                                     *
C *  CALLED BY     : SXTMED                                             *
C *  CONTACT       :                                                    *
C *                                                                     *
C *  ORIGIN        : NICK VAN EIJNDHOVEN                                *
C *  REWRITTEN     :                                                    *
C *  MODIFICATIONS :                                                    *
C *                                                                     *
C ***********************************************************************
C

      IMPLICIT NONE

      CALL GSTMED(300,'Mylar   $',300,0,0,0.,1.,0.1,0.1,1.E-4,5.E-4,0,0)
      CALL GSTMED(301,'Gas     $',301,0,0,0.,1.,0.1,0.1, 0.01,   1.,0,0)
      CALL GSTMED(302,'Fe mesh $',302,0,0,0.,1.,0.1,0.1,1.E-4,5.E-4,0,0)
      CALL GSTMED(303,'G10 fram$',303,0,0,0.,1.,0.1,0.1, 0.10,  0.1,0,0)
      CALL GSTMED(305,'Gas sen $',301,1,0,0.,1.,0.1,0.1, 0.01,   1.,0,0)

      CALL GSTMED(398,'Vacuum  $',398,0,0,0.,1.,0.1,0.1,0.1,0.1,0,0)
      CALL GSTMED(399,'Air gaps$',399,0,0,0.,1.,0.1,0.1,0.1,0.1,0,0)

      CALL GSTMED(304,'Polystyrene $',304,0,0,0.,1.,0.1,0.1,0.1,0.1,0,0)

      RETURN
      END


*+DECK,S3GEOM.
*CMZ :  2.05/33 22/06/95  14.44.49  by  Hal Kalechofsky
*CMZ :  2.05/17 04/06/95  18.26.45  by  Hal Kalechofsky
*CMZ :  2.05/14 20/05/95  06.11.49  by  Hal Kalechofsky
*CMZ :  2.05/12 17/05/95  14.36.04  by  Hal Kalechofsky
*CMZ :  2.05/06 23/04/95  06.15.21  by  Aris Angelis
*CMZ :  1.01/00 17/07/94  18.36.55  by  Hal Kalechofsky
*CMZ :  1.00/00 05/07/93  15.43.49  by  Nick van Eijndhoven (RUU/CERN)
*-- Author :    Nick van Eijndhoven (CERN)   03/12/90
      SUBROUTINE S3GEOM



C
C ***********************************************************************
C *                                                                     *
C *              Definition of  MSAC Geometry                           *
C *                                                                     *
C ***********************************************************************
C *                                                                     *
C *  CALLED BY     : SXGEOM                                             *
C *  CONTACT       :                                                    *
C *                                                                     *
C *  ORIGIN        : NICK VAN EIJNDHOVEN                                *
C *  COMPLETELY REWRITTEN : ARIS L. S. ANGELIS                          *
C *  MODIFICATIONS :
C *                                                                     *
C ***********************************************************************
C
C      IMPLICIT NONE
*KEEP,GCONST.
      COMMON/GCONST/PI,TWOPI ,PIBY2,DEGRAD,RADDEG,CLIGHT ,BIG,EMASS
      COMMON/GCONSX/EMMU,PMASS,AVO
C
*KEEP,SCXGEO.
C --- Common which contains some general geometry parameters ---
      REAL DWA98,DWMAG,DTARG
     $,    DWA98X,DWA98Y,DWA98Z
     $,    DMAGNX,DMAGNY,DMAGNZ
     $,    DTARGX,DTARGY,DTARGZ
     $,    XTARG,YTARG,ZTARG,XMAG,YMAG,ZMAG
      COMMON /SCXGEO/ DWA98(3),DWMAG(3),DTARG(3)
     $,               DWA98X,DWA98Y,DWA98Z
     $,               DMAGNX,DMAGNY,DMAGNZ
     $,               DTARGX,DTARGY,DTARGZ
     $,               XTARG,YTARG,ZTARG,XMAG,YMAG,ZMAG
C
*KEEP,SC3POS.
C --- Common which contains the chamber positions in the WA98 frame ---
      INTEGER MXCHAM,MXCAME
      PARAMETER(MXCHAM=6,MXCAME=11)
      REAL XC10,YC10,ZC10,XC20,YC20,ZC20
     $,    XC30,YC30,ZC30,XC40,YC40,ZC40
     $,    XC50,YC50,ZC50,XC60,YC60,ZC60
     $,    XC70,YC70,ZC70
     $,    XC21,YC21,ZC21,XC31,YC31,ZC31
     $,    XC41,YC41,ZC41,XC51,YC51,ZC51
      COMMON /SC3POS/ XC10,YC10,ZC10,XC20,YC20,ZC20
     $,    XC30,YC30,ZC30,XC40,YC40,ZC40
     $,    XC50,YC50,ZC50,XC60,YC60,ZC60
     $,    XC70,YC70,ZC70
     $,    XC21,YC21,ZC21,XC31,YC31,ZC31
     $,    XC41,YC41,ZC41,XC51,YC51,ZC51
C
C----
      real phi2

C**> Centres of chamber ionisation gaps relative to target.
      DIMENSION ZCENT(1:7),XCENT(1:7)
      DATA ZCENT / 592.09,  615.72,  703.29,
     &             822.43,  941.56, 1060.70, 1179.83 /
      DATA XCENT / -154.39, -162.53, -213.83,
     &             -254.85, -295.88, -336.90, -377.92 /
C**> Tilt angle of chambers relative to beam line (degrees).
      DATA ANGLEB /19./
C**> Forward tilt angle of mirrors relative to chambers (degrees).
      DATA ANGLEM /42./
C**> Distance to lift mirrors relative to corresponding chamber centre (cm).
      DATA YLIFT /11./
C**> Straight line distance between the front face of the small light
C**> chamber and the front face of the first large light chamber, and
C**> between the front faces of the large light chambers (cm).
      DATA D37 /126./, D23 /99.5/
C**> Distance (in cm) from centre of chamber ionisation gap to
C**> closest mylar window (upstream).
      DATA DCOUT /2.7/
C**> Z of Magnet centre relative to target (cm).
      DATA ZMAGNT /328./
C**> Overall chamber box, including frames, half-lengths in X,Y,Z.
      DIMENSION D37CH(1:3),D12CH(1:3)
      DATA D37CH  /92.0, 76.0, 7.18 /  ! For large light chambers.
      DATA D12CH  /70.0, 56.5, 5.00 /  ! For small light/pad chamber.
C*> Horizontal and vertical large light chamber frame boxes,half-lengths, 1cm
C**> left off on each side in X and Y to account for the G10 border pieces.
      DIMENSION D37HF(1:3),D37VF(1:3)
      DATA D37HF  /91.0,  7.0, 7.18 /
      DATA D37VF  / 5.0, 61.0, 7.18 /
C**> Horizontal and vertical small light/pad chamber frame boxes,half-lengths,
C**> 1cm left off on each side in X and Y to account for the G10 border pieces.
      DIMENSION D12HF(1:3),D12VF(1:3)
      DATA D12HF  /69.0,  6.0, 5.00 /
      DATA D12VF  / 4.0, 43.5, 5.00 /
C**> Air box volume per G10 honeycombe cell such that average honeycombe
C**> density of chamber frames is 48 kg/m**3.
C**> For large light chambers 1.26 cm left as solid G10 at each end along Z to
C**> simulate the three 4 mm solid G10 frames + total skin thickness of 1.32 cm.
      DIMENSION D37HO(1:3)
      DATA D37HO / 0.493, 0.493, 5.92 /
C**> For small light/pad chambers assume total skin thickness + any solid G10
C**> frames scale with overall chamber thickness relative to large chambers.
C**> => For small light/pad chambers 0.88 cm left as solid G10 at each end along Zto
      DIMENSION D12HO(1:3)
      DATA D12HO / 0.493, 0.493, 4.12 /
C**> Active gas (Argon) box half-lengths.
      DIMENSION D37NE(1:3),D12NE(1:3)
      DATA D37NE / 80.0, 60.0, 7.18 / ! For large light chambers.
      DATA D12NE / 60.0, 42.5, 5.00 / ! For small light/pad chambers.
C**> Double flow mylar window box half-lengths.
      DIMENSION D37MW(1:3),D12MW(1:3)
      DATA D37MW / 80.0, 60.0, 0.0050 / ! For large light chambers.
      DATA D12MW / 60.0, 42.5, 0.0050 / ! For small light/pad chambers.
C**> Half-lengths of Fe plate of equivalent thickness = 0.00990 cm
C**> simulating the 12 meshes of the large light chambers.
      DIMENSION D37FE(1:3)
      DATA D37FE / 80.0, 60.0, 0.004950 /
C**> Half-lengths of Fe plate of equivalent thickness = 0.00825 cm
C**> simulating the 10 meshes of the small light/pad chambers.
      DIMENSION D12FE(1:3)
      DATA D12FE / 60.0, 42.5, 0.004125 /
C**> Half-lengths of sensitive fake plane at centre of ionisation gap.
      DIMENSION D37SN(1:3)
      DATA D37SN / 80.0, 60.0, 0.001 /
      DIMENSION D12SN(1:3)
      DATA D12SN / 60.0, 42.5, 0.001 /
C**> Half-lengths of polystyrene box simulating the WLS at edge of light
C**> chambers (1 cm missing off each end in x to allow for gas circulation).
      DIMENSION D37WL(1:3),D12WL(1:3)
      DATA D37WL / 79.0, 60.0, 0.05 / ! Large light chambers.
      DATA D12WL / 59.0, 42.5, 0.05 / ! Small light chambers.
C**> Half-lengths of Cu plate simulating the pad plane.
Cc    DIMENSION DPACU(1:3)
Cc    DATA DPACU / 60.0, 42.5, 0.0100 /
C**> Overall mirror box containing Al-mylar mirror plus frames, half-lengths.
      DIMENSION D37MR(1:3),D12MR(1:3)
      DATA D37MR / 90.0, 75.0, 0.5105 / ! For mirror behind large light chambers.
      DATA D12MR / 69.0, 56.0, 0.5105 / ! For mirror behind small light chamber.
C**> Half-lengths of horizontal, vertical and spine frame boxes for mirror.
C**> For mirror behind large light chambers.
      DIMENSION DM37HF(1:3),DM37VF(1:3),DM37SF(1:3)
      DATA DM37HF / 90.0,  5.0,  0.5080 /
      DATA DM37VF /  5.0, 65.0,  0.5080 /
      DATA DM37SF /  2.5, 65.0,  0.5080 /
C**> For mirror behind small light chambers.
      DIMENSION DM12HF(1:3),DM12VF(1:3),DM12SF(1:3)
      DATA DM12HF / 69.0,  5.0,  0.5080 /
      DATA DM12VF /  5.0, 46.0,  0.5080 /
      DATA DM12SF /  2.5, 46.0,  0.5080 /
C**> Half-lengths of air cube box inserted per 1x1 cm frame cell to simulate
C**> honeycombe in mirror frames (density = 3 kg/m**2 for 1 cm thick frame sheets).
      DIMENSION DM37HO(1:3),DM12HO(1:3)
      DATA DM37HO / 0.454,  0.454,  0.5080 / ! For mirror behind large light chambers.
      DATA DM12HO / 0.454,  0.454,  0.5080 / ! For mirror behind small light chamber.
C**> Half-lengths of box simulating the Al-mylar reflective sheet.
      DIMENSION DM37AL(1:3),DM12AL(1:3)
      DATA DM37AL / 90.0, 75.0,  0.0025 / ! For mirror behind large light chambers.
      DATA DM12AL / 69.0, 56.0,  0.0025 / ! For mirror behind small light chamber.
cC**> When running with mirrors upright...
c      D37MR(3)=D37MR(3)*1.414
c      D12MR(3)=D12MR(3)*1.414
c      DM37HF(3)=DM37HF(3)*1.414
c      DM37VF(3)=DM37VF(3)*1.414
c      DM37SF(3)=DM37SF(3)*1.414
c      DM12HF(3)=DM12HF(3)*1.414
c      DM12VF(3)=DM12VF(3)*1.414
c      DM12SF(3)=DM12SF(3)*1.414
c      DM37HO(3)=DM37HO(3)*1.414
c      DM12HO(3)=DM12HO(3)*1.414
c      DM37AL(3)=DM37AL(3)*1.414
c      DM12AL(3)=DM12AL(3)*1.414
c      D37MR(2)=D37MR(2)*0.707
c      D12MR(2)=D12MR(2)*0.707
c      DM37HF(2)=DM37HF(2)*0.707
c      DM37VF(2)=DM37VF(2)*0.707
c      DM37SF(2)=DM37SF(2)*0.707
c      DM12HF(2)=DM12HF(2)*0.707
c      DM12VF(2)=DM12VF(2)*0.707
c      DM12SF(2)=DM12SF(2)*0.707
c      DM37HO(2)=DM37HO(2)*0.707
c      DM12HO(2)=DM12HO(2)*0.707
c      DM37AL(2)=DM37AL(2)*0.707
c      DM12AL(2)=DM12AL(2)*0.707
C----
C**> Define the large light chamber box volume and fill with G10.
      CALL GSVOLU('CH37','BOX ',303,D37CH,3,I)


C**> Define the frames for the large light chamber.
C**> The horizontal and vertical G10 honeycombe frame structures.
      CALL GSVOLU('F37H','BOX ',303,D37HF,3,I)
      CALL GSVOLU('F37V','BOX ',303,D37VF,3,I)
C**> Divide the large light chamber frame boxes in 1x1 cm cells in X-Y.
C**> The horizontal frames.
      CALL GSDVN('S37H','F37H',14,2)
      CALL GSDVN('C37H','S37H',182,1)
C**> The vertical frames.
      CALL GSDVN('S37V','F37V',122,2)
      CALL GSDVN('C37V','S37V',10,1)
C**> Put a box full of air in each cell to simulate the honeycombe. This is
C**> assumed to simulate also the frames made out of the equal density foam.
      CALL GSVOLU('HO37','BOX ',399,D37HO,3,I)
      CALL GSPOS('HO37',1,'C37H',0.,0.,0.,0,'ONLY') ! Horizontal frames.
      CALL GSPOS('HO37',1,'C37V',0.,0.,0.,0,'ONLY') ! Vertical frames.
C**> Create the Ar box to simulate the large light chamber active volume.
      CALL GSVOLU('NE37','BOX ',301,D37NE,3,I)
C**> Create the box to simulate the large light chamber mylar windows.
      CALL GSVOLU('MW37','BOX ',300,D37MW,3,I)
C**>  Create a central iron plate to simulate the large light chamber meshes.
      CALL GSVOLU('FE37','BOX ',302,D37FE,3,I)
C**>  Create a sensitive plane to record hits.
      CALL GSVOLU('SN37','BOX ',305,D37SN,3,I)
C**> Create a polystyrene 1mm thick box to simulate the large light chamber WLS.
      CALL GSVOLU('WL37','BOX ',304,D37WL,3,I)
C**> Construct the interior of the large light chamber gas volume.
C**> Upstream/downstream mylar windows.
      ZMW=D37MW(3)-D37NE(3)
      CALL GSPOS('MW37',1,'NE37',0.,0., ZMW,0,'ONLY')
      CALL GSPOS('MW37',2,'NE37',0.,0.,-ZMW,0,'ONLY')
C**> Central Fe "mesh" plate.
      CALL GSPOS('FE37',1,'NE37',0.,0.,0.,0,'ONLY')
C**> Sensitive volume of the chamber
      ZSN=D37NE(3)-DCOUT
      CALL GSPOS('SN37',1,'NE37',0.,0.,-ZSN,0,'ONLY')
C**> WLS polystyrene box 2.12 cm inside Ar volume on light gap end
C**> of chamber (downstream).
      ZWLS=D37NE(3)-2.12-D37WL(3)
      CALL GSPOS('WL37',1,'NE37',0.,0.,ZWLS,0,'ONLY')
C**> Construct the large light chamber by placing the various
C**> boxes and frames inside the large light chamber volume.
C**> Upper/Lower horizontal frames (1 cm shift to account for border pieces).
      YH=D37CH(2)-1.-D37HF(2)
      CALL GSPOS('F37H',1,'CH37',0.,YH,0.,0,'ONLY')
      CALL GSPOS('F37H',2,'CH37',0.,-YH,0.,0,'ONLY')
C**> Left/Right vertical frames (1 cm shift to account for border pieces).
      XV=D37CH(1)-1.-D37VF(1)
      CALL GSPOS('F37V',1,'CH37',XV,0.,0.,0,'ONLY')
      CALL GSPOS('F37V',2,'CH37',-XV,0.,0.,0,'ONLY')
C**> The Ar gas volume.
      CALL GSPOS('NE37',1,'CH37',0.,0.,0.,0,'ONLY')
C----
C**> Define the small light/pad chamber box volume and fill with G10.
C**> Define a separate volume for the pad chamber to allow for the
C**> extra pad plane and to exclude the WLS.
      CALL GSVOLU('CH12','BOX ',303,D12CH,3,I)
      CALL GSVOLU('CHPA','BOX ',303,D12CH,3,I)
C**> Define the frames for the small light/pad chamber.
C**> The horizontal and vertical G10 honeycombe frame structures.
      CALL GSVOLU('F12H','BOX ',303,D12HF,3,I)
      CALL GSVOLU('F12V','BOX ',303,D12VF,3,I)
C**> Divide the small light/pad chamber frame boxes in 1x1 cm cells in X-Y.
C**> The horizontal frames.
      CALL GSDVN('S12H','F12H',12,2)
      CALL GSDVN('C12H','S12H',138,1)
C**> The vertical frames.
      CALL GSDVN('S12V','F12V',87,2)
      CALL GSDVN('C12V','S12V',8,1)
C**> Put a box full of air in each cell to simulate the honeycombe. This is
C**> assumed to simulate also the frames made out of the equal density foam.
      CALL GSVOLU('HO12','BOX ',399,D12HO,3,I)
      CALL GSPOS('HO12',1,'C12H',0.,0.,0.,0,'ONLY') ! Horizontal frames.
      CALL GSPOS('HO12',1,'C12V',0.,0.,0.,0,'ONLY') ! Vertical frames.
C**> Create the Ar boxes to simulate the small light & pad chamber active volume.
      CALL GSVOLU('NE12','BOX ',301,D12NE,3,I)
      CALL GSVOLU('NEPA','BOX ',301,D12NE,3,I)
C**> Create the box to simulate the small light/pad chamber mylar windows.
      CALL GSVOLU('MW12','BOX ',300,D12MW,3,I)
C**> Create a central iron plate to simulate the small light/pad chamber meshes.
      CALL GSVOLU('FE12','BOX ',302,D12FE,3,I)
C**> Create a sensitive plane to record hits.
      CALL GSVOLU('SN12','BOX ',305,D12SN,3,I)
C**> Create a polystyrene 1mm thick box to simulate the small light chamber WLS.
      CALL GSVOLU('WL12','BOX ',304,D12WL,3,I)
C**> Construct the interior of the small light chamber & pad chamber gas volumes.
C**> Upstream/downstream mylar windows.
      ZMW=D12MW(3)-D12NE(3)
      CALL GSPOS('MW12',1,'NE12',0.,0., ZMW,0,'ONLY')
      CALL GSPOS('MW12',2,'NE12',0.,0.,-ZMW,0,'ONLY')
      CALL GSPOS('MW12',3,'NEPA',0.,0., ZMW,0,'ONLY')
      CALL GSPOS('MW12',4,'NEPA',0.,0.,-ZMW,0,'ONLY')
C**> Central Fe "mesh" plate.
      CALL GSPOS('FE12',1,'NE12',0.,0.,0.,0,'ONLY')
      CALL GSPOS('FE12',2,'NEPA',0.,0.,0.,0,'ONLY')
C**> Sensitive volume of the chamber
      ZSN=D12NE(3)-DCOUT
      CALL GSPOS('SN12',1,'NE12',0.,0.,-ZSN,0,'ONLY')
      CALL GSPOS('SN12',1,'NEPA',0.,0.,-ZSN,0,'ONLY')
C**> WLS polystyrene box 2.12 cm inside Ar volume on light gap end
C**> of chamber (downstream).
      ZWLS=D12NE(3)-2.12-D12WL(3)
      CALL GSPOS('WL12',1,'NE12',0.,0.,ZWLS,0,'ONLY')
C**> Cu "pad" plate 1. cm inside Ar volume edge at downstream end.
Cc    ZCU=D12NE(3)-1.-DPACU(3)
Cc    CALL GSPOS('CUPA',1,'NEPA',0.,0.,ZCU,0,'ONLY')
C**> Construct the small light chamber & pad chamber by placing the various
C**> boxes and frames inside the large light chamber volume.
C**> Upper/Lower horizontal frames (1 cm shift to account for border pieces).
      YH=D12CH(2)-1.-D12HF(2)
      CALL GSPOS('F12H',1,'CH12',0.,YH,0.,0,'ONLY')
      CALL GSPOS('F12H',2,'CH12',0.,-YH,0.,0,'ONLY')
      CALL GSPOS('F12H',3,'CHPA',0.,YH,0.,0,'ONLY')
      CALL GSPOS('F12H',4,'CHPA',0.,-YH,0.,0,'ONLY')
C**> Left/Right vertical frames (1 cm shift to account for border pieces).
      XV=D12CH(1)-1.-D12VF(1)
      CALL GSPOS('F12V',1,'CH12',XV,0.,0.,0,'ONLY')
      CALL GSPOS('F12V',2,'CH12',-XV,0.,0.,0,'ONLY')
      CALL GSPOS('F12V',3,'CHPA',XV,0.,0.,0,'ONLY')
      CALL GSPOS('F12V',4,'CHPA',-XV,0.,0.,0,'ONLY')
C**> The Ar gas volume.
      CALL GSPOS('NE12',1,'CH12',0.,0.,0.,0,'ONLY')
      CALL GSPOS('NEPA',1,'CHPA',0.,0.,0.,0,'ONLY')
C**> Define rotation matrix for the 19 degree angle of the chambers
C**> relative to the beam line:
C**> theta1=90-19,phi1=0,theta2=90,phi2=90,theta3=19,phi3=180.
      CALL GSROTM(310,71.,0.,90.,90.,19.,180.)
      CALL GPROTM(310)
C----
C**> Define the overall mirror box volume and fill with air.
      CALL GSVOLU('MR37','BOX ',399,D37MR,3,I) ! For the large mirrors.
      CALL GSVOLU('MR12','BOX ',399,D12MR,3,I) ! For the small mirror.
C**> Define boxes for horizontal and vertical frames and spine
C**> for large mirror and fill with G10.
      CALL GSVOLU('M37H','BOX ',303,DM37HF,3,I)
      CALL GSVOLU('M37V','BOX ',303,DM37VF,3,I)
      CALL GSVOLU('M37S','BOX ',303,DM37SF,3,I)
C**> Define boxes for horizontal and vertical frames and spine
C**> for small mirror and fill with G10.
      CALL GSVOLU('M12H','BOX ',303,DM12HF,3,I)
      CALL GSVOLU('M12V','BOX ',303,DM12VF,3,I)
      CALL GSVOLU('M12S','BOX ',303,DM12SF,3,I)
C**> Divide the three large mirror frames in 1x1 cm cells in X-Y all along Z.
      CALL GSDVN('M7HS','M37H',10,2)
      CALL GSDVN('M7HC','M7HS',180,1)
      CALL GSDVN('M7VS','M37V',130,2)
      CALL GSDVN('M7VC','M7VS',10,1)
      CALL GSDVN('M7SS','M37S',130,2)
      CALL GSDVN('M7SC','M7SS',5,1)
C**> Divide the three small mirror frames in 1x1 cm cells in X-Y all along Z.
      CALL GSDVN('M2HS','M12H',10,2)
      CALL GSDVN('M2HC','M2HS',138,1)
      CALL GSDVN('M2VS','M12V',92,2)
      CALL GSDVN('M2VC','M2VS',10,1)
      CALL GSDVN('M2SS','M12S',92,2)
      CALL GSDVN('M2SC','M2SS',5,1)
C**> Define air cube box per 1x1 cm frame cell to simulate honeycombe.
      CALL GSVOLU('M7HO','BOX ',399,DM37HO,3,I) ! For the large mirrors.
      CALL GSVOLU('M2HO','BOX ',399,DM12HO,3,I) ! For the small mirror.
C**> Insert an air cube in each frame cell of the large mirror.
      CALL GSPOS('M7HO',1,'M7HC',0.,0.,0.,0,'ONLY')
      CALL GSPOS('M7HO',1,'M7VC',0.,0.,0.,0,'ONLY')
      CALL GSPOS('M7HO',1,'M7SC',0.,0.,0.,0,'ONLY')
C**> Insert an air cube in each frame cell of the small mirror.
      CALL GSPOS('M2HO',1,'M2HC',0.,0.,0.,0,'ONLY')
      CALL GSPOS('M2HO',1,'M2VC',0.,0.,0.,0,'ONLY')
      CALL GSPOS('M2HO',1,'M2SC',0.,0.,0.,0,'ONLY')
C**> Define box for Al-mylar sheet and fill with mylar.
      CALL GSVOLU('M7AL','BOX ',300,DM37AL,3,I) ! For the large mirrors.
      CALL GSVOLU('M2AL','BOX ',300,DM12AL,3,I) ! For the small mirror.
C**> Construct a large mirror out of all frames plus Al-mylar.
C**> Frames on downstream side of mirror box.
C**> Spinal frame.
      ZMF=D37MR(3)-DM37SF(3)
      CALL GSPOS('M37S',1,'MR37',0.,0.,ZMF,0,'ONLY')
C**> Horizontal frames.
      YMHF=DM37VF(2)+DM37HF(2)
      CALL GSPOS('M37H',1,'MR37',0.,YMHF,ZMF,0,'ONLY')
      CALL GSPOS('M37H',2,'MR37',0.,-YMHF,ZMF,0,'ONLY')
C**> Vertical frames.
      XMVF=DM37HF(1)-DM37VF(1)
      CALL GSPOS('M37V',1,'MR37',XMVF,0.,ZMF,0,'ONLY')
      CALL GSPOS('M37V',2,'MR37',-XMVF,0.,ZMF,0,'ONLY')
C**> Al-mylar on upstream side of mirror box.
      ZML=D37MR(3)-DM37AL(3)
      CALL GSPOS('M7AL',1,'MR37',0.,0.,-ZML,0,'ONLY')
C**> Construct a small mirror out of all frames plus Al-mylar.
C**> Frames on downstream side of mirror box.
C**> Spinal frame.
      ZMF=D12MR(3)-DM12SF(3)
      CALL GSPOS('M12S',1,'MR12',0.,0.,ZMF,0,'ONLY')
C**> Horizontal frames.
      YMHF=DM12VF(2)+DM12HF(2)
      CALL GSPOS('M12H',1,'MR12',0.,YMHF,ZMF,0,'ONLY')
      CALL GSPOS('M12H',2,'MR12',0.,-YMHF,ZMF,0,'ONLY')
C**> Vertical frames.
      XMVF=DM12HF(1)-DM12VF(1)
      CALL GSPOS('M12V',1,'MR12',XMVF,0.,ZMF,0,'ONLY')
      CALL GSPOS('M12V',2,'MR12',-XMVF,0.,ZMF,0,'ONLY')
C**> Al-mylar on upstream side of mirror box.
      ZML=D12MR(3)-DM12AL(3)
      CALL GSPOS('M2AL',1,'MR12',0.,0.,-ZML,0,'ONLY')
C**> Define rotation matrix for the 19 degree angle of the mirrors
C**> relative to the beam line + their 45 degree forward tilt:
C**>  Theta1=90-19 and Phi1=0, exact values.
C**>  Theta2~=90+45 and Phi2~=90-19, close approximation, adjusted by Geant.
C**>  Theta3~~90 and Phi3~~360-108, gross approximation, calculated by Geant.
      phi2=90+anglem
      CALL GSROTM(320,71.,0.,phi2,71.,48.04,251.97)
c      CALL GSROTM(320,71.,0.,135.,71.,48.04,251.97)
C      CALL GPROTM(320)
C----
C**> Place chambers in WA98 (-ve particle side) with mirrors in between.
C**> (Note X is negative here).
      PI=ACOS(-1.)
      DR=PI/180.
      RD=1./DR
      ANGCH=ANGLEB*DR
      COSCH=COS(ANGCH)
      SINCH=SIN(ANGCH)
      DC37=D37CH(3)-DCOUT
      DZC37=DC37*COSCH
      DXC37=DC37*SINCH
      DC12=D12CH(3)-DCOUT
      DZC12=DC12*COSCH
      DXC12=DC12*SINCH
C**> Position of mirrorrs relative to chambers.
      ANGMR=ANGLEM*DR
      COSMR=COS(ANGMR)
      SINMR=SIN(ANGMR)
      CTAMR=COSMR/SINMR
      DM37=D37CH(3)+(D37MR(2)-D37MR(3)*CTAMR)*COSMR+D37MR(3)/SINMR
      DM37=DM37 +0.0 !(safety)
      DM37=0.5*D37 ! Half the wavelength distance of chambers 3-7.
      DZM37=DM37*COSCH
      DXM37=DM37*SINCH
      DM12=D12CH(3)+(D12MR(2)-D12MR(3)*CTAMR)*COSMR+D12MR(3)/SINMR
      DM12=DM12 +0.0 !(safety)
      DM12=0.5*D23 ! Half the wavelength distance of chambers 2-3.
      DZM12=DM12*COSCH
      DXM12=DM12*SINCH
C**> Pad Chamber 1, no mirror, in WMAG volume.
      XC=XCENT(1)-DXC12
      YC=YTARG
      ZC=ZCENT(1)+DZC12
      ZCM=ZC-ZMAGNT
c      write (6,'(a31,4f8.2)')
c     & ' Pad Chamber 1: xc,yc,zc,zcm = ',xc,yc,zc,zcm
Cc      CALL GSPOS('CHPA',10,'WMAG',XC,YC,ZCM,310,'ONLY')
C**> Small Light Chamber 2 and mirror, in WMAG volume.
      XC=XCENT(2)-DXC12
      YC=YTARG
      ZC=ZCENT(2)+DZC12
      ZCM=ZC-ZMAGNT
c      write (6,'(a39,4f8.2)')
c     & ' Small Light Chamber 2: xc,yc,zc,zcm = ',xc,yc,zc,zcm
      CALL GSPOS('CH12',20,'WMAG',XC,YC,ZCM,310,'ONLY')
      XM=XC-DXM12
      YM=YC
      ZM=ZC+DZM12
      ZMM=ZM-ZMAGNT
c      write (6,'(a44,4f8.2)')
c     & ' Small Mirror for Chamber 2: xm,ym,zm,zmm = ',xm,ym,zm,zmm
Cc      CALL GSPOS('MR12',20,'WMAG',XM,YM,ZMM,320,'ONLY')
      CALL GSPOS('MR12',20,'WMAG',XM,YM,ZMM,320,'ONLY')
C**> Large Light Chamber 3 and mirror, in WMAG volume.
      XC=XCENT(3)-DXC37
      YC=YTARG
      ZC=ZCENT(3)+DZC37
      ZCM=ZC-ZMAGNT
c      write (6,'(a39,4f8.2)')
c     & ' Large Light Chamber 3: xc,yc,zc,zcm = ',xc,yc,zc,zcm
      CALL GSPOS('CH37',30,'WMAG',XC,YC,ZCM,310,'ONLY')
      XM=XC-DXM37
      YM=YC+YLIFT
      ZM=ZC+DZM37
      ZMM=ZM-ZMAGNT
c      write (6,'(a44,4f8.2)')
c     & ' Large Mirror for Chamber 3: xm,ym,zm,zmm = ',xm,ym,zm,zmm
Cc      CALL GSPOS('MR37',30,'WMAG',XM,YM,ZMM,320,'ONLY')
      CALL GSPOS('MR37',30,'WMAG',XM,YM,ZMM,320,'ONLY')
C**> Large Light Chamber 4 and mirror, in WMAG volume.
      XC=XCENT(4)-DXC37
      YC=YTARG
      ZC=ZCENT(4)+DZC37
      ZCM=ZC-ZMAGNT
c      write (6,'(a39,4f8.2)')
c     & ' Large Light Chamber 4: xc,yc,zc,zcm = ',xc,yc,zc,zcm
      CALL GSPOS('CH37',40,'WMAG',XC,YC,ZCM,310,'ONLY')
      XM=XC-DXM37
      YM=YC+YLIFT
      ZM=ZC+DZM37
      ZMM=ZM-ZMAGNT
c      write (6,'(a44,4f8.2)')
c     & ' Large Mirror for Chamber 4: xm,ym,zm,zmm = ',xm,ym,zm,zmm
Cc      CALL GSPOS('MR37',40,'WMAG',XM,YM,ZMM,320,'ONLY')
      CALL GSPOS('MR37',40,'WMAG',XM,YM,ZMM,320,'ONLY')
C**> Large Light Chamber 5 and mirror, in WMAG volume.
      XC=XCENT(5)-DXC37
      YC=YTARG
      ZC=ZCENT(5)+DZC37
      ZCM=ZC-ZMAGNT
c      write (6,'(a39,4f8.2)')
C     & ' Large Light Chamber 5: xc,yc,zc,zcm = ',xc,yc,zc,zcm
      CALL GSPOS('CH37',50,'WMAG',XC,YC,ZCM,310,'ONLY')
      XM=XC-DXM37
      YM=YC+YLIFT
      ZM=ZC+DZM37
      ZMM=ZM-ZMAGNT
c      write (6,'(a44,4f8.2)')
c     & ' Large Mirror for Chamber 5: xm,ym,zm,zmm = ',xm,ym,zm,zmm
Cc      CALL GSPOS('MR37',50,'WMAG',XM,YM,ZMM,320,'ONLY')
      CALL GSPOS('MR37',50,'WMAG',XM,YM,ZMM,320,'ONLY')
C**> Large Light Chamber 6 and mirror, in WA98 volume.
      XC=XCENT(6)-DXC37
      YC=YTARG
      ZC=ZCENT(6)+DZC37
      ZCM=ZC-ZMAGNT
c      write (6,'(a39,4f8.2)')
c     & ' Large Light Chamber 6: xc,yc,zc,zcm = ',xc,yc,zc,zcm
      CALL GSPOS('CH37',60,'WMAG',XC,YC,ZCM,310,'ONLY')
      XM=XC-DXM37
      YM=YC+YLIFT
      ZM=ZC+DZM37
      ZMM=ZM-ZMAGNT
c      write (6,'(a44,4f8.2)')
c     & ' Large Mirror for Chamber 6: xm,ym,zm,zmm = ',xm,ym,zm,zmm
Cc      CALL GSPOS('MR37',60,'WMAG',XM,YM,ZMM,320,'ONLY')
      CALL GSPOS('MR37',60,'WMAG',XM,YM,ZMM,320,'ONLY')
C**> Large Light Chamber 7 and mirror, in WA98 volume.
      XC=XCENT(7)-DXC37
      YC=YTARG
      ZC=ZCENT(7)+DZC37
      ZCM=ZC-ZMAGNT
c      write (6,'(a39,4f8.2)')
c     & ' Large Light Chamber 7: xc,yc,zc,zcm = ',xc,yc,zc,zcm
      CALL GSPOS('CH37',70,'WMAG',XC,YC,ZCM,310,'ONLY')
      XM=XC-DXM37
      YM=YC+YLIFT
      ZM=ZC+DZM37
      ZMM=ZM-ZMAGNT
c      write (6,'(a44,4f8.2)')
c     & ' Large Mirror for Chamber 7: xm,ym,zm,zmm = ',xm,ym,zm,zmm
Cc      CALL GSPOS('MR37',70,'WMAG',XM,YM,ZMM,320,'ONLY')
      CALL GSPOS('MR37',70,'WMAG',XM,YM,ZMM,320,'ONLY')
C----
C**> Set the "seen" attributes for the drawings.
      CALL GSATT('CH37','SEEN',0)
      CALL GSATT('CH12','SEEN',0)
      CALL GSATT('CHPA','SEEN',0)
      CALL GSATT('F37H','SEEN',-2)
      CALL GSATT('F37V','SEEN',-2)
      CALL GSATT('F12H','SEEN',-2)
      CALL GSATT('F12V','SEEN',-2)
      CALL GSATT('HO37','SEEN',0)
      CALL GSATT('HO12','SEEN',0)
      CALL GSATT('MW37','SEEN',0)
      CALL GSATT('MW12','SEEN',0)
      CALL GSATT('FE37','SEEN',0)
      CALL GSATT('FE12','SEEN',0)
      CALL GSATT('WL37','SEEN',0)
      CALL GSATT('WL12','SEEN',0)
      CALL GSATT('MR37','SEEN',0)
      CALL GSATT('MR12','SEEN',0)
      CALL GSATT('M37H','SEEN',-2)
      CALL GSATT('M37V','SEEN',-2)
      CALL GSATT('M37S','SEEN',-2)
      CALL GSATT('M12H','SEEN',-2)
      CALL GSATT('M12V','SEEN',-2)
      CALL GSATT('M12S','SEEN',-2)
      CALL GSATT('M7HO','SEEN',0)
      CALL GSATT('M2HO','SEEN',0)
      CALL GSATT('M7AL','SEEN',0)
      CALL GSATT('M2AL','SEEN',0)

      RETURN
      END


*+DECK,S3SENS.
*CMZ :  2.05/14 20/05/95  06.11.49  by  Hal Kalechofsky
*CMZ :  2.05/12 16/05/95  22.11.16  by  Hal Kalechofsky
*CMZ :  2.05/06 03/04/95  13.22.16  by  Aris Angelis
*CMZ :  1.01/00 14/07/94  17.38.28  by  Hal Kalechofsky
*CMZ :  1.00/00 30/11/90  15.16.25  by  Nick van Eijndhoven (CERN)
*-- Author :    Nick van Eijndhoven (CERN)   30/11/90
      SUBROUTINE S3SENS

C
C ***********************************************************************
C *                                                                     *
C *              Definition of Sensitive Elements for MSACs             *
C *                                                                     *
C ***********************************************************************
C *                                                                     *
C *  CALLED BY     : SXSENS                                             *
C *  CONTACT       :                                                    *
C *                                                                     *
C *  ORIGIN        : NICK VAN EIJNDHOVEN                                *
C *  COMPLETELY REWRITTEN : ARIS L. S. ANGELIS                          *
C *  MODIFICATIONS :
C *                                                                     *
C ***********************************************************************
C

      IMPLICIT NONE

      INTEGER NV,NH
      PARAMETER (NV=2)
      PARAMETER (NH=4)

      CHARACTER*4 NAMESV(NV),NAMESH(NH)
      INTEGER NBITSV(NV),NBITSH(NH),ISET,IDET
      REAL ORIG(NH),FACT(NH)

      DATA NBITSV / NV*8 /
      DATA NBITSH / NH*32/
      DATA ORIG   / 0.,0.,1000.,1000./
      DATA FACT   / 1.,3*1.E5/


* --- Define info for each Hit

      NAMESH(1)='IPART'
      NAMESH(2)='P'
      NAMESH(3)='X'
      NAMESH(4)='Y'

* --- Define each pad as sensitive detector ---

      NAMESV(1)='CH37'
      NAMESV(2)='SN37'

* --- Store Hits and Sensitive Detectors in Geant banks		

      CALL GSDET('MSAC','SN37',NV,NAMESV,NBITSV,301,1000,1000,ISET,IDET)
      CALL GSDETH('MSAC','SN37',NH,NAMESH,NBITSH,ORIG,FACT)

      NAMESV(1)='CH12'
      NAMESV(2)='SN12'

      CALL GSDET('MSAC','SN12',NV,NAMESV,NBITSV,302,1000,1000,ISET,IDET)
      CALL GSDETH('MSAC','SN12',NH,NAMESH,NBITSH,ORIG,FACT)

      RETURN
      END




*+DECK,S3DRAW.
*CMZ :  2.05/14 20/05/95  06.11.49  by  Hal Kalechofsky
*CMZ :  2.05/12 18/05/95  21.24.36  by  Hal Kalechofsky
*CMZ :  1.01/00 14/07/94  17.38.48  by  Hal Kalechofsky
*CMZ :  1.00/00 30/11/90  15.16.25  by  Nick van Eijndhoven (CERN)
*-- Author :    Nick van Eijndhoven (CERN)   30/11/90
      SUBROUTINE S3DRAW

C
C ***********************************************************************
C *                                                                     *
C *                       Drawing MSACs                                 *
C *                                                                     *
C ***********************************************************************
C *                                                                     *
C *  CALLED BY     : SXDRAW                                             *
C *  CONTACT       :                                                    *
C *                                                                     *
C *  ORIGIN        : NICK VAN EIJNDHOVEN                                *
C *  COMPLETELY REWRITTEN : ARIS L. S. ANGELIS                          *
C *  MODIFICATIONS :
C *                                                                     *
C ***********************************************************************
C

C     IMPLICIT NONE

*KEEP,GCONST.
      COMMON/GCONST/PI,TWOPI ,PIBY2,DEGRAD,RADDEG,CLIGHT ,BIG,EMASS
      COMMON/GCONSX/EMMU,PMASS,AVO
C
*KEEP,SCXGEO.
C --- Common which contains some general geometry parameters ---
      REAL DWA98,DWMAG,DTARG
     $,    DWA98X,DWA98Y,DWA98Z
     $,    DMAGNX,DMAGNY,DMAGNZ
     $,    DTARGX,DTARGY,DTARGZ
     $,    XTARG,YTARG,ZTARG,XMAG,YMAG,ZMAG
      COMMON /SCXGEO/ DWA98(3),DWMAG(3),DTARG(3)
     $,               DWA98X,DWA98Y,DWA98Z
     $,               DMAGNX,DMAGNY,DMAGNZ
     $,               DTARGX,DTARGY,DTARGZ
     $,               XTARG,YTARG,ZTARG,XMAG,YMAG,ZMAG
C
*KEEP,SC3POS.
C --- Common which contains the chamber positions in the WA98 frame ---
      INTEGER MXCHAM,MXCAME
      PARAMETER(MXCHAM=6,MXCAME=11)
      REAL XC10,YC10,ZC10,XC20,YC20,ZC20
     $,    XC30,YC30,ZC30,XC40,YC40,ZC40
     $,    XC50,YC50,ZC50,XC60,YC60,ZC60
     $,    XC70,YC70,ZC70
     $,    XC21,YC21,ZC21,XC31,YC31,ZC31
     $,    XC41,YC41,ZC41,XC51,YC51,ZC51
      COMMON /SC3POS/ XC10,YC10,ZC10,XC20,YC20,ZC20
     $,    XC30,YC30,ZC30,XC40,YC40,ZC40
     $,    XC50,YC50,ZC50,XC60,YC60,ZC60
     $,    XC70,YC70,ZC70
     $,    XC21,YC21,ZC21,XC31,YC31,ZC31
     $,    XC41,YC41,ZC41,XC51,YC51,ZC51
C
*+SEQ,GCDRAW.

*
* --- Drawings
*

C     CALL GDTREE('TCH ',0,011111)
      CALL GDFSPC('TCH ',0,0)

      RETURN
      END


*+DECK,S3END.
*CMZ :  2.05/33 22/06/95  14.46.03  by  Hal Kalechofsky
*CMZ :  2.05/14 20/05/95  06.11.49  by  Hal Kalechofsky
*CMZ :  2.05/12 17/05/95  14.36.04  by  Hal Kalechofsky
*CMZ :  2.05/11 16/05/95  07.56.07  by  Hal Kalechofsky
*CMZ :  1.01/00 14/07/94  17.42.44  by  Hal Kalechofsky
*CMZ :  1.00/00 30/11/90  17.43.09  by  Nick van Eijndhoven (CERN)
*-- Author :    Nick van Eijndhoven (CERN)   30/11/90
      SUBROUTINE S3END

C
C ***********************************************************************
C *                                                                     *
C *              Termination  of  MSACs  Run                            *
C *                                                                     *
C ***********************************************************************
C *                                                                     *
C *  CALLED BY     : SXEND                                              *
C *  CONTACT       :                                                    *
C *                                                                     *
C *  ORIGIN        : NICK VAN EIJNDHOVEN                                *
C *  COMPLETELY REWRITTEN : ARIS L. S. ANGELIS                          *
C *  MODIFICATIONS :                                                    *
C *                                                                     *
C ***********************************************************************
C

      IMPLICIT NONE

*
* --- Print Message
*

      PRINT 1000
 1000 FORMAT(1H /1H ,36('*'),' S3END  ',36('*')/
     $ 1H ,20X,'MSAC simulation package terminated'/
     $ 1H ,80('*'))

      RETURN
      END

*+DECK,S3KEY.
*CMZ :  2.05/16 23/05/95  15.02.43  by  Hal Kalechofsky
*CMZ :  2.05/15 23/05/95  11.25.21  by  Hal Kalechofsky
*CMZ :  2.05/14 20/05/95  08.57.57  by  Hal Kalechofsky
*CMZ :  2.05/13 19/05/95  15.38.06  by  Hal Kalechofsky
*CMZ :  2.05/12 18/05/95  22.00.12  by  Hal Kalechofsky
*-- Author :
      SUBROUTINE S3KEY

C
C ***********************************************************************
C *                                                                     *
C *                Definition of FFREAD Keys                            *
C *                                                                     *
C ***********************************************************************
C *                                                                     *
C *  CALLED BY     : SXKEY                                              *
C *  CONTACT       :                                                    *
C *                                                                     *
C *  ORIGIN        : NICK VAN EIJNDHOVEN                                *
C *  COMPLETELY REWRITTEN : ARIS L. S. ANGELIS                          *
C *  MODIFICATIONS :                                                    *
C *                                                                     *
C ***********************************************************************

      IMPLICIT NONE
*KEEP,SC3FFK.
C --- Common with the users defined FFKEY cards
      INTEGER INAME1,INAME2,IMIX1
      REAL SNAME1,SNAME2,SMIX2,SMIX3
      COMMON /SC3FFK/INAME1,INAME2,SNAME1,SNAME2,IMIX1,SMIX2,SMIX3
C

* Here write comments for each card. Transfer the same comments to the
* runcards file.
* In the examples the data cards are EXMP1, EXMP2 and EXMP3.
* The first one has two Integer variables, INAME1 and INAME2 that can
* take the values that the user specifies from the runcards file.
* Similarly the EXMP2 has 2 real variables while the EXMP3 has 3 mixed
* variables
*
* DATA CARD : EXMP1
*             to control the ...........
* INAME1 = 100 ==> ....
* INAME1 = 200 ==> ....
*
* INAME2 = 1000 ==> ...
* INAME2 = 2000 ==> ...
*
*
* DATA CARD : EXMP2
*             to control the ...........
* SNAME1 = 100. ==> ....
* SNAME1 = 200. ==> ....
*
* SNAME2 = 1000. ==> ...
* SNAME2 = 2000. ==> ...
*

      INAME1 = 100
      INAME2 = 1000
      CALL FFKEY('EXMP1',INAME1,       2,'INTEGER')

      SNAME1 = 100.0
      SNAME2 = 1000.0
      CALL FFKEY('EXMP2',SNAME1,       2,'REAL')

      IMIX1 = 0
      SMIX2 = 0.
      SMIX3 = 0.
      CALL FFKEY( 'EXMP3',IMIX1,3,'MIXE' )


 9999 CONTINUE
      RETURN
      END
