C
C       RDM TRUE IS RADIUS MODE FOR GUI
C       RDM FALSE IS CURVATURE MODE FOR GUI
        LOGICAL RDM
        COMMON/MDR/RDM
C
C     DON'T FORGET ABOUT ALENA WHEN CHANGING LENS DATA SIZES
C       VARIABLES FOR SPSRF FITTING
C       THIS SETS THE MAXIMUM NUMBER OF DATA PAIRS WHICH
C       MAY BE FIT. SET NOW AT 2000
C       MAXSPS IS SET TO 2000 IN PROGRAM.FOR
C
C       NOTE:
C       NMAX, THE VALUE FOR DIM OF TMP SVD ROUTINES SHOULD BE
C       CHANGED TO MATCH THE VALUE OF MAXSPS SET IN PROGRAM.FOR
C       NMAX IS THE NUMBER OF DATA POINTS WHICH MAY BE FIT.
C
C      PRINCIPLE PLANE DATA CALCULATED WITH THE LAST FIRD COMMAND
        REAL*8 PPY1,PPY2,PPX1,PPX2
        COMMON/PPLANES/PPY1,PPY2,PPX1,PPX2
C
        CHARACTER IDTAG(1:10)*75
        COMMON/TAGID/IDTAG
        REAL*8 DDATA(1:4,1:2000),CFTYPE(1:96)
        COMMON/SPDATA/DDATA
        COMMON/CFTYP/CFTYPE
        INTEGER MAXSPS
        COMMON/MXSPS/MAXSPS
C
C       SPOT DIAGRAM AND CAPFN EXISTENCE FLAGS
C
        LOGICAL GSPDEXT,SPDEXT,CPFNEXT,PSFEXT
C
        COMMON/SPDYES/GSPDEXT,SPDEXT,CPFNEXT,PSFEXT
C
C     TIME AND DATE STAMPING ADDED 5/25/95 AT GOLDYS REQUEST
      LOGICAL STMPT,STMPD
      COMMON/STAMPIT/STMPT,STMPD
C
C       COEFFICIENT FLAGS FOR SPECIAL SURFACES
C
        INTEGER CFF(1:96),LNSTYP
C
      COMMON/ENDER/LNSTYP
C
        COMMON/CCOEF/CFF
C
C       SET FOR 500 SURFACE LENSES
C       VARIABLES FOR THE CURRENT LENS
        CHARACTER LI*80,LIC(1:4)*80,INNI*80,LLTYPE*80,
     1GLANAM(0:499,1:2)*13,LBL(0:499)*80,PLBL(0:499)*80
      INTEGER LICCNT,NEWOBJ,NEWREF,NEWIMG
     2  ,OLDOBJ,OLDREF,OLDIMG,MAXSUR,FLCHG(0:499),SSIZ,LSIZ,PSIZ
C       LSIZ IS NUMBER OF PARAMETERS PER LENS SURFACE
C       SSIZ IS NUMBER OF PARAMETERS IN SYSTEM
C       PSIZ IS NUMBER OF PARAMETERS PER LENS PIKUP
C
      INTEGER RAYSIZ,CFLDCNT,AFLDCNT,PFLDCNT,CFLDTYPE,PFLDTYPE
     1,AFLDTYPE,AFLDTYPECF,DIFSIZ,AFLDCNTCF,BFLDCNT,BFLDTYPE
     2,BFLDTYPECF,BFLDCNTCF
C
        COMMON/FLCH/FLCHG
C
        COMMON/MXSUR/MAXSUR
C
C     EULER TRUE OR FALSE SETS THE PROGRAM SURFACE ANGLES MODE TO
C     EITHER "EULER" OR "RIGHT" OR TO "MIXED" MODE. "MIXED" IS THE DEFAULT
C     SET IN PROGRAM.FOR AT START UP. fLAG IS PASSED BY COMMON MANED "OILY"
        LOGICAL EULER
        COMMON/OILY/EULER
C
C       SSIZ IS THE SIZE OF THE SYSTEM ARRAYS AND LSIZ IS THE
C       NUMBER OF PARAMETERS PER SURFACE IN THE LENS ARRAYS
C       PSIZ IS THE NUMBER OF THINGS IN THE PIKUP ARRAY
C       RAYSIZ IS THE NUMBER OF RAY PARAMETERS STORED
C       DIFSIZ IS THE NUMBER OF DIFF RAY PARAMETERS STORED
        COMMON/SYSSIZ/SSIZ,LSIZ,PSIZ,RAYSIZ,DIFSIZ
C
        REAL*8 SYSTEM1(1:150),CFLDS(1:2,1:10),PFLDS(1:2,1:10),
     1  ALENS(1:160,0:499),SOLVE(0:9,0:499),PIKUP(1:6,0:499,1:45),
     2  FTFL01(1:96,0:499),AFLDS(1:2,1:10),MULTCLAP(1:1000,1:3,0:499)
     3  ,MULTCLAPP(1:1000,1:3,0:499),MULTCOBS(1:1000,1:3,0:499),
     4  MULTCOBSP(1:1000,1:3,0:499),AFLDSCF(1:2,1:10)
     5,BFLDS(1:2,1:10),BFLDSCF(1:2,1:10)
     6,IPOLYX(1:200,0:499,1:4),IPOLYY(1:200,0:499,1:4)
        COMMON/MULTICLAP/MULTCLAP,MULTCLAPP
        COMMON/MULTICOBS/MULTCOBS,MULTCOBSP
        COMMON/FIELDING/PFLDS,CFLDS,AFLDS,PFLDCNT,CFLDCNT,AFLDCNT,
     1PFLDTYPE,CFLDTYPE,AFLDTYPE,AFLDTYPECF,AFLDSCF,AFLDCNTCF
     2,BFLDS,BFLDCNT,BFLDTYPE,BFLDTYPECF,BFLDSCF,BFLDCNTCF
        COMMON/SPFT/FTFL01
        COMMON/SLV/SOLVE
        COMMON/PIK/PIKUP
      COMMON/LLABL/LBL
        COMMON/GLNAME/GLANAM
        COMMON/LTITLE/LI,LIC,INNI,LLTYPE
        COMMON/CTITLE/LICCNT
        COMMON/LENS1/SYSTEM1,ALENS
        COMMON/LENS2/IPOLYX,IPOLYY
        COMMON/NNWW55/NEWOBJ,NEWREF,NEWIMG,OLDOBJ,OLDREF,OLDIMG
