/* Bessel and Neumann functions for G77 compatibility. */
add_sym_1 ("besj0", GFC_ISYM_J0, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
- gfc_check_fn_r, NULL, gfc_resolve_g77_math1,
+ gfc_check_fn_r, gfc_simplify_bessel_j0, gfc_resolve_g77_math1,
x, BT_REAL, dr, REQUIRED);
make_alias ("bessel_j0", GFC_STD_F2008);
add_sym_1 ("dbesj0", GFC_ISYM_J0, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
- gfc_check_fn_d, NULL, gfc_resolve_g77_math1,
+ gfc_check_fn_d, gfc_simplify_bessel_j0, gfc_resolve_g77_math1,
x, BT_REAL, dd, REQUIRED);
make_generic ("bessel_j0", GFC_ISYM_J0, GFC_STD_F2008);
add_sym_1 ("besj1", GFC_ISYM_J1, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
- gfc_check_fn_r, NULL, gfc_resolve_g77_math1,
+ gfc_check_fn_r, gfc_simplify_bessel_j1, gfc_resolve_g77_math1,
x, BT_REAL, dr, REQUIRED);
make_alias ("bessel_j1", GFC_STD_F2008);
add_sym_1 ("dbesj1", GFC_ISYM_J1, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
- gfc_check_fn_d, NULL, gfc_resolve_g77_math1,
+ gfc_check_fn_d, gfc_simplify_bessel_j1, gfc_resolve_g77_math1,
x, BT_REAL, dd, REQUIRED);
make_generic ("bessel_j1", GFC_ISYM_J1, GFC_STD_F2008);
add_sym_2 ("besjn", GFC_ISYM_JN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
- gfc_check_besn, NULL, gfc_resolve_besn,
+ gfc_check_besn, gfc_simplify_bessel_jn, gfc_resolve_besn,
n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED);
make_alias ("bessel_jn", GFC_STD_F2008);
add_sym_2 ("dbesjn", GFC_ISYM_JN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
- gfc_check_besn, NULL, gfc_resolve_besn,
+ gfc_check_besn, gfc_simplify_bessel_jn, gfc_resolve_besn,
n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED);
make_generic ("bessel_jn", GFC_ISYM_JN, GFC_STD_F2008);
add_sym_1 ("besy0", GFC_ISYM_Y0, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
- gfc_check_fn_r, NULL, gfc_resolve_g77_math1,
+ gfc_check_fn_r, gfc_simplify_bessel_y0, gfc_resolve_g77_math1,
x, BT_REAL, dr, REQUIRED);
make_alias ("bessel_y0", GFC_STD_F2008);
add_sym_1 ("dbesy0", GFC_ISYM_Y0, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
- gfc_check_fn_d, NULL, gfc_resolve_g77_math1,
+ gfc_check_fn_d, gfc_simplify_bessel_y0, gfc_resolve_g77_math1,
x, BT_REAL, dd, REQUIRED);
make_generic ("bessel_y0", GFC_ISYM_Y0, GFC_STD_F2008);
add_sym_1 ("besy1", GFC_ISYM_Y1, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
- gfc_check_fn_r, NULL, gfc_resolve_g77_math1,
+ gfc_check_fn_r, gfc_simplify_bessel_y1, gfc_resolve_g77_math1,
x, BT_REAL, dr, REQUIRED);
make_alias ("bessel_y1", GFC_STD_F2008);
add_sym_1 ("dbesy1", GFC_ISYM_Y1, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
- gfc_check_fn_d, NULL, gfc_resolve_g77_math1,
+ gfc_check_fn_d, gfc_simplify_bessel_y1, gfc_resolve_g77_math1,
x, BT_REAL, dd, REQUIRED);
make_generic ("bessel_y1", GFC_ISYM_Y1, GFC_STD_F2008);
add_sym_2 ("besyn", GFC_ISYM_YN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
- gfc_check_besn, NULL, gfc_resolve_besn,
+ gfc_check_besn, gfc_simplify_bessel_yn, gfc_resolve_besn,
n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dr, REQUIRED);
make_alias ("bessel_yn", GFC_STD_F2008);
add_sym_2 ("dbesyn", GFC_ISYM_YN, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dd, GFC_STD_GNU,
- gfc_check_besn, NULL, gfc_resolve_besn,
+ gfc_check_besn, gfc_simplify_bessel_yn, gfc_resolve_besn,
n, BT_INTEGER, di, REQUIRED, x, BT_REAL, dd, REQUIRED);
make_generic ("bessel_yn", GFC_ISYM_YN, GFC_STD_F2008);
gfc_expr *
+gfc_simplify_bessel_j0 (gfc_expr *x)
+{
+#if MPFR_VERSION >= MPFR_VERSION_NUM(2,3,0)
+ gfc_expr *result;
+
+ if (x->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ result = gfc_constant_result (x->ts.type, x->ts.kind, &x->where);
+ gfc_set_model_kind (x->ts.kind);
+ mpfr_j0 (result->value.real, x->value.real, GFC_RND_MODE);
+
+ return range_check (result, "BESSEL_J0");
+#else
+ return NULL;
+#endif
+}
+
+
+gfc_expr *
+gfc_simplify_bessel_j1 (gfc_expr *x)
+{
+#if MPFR_VERSION >= MPFR_VERSION_NUM(2,3,0)
+ gfc_expr *result;
+
+ if (x->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ result = gfc_constant_result (x->ts.type, x->ts.kind, &x->where);
+ gfc_set_model_kind (x->ts.kind);
+ mpfr_j1 (result->value.real, x->value.real, GFC_RND_MODE);
+
+ return range_check (result, "BESSEL_J1");
+#else
+ return NULL;
+#endif
+}
+
+
+gfc_expr *
+gfc_simplify_bessel_jn (gfc_expr *order, gfc_expr *x)
+{
+#if MPFR_VERSION >= MPFR_VERSION_NUM(2,3,0)
+ gfc_expr *result;
+ long n;
+
+ if (x->expr_type != EXPR_CONSTANT || order->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ n = mpz_get_si (order->value.integer);
+ result = gfc_constant_result (x->ts.type, x->ts.kind, &x->where);
+ gfc_set_model_kind (x->ts.kind);
+ mpfr_jn (result->value.real, n, x->value.real, GFC_RND_MODE);
+
+ return range_check (result, "BESSEL_JN");
+#else
+ return NULL;
+#endif
+}
+
+
+gfc_expr *
+gfc_simplify_bessel_y0 (gfc_expr *x)
+{
+#if MPFR_VERSION >= MPFR_VERSION_NUM(2,3,0)
+ gfc_expr *result;
+
+ if (x->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ result = gfc_constant_result (x->ts.type, x->ts.kind, &x->where);
+ gfc_set_model_kind (x->ts.kind);
+ mpfr_y0 (result->value.real, x->value.real, GFC_RND_MODE);
+
+ return range_check (result, "BESSEL_Y0");
+#else
+ return NULL;
+#endif
+}
+
+
+gfc_expr *
+gfc_simplify_bessel_y1 (gfc_expr *x)
+{
+#if MPFR_VERSION >= MPFR_VERSION_NUM(2,3,0)
+ gfc_expr *result;
+
+ if (x->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ result = gfc_constant_result (x->ts.type, x->ts.kind, &x->where);
+ gfc_set_model_kind (x->ts.kind);
+ mpfr_y1 (result->value.real, x->value.real, GFC_RND_MODE);
+
+ return range_check (result, "BESSEL_Y1");
+#else
+ return NULL;
+#endif
+}
+
+
+gfc_expr *
+gfc_simplify_bessel_yn (gfc_expr *order, gfc_expr *x)
+{
+#if MPFR_VERSION >= MPFR_VERSION_NUM(2,3,0)
+ gfc_expr *result;
+ long n;
+
+ if (x->expr_type != EXPR_CONSTANT || order->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ n = mpz_get_si (order->value.integer);
+ result = gfc_constant_result (x->ts.type, x->ts.kind, &x->where);
+ gfc_set_model_kind (x->ts.kind);
+ mpfr_yn (result->value.real, n, x->value.real, GFC_RND_MODE);
+
+ return range_check (result, "BESSEL_YN");
+#else
+ return NULL;
+#endif
+}
+
+
+gfc_expr *
gfc_simplify_bit_size (gfc_expr *e)
{
gfc_expr *result;