* @param phase
   * @param MV_returnarray
   * @return int
   */
  public static int computeNextMoonPhase(int n, Keyword phase, Object [] MV_returnarray) {
    { int i = 0;
      double am = 0.0;
      double as = 0.0;
      double c = 0.0;
      double x = 0.0;
      double x2 = 0.0;
      double extra = 0.0;
      double rad = Stella.PI / 180.0;
      int julianDay = 0;

      if (phase == Stella.KWD_NEW_MOON) {
        c = ((double)(n));
        julianDay = 0;
      }
      else if (phase == Stella.KWD_FIRST_QUARTER) {
        c = n + 0.25;
        julianDay = 7;
      }
      else if (phase == Stella.KWD_FULL_MOON) {
        c = n + 0.5;
        julianDay = 14;
      }
      else if (phase == Stella.KWD_LAST_QUARTER) {
        c = n + 0.75;
        julianDay = 21;
      }
      else {
        { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

          stream000.nativeStream.print("`" + phase + "' is not a valid case option");
          throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
        }
      }
      x = c / 1236.85;
      x2 = x * x;
      as = 359.2242 + (29.105356 * c);
      am = 306.0253 + (385.816918 * c) + (0.01073 * x2);
      julianDay = 2415020 + (28 * n) + julianDay;
      extra = 0.75933 + (1.53058868 * c) + ((1.178e-4 - (1.55e-7 * x)) * x2);
      if ((phase == Stella.KWD_NEW_MOON) ||
          (phase == Stella.KWD_FULL_MOON)) {
        extra = extra + (((0.1734 - (3.93e-4 * x)) * Math.sin((as * rad))) - (0.4068 * Math.sin((am * rad))));
      }
      else if ((phase == Stella.KWD_FIRST_QUARTER) ||
          (phase == Stella.KWD_LAST_QUARTER)) {
        extra = extra + (((0.1721 - (4.0e-4 * x)) * Math.sin((as * rad))) - (0.628 * Math.sin((am * rad))));
      }
      else {
        { OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

          stream001.nativeStream.print("`" + phase + "' is not a valid case option");
          throw ((StellaException)(StellaException.newStellaException(stream001.theStringReader()).fillInStackTrace()));
        }
      }
      i = ((extra >= 0.0) ? Native.floor(extra) : Native.ceiling(extra - 1.0));
      { int _return_temp = julianDay + i;

        MV_returnarray[0] = FloatWrapper.wrapFloat(extra - i);
        return (_return_temp);
      }
    }
  }