C
C       VARIABLES FOR THE PERMANENT LENS USED TO FORM CFGS
        CHARACTER LICP(1:4)*80,LIP*80,GLANMP(0:499,1:2)*13,INNIP*80
     1,LLTYPEP*80
        REAL*8 SYSP(1:150),ALENP(1:160,0:499),PIPOLYX(1:200,0:499,1:4),
     1  SLVP(0:9,0:499),PIKP(1:6,0:499,1:45),FT01P(1:96,0:499),
     2  PIPOLYY(1:200,0:499,1:4)
C
      REAL*8 INR
      COMMON/INRPHAS/INR
C
        COMMON/PLENS/SYSP,ALENP,SLVP,PIKP,FT01P
        COMMON/PLENS2/PIPOLYX,PIPOLYY
C
        COMMON/CPLENS/GLANMP,LIP,LICP,INNIP,LLTYPEP
C
      COMMON/PLLABL/PLBL
C
C       VARIABLES FOR PARAXIAL AND 357 DATA
C       COLX AND COLY ARE COLOR PARAX TRACES WITHOUT SOLVE
C       OR PIKUP RESOLUTION AND ARE USED IN CALCULATING
C       3,5,7 CHROMATIC DIFFERENCES
C
        REAL*8 MAB3(1:11,0:499),PXTRAY(1:8,0:499),
     1  PXTRAX(1:8,0:499),COLORX(1:8,0:499),COLORY(1:8,0:499)
     2  ,SAB57(1:20,0:499),MAB57(1:20,0:499),XMAB3(1:11,0:499)
     3  ,XMAB57(1:20,0:499),XSAB57(1:20,0:499)
     3  ,O_PXTRAY(1:8,0:499),O_PXTRAX(1:8,0:499)
C
        REAL*8 COLY(1:8,0:499),COLX(1:8,0:499)
C
C       CHROMATIC 357 CONTRIBUTIONS
C
        REAL*8 PDF3(1:10,0:499),PDF57(1:20,0:499),
     1  SDF3(1:10,0:499),SDF57(1:20,0:499),
     2  XPDF3(1:10,0:499),XPDF57(1:20,0:499),
     3  XSDF3(1:10,0:499),XSDF57(1:20,0:499)
C
C     FIRST DIMENSION IS FOV NUMBER ,NO 1, NO2 AND NO3.
C     SECOND DIMENSION IS THE ITEM NUMBER
C     THIRD DIMENSION DESIGNATES TYPE OF DATA STORED
C     WHICH VARIES FOR EACH TYPE OF PLOT
C     FOURTH DIMENSION IS WAVELENGTH NUMBER 1 TO 10
C
      REAL*8 FFAANN(1:3,1:21,1:6,1:10),
     1ABSIS,DRAX(1:21),DRAY(1:21)
     2,STEPJP
C
        COMMON/CR1/MAB3,MAB57,SAB57,XMAB3,XMAB57,XSAB57,COLORY,COLORX
     1  ,COLY,COLX,PDF3,PDF57,SDF3,SDF57,XPDF3,XPDF57,XSDF3,XSDF57
     2  ,FFAANN,ABSIS,DRAX,DRAY,STEPJP
C
        COMMON/PARAX_IAL/PXTRAY,PXTRAX,O_PXTRAY,O_PXTRAX
C
C       REAL RAY TRACE VARIABLES
C
C       FOBYES IS A FLAG SET WHEN A FOB IS ISSUED
C       IT IS PASSED VIA
C       THE COMMON/YESFOB/FOBYES
C
C       LAST FOB DATA (USED FOR TRACING WHEN REF RAY FAILS AND NULL
C       IS TRUE)
C       CHLFOB HOLDS THE LAST QUALIFIER USED WITH THE LAST FOB
        CHARACTER CHLFOB*8
        COMMON/CHL/CHLFOB
C       LFOB(1:7) HOLDS THE LAST NUMERIC DATA USED WITH THE LAST FOB
        REAL*8 LFOB(1:7),LFOBA(1:3)
        COMMON/LFFOB/LFOB,LFOBA
C       1=NW1
C       2=NW2
C       3=NW3
C       4=NW4
C       5=DBLE(NEWOBJ)
C       6=DBLE(NEWREF)
C       7=DBLE(NEWIMG)
C       LFOBA(1:3) HOLDS THE LAST NUMERIC DATA USED WITH THE LAST FOBA
C       1=NW1
C       2=NW2
C       3=NW3
C
        LOGICAL FOBYES,REVSTR
C     REVSTR IS TRUE IF ALENS(NEWOBJ) IS NEG AND IS USED TO ADJUST
C     SIGNS IN OPD CALCS
        COMMON/REVST/REVSTR
        COMMON/YESFOB/FOBYES
