%N addpoly %F $MIR/src/subs/calpoly.for
%D Add a polynomial to the database of polynomials
%: calibration, polynomials
%P pjt
%B
        INTEGER FUNCTION addpoly( code, bl, porder, ppoly, valid)
        IMPLICIT NONE

        CHARACTER code*(*)
        INTEGER   bl, porder
        REAL      ppoly(*), valid(2)

   Add new polynomial to database: insert & delete such that no
   gaps exist and they are still time sorted.....
   This code could perhaps also be used to DELETE a polynomial 
   from the database, but we don't have any use for that yet.

   Input:
       code      associated phase/amp code
       bl        associated baseline [b=findbase(bl); b=1..nbl]
       porder    order to fit (0..MAXORDER)
       ppoly     poly(0..porder) coefficients for polynomial
       valid     validity of new polynomial
   Output:
