      subroutine FPGRLAB(icall)
c
c Write a graph label at the bottom of the page, including
c a page number and a run label.
c
c This assumes that SGLIB has already initialized the plot
c and moved to the graphics page.
c
c
      use rfxqlo_private
      IMPLICIT NONE
c
      integer, intent(in) :: icall      ! =1: include freq & Nphi label
c
C============
C idecl:  explicitize implicit INTEGER declarations:
      INTEGER ilen,i
C============
      integer ipage,jnphi
      real*8 zfreq
      character*81 istring,fstring
      character*15 time_str
      save ipage
      data ipage/0/
 
      ipage=ipage+1
 
      istring=' '
      if(ipage .lt. 1000) then
         write(istring,10) ipage,trim(rfx_sys%run_label)
 10      format(i3,' ',a)
      else
         write(istring,11) trim(rfx_sys%run_label)
 11      format('*** ',a)
      endif
 
      write(time_str,12) rfx_sys%time
 12   format(' at ',f7.3,' sec')
	
      ilen=len_trim(istring)
      do i=  ilen,1,-1
         if(istring(i:i).ne.' ') go to 13
      enddo
 13   istring=istring(1:i)//time_str
      
      if(icall.eq.1) then
         call fpgrlab_nf(istring)
      endif
      
      call chrsiz(2)
 
c istring may contain a "$" in the file name (for example, in a
c logical disk name), which SGLIB misinterpets as the end of the
c string.  So explicitly tell SGLIB the length of the string:
c
      ilen=len_trim(istring)
      call agtmhs(5,5,istring,ilen)
      call chrsiz(1)
 
      return
      end
c-------------------------------------------
      subroutine fpgrlab_nf(str)
c
      use rfxqlo_private
      IMPLICIT NONE
c
c  append "f = #.# MHz Nphi = ##" to the label...
c
      character*(*), intent(inout) :: str
c
c---------------------
      integer :: ilenp
      real*8, parameter :: CM6 = 1.0d6
      character*40 fstring
c---------------------
c
      if(str.eq.' ') then
         ilenp=0
      else
         ilenp=len_trim(str)
      endif

      fstring=' '
      write(fstring,'("; f=",f7.3," MHz; Nphi=",i4)') 
     >   antenna_array(selected_antenna)%freq/CM6,
     >   antenna_array(selected_antenna)%nphi(selected_nphi)
         
      str(ilenp+1:) = trim(fstring)

      return
      end