C
        REAL*8 SAVE(1:50,0:499),DIFF(1:18,0:499),
     1  RFDIFF(1:18,0:499),REFRY(1:50,0:499),RAYRAY(1:50,0:499),
     2  DELX,DELY,RFDELX,RFDELY,RELX,RELY,CURLAM,OLREFRY(1:50,0:499)
     3  ,OLRFDIFF(1:18,0:499),H_RAY(1:50,0:499)
C
        REAL*8 GPXY(1:4,0:499)
        COMMON/PXYG/GPXY
C
        REAL*8 QRAY(1:9,0:499)
C
C     QRAY IS USED IN QUICK RAY TRACING FOR THE FOOTPRINT
C     OPTION
        COMMON/KURLAM/CURLAM
        COMMON/SV/SAVE
        COMMON/DDIIFF/DIFF,DELX,DELY
        COMMON/RRIIFF/RFDIFF,RFDELX,RFDELY,OLRFDIFF
        COMMON/REFR/REFRY,OLREFRY
        COMMON/RAYCMN/RAYRAY,RELX,RELY,QRAY,H_RAY
C
C       LDIF TRUE MAKES DIFFERENTIAL RAYS TRACE, LDIF FALSE KEEPS
C       THEM FROM BEING TRACED. THE LDIF IS CONTROLED BY THE
C       "DIFRAY" COMMAND FROM THE CMD LEVEL. THE PROGRAM STARTS WITH
C       LDIF = .TRUE., SET IN PROGRAM.FOR
C
C       LDIF2 TRUE MAKES DIFFERENTIAL REF RAYS TRACE, LDIF2 FALSE KEEPS
C       THEM FROM BEING TRACED. THE LDIF2 IS CONTROLED BY THE
C       "DIFFOB" COMMAND FROM THE CMD LEVEL. THE PROGRAM STARTS WITH
C       LDIF2 = .TRUE., SET IN PROGRAM.FOR
C
C       LVIG TRUE MAKES VIGNETTING OPTIONAL COMMANDS USE VIGNETTING
C       LVIG = .TRUE., SET IN PROGRAM.FOR
C
C       NOVIRT TRUE TURNS OFF VIRTUAL RAY PLOTTING AND IS THE PROGRAM DEFAULT
C       NOVIRT = .TRUE., SET IN PROGRAM.FOR
C
        LOGICAL LDIF,OLDIF,LDIF2,NOVIRT,LVIG,OLDIF2,OPDIF
C
        COMMON/LDFLDF/LDIF,OLDIF,LDIF2,NOVIRT,LVIG,OLDIF2,OPDIF
C
        REAL*8 OFFX,OFFY,OFFZ,OFFA,OFFB,OFFC
        INTEGER GLSURF
        LOGICAL GLOBE
        COMMON/GLOBL1/GLOBE
        COMMON/GLOBL2/OFFX,OFFY,OFFZ,OFFA,OFFB,OFFC,GLSURF
C
        REAL*8 OOFFX,OOFFY,OOFFZ,OOFFA,OOFFB,OOFFC
        INTEGER OLSURF
        LOGICAL OGLOBE
        COMMON/OLOBL1/OGLOBE
        COMMON/OLOBL2/OOFFX,OOFFY,OOFFZ,OOFFA,OOFFB,OOFFC,OLSURF
C
C       VERTEX HAS GLOBAL VERTEX DATA STORED AND
C       GLRAY HAS X,Y,Z,L,M,N,LP,MP,NP,LN,MN,MM DATA FOR CURRENT RAY
C       IN GLOBAL REPRESENTATION
        REAL*8 VERTEX(1:12,0:499),GLRAY(1:12,0:499)
        COMMON/VERT/VERTEX,GLRAY
C
C       DATA FOR RAY PLOTTING (3/27/92)
C       VERTEX HAS GLOBAL VERTEX DATA STORED AND
C
C       DATA FOR RAY PLOTTING (3/27/92)
C       VERTEX HAS GLOBAL VERTEX DATA STORED AND
C       GLBRAY HAS X,Y,Z,L,M,N,LP,MP,NP DATA FOR CURRENT RAY
C       IN GLOBAL REPRESENTATION FOR PLOTTING
C
      REAL*8 GLPRAY(1:9,0:499),PGLPRAY(1:12,0:499)
C
      COMMON/GLPL/GLPRAY,PGLPRAY
C
      LOGICAL GLVIRT(0:499)
C
      COMMON/GLPLVT/GLVIRT
C
        LOGICAL PLTRAY
C
        COMMON/PLRAYY/PLTRAY
C
        LOGICAL DUM(0:499)
C
        COMMON/DUMREV/DUM
C
      LOGICAL DUMMMY(0:499)
C
      COMMON/DUMMMM/DUMMMY
C
      INTEGER SURF
C
      COMMON/SURCNT/SURF
C
C     RAYTRACE VARIABLES PASSED WITH TH1S INCLUDE
C
C
        COMMON/RAYC/RAYCOD
C
        REAL*8 DINFAC,ONTOL,SINGTOL
     1  ,DINMUL,PFAC,SAGDEL,LINTOL,
     3  SURTOL,AIMTOL,SERINC,SERLIM,CAIMTOL,
     8  DIFTOL,DELSUR,PFACA,PFACM,NMFTOL,IPFTOL
C
        LOGICAL REFEXT,NULL,FAIL,RAYEXT,GPRAYEXT
C
        COMMON/RFEXIT/REFEXT,NULL
C
        COMMON/RYEXIT/RAYEXT,FAIL
C
        COMMON/GPRYEXIT/GPRAYEXT
C
        INTEGER RAYCOD(1:2),REFITR,MRAYS
     7  ,NRAITR,HHHOPD,FLOOD,ASIAD,ASITD,NMIT,IPIT
C
       COMMON/OPCON1/SURTOL,AIMTOL,PFAC,DINMUL,
     1 DIFTOL,DELSUR,DINFAC,SAGDEL,MRAYS,CAIMTOL
     2,PFACA,PFACM,NMIT,IPIT,NMFTOL,IPFTOL,SERINC,SERLIM
     3,ONTOL,SINGTOL,LINTOL

        COMMON/OPCON2/
     1  NRAITR,HHHOPD,FLOOD,ASIAD,ASITD,REFITR
C
C       THIS IS THE PLOTTING INCLUDE FILE STUFF
C
        CHARACTER PPLI*80
C
        COMMON/PPLLII/PPLI
C
        LOGICAL DASHH
C
        LOGICAL PLTLBL,PLTLLI,DRALOK,DRAVUE,LOKFLG,VUEFLG,VIGFLG
C
      COMMON/DLK/DRALOK,DRAVUE,LOKFLG,VUEFLG,VIGFLG
C
      COMMON/PLOLLI/PLTLLI,PLTLBL
C
      INTEGER LBLSURF
C
      COMMON/SURFLBL/LBLSURF
C
        COMMON/DDASHH/DASHH
C
        INTEGER DEVTYP,LNTYPE,SYMB,ORX,ORY,PENSTA
     1  ,YPEN,XPEN,YPENOL,XPENOL,OLLNTP
C
        COMMON/LNTP/LNTYPE,OLLNTP
C
        REAL*8 SCFAY,SCFAX,PSIZY,PSIZX
     1  ,SCFAYP,SCFAXP,PSIZYP,PSIZXP
C
        REAL*8 LOOKY,LOOKX,LOOKZ,VIEALF,VIEPHI
C
        COMMON/LOOKER/LOOKY,LOOKX,LOOKZ,VIEALF,VIEPHI
C
        COMMON/PORIGN/ORX,ORY
C
        COMMON/PLSCL/SCFAY,SCFAX,PSIZY,PSIZX
     1  ,SCFAYP,SCFAXP,PSIZYP,PSIZXP
C
        LOGICAL GRASET,PLEXIS,PLTAXS,AUTSL,PLSC,PLSZ
     1,SCFLG,SZFLG,DRASCL,DRASZZ,PLTVIG,DXFSET,DXFEXIS
C
      CHARACTER LAYER*8
      COMMON/DXFLAYERVAL/LAYER
C
        COMMON/PENPEN/PENSTA,YPEN,XPEN,YPENOL,XPENOL
C
        COMMON/GRAPH/GRASET,PLEXIS,PLTAXS,AUTSL,PLSC,PLSZ
     1,SCFLG,SZFLG,DRASCL,DRASZZ,PLTVIG,DXFSET,DXFEXIS
C
        COMMON/DVTYPE/DEVTYP
C
        INTEGER NTSIZ,SYMSIZ,LABSIZ
C
        INTEGER NTANG,SYMANG,LABANG
C
        COMMON/LABLEL/LABSIZ,LABANG
C
        COMMON/NNOTEE/NTSIZ,NTANG
C
        COMMON/SIMBOL/SYMB,SYMSIZ,SYMANG
C
C     RIGHT,CENTER AND LEFT PLOT JUSTIFICATION FLAG FOR PLOTS
C     OF THE LENS DATA
C
C     RCL=1 MEANS LEFT JUSTIFY
C     RCL=2 MEANS CENTER JUSTIFY (DEFAULT)
C     RCL=3 MEANS RIGHT JUSTIFY
C     JUSOFF IS THE DEVICE COORDINATE X-OFFSET TO BE USED.
C     THE DEFAULT IS ALWAYS 0 AND IT IS ALWAYS CALCULATED ONCE
C     FOR EACH PLOT WHEREIN IT HAS MEANING.
C
      INTEGER RCL
      REAL*8 JUSOFF
      COMMON/JUSRCL/JUSOFF,RCL
C
C     NOW THE FLAGS TO TRACK IF THINGS HAVE BEEN DONE ONCE
C
C     FLAG TO SEE IF "LBL" HAS BEEN PLOTTED
C     BY DEFAULT SET TO FALSE
C                LBLFLG=.FALSE.
C
C     FLAG TO SEE IF "LI" HAS BEEN PLOTTED
C     BY DEFAULT SET TO FALSE
C                LIFLG=.FALSE.
C
C     FLAG TO SEE IF "AXIS" HAS BEEN PLOTTED
C     BY DEFAULT SET TO FALSE
C                AXFLG=.FALSE.
C
C     FLAG TO SEE IF "LABLE" HAS BEEN PLOTTED
C     BY DEFAULT SET TO FALSE
C                LBLFLG=.FALSE.
C
C     FLAG TO SEE IF AN AUTO-SCALE FACTOR HAS BEEN CALCULATED
C     BY DEFAULT SET TO FALSE
C                ASCFLG=.FALSE.
C
      LOGICAL LIFLG,AXFLG,LBLFLG,ASCFLG
C
      COMMON/PLTDUN/LIFLG,LBLFLG,AXFLG,ASCFLG
C
C     LAST STARTING AND ENDING SURFACE FOR LENS PLOTS ARE
C     STASUR AND STPSUR
C
      INTEGER STASUR,STPSUR
C
      COMMON/STASTP/STASUR,STPSUR
C
C     SETS CLIPPING VALUES FOR CALLS TO PLOTTO
      INTEGER XXMIN,XXMAX,YYMIN,YYMAX
      COMMON/BONDRY/XXMIN,XXMAX,YYMIN,YYMAX
C
      INTEGER SURA,SURB
C
      COMMON/PROSUR/SURA,SURB
C
C     CERTER OF ROTATION FOR LOOK/VIEW, HAS IT BEEN SET
C
      LOGICAL ROTSET
C
      REAL*8 XROT,YROT,ZROT
C
      COMMON/RTST/ROTSET
C
      COMMON/ROTPNT/XROT,YROT,ZROT

C     NEXT LINES DEFINE AND PASS THE ARRAY THAT
C     HOLDS RAY PLOTTING DATA
C     AND EDGE PLOTTING DATA
C     AND CLAP PLOTTING DATA
C     AND PROFILE PLOTTING DATA
C
C     P1ARAY MOVED TO GLOBALS.FOR AND IS NOW ALLOCATABLE
C
C     PLOT SHIFTS AND ROTATIONS
C
      INTEGER PXSHFT,PYSHFT,PGAMMA
C
      COMMON/SHFTER/PXSHFT,PYSHFT,PGAMMA
C
C     NOW FAN PLOTTING VARIABLES
C
      LOGICAL FANWV1,FANWV2,FANWV3,FANWV4,FANWV5,FANCW,SSIFLG
     1,FANWV6,FANWV7,FANWV8,FANWV9,FANWV10,FSSIFLG
C
      COMMON/PLTFAN/FANWV1,FANWV2,FANWV3,FANWV4,FANWV5,FANCW,SSIFLG
     1,FANWV6,FANWV7,FANWV8,FANWV9,FANWV10,FSSIFLG
C
      REAL*8 FANOFF,YFOB1,YFOB2,YFOB3,
     1 XFOB1,XFOB2,XFOB3,SSI,FSSI
C
      INTEGER FANTYP,QALTYP,FANNUM,FANNM1,FANNM2,REFWV,FANNOB
     1,FANNRF,FANNIM
C
      COMMON/PLTFN1/FANOFF,YFOB1,YFOB2,YFOB3,XFOB1,
     1XFOB2,XFOB3,SSI,FANTYP,QALTYP,FANNUM,FANNM1,FANNM2
     2,FANNOB,FANNRF,FANNIM,REFWV,FSSI
C
      INTEGER MAXFAN
     2,DRAFLG(1:21),DRAFLG2(1:21),NDRAX(1:21),NDRAY(1:21)
C
        COMMON/PFFAAN/MAXFAN,DRAFLG,DRAFLG2,NDRAX,NDRAY
C
C     ALL PROGRAM DISPLAY COLORS ARE DONE HERE
C
      INTEGER COLRAY,COLCLP,COLCOB,COLEDG,COLPRO,COLAXS,COLBAC
     1,COLR1,COLR2,COLR3,COLR4,COLR5,COLFRM,COLLBL,COLSPE
     2,COLPEN,COLR6,COLR7,COLR8,COLR9,COLR10,COLDEF
C
      COMMON/COLERS/COLRAY,COLCLP,COLCOB,COLEDG,COLPRO,COLAXS,COLBAC
     1,COLR1,COLR2,COLR3,COLR4,COLR5,COLFRM,COLLBL,COLSPE
     2,COLPEN,COLR6,COLR7,COLR8,COLR9,COLR10,COLDEF
C
C     COLRAY IS THE RAY COLOR IN LAYOUTS
C     COLCLP IS THE CLEAR APERTURE COLOR IN LAYOUTS
C     COLCOB IS THE OBSCURATION COLOR IN LAYOUTS
C     COLEDG IS THE EDGE COLOR IN LAYOUTS
C     COLPRO IS THE PROFILE COLOR IN LAYOUTS
C     COLAXS IS THE AXES (BOTTOM OF PLOT) COLOR IN LAYOUTS
C     COLBAC IS THE BACKGROUND COLOR IN ALL PLOTS
C     COLR1 IS THE COLOR FOR WAVELENGTH 1 IN OTHER PLOTS (RIM, MTF ETC)
C     COLR2 IS THE COLOR FOR WAVELENGTH 2 IN OTHER PLOTS (RIM, MTF ETC)
C     COLR3 IS THE COLOR FOR WAVELENGTH 3 IN OTHER PLOTS (RIM, MTF ETC)
C     COLR4 IS THE COLOR FOR WAVELENGTH 4 IN OTHER PLOTS (RIM, MTF ETC)
C     COLR5 IS THE COLOR FOR WAVELENGTH 5 IN OTHER PLOTS (RIM, MTF ETC)
C     COLR6 IS THE COLOR FOR WAVELENGTH 6 IN OTHER PLOTS (RIM, MTF ETC)
C     COLR7 IS THE COLOR FOR WAVELENGTH 7 IN OTHER PLOTS (RIM, MTF ETC)
C     COLR8 IS THE COLOR FOR WAVELENGTH 8 IN OTHER PLOTS (RIM, MTF ETC)
C     COLR9 IS THE COLOR FOR WAVELENGTH 9 IN OTHER PLOTS (RIM, MTF ETC)
C     COLR10 IS THE COLOR FOR WAVELENGTH 10 IN OTHER PLOTS (RIM, MTF ETC)
C     COLFRM IS THE FRAMING COLOR IN ALL PLOTS
C     COLLBL IS THE LABELING COLOR IN ALL PLOTS
C     COLTXT IS THE COLOR IN ALL NON-GRAPHIC TEXT
C     TXTBAC IS THE COLOR OF NON-GRAPHICS BACKGROUND
C     COLSPE IS THE COLOR OF ALL CURVES PLOTTED IN THE SPECTRAL SECTION
C     OF THE PROGRAM
C
C     NEW COMMONS FOR MARCH 4993
      LOGICAL MSG
      COMMON/RAYMES/MSG
      INTEGER STOPP
      COMMON/RAYSTP/STOPP
      INTEGER ISURI
      COMMON/RAYSUR/ISURI
      CHARACTER WWQ*8
      REAL*8 WW1,WW2,WW3,WW4,WW5
      COMMON/RAYWWQ/WWQ
      COMMON/RAYNWR/WW1,WW2,WW3,WW4,WW5
      REAL*8 WVN
      COMMON/RAYWVN/WVN
      INTEGER CACOCH,FOB0
      COMMON/RFSTUF/CACOCH,FOB0
      LOGICAL RV,POSRAY
      COMMON/RAYREV/RV,POSRAY
      INTEGER R_I,INTERS,SEC
      REAL*8 R_X,R_Y,R_Z,R_L,R_M,R_N,XSTRT,YSTRT,ZSTRT
     1,X1AIM,Y1AIM,Z1AIM,XAIMOL,YAIMOL,ZAIMOL,COSI,COSIP,LN,MN,NN
     2,R_XAIM,R_YAIM,R_ZAIM,XOLD,YOLD,ZOLD,OLDL,OLDM,OLDN,
     3XXXANG,YYYANG,ZZZANG,YR_L,YR_M,YR_N
     4,YOLDL,YOLDM,YOLDN
      COMMON/R_XYZ/R_X,R_Y,R_Z,R_L,R_M,R_N,X1AIM,Y1AIM,Z1AIM
     2,XAIMOL,YAIMOL,ZAIMOL,COSI,COSIP,LN,MN,NN,R_XAIM,R_YAIM,R_ZAIM
     3,XOLD,YOLD,ZOLD,OLDL,OLDM,OLDN,R_I,INTERS,SEC,YR_L
     4,YR_M,YR_N,YOLDL,YOLDM,YOLDN
      REAL*8 RXL(0:499),RXM(0:499),RXN(0:499)
      REAL*8 RYL(0:499),RYM(0:499),RYN(0:499)
      COMMON/YXVECT/RXL,RXM,RXN,RYL,RYM,RYN

C
      COMMON/MAIIAM/XSTRT,YSTRT,ZSTRT,YYYANG,XXXANG
     1,ZZZANG
C
      REAL*8 R_TX,R_TY,R_TZ
      COMMON/BAKK1/R_TX,R_TY,R_TZ
C
      REAL*8 RCOR,OCOR
      COMMON/PASOPD/RCOR,OCOR
C
      REAL*8 X0,Y0,XT(1:2000),YT(1:2000)
      INTEGER NP
      COMMON/J_INSIDE/X0,Y0,XT,YT,NP
C
C     AUTOMATIC EXIT PUPIL CALCULATION FLAG
      LOGICAL EXPAUT
      COMMON/EXITP/EXPAUT
C
C     REFERENCE SPHERE CENT OF CHIEF FLAG
      INTEGER REFLOC
      LOGICAL CENCEN
C     REFLOC=1 = CHIEF RAY
C     REFLOC=2 = SPOT CENTROID
C     REFLOC=3 = REMOVE TILT
C     REFLOC=4 = REMOVE TILT AND FOCUS
      COMMON/LOCREF/REFLOC,CENCEN
C
C     COMMON FOR PHASE SURFACES
      REAL*8 PHASE,DELL,DELM,RLRL,RMRM,RNRN,MYX,MYY
      INTEGER MYI,XRLRL,XRMRM,XRNRN,YRLRL,YRMRM,YRNRN
C
      COMMON/PHASER/PHASE,DELL,DELM,RLRL,RMRM,RNRN,MYX,MYY,MYI
     1,XRLRL,XRMRM,XRNRN,YRLRL,YRMRM,YRNRN
C
C     FFL,BFL AND MAGS BASED ON PARAXIAL OR DIFFERENTIAL TRACE
C
      REAL*8 RMAGX,RMAGY,RFFLX,RFFLY,RBFLX,RBFLY
     1,MAGXOR,MAGYOR,RFFNX,RFFNY,RBFNX,RBFNY,REFLX,REFLY
     2,ENPUDX,ENPUDY,EXPUDX,EXPUDY
C
      COMMON/FLSCALE/RMAGX,RMAGY,RFFLX,RFFLY,RBFLX,RBFLY,MAGXOR,MAGYOR
     1,RFFNX,RFFNY,RBFNX,RBFNY,REFLX,REFLY,ENPUDX,ENPUDY,EXPUDX,EXPUDY
C
      REAL*8 GLSWV(1:10)
C
      COMMON/GLWV/GLSWV
C
C     TRACKS IF WE ARE DOING A LENS RETRIEVAL FROM THE LIBRARY
      LOGICAL LIBGET
      COMMON/GETLIB/LIBGET
C
C     ENTRANCE AND EXIT PUPIL POSITIONS AND DIAMETERS
      REAL*8 ENPOSX,ENPOSY,ENDIAX,ENDIAY,EXPOSX,EXPOSY
     1,EXDIAX,EXDIAY,ENPUX,ENPUY,ENPUZ,EXPUX,EXPUY,EXPUZ
C
      COMMON/JAGGER/ENPOSX,ENPOSY,EXPOSX,EXPOSY,ENDIAX,ENDIAY
     1,EXDIAX,EXDIAY,ENPUX,ENPUY,ENPUZ,EXPUX,EXPUY,EXPUZ
C
      REAL*8 R_L0,R_M0,R_N0
C
      COMMON/DPAHSE/R_L0,R_M0,R_N0
C
      REAL*8 XAIMER,YAIMER,ZAIMER
C
      COMMON/AIMIT/XAIMER,YAIMER,ZAIMER
C
C     REAL RAY VARIABLES FOR TRACE
      LOGICAL NINTY,ANGIN,RVSTART
C
      COMMON/ANGER/ANGIN,NINTY,RVSTART
C
      REAL*8 XC,YC,ZC
C
      COMMON/ZEEEEE/XC,YC,ZC
C
      REAL*8 TRYX,TRYY,TRYZ

      COMMON/TRYIT/TRYX,TRYY,TRYZ
C
C       AIMRFDIF AND AIMRYDIF ARE TRUE FOR ITERATIVE
C       DIFFERENTIAL RAY AIMING AND FALSE FOR NO DIFFERENTIAL RAY
C       AIMING. uSED TO SPEED UP OPTIMIZATION
C
      LOGICAL AIMRFDIF,AIMRYDIF
C
      COMMON/DIFAIM/AIMRFDIF,AIMRYDIF
C
      LOGICAL ANAAIM
C
      COMMON/AIMANA/ANAAIM
C
      LOGICAL ITRACE
C
      COMMON/TRACEI/ITRACE
C
      LOGICAL LORIENT
C
      INTEGER SORIENT
C
      COMMON/ANDY/LORIENT,SORIENT
C
      LOGICAL MTFGRIDS
C
      COMMON/GRIDMTF/MTFGRIDS

        LOGICAL VIGOFF,VSYM, VIEOVERLAY
C
        COMMON/OFFVIG/VIGOFF,VSYM,VIEOVERLAY
C
      INTEGER GRSPT
C
      COMMON/SPOTGR/GRSPT
C
C     CMD LEVEL PIVOT POSITIONS FOR STILT AND BTILT COMMANDS
      REAL*8 STILTXP,STILTYP,STILTZP
      REAL*8 BTILTXP,BTILTYP,BTILTZP
      COMMON/STILTPIV/STILTXP,STILTYP,STILTZP
      COMMON/BTILTPIV/BTILTXP,BTILTYP,BTILTZP
      LOGICAL STILTAUTO, BTILTAUTO
      COMMON/AUTOPIV/STILTAUTO,BTILTAUTO
C
C     THRU-FOCUS VARIABLES FOR TFMOTION COMMAND
      REAL*8 TFDELT,TFTMIN,TFTMAX
      INTEGER TFSURF,TFDIRECTION
      COMMON/TFSTUFF/TFDELT,TFTMIN,TFTMAX,TFSURF,TFDIRECTION
C     REMEMBERS FOB FOR TF CALCS
      REAL*8 TFFOB(1:7)
      COMMON/TFFOBS/TFFOB
C     REMEMBERS FREQ FOR TF CALCS
      REAL*8 TFFREQ
      COMMON/TFFREQS/TFFREQ
      LOGICAL COATSET
      COMMON/SETCOATSET/COATSET
C
C     ADDED FOR 1/12/99 TO SUPPORT CURVED IMAGE PLANE
C     REPRESENTATIONS
C
      REAL*8 IPLANE_X ,IPLANE_Y ,IPLANE_Z
      REAL*8 IPLANE_L ,IPLANE_M ,IPLANE_N
      REAL*8 IPLANE_LN,IPLANE_MN,IPLANE_NN
      COMMON/KENNY/IPLANE_X,IPLANE_Y,IPLANE_Z,
     1IPLANE_L,IPLANE_M,IPLANE_N,IPLANE_LN,IPLANE_MN,IPLANE_NN
C
      LOGICAL CARTMAN
      COMMON/BILLYBEER/CARTMAN
C
      REAL*8 COS_B_ANG,COS_A_ANG
      COMMON/CARTANG/COS_A_ANG,COS_B_ANG
      REAL*8 NEWX,NEWY,NEWZ
      COMMON/CARTPOS/NEWX,NEWY,NEWZ
C
      INTEGER ALLONUM
      LOGICAL ALLO
      COMMON/CAPALLO/ALLO,ALLONUM
C
      LOGICAL SUMMOR
      COMMON/ORSUMM/SUMMOR
C
      LOGICAL USEOLREF,SAVEREF
C
      COMMON/OLDDATA/USEOLREF,SAVEREF
C
C     USED BY SAVERAY, RESTRAY AND CLEARRAY COMMANDS
C
      REAL*8 OLD_REF,OLD_RAY,OLD_REF_DIF,OLD_RAY_DIF
     1,SLFOB,SLFOBA
C
      DIMENSION OLD_REF(1:50,0:499),OLD_RAY(1:50,0:499),
     1OLD_REF_DIF(1:18,0:499),
     1OLD_RAY_DIF(1:18,0:499),SLFOB(1:7),SLFOBA(1:3)
C
!      LOGICAL SLDIF,SLDIF2
C
      COMMON/RAYSAVERAY/OLD_REF,OLD_RAY,OLD_REF_DIF,OLD_RAY_DIF,SLFOB
     1,SLFOBA
C
      LOGICAL SREFEXT,SRAYEXT,SRAYDIFEXT,SREFDIFEXT
C
      COMMON/RAYSAVEFLAG/SREFEXT,SRAYEXT,SRAYDIFEXT,SREFDIFEXT
