      SUBROUTINE CALCNEEDSET(ip2,maxlevel,mparms,ireqpars,
     * ireqpars2,ireqex)

C     CALCNEEDSET READS IN THE CODES OF THE MEASURED PARAMETERS
C     NEEDED TO CALCULATE THE CALCULATED PARAMETERS AND SETS
C     THE EXTRA CODES IN IP2

c***************************************************************
c
c    Passed Variables:
c     ip2 - parameter codes
c     maxlevel - maximum number of levels
c     mparms - number of possible measured parameters (including
c              second headers)
c     ireqpars - total number of measured parameters requested
c     ireqpars2 - total number of calculated parameters requested
c     ireqex - necessary measured parameters which are not yet
c     requested
c
c****************************************************************

      parameter (maxcalc=200)

      character*80 filename
      dimension ipc(5), ip2(0:maxlevel)

      common /calctype/ ipx(maxcalc)

      ireqex=0

c*****************************************************************
c
c    Open calc.need which contains the necessary information
c
c*****************************************************************

      call extraname('sys.inf'//CHAR(0),
     * 'calc.need'//CHAR(0),filename)
      open(10,file=filename,status='old')

      read(10,'(a1)') filename
      read(10,'(a1)') filename
      read(10,'(a1)') filename

      do 90 n=1,maxcalc

c******************************************************************
c
c    Read in necessary information
c
c******************************************************************

       read(10,800,end=4) nccode,(ipc(nn),nn=1,nccode)
       write(6,*)'ipcc',nccode,ipc(1),ipc(2)

c******************************************************************
c
c    See if this is one of the requested calculated parameters
c
c******************************************************************

      do 85 n0=ireqpars+1,ireqpars+ireqpars2

       if ( n .eq. ipx(n0)) then

c******************************************************************
c
c    See if the necessary parameters are already requested
c
c******************************************************************

       do 100 n2=1,nccode

        ifound=0
        do 101 n3=1,ireqpars+ireqpars2+ireqex

         if ( ip2(n3) .eq. ipc(n2) ) ifound=1

101     continue

        if ( ifound .eq. 0 ) then
         ireqex=ireqex+1
         ip2(ireqpars+ireqpars2+ireqex) = ipc(n2)
        endif

100    continue

       endif

85     continue

90    continue
800   format(59x,i2,2x,5i2)

4     close(10)

      return
      end
