plotsp(3f) - [M_datapac:LINE_PLOT] generate a line printer spectrum
plot
SUBROUTINE PLOTSP(Y,N,Idf)
REAL(kind=wp),intent(in) :: Y(:)
INTEGER,intent(in) :: N
INTEGER,intent(in) :: Idf
This routine yields a one-page plot of the spectrum, along with upper
and lower limits of the spectrum.
The convention has been followed that if the integer input parameter
idf has the value 0, then no confidence limits will be computed and
only the spectrum itself will be plotted out.
Multiple plot points are not indicated.
The first point will be plotted on the left vertical axis the
last point will be plotted on the right vertical axis there is no
restriction on the maximum value of n for this routine.
X description of parameter
Y description of parameter
Sample program:
program demo_plotsp
use M_datapac, only : plotsp
implicit none
! call plotsp(x,y)
end program demo_plotsp
Results:
The original DATAPAC library was written by James Filliben of the Statistical
Engineering Division, National Institute of Standards and Technology.
John Urban, 2022.05.31
CC0-1.0
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | Y(:) | |||
integer, | intent(in) | :: | N | |||
integer, | intent(in) | :: | Idf |
Type | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|
integer | :: | IGRaph(55,130) |
SUBROUTINE PLOTSP(Y,N,Idf) REAL(kind=wp),intent(in) :: Y(:) INTEGER,intent(in) :: N INTEGER,intent(in) :: Idf REAL(kind=wp) :: ai, an, df, hold, pp025, pp975, ratiox, ratioy, slower, spmax, spmin, supper, xi, ylable, ymax, ymin INTEGER :: i, iflag, j, k, mx, my ! !--------------------------------------------------------------------- ! CHARACTER(len=4) :: IGRaph CHARACTER(len=4) :: blank , hyphen , alphai , alphax , dot ! DIMENSION ylable(11) COMMON /BLOCK1/ IGRaph(55,130) ! DATA blank , hyphen , alphai/' ' , '-' , 'I'/ DATA alphax/'X'/ DATA dot/'.'/ ! ! CHECK THE INPUT ARGUMENTS FOR ERRORS ! IF ( N<1 ) THEN WRITE (G_IO,99001) 99001 FORMAT (' ***** FATAL ERROR--THE SECOND INPUT ARGUMENT TO THE PLOTSP SUBROUTINE IS NON-POSITIVE *****') WRITE (G_IO,99002) N 99002 FORMAT (' ***** THE VALUE OF THE ARGUMENT IS ',I0,' *****') RETURN ELSEIF ( N==1 ) THEN WRITE (G_IO,99003) 99003 FORMAT (' ***** NON-FATAL DIAGNOSTIC--THE SECOND INPUT ARGUMENT TO PLOTSP(3f) HAS THE VALUE 1 *****') RETURN ELSE hold = Y(1) DO i = 2 , N IF ( Y(i)/=hold ) GOTO 50 ENDDO WRITE (G_IO,99004) hold 99004 FORMAT (' ***** NON-FATAL DIAGNOSTIC--THE FIRST INPUT ARGUMENT (A VECTOR) TO PLOTSP(3f) HAS ALL ELEMENTS = ', & & E15.8,' *****') ! !-----START POINT----------------------------------------------------- ! 50 continue an = N ! ! DETERMINE THE MINIMUM AND MAXIMUM OF THE SPECTRUM ! spmin = Y(1) spmax = Y(1) DO i = 2 , N IF ( Y(i)<spmin ) spmin = Y(i) IF ( Y(i)>spmax ) spmax = Y(i) ENDDO ! ! COMPUTE THE MAXIMUM VALUE OF THE UPPER CONFIDENCE LIMIT ! AND THE MINIMUM VALUE OF THE LOWER CONFIDENCE LIMIT--THESE TWO VALUES ! WILL DEFINE THE RANGE OF VALUES TO BE LISTED ON THE VERTICAL AXIS ! IF ( Idf==0 ) THEN ymin = spmin ymax = spmax ELSE df = Idf CALL CHSPPF(0.975_wp,Idf,pp975) CALL CHSPPF(0.025_wp,Idf,pp025) ymax = df*spmax/pp025 ymin = df*spmin/pp975 ENDIF ! ! DETERMINE THE 11 VALUES TO BE LISTED ON THE LEFT VERTICAL AXIS ! DO i = 1 , 11 ylable(i) = ymax - ((FLOAT(i-1))/10.0_wp)*(ymax-ymin) ENDDO ! ! BLANK OUT THE GRAPH DO i = 1 , 55 DO j = 1 , 130 IGRaph(i,j) = blank ENDDO ENDDO ! ! PRODUCE THE Y AXIS DO i = 5 , 55 IGRaph(i,10) = alphai IGRaph(i,130) = alphai ENDDO DO i = 5 , 55 , 5 IGRaph(i,10) = hyphen IGRaph(i,130) = hyphen ENDDO ! ! PRODUCE THE X AXIS DO j = 10 , 130 IGRaph(55,j) = hyphen IGRaph(5,j) = hyphen ENDDO DO j = 10 , 130 , 10 IGRaph(55,j) = alphai IGRaph(5,j) = alphai ENDDO ! ! DETERMINE THE (X,Y) PLOT POSITIONS ratioy = 50.0_wp/(ymax-ymin) ratiox = 240.0_wp DO i = 1 , N ai = i xi = (ai-1.0_wp)/(2.0_wp*(an-1.0_wp)) mx = ratiox*xi + 0.5_wp mx = mx + 10 IF ( Idf/=0 ) THEN supper = df*Y(i)/pp025 slower = df*Y(i)/pp975 my = ratioy*(supper-ymin) + 0.5_wp my = 55 - my IGRaph(my,mx) = dot my = ratioy*(slower-ymin) + 0.5_wp my = 55 - my IGRaph(my,mx) = dot ENDIF my = ratioy*(Y(i)-ymin) + 0.5_wp my = 55 - my IGRaph(my,mx) = alphax ENDDO ! ! WRITE OUT THE GRAPH WRITE (G_IO,99005) 99005 FORMAT ('1') DO i = 5 , 55 iflag = i - (i/5)*5 k = i/5 IF ( iflag/=0 ) WRITE (G_IO,99006) (IGRaph(i,j),j=1,130) 99006 FORMAT (' ',130A1) IF ( iflag==0 ) WRITE (G_IO,99007) ylable(k) ,(IGRaph(i,j),j=10,130) 99007 FORMAT (' ',F9.2,130A1) ENDDO WRITE (G_IO,99008) 99008 FORMAT (& & ' FREQ .000 .042 .083 .125 .167 .208 .250& &.292 .333 .375 .417 .458 .500') WRITE (G_IO,99009) 99009 FORMAT (' ',& &'PERIOD INF 24.0 12.0 8.00 6.00 4.80 & & 4.00 3.43 3.00 2.67 2.40 2.18 2.00& &') ENDIF END SUBROUTINE PLOTSP