C
      LOGICAL CHRSHIFTEXT
      COMMON/CHRSHIFTER/CHRSHIFTEXT
C
      LOGICAL NOCOAT
      COMMON/COATNO/NOCOAT
C
      INTEGER SAGCODE
      COMMON/CODESAG/SAGCODE
C
C     REAL HOE STUFF
C
      INTEGER HOE_WAV_NUM
      REAL*8 XHOE,YHOE,ZHOE,L1HOE,M1HOE,N1HOE,L2HOE,M2HOE,N2HOE
      INTEGER HOE_DO_IT,HOECFG1,HOECFG2,BLACK_HOE,WHITE_HOE,
     1YELLOW_HOE,BROWN_HOE,VELVET_JONES,HOE_X1,HOE_Y1,HOE_Z1
     2,HOE_X2,HOE_Y2,HOE_Z2

      COMMON/BE_A_HOE/XHOE,YHOE,ZHOE,L1HOE,M1HOE,N1HOE
     1,L2HOE,M2HOE,N2HOE,HOE_DO_IT,HOECFG1,HOECFG2
     2,BLACK_HOE,WHITE_HOE,YELLOW_HOE,BROWN_HOE,VELVET_JONES
     3,HOE_X1,HOE_Y1,HOE_Z1,HOE_X2,HOE_Y2,HOE_Z2,HOE_WAV_NUM
C
      LOGICAL RAYCLEAR
      COMMON/CLEARRAY/RAYCLEAR

      REAL*8 POLANGX(0:499),POLANGY(0:499)
      LOGICAL POLEXT
      COMMON/ANGPOL/POLANGX,POLANGY,POLEXT
C
C       GUI LENS EDITOR SURFACE NUMBER TRACKER
C
        INTEGER EDIT_SURFACE
        COMMON/SURFACE_EDIT/EDIT_SURFACE
C
C
C       TRACK IF THE SPREAD SHEET LENS EDITOR IS OPEN
        LOGICAL EDITOROPEN
        COMMON/OPENEDIT/EDITOROPEN
C

        CHARACTER*80 MFG,CATNUM

        COMMON/CATNUMMFG/MFG,CATNUM
C
C       ARRAY TO SUPPORT GLASS CATALOG SURFACE EDIT
        CHARACTER CATARRAY(1:9999)*50,FNDARRAY(1:9999)*27
        COMMON/ARRAYCAT/CATARRAY,FNDARRAY
C
C       ARRAY TO SUPPORT LIB P GUI
        CHARACTER LIBARRAY(1:999)*80,LFNDARRAY(1:999)*80
        COMMON/ARRAYLIB/LIBARRAY,LFNDARRAY
C
        LOGICAL REFMISS
        COMMON/REFMISSREF/REFMISS
C
C       BULK ABSORBTION COEFFICIENT ADDED TO COATINGS ON 12/10/2002
C       see code changes in raytra5.for and raytra6.for
C
      REAL*8 ABSCOEF(1:10),OLDABSCOEF(1:10)
      COMMON/COEFABS/ABSCOEF,OLDABSCOEF
C
        REAL*8 GUTRAY(1:50,0:499)
        COMMON/GUTGUT/GUTRAY
C
C       TRACK IF DIFFERENTIAL TRACING IS GOING ON
        LOGICAL DIFRAY_TRACE,DIFREF_TRACE
        COMMON/RAYREF_DIF/DIFRAY_TRACE,DIFREF_TRACE
C
C       3/20/2003 REMEMBER LAST NSS RAY COORDINATES BEFORE STRIKING
C       EXIT PORT
        REAL*8 LAST_NSS_R_X,LAST_NSS_R_Y,LAST_NSS_R_Z
        REAL*8 LAST_NSS_R_L,LAST_NSS_R_M,LAST_NSS_R_N
        COMMON/NSS_LASTRAY/LAST_NSS_R_X,LAST_NSS_R_Y,LAST_NSS_R_Z ,
     1  LAST_NSS_R_L,LAST_NSS_R_M,LAST_NSS_R_N
C
        REAL*8 LAST_NSS_OR_X,LAST_NSS_OR_Y,LAST_NSS_OR_Z
        REAL*8 LAST_NSS_OR_L,LAST_NSS_OR_M,LAST_NSS_OR_N
        COMMON/NSS_OLASTRAY/LAST_NSS_OR_X,LAST_NSS_OR_Y,LAST_NSS_OR_Z ,
     1  LAST_NSS_OR_L,LAST_NSS_OR_M,LAST_NSS_OR_N
C
C       DEFORMABLE MIRROR DATA
C

      REAL*8 DEFGR1,DEFGR2,DEFGR3,DEFGR4,DEFGR5,DEFGR6
     1,DEFGR7,DEFGR8
      INTEGER ACTNUM
      COMMON/DEFGRS/DEFGR1,DEFGR2,DEFGR3,DEFGR4,DEFGR5,DEFGR6,DEFGR7
     2,ACTNUM,DEFGR8
C
C       TO LET PLOT SCALE KNOW IT IT IS WORKING NSS
!        LOGICAL NSSSCALE
C
C       ARRAY LENS SUPPORT (6/23/2004)
        REAL*8 A_R_X,A_R_Y,A_R_Z,A_R_L,A_R_M,A_R_N,OLDARRAYX,OLDARRAYY
        COMMON/ARRAYLENS/A_R_X,A_R_Y,A_R_Z,A_R_L,A_R_M,A_R_N
     1  ,OLDARRAYX,OLDARRAYY
C
