OSDN Git Service

PR fortran/26025
[pf3gnuchains/gcc-fork.git] / libgfortran / generated / minloc0_4_r10.c
index 43118ce..2f70c74 100644 (file)
@@ -76,16 +76,8 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 
       if (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound != rank)
         runtime_error ("dimension of return array incorrect");
-
-      if (retarray->dim[0].stride == 0)
-       retarray->dim[0].stride = 1;
     }
 
-  /* TODO:  It should be a front end job to correctly set the strides.  */
-
-  if (array->dim[0].stride == 0)
-    array->dim[0].stride = 1;
-
   dstride = retarray->dim[0].stride;
   dest = retarray->data;
   for (n = 0; n < rank; n++)
@@ -106,7 +98,7 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 
   /* Initialize the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 1;
+    dest[n * dstride] = 0;
   {
 
   GFC_REAL_10 minval;
@@ -118,7 +110,7 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray,
       {
         /* Implementation start.  */
 
-  if (*base < minval)
+  if (*base < minval || !dest[0])
     {
       minval = *base;
       for (n = 0; n < rank; n++)
@@ -136,7 +128,7 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray,
              the next dimension.  */
           count[n] = 0;
           /* We could precalculate these products, but this is a less
-             frequently used path so proabably not worth it.  */
+             frequently used path so probably not worth it.  */
           base -= sstride[n] * extent[n];
           n++;
           if (n == rank)
@@ -196,19 +188,8 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 
       if (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound != rank)
         runtime_error ("dimension of return array incorrect");
-
-      if (retarray->dim[0].stride == 0)
-       retarray->dim[0].stride = 1;
     }
 
-  /* TODO:  It should be a front end job to correctly set the strides.  */
-
-  if (array->dim[0].stride == 0)
-    array->dim[0].stride = 1;
-
-  if (mask->dim[0].stride == 0)
-    mask->dim[0].stride = 1;
-
   dstride = retarray->dim[0].stride;
   dest = retarray->data;
   for (n = 0; n < rank; n++)
@@ -241,7 +222,7 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 
   /* Initialize the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 1;
+    dest[n * dstride] = 0;
   {
 
   GFC_REAL_10 minval;
@@ -253,7 +234,7 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
       {
         /* Implementation start.  */
 
-  if (*mbase && *base < minval)
+  if (*mbase && (*base < minval || !dest[0]))
     {
       minval = *base;
       for (n = 0; n < rank; n++)
@@ -272,7 +253,7 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
              the next dimension.  */
           count[n] = 0;
           /* We could precalculate these products, but this is a less
-             frequently used path so proabably not worth it.  */
+             frequently used path so probably not worth it.  */
           base -= sstride[n] * extent[n];
           mbase -= mstride[n] * extent[n];
           n++;
@@ -293,4 +274,53 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
   }
 }
 
+
+extern void sminloc0_4_r10 (gfc_array_i4 * const restrict, 
+       gfc_array_r10 * const restrict, GFC_LOGICAL_4 *);
+export_proto(sminloc0_4_r10);
+
+void
+sminloc0_4_r10 (gfc_array_i4 * const restrict retarray, 
+       gfc_array_r10 * const restrict array,
+       GFC_LOGICAL_4 * mask)
+{
+  index_type rank;
+  index_type dstride;
+  index_type n;
+  GFC_INTEGER_4 *dest;
+
+  if (*mask)
+    {
+      minloc0_4_r10 (retarray, array);
+      return;
+    }
+
+  rank = GFC_DESCRIPTOR_RANK (array);
+
+  if (rank <= 0)
+    runtime_error ("Rank of array needs to be > 0");
+
+  if (retarray->data == NULL)
+    {
+      retarray->dim[0].lbound = 0;
+      retarray->dim[0].ubound = rank-1;
+      retarray->dim[0].stride = 1;
+      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->offset = 0;
+      retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank);
+    }
+  else
+    {
+      if (GFC_DESCRIPTOR_RANK (retarray) != 1)
+       runtime_error ("rank of return array does not equal 1");
+
+      if (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound != rank)
+        runtime_error ("dimension of return array incorrect");
+    }
+
+  dstride = retarray->dim[0].stride;
+  dest = retarray->data;
+  for (n = 0; n<rank; n++)
+    dest[n * dstride] = 0 ;
+}
 #endif