summaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/intrinsics/random.c')
-rw-r--r--libgfortran/intrinsics/random.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/libgfortran/intrinsics/random.c b/libgfortran/intrinsics/random.c
index 0d1f25f7041..803049b065f 100644
--- a/libgfortran/intrinsics/random.c
+++ b/libgfortran/intrinsics/random.c
@@ -374,8 +374,8 @@ arandom_r4 (gfc_array_r4 *x)
for (n = 0; n < dim; n++)
{
count[n] = 0;
- stride[n] = x->dim[n].stride;
- extent[n] = x->dim[n].ubound + 1 - x->dim[n].lbound;
+ stride[n] = GFC_DESCRIPTOR_STRIDE(x,n);
+ extent[n] = GFC_DESCRIPTOR_EXTENT(x,n);
if (extent[n] <= 0)
return;
}
@@ -441,8 +441,8 @@ arandom_r8 (gfc_array_r8 *x)
for (n = 0; n < dim; n++)
{
count[n] = 0;
- stride[n] = x->dim[n].stride;
- extent[n] = x->dim[n].ubound + 1 - x->dim[n].lbound;
+ stride[n] = GFC_DESCRIPTOR_STRIDE(x,n);
+ extent[n] = GFC_DESCRIPTOR_EXTENT(x,n);
if (extent[n] <= 0)
return;
}
@@ -511,8 +511,8 @@ arandom_r10 (gfc_array_r10 *x)
for (n = 0; n < dim; n++)
{
count[n] = 0;
- stride[n] = x->dim[n].stride;
- extent[n] = x->dim[n].ubound + 1 - x->dim[n].lbound;
+ stride[n] = GFC_DESCRIPTOR_STRIDE(x,n);
+ extent[n] = GFC_DESCRIPTOR_EXTENT(x,n);
if (extent[n] <= 0)
return;
}
@@ -583,8 +583,8 @@ arandom_r16 (gfc_array_r16 *x)
for (n = 0; n < dim; n++)
{
count[n] = 0;
- stride[n] = x->dim[n].stride;
- extent[n] = x->dim[n].ubound + 1 - x->dim[n].lbound;
+ stride[n] = GFC_DESCRIPTOR_STRIDE(x,n);
+ extent[n] = GFC_DESCRIPTOR_EXTENT(x,n);
if (extent[n] <= 0)
return;
}
@@ -690,13 +690,13 @@ random_seed_i4 (GFC_INTEGER_4 *size, gfc_array_i4 *put, gfc_array_i4 *get)
runtime_error ("Array rank of PUT is not 1.");
/* If the array is too small, abort. */
- if (((put->dim[0].ubound + 1 - put->dim[0].lbound)) < kiss_size)
+ if (GFC_DESCRIPTOR_EXTENT(put,0) < kiss_size)
runtime_error ("Array size of PUT is too small.");
/* We copy the seed given by the user. */
for (i = 0; i < kiss_size; i++)
memcpy (seed + i * sizeof(GFC_UINTEGER_4),
- &(put->data[(kiss_size - 1 - i) * put->dim[0].stride]),
+ &(put->data[(kiss_size - 1 - i) * GFC_DESCRIPTOR_STRIDE(put,0)]),
sizeof(GFC_UINTEGER_4));
/* We put it after scrambling the bytes, to paper around users who
@@ -712,7 +712,7 @@ random_seed_i4 (GFC_INTEGER_4 *size, gfc_array_i4 *put, gfc_array_i4 *get)
runtime_error ("Array rank of GET is not 1.");
/* If the array is too small, abort. */
- if (((get->dim[0].ubound + 1 - get->dim[0].lbound)) < kiss_size)
+ if (GFC_DESCRIPTOR_EXTENT(get,0) < kiss_size)
runtime_error ("Array size of GET is too small.");
/* Unscramble the seed. */
@@ -720,7 +720,7 @@ random_seed_i4 (GFC_INTEGER_4 *size, gfc_array_i4 *put, gfc_array_i4 *get)
/* Then copy it back to the user variable. */
for (i = 0; i < kiss_size; i++)
- memcpy (&(get->data[(kiss_size - 1 - i) * get->dim[0].stride]),
+ memcpy (&(get->data[(kiss_size - 1 - i) * GFC_DESCRIPTOR_STRIDE(get,0)]),
seed + i * sizeof(GFC_UINTEGER_4),
sizeof(GFC_UINTEGER_4));
}
@@ -757,12 +757,12 @@ random_seed_i8 (GFC_INTEGER_8 *size, gfc_array_i8 *put, gfc_array_i8 *get)
runtime_error ("Array rank of PUT is not 1.");
/* If the array is too small, abort. */
- if (((put->dim[0].ubound + 1 - put->dim[0].lbound)) < kiss_size / 2)
+ if (GFC_DESCRIPTOR_EXTENT(put,0) < kiss_size / 2)
runtime_error ("Array size of PUT is too small.");
/* This code now should do correct strides. */
for (i = 0; i < kiss_size / 2; i++)
- memcpy (&kiss_seed[2*i], &(put->data[i * put->dim[0].stride]),
+ memcpy (&kiss_seed[2*i], &(put->data[i * GFC_DESCRIPTOR_STRIDE(put,0)]),
sizeof (GFC_UINTEGER_8));
}
@@ -774,12 +774,12 @@ random_seed_i8 (GFC_INTEGER_8 *size, gfc_array_i8 *put, gfc_array_i8 *get)
runtime_error ("Array rank of GET is not 1.");
/* If the array is too small, abort. */
- if (((get->dim[0].ubound + 1 - get->dim[0].lbound)) < kiss_size / 2)
+ if (GFC_DESCRIPTOR_EXTENT(get,0) < kiss_size / 2)
runtime_error ("Array size of GET is too small.");
/* This code now should do correct strides. */
for (i = 0; i < kiss_size / 2; i++)
- memcpy (&(get->data[i * get->dim[0].stride]), &kiss_seed[2*i],
+ memcpy (&(get->data[i * GFC_DESCRIPTOR_STRIDE(get,0)]), &kiss_seed[2*i],
sizeof (GFC_UINTEGER_8));
}