      subroutine regplt(delth,theta,instd,cf,itech,iord)                REGP001
c ----------------------------------------------------------------      REGP002
c      plots the polynomial fit data from sbr stdard (XLAT)             REGP003
c ----------------------------------------------------------------      REGP004
c      version 4.0 last revised 8.11.89 LLNL                            REGP005
c      parameter ns = number of standard lines, ipl = unit spec         REGP006
c ---------------------------------------------------------------       REGP007
       parameter (ns=30,ipl=6)                                          REGP008
       dimension delth(ns),theta(ns),del(90),cf(ns-1)                   REGP009
       dimension mat(90,71),axlabl(5)                                   REGP010
                                                                        REGP011
c ---- choose a reasonable theta range (10 deg more than last std line) REGP012
      if (itech.eq.2) then                                              REGP013
         irange=55                                                      REGP014
      else                                                              REGP015
         irange=int(theta(instd))+10                                    REGP016
      end if                                                            REGP017
      if (irange.gt.90) irange=89                                       REGP018
                                                                        REGP019
C ------ calculate deviations from standard reflections                 REGP020
       do 0001 j=1,irange                                               REGP021
          del(j)=0                                                      REGP022
          do 0001 i=1,iord+1                                            REGP023
             del(j)=del(j)+cf(i)*j**(i-1)                               REGP024
 0001  continue                                                         REGP025
                                                                        REGP026
c ---- find largest deviation in theta range                            REGP027
       ymax=abs(del(1))                                                 REGP028
       do 0002 i=1,irange                                               REGP029
          temp=abs(del(i))                                              REGP030
          if(ymax.lt.temp) ymax=temp                                    REGP031
 0002  continue                                                         REGP032
                                                                        REGP033
c ---- maybe a standard value is even more off                          REGP034
       do 0003 i=1,instd                                                REGP035
          temp=abs(delth(i))                                            REGP036
          if(ymax.lt.temp) ymax=temp                                    REGP037
 0003  continue                                                         REGP038
                                                                        REGP039
      write (ipl,9001)                                                  REGP040
      write (ipl,9002)                                                  REGP041
                                                                        REGP042
c ---- initialize                                                       REGP043
       do 0004 j=1,irange                                               REGP044
          do 0004 i=1, 71                                               REGP045
             mat(j,i)=' '                                               REGP046
             mat(j,1)='I'                                               REGP047
             mat(j,71)='I'                                              REGP048
 0004        mat(j,35)='.'                                              REGP049
                                                                        REGP050
c ---- normalize to -35,0,35 columns and fill plot array                REGP051
       ymax=ymax*1.0e4                                                  REGP052
                                                                        REGP053
c ---- graph                                                            REGP054
       do 0005 i=1,irange                                               REGP055
          temp=del(i)*350000.0/ymax+36.6                                REGP056
          itemp=int(temp)                                               REGP057
 0005     mat(i,itemp)='*'                                              REGP058
                                                                        REGP059
c ---- data points standard                                             REGP060
       do 0006 i=1,instd                                                REGP061
          temp=delth(i)*350000.0/ymax+36.5                              REGP062
          itempd=aint(temp)                                             REGP063
          itempt=aint(theta(i)+0.5)                                     REGP064
          if (mat(itempt,itempd).eq.'*') then                           REGP065
             mat(itempt,itempd)='2'                                     REGP066
          else                                                          REGP067
             mat(itempt,itempd)='O'                                     REGP068
          end if                                                        REGP069
 0006  continue                                                         REGP070
                                                                        REGP071
c ---- plot array                                                       REGP072
       write(ipl,'(5x,''i'',69(''-''),''i'')')                          REGP073
       do 0007 i=2,irange                                               REGP074
          if (mod(i,10).eq.0) then                                      REGP075
             write(ipl,'(i3,2x,71a1)') i,(mat(i,j),j=1,71)              REGP076
          else                                                          REGP077
             write(ipl,'(5x,71a1)') (mat(i,j),j=1,71)                   REGP078
          end if                                                        REGP079
 0007  continue                                                         REGP080
                                                                        REGP081
c ---- calculate values for axis labels last row                        REGP082
       axlabl(1)= - ymax/10000.0                                        REGP083
       axlabl(2)= axlabl(1)/2.0                                         REGP084
       axlabl(3)= 0.0                                                   REGP085
       axlabl(4)= - axlabl(2)                                           REGP086
       axlabl(5)= - axlabl(1)                                           REGP087
                                                                        REGP088
       write (ipl,9003)                                                 REGP089
       write (ipl,9004) (axlabl(i),i=1,5)                               REGP090
                                                                        REGP091
      return                                                            REGP092
                                                                        REGP093
 9001 format (1x,//,19X,'Graphic presentation of polynomial regression')REGP094
 9002 format (1x,18x,45('='),/)                                         REGP095
 9003 format (5X,'I',17('-'),'I',16('-'),'I',16('-'),'I',17('-'),'I')   REGP096
 9004 format (1X,F6.3,12X,F6.3,11X,F6.3,11X,F6.3,12X,F6.3 )             REGP097
                                                                        REGP098
      end                                                               REGP099
                                                                        REGP100
