public static function Refco($phpa, $tc, $rh, $wl, &$refa, &$refb) {
    $optic;
    $p;
    $t;
    $r;
    $w;
    $ps;
    $pw;
    $tk;
    $wlsq;
    $gamma;
    $beta;

    /* Decide whether optical/IR or radio case:  switch at 100 microns. */
    $optic = ( $wl <= 100.0 );

    /* Restrict parameters to safe values. */
    $t = max($tc, -150.0);
    $t = min($t, 200.0);
    $p = max($phpa, 0.0);
    $p = min($p, 10000.0);
    $r = max($rh, 0.0);
    $r = min($r, 1.0);
    $w = max($wl, 0.1);
    $w = min($w, 1e6);

    /* Water vapour pressure at the observer. */
    if ($p > 0.0) {
      $ps = pow(10.0,
                      ( 0.7859 + 0.03477 * $t ) /
                      ( 1.0 + 0.00412 * $t )) *
              ( 1.0 + $p * ( 4.5e-6 + 6e-10 * $t * $t ) );
      $pw = $r * $ps / ( 1.0 - (1.0 - $r) * $ps / $p );
    }
    else {
      $pw = 0.0;
    }

    /* Refractive index minus 1 at the observer. */
    $tk = $t + 273.15;
    if ($optic) {
      $wlsq  = $w * $w;
      $gamma = ( ( 77.53484e-6 +
              ( 4.39108e-7 + 3.666e-9 / $wlsq ) / $wlsq ) * $p - 11.2684e-6 * $pw ) / $tk;
    }
    else {
      $gamma = ( 77.6890e-6 * $p - ( 6.3938e-6 - 0.375463 / $tk ) * $pw ) / $tk;
    }

    /* Formula for beta from Stone, with empirical adjustments. */
    $beta = 4.4474e-6 * $tk;
    if (!$optic)
      $beta -= 0.0074 * $pw * $beta;

    /* Refraction constants from Green. */
    $refa = $gamma * ( 1.0 - $beta );
    $refb = - $gamma * ( $beta - $gamma / 2.0 );

    /* Finished. */
  }