aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/generated/maxloc1_16_r8.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/generated/maxloc1_16_r8.c')
-rw-r--r--libgfortran/generated/maxloc1_16_r8.c114
1 files changed, 86 insertions, 28 deletions
diff --git a/libgfortran/generated/maxloc1_16_r8.c b/libgfortran/generated/maxloc1_16_r8.c
index 34d5ada7dc9..a060e0620a8 100644
--- a/libgfortran/generated/maxloc1_16_r8.c
+++ b/libgfortran/generated/maxloc1_16_r8.c
@@ -1,5 +1,5 @@
/* Implementation of the MAXLOC intrinsic
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2007 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -28,11 +28,10 @@ License along with libgfortran; see the file COPYING. If not,
write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
-#include "config.h"
+#include "libgfortran.h"
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
-#include "libgfortran.h"
#if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_16)
@@ -117,7 +116,26 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
else
{
if (rank != GFC_DESCRIPTOR_RANK (retarray))
- runtime_error ("rank of return array incorrect");
+ runtime_error ("rank of return array incorrect in"
+ " MAXLOC intrinsic: is %ld, should be %ld",
+ (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+ (long int) rank);
+
+ if (compile_options.bounds_check)
+ {
+ for (n=0; n < rank; n++)
+ {
+ index_type ret_extent;
+
+ ret_extent = retarray->dim[n].ubound + 1
+ - retarray->dim[n].lbound;
+ if (extent[n] != ret_extent)
+ runtime_error ("Incorrect extent in return value of"
+ " MAXLOC intrinsic in dimension %ld:"
+ " is %ld, should be %ld", (long int) n + 1,
+ (long int) ret_extent, (long int) extent[n]);
+ }
+ }
}
for (n = 0; n < rank; n++)
@@ -191,14 +209,14 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
extern void mmaxloc1_16_r8 (gfc_array_i16 * const restrict,
gfc_array_r8 * const restrict, const index_type * const restrict,
- gfc_array_l4 * const restrict);
+ gfc_array_l1 * const restrict);
export_proto(mmaxloc1_16_r8);
void
mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
gfc_array_r8 * const restrict array,
const index_type * const restrict pdim,
- gfc_array_l4 * const restrict mask)
+ gfc_array_l1 * const restrict mask)
{
index_type count[GFC_MAX_DIMENSIONS];
index_type extent[GFC_MAX_DIMENSIONS];
@@ -207,13 +225,14 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
index_type mstride[GFC_MAX_DIMENSIONS];
GFC_INTEGER_16 * restrict dest;
const GFC_REAL_8 * restrict base;
- const GFC_LOGICAL_4 * restrict mbase;
+ const GFC_LOGICAL_1 * restrict mbase;
int rank;
int dim;
index_type n;
index_type len;
index_type delta;
index_type mdelta;
+ int mask_kind;
dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1;
@@ -221,13 +240,27 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0)
return;
+
+ mbase = mask->data;
+
+ mask_kind = GFC_DESCRIPTOR_SIZE (mask);
+
+ if (mask_kind == 1 || mask_kind == 2 || mask_kind == 4 || mask_kind == 8
+#ifdef HAVE_GFC_LOGICAL_16
+ || mask_kind == 16
+#endif
+ )
+ mbase = GFOR_POINTER_TO_L1 (mbase, mask_kind);
+ else
+ runtime_error ("Funny sized logical array");
+
delta = array->dim[dim].stride;
- mdelta = mask->dim[dim].stride;
+ mdelta = mask->dim[dim].stride * mask_kind;
for (n = 0; n < dim; n++)
{
sstride[n] = array->dim[n].stride;
- mstride[n] = mask->dim[n].stride;
+ mstride[n] = mask->dim[n].stride * mask_kind;
extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
if (extent[n] < 0)
@@ -237,7 +270,7 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
for (n = dim; n < rank; n++)
{
sstride[n] = array->dim[n + 1].stride;
- mstride[n] = mask->dim[n + 1].stride;
+ mstride[n] = mask->dim[n + 1].stride * mask_kind;
extent[n] =
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
@@ -279,7 +312,35 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
else
{
if (rank != GFC_DESCRIPTOR_RANK (retarray))
- runtime_error ("rank of return array incorrect");
+ runtime_error ("rank of return array incorrect in MAXLOC intrinsic");
+
+ if (compile_options.bounds_check)
+ {
+ for (n=0; n < rank; n++)
+ {
+ index_type ret_extent;
+
+ ret_extent = retarray->dim[n].ubound + 1
+ - retarray->dim[n].lbound;
+ if (extent[n] != ret_extent)
+ runtime_error ("Incorrect extent in return value of"
+ " MAXLOC intrinsic in dimension %ld:"
+ " is %ld, should be %ld", (long int) n + 1,
+ (long int) ret_extent, (long int) extent[n]);
+ }
+ for (n=0; n<= rank; n++)
+ {
+ index_type mask_extent, array_extent;
+
+ array_extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
+ mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
+ if (array_extent != mask_extent)
+ runtime_error ("Incorrect extent in MASK argument of"
+ " MAXLOC intrinsic in dimension %ld:"
+ " is %ld, should be %ld", (long int) n + 1,
+ (long int) mask_extent, (long int) array_extent);
+ }
+ }
}
for (n = 0; n < rank; n++)
@@ -292,22 +353,11 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
dest = retarray->data;
base = array->data;
- mbase = mask->data;
-
- if (GFC_DESCRIPTOR_SIZE (mask) != 4)
- {
- /* This allows the same loop to be used for all logical types. */
- assert (GFC_DESCRIPTOR_SIZE (mask) == 8);
- for (n = 0; n < rank; n++)
- mstride[n] <<= 1;
- mdelta <<= 1;
- mbase = (GFOR_POINTER_L8_TO_L4 (mbase));
- }
while (base)
{
const GFC_REAL_8 * restrict src;
- const GFC_LOGICAL_4 * restrict msrc;
+ const GFC_LOGICAL_1 * restrict msrc;
GFC_INTEGER_16 result;
src = base;
msrc = mbase;
@@ -403,13 +453,21 @@ smaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
}
else
{
- if (GFC_DESCRIPTOR_RANK (retarray) != 1)
- runtime_error ("rank of return array does not equal 1");
+ if (compile_options.bounds_check)
+ {
+ int ret_rank;
+ index_type ret_extent;
- if (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound != rank)
- runtime_error ("dimension of return array incorrect");
- }
+ ret_rank = GFC_DESCRIPTOR_RANK (retarray);
+ if (ret_rank != 1)
+ runtime_error ("rank of return array in MAXLOC intrinsic"
+ " should be 1, is %ld", (long int) ret_rank);
+ ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
+ if (ret_extent != rank)
+ runtime_error ("dimension of return array incorrect");
+ }
+ }
dstride = retarray->dim[0].stride;
dest = retarray->data;