      SUBROUTINE UORDERFIND(jj,ju,jp)

C     UORDERFIND RETURNS THE ORDER OF A STATION GIVEN THE UNIQUE
C     STATION NUMBER

c**************************************
c
c    Passed Variables
c
c     jj - order of profile in file
c     ju - unique station ID
c     jp - probe code number
c     itime - set to one if file has been opened, 0 to open,
c           -1 to close
c
c*************************************

      parameter (iufile=509)
      parameter (maxprobe=100)

      dimension itime(0:maxprobe),nuniq(0:maxprobe)
      dimension iufilen(0:maxprobe)

      character*11 ctype(maxprobe)
      character*80 filename

      common /silent/ isilent
      common /probes/ ctype

      save itime
      save nuniq
      save iufilen

c******************************************
c
c    Check if this is permanent or temporary
c    unique station numbers
c
c******************************************

      jpx=0
      juu=ju
      if ( ju .lt. 0 ) then
       juu=-ju
       jpx=jp
      endif

c******************************************
c
c    Open unique station file if this is
c    the first time through subroutine
c
c******************************************

      if ( itime(jpx) .eq. 1) then
c      call filerewind(iufilen(jpx))
      else
       if ( jpx .eq. 0 ) then
        call extraname('sys.inf'//CHAR(0),'uniqall.s'//CHAR(0),filename)
        iufilen(0)=iufile
       else
        call maskname('uniqallt.s'//CHAR(0),0,filename,jp)
        iufilen(jpx)=250+jp
       endif
       call fileopen(filename,'rb+'//CHAR(0),iufilen(jpx))
       call fileend(iufilen(jpx))
       call filepos(iufilen(jpx),0,1,nuniq(jpx))
       call filerewind(iufilen(jpx))
       itime(jpx)=1
      endif

c*********************************************c
c
c    Read mask until proper station id is found
c
c*********************************************


      if ( juu .le. nuniq(jpx) ) then
       call posfile(juu,iufilen(jpx))
       call readmask(jj,iufilen(jpx),iend)
      endif

      if ( jj .eq. 0 .or. juu .gt. nuniq(jpx) ) then
       if ( isilent .eq. 0 ) 
     * write(6,*) 'Unique station number not found:',ju
       jj=-1
      endif

      return
      end
