re PR libfortran/19106 ([4.0 only] segfault in executable for print *,sum(a,dim=2,mask=a>0))

2005-04-09  Thomas Koenig  <Thomas.Koenig@online.de>

        PR libfortran/19106
        PR libfortran/19014
        * m4/ifunction.m4 (name`'rtype_qual`_'atype_code): ditto.
        If retarray->data is NULL (i.e. the front end does not
        know the rank and dimenson of the array), fill in its
        properties and allocate memory.
        Change the assertions about rank and dimension of retarray into
        runtime errors and only check them for retarray->data != NULL.
        Do the same for correcting the stride from 0 to 1 in retarray.
        (`m'name`'rtype_qual`_'atype_code): Likewise.
        * m4/iforeach.m4 (name`'rtype_qual`_'atype_code): Likewise.
        Change assertion about rank of array to runtime error.
        (`m'name`'rtype_qual`_'atype_code): Likewise.
        * generated/all_l4.c: Regenerated.
        * generated/all_l8.c: Regenerated.
        * generated/any_l4.c: Regenerated.
        * generated/any_l8.c: Regenerated.
        * generated/count_4_l4.c: Regenerated.
        * generated/count_4_l8.c: Regenerated.
        * generated/count_8_l4.c: Regenerated.
        * generated/count_8_l8.c: Regenerated.
        * generated/maxloc0_4_i4.c: Regenerated.
        * generated/maxloc0_4_i8.c: Regenerated.
        * generated/maxloc0_4_r4.c: Regenerated.
        * generated/maxloc0_4_r8.c: Regenerated.
        * generated/maxloc0_8_i4.c: Regenerated.
        * generated/maxloc0_8_i8.c: Regenerated.
        * generated/maxloc0_8_r4.c: Regenerated.
        * generated/maxloc0_8_r8.c: Regenerated.
        * generated/maxloc1_4_i4.c: Regenerated.
        * generated/maxloc1_4_i8.c: Regenerated.
        * generated/maxloc1_4_r4.c: Regenerated.
        * generated/maxloc1_4_r8.c: Regenerated.
        * generated/maxloc1_8_i4.c: Regenerated.
        * generated/maxloc1_8_i8.c: Regenerated.
        * generated/maxloc1_8_r4.c: Regenerated.
        * generated/maxloc1_8_r8.c: Regenerated.
        * generated/maxval_i4.c: Regenerated.
        * generated/maxval_i8.c: Regenerated.
        * generated/maxval_r4.c: Regenerated.
        * generated/maxval_r8.c: Regenerated.
        * generated/minloc0_4_i4.c: Regenerated.
        * generated/minloc0_4_i8.c: Regenerated.
        * generated/minloc0_4_r4.c: Regenerated.
        * generated/minloc0_4_r8.c: Regenerated.
        * generated/minloc0_8_i4.c: Regenerated.
        * generated/minloc0_8_i8.c: Regenerated.
        * generated/minloc0_8_r4.c: Regenerated.
        * generated/minloc0_8_r8.c: Regenerated.
        * generated/minloc1_4_i4.c: Regenerated.
        * generated/minloc1_4_i8.c: Regenerated.
        * generated/minloc1_4_r4.c: Regenerated.
        * generated/minloc1_4_r8.c: Regenerated.
        * generated/minloc1_8_i4.c: Regenerated.
        * generated/minloc1_8_i8.c: Regenerated.
        * generated/minloc1_8_r4.c: Regenerated.
        * generated/minloc1_8_r8.c: Regenerated.
        * generated/minval_i4.c: Regenerated.
        * generated/minval_i8.c: Regenerated.
        * generated/minval_r4.c: Regenerated.
        * generated/minval_r8.c: Regenerated.
        * generated/product_c4.c: Regenerated.
        * generated/product_c8.c: Regenerated.
        * generated/product_i4.c: Regenerated.
        * generated/product_i8.c: Regenerated.
        * generated/product_r4.c: Regenerated.
        * generated/product_r8.c: Regenerated.
        * generated/sum_c4.c: Regenerated.
        * generated/sum_c8.c: Regenerated.
        * generated/sum_i4.c: Regenerated.
        * generated/sum_i8.c: Regenerated.
        * generated/sum_r4.c: Regenerated.
        * generated/sum_r8.c: Regenerated.

2005-04-09  Thomas Koenig  <Thomas.Koenig@online.de>

        * gfortran.fortran-torture/execute/intrinsic_anyall.f90:
        Added test for callee-allocated arrays with write statements.
        * gfortran.fortran-torture/execute/intrinsic_count.f90: Likewise.
        * gfortran.fortran-torture/execute/intrinsic_mmloc.f90: Likewise.
        * gfortran.fortran-torture/execute/intrinsic_mmval.f90: Likewise.
        * gfortran.fortran-torture/execute/intrinsic_product.f90: Likewise.
        * gfortran.fortran-torture/execute/intrinsic_sum.f90: Likewise.

From-SVN: r97929
This commit is contained in:
Thomas Koenig 2005-04-09 21:38:47 +00:00 committed by Thomas Koenig
parent e5e625da47
commit 50dd63a962
70 changed files with 2471 additions and 512 deletions

View File

@ -1,3 +1,13 @@
2005-04-09 Thomas Koenig <Thomas.Koenig@online.de>
* gfortran.fortran-torture/execute/intrinsic_anyall.f90:
Added test for callee-allocated arrays with write statements.
* gfortran.fortran-torture/execute/intrinsic_count.f90: Likewise.
* gfortran.fortran-torture/execute/intrinsic_mmloc.f90: Likewise.
* gfortran.fortran-torture/execute/intrinsic_mmval.f90: Likewise.
* gfortran.fortran-torture/execute/intrinsic_product.f90: Likewise.
* gfortran.fortran-torture/execute/intrinsic_sum.f90: Likewise.
2005-04-09 Thomas Koenig <Thomas.Koenig@online.de> 2005-04-09 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/20163 PR libfortran/20163

View File

@ -3,6 +3,7 @@ program anyall
implicit none implicit none
logical, dimension(3, 3) :: a logical, dimension(3, 3) :: a
logical, dimension(3) :: b logical, dimension(3) :: b
character(len=10) line
a = .false. a = .false.
if (any(a)) call abort if (any(a)) call abort
@ -13,6 +14,12 @@ program anyall
if (.not. b(1)) call abort if (.not. b(1)) call abort
if (b(2)) call abort if (b(2)) call abort
if (.not. b(3)) call abort if (.not. b(3)) call abort
b = .false.
write (line, 9000) any(a,1)
read (line, 9000) b
if (.not. b(1)) call abort
if (b(2)) call abort
if (.not. b(3)) call abort
a = .true. a = .true.
if (.not. all(a)) call abort if (.not. all(a)) call abort
@ -23,4 +30,12 @@ program anyall
if (b(1)) call abort if (b(1)) call abort
if (.not. b(2)) call abort if (.not. b(2)) call abort
if (b(3)) call abort if (b(3)) call abort
b = .false.
write (line, 9000) all(a,1)
read (line, 9000) b
if (b(1)) call abort
if (.not. b(2)) call abort
if (b(3)) call abort
9000 format (9L1)
end program end program

View File

@ -4,6 +4,7 @@ program intrinsic_count
logical(kind=4), dimension (3, 5) :: a logical(kind=4), dimension (3, 5) :: a
integer(kind=4), dimension (5) :: b integer(kind=4), dimension (5) :: b
integer i integer i
character(len=10) line
a = .false. a = .false.
if (count(a) .ne. 0) call abort if (count(a) .ne. 0) call abort
@ -13,9 +14,21 @@ program intrinsic_count
a(2, 2) = .false. a(2, 2) = .false.
a(2, 5) = .false. a(2, 5) = .false.
if (count(a) .ne. 12) call abort if (count(a) .ne. 12) call abort
write (line, 9000) count(a)
read (line, 9000) i
if (i .ne. 12) call abort
b(1:3) = count(a, 2); b(1:3) = count(a, 2);
if (b(1) .ne. 4) call abort if (b(1) .ne. 4) call abort
if (b(2) .ne. 3) call abort if (b(2) .ne. 3) call abort
if (b(3) .ne. 5) call abort if (b(3) .ne. 5) call abort
b = 0
write (line, 9000) count(a,2)
read (line, 9000) b
if (b(1) .ne. 4) call abort
if (b(2) .ne. 3) call abort
if (b(3) .ne. 5) call abort
9000 format(3I3)
end program end program

View File

@ -5,6 +5,7 @@ program testmmloc
integer, dimension (3) :: b integer, dimension (3) :: b
logical, dimension (3, 3) :: m logical, dimension (3, 3) :: m
integer i integer i
character(len=10) line
a = reshape ((/1, 2, 3, 5, 4, 6, 9, 8, 7/), (/3, 3/)); a = reshape ((/1, 2, 3, 5, 4, 6, 9, 8, 7/), (/3, 3/));
@ -12,6 +13,12 @@ program testmmloc
if (b(1) .ne. 1) call abort if (b(1) .ne. 1) call abort
if (b(2) .ne. 2) call abort if (b(2) .ne. 2) call abort
if (b(3) .ne. 3) call abort if (b(3) .ne. 3) call abort
b = -1
write (line, 9000) minloc(a,1)
read (line, 9000) b
if (b(1) .ne. 1) call abort
if (b(2) .ne. 2) call abort
if (b(3) .ne. 3) call abort
m = .true. m = .true.
m(1, 1) = .false. m(1, 1) = .false.
@ -20,19 +27,43 @@ program testmmloc
if (b(1) .ne. 2) call abort if (b(1) .ne. 2) call abort
if (b(2) .ne. 2) call abort if (b(2) .ne. 2) call abort
if (b(3) .ne. 3) call abort if (b(3) .ne. 3) call abort
b = -1
write (line, 9000) minloc(a, 1, m)
read (line, 9000) b
if (b(1) .ne. 2) call abort
if (b(2) .ne. 2) call abort
if (b(3) .ne. 3) call abort
b(1:2) = minloc(a) b(1:2) = minloc(a)
if (b(1) .ne. 1) call abort if (b(1) .ne. 1) call abort
if (b(2) .ne. 1) call abort if (b(2) .ne. 1) call abort
b = -1
write (line, 9000) minloc(a)
read (line, 9000) b
if (b(1) .ne. 1) call abort
if (b(2) .ne. 1) call abort
if (b(3) .ne. 0) call abort
b(1:2) = minloc(a, mask=m) b(1:2) = minloc(a, mask=m)
if (b(1) .ne. 2) call abort if (b(1) .ne. 2) call abort
if (b(2) .ne. 1) call abort if (b(2) .ne. 1) call abort
b = -1
write (line, 9000) minloc(a, mask=m)
read (line, 9000) b
if (b(1) .ne. 2) call abort
if (b(2) .ne. 1) call abort
if (b(3) .ne. 0) call abort
b = maxloc (a, 1) b = maxloc (a, 1)
if (b(1) .ne. 3) call abort if (b(1) .ne. 3) call abort
if (b(2) .ne. 3) call abort if (b(2) .ne. 3) call abort
if (b(3) .ne. 1) call abort if (b(3) .ne. 1) call abort
b = -1
write (line, 9000) maxloc(a, 1)
read (line, 9000) b
if (b(1) .ne. 3) call abort
if (b(2) .ne. 3) call abort
if (b(3) .ne. 1) call abort
m = .true. m = .true.
m(1, 2) = .false. m(1, 2) = .false.
@ -41,12 +72,31 @@ program testmmloc
if (b(1) .ne. 3) call abort if (b(1) .ne. 3) call abort
if (b(2) .ne. 3) call abort if (b(2) .ne. 3) call abort
if (b(3) .ne. 2) call abort if (b(3) .ne. 2) call abort
b = -1
write (line, 9000) maxloc(a, 1, m)
read (line, 9000) b
if (b(1) .ne. 3) call abort
if (b(2) .ne. 3) call abort
if (b(3) .ne. 2) call abort
b(1:2) = maxloc(a) b(1:2) = maxloc(a)
if (b(1) .ne. 1) call abort if (b(1) .ne. 1) call abort
if (b(2) .ne. 3) call abort if (b(2) .ne. 3) call abort
b = -1
write (line, 9000) maxloc(a)
read (line, 9000) b
if (b(1) .ne. 1) call abort
if (b(2) .ne. 3) call abort
b(1:2) = maxloc(a, mask=m) b(1:2) = maxloc(a, mask=m)
if (b(1) .ne. 2) call abort if (b(1) .ne. 2) call abort
if (b(2) .ne. 3) call abort if (b(2) .ne. 3) call abort
b = -1
write (line, 9000) maxloc(a, mask=m)
read (line, 9000) b
if (b(1) .ne. 2) call abort
if (b(2) .ne. 3) call abort
if (b(3) .ne. 0) call abort
9000 format (3I3)
end program end program

View File

@ -5,24 +5,35 @@ program testmmval
integer, dimension (3) :: b integer, dimension (3) :: b
logical, dimension (3, 3) :: m logical, dimension (3, 3) :: m
integer i integer i
character (len=9) line
a = reshape ((/1, 2, 3, 5, 4, 6, 9, 8, 7/), (/3, 3/)); a = reshape ((/1, 2, 3, 5, 4, 6, 9, 8, 7/), (/3, 3/));
b = minval (a, 1) b = minval (a, 1)
if (any(b .ne. (/1, 4, 7/))) call abort if (any(b .ne. (/1, 4, 7/))) call abort
write (line, 9000) minval (a, 1)
if (line .ne. ' 1 4 7') call abort
m = .true. m = .true.
m(1, 1) = .false. m(1, 1) = .false.
m(1, 2) = .false. m(1, 2) = .false.
b = minval (a, 1, m) b = minval (a, 1, m)
if (any(b .ne. (/2, 4, 7/))) call abort if (any(b .ne. (/2, 4, 7/))) call abort
write (line, 9000) minval(a, 1, m)
if (line .ne. ' 2 4 7') call abort
b = maxval (a, 1) b = maxval (a, 1)
if (any(b .ne. (/3, 6, 9/))) call abort if (any(b .ne. (/3, 6, 9/))) call abort
write (line, 9000) maxval (a, 1)
if (line .ne. ' 3 6 9') call abort
m = .true. m = .true.
m(1, 2) = .false. m(1, 2) = .false.
m(1, 3) = .false. m(1, 3) = .false.
b = maxval (a, 1, m) b = maxval (a, 1, m)
if (any(b .ne. (/3, 6, 8/))) call abort if (any(b .ne. (/3, 6, 8/))) call abort
write (line, 9000) maxval(a, 1, m)
if (line .ne. ' 3 6 8') call abort
9000 format(3I3)
end program end program

View File

@ -4,6 +4,7 @@ program testproduct
integer, dimension (3, 3) :: a integer, dimension (3, 3) :: a
integer, dimension (3) :: b integer, dimension (3) :: b
logical, dimension (3, 3) :: m logical, dimension (3, 3) :: m
character(len=12) line
a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/)); a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/));
@ -11,8 +12,14 @@ program testproduct
if (any(b .ne. (/6, 120, 504/))) call abort if (any(b .ne. (/6, 120, 504/))) call abort
write (line, 9000) product(a,1)
if (line .ne. ' 6 120 504') call abort
if (product (a) .ne. 362880) call abort if (product (a) .ne. 362880) call abort
write (line, 9010) product(a)
if (line .ne. '362880') call abort
m = .true. m = .true.
m(1, 1) = .false. m(1, 1) = .false.
m(2, 1) = .false. m(2, 1) = .false.
@ -20,6 +27,14 @@ program testproduct
if (any(b .ne. (/28, 40, 162/))) call abort if (any(b .ne. (/28, 40, 162/))) call abort
write (line, 9000) product(a, 2, m)
if (line .ne. ' 28 40 162') call abort
if (product (a, mask=m) .ne. 181440) call abort if (product (a, mask=m) .ne. 181440) call abort
write (line, 9010) product(a, mask=m)
if (line .ne. '181440') call abort
9000 format (3I4)
9010 format (I6)
end program end program

View File

@ -5,22 +5,35 @@ program testforall
integer, dimension (3) :: b integer, dimension (3) :: b
logical, dimension (3, 3) :: m logical, dimension (3, 3) :: m
integer i integer i
character(len=9) line
a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/)); a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/));
if (sum(a) .ne. 45) call abort if (sum(a) .ne. 45) call abort
write (line, 9000) sum(a)
if (line .ne. ' 45 ') call abort
b = sum (a, 1) b = sum (a, 1)
if (b(1) .ne. 6) call abort if (b(1) .ne. 6) call abort
if (b(2) .ne. 15) call abort if (b(2) .ne. 15) call abort
if (b(3) .ne. 24) call abort if (b(3) .ne. 24) call abort
write (line, 9000) sum (a, 1)
if (line .ne. ' 6 15 24') call abort
m = .true. m = .true.
m(1, 1) = .false. m(1, 1) = .false.
m(2, 1) = .false. m(2, 1) = .false.
if (sum (a, mask=m) .ne. 42) call abort if (sum (a, mask=m) .ne. 42) call abort
write(line, 9000) sum (a, mask=m)
if (line .ne. ' 42 ') call abort
b = sum (a, 2, m) b = sum (a, 2, m)
if (b(1) .ne. 11) call abort if (b(1) .ne. 11) call abort
if (b(2) .ne. 13) call abort if (b(2) .ne. 13) call abort
if (b(3) .ne. 18) call abort if (b(3) .ne. 18) call abort
write (line, 9000) sum (a, 2, m)
if (line .ne. ' 11 13 18') call abort
9000 format(3I3)
end program end program

View File

@ -1,3 +1,79 @@
2005-04-09 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/19106
PR libfortran/19014
* m4/ifunction.m4 (name`'rtype_qual`_'atype_code): ditto.
If retarray->data is NULL (i.e. the front end does not
know the rank and dimenson of the array), fill in its
properties and allocate memory.
Change the assertions about rank and dimension of retarray into
runtime errors and only check them for retarray->data != NULL.
Do the same for correcting the stride from 0 to 1 in retarray.
(`m'name`'rtype_qual`_'atype_code): Likewise.
* m4/iforeach.m4 (name`'rtype_qual`_'atype_code): Likewise.
Change assertion about rank of array to runtime error.
(`m'name`'rtype_qual`_'atype_code): Likewise.
* generated/all_l4.c: Regenerated.
* generated/all_l8.c: Regenerated.
* generated/any_l4.c: Regenerated.
* generated/any_l8.c: Regenerated.
* generated/count_4_l4.c: Regenerated.
* generated/count_4_l8.c: Regenerated.
* generated/count_8_l4.c: Regenerated.
* generated/count_8_l8.c: Regenerated.
* generated/maxloc0_4_i4.c: Regenerated.
* generated/maxloc0_4_i8.c: Regenerated.
* generated/maxloc0_4_r4.c: Regenerated.
* generated/maxloc0_4_r8.c: Regenerated.
* generated/maxloc0_8_i4.c: Regenerated.
* generated/maxloc0_8_i8.c: Regenerated.
* generated/maxloc0_8_r4.c: Regenerated.
* generated/maxloc0_8_r8.c: Regenerated.
* generated/maxloc1_4_i4.c: Regenerated.
* generated/maxloc1_4_i8.c: Regenerated.
* generated/maxloc1_4_r4.c: Regenerated.
* generated/maxloc1_4_r8.c: Regenerated.
* generated/maxloc1_8_i4.c: Regenerated.
* generated/maxloc1_8_i8.c: Regenerated.
* generated/maxloc1_8_r4.c: Regenerated.
* generated/maxloc1_8_r8.c: Regenerated.
* generated/maxval_i4.c: Regenerated.
* generated/maxval_i8.c: Regenerated.
* generated/maxval_r4.c: Regenerated.
* generated/maxval_r8.c: Regenerated.
* generated/minloc0_4_i4.c: Regenerated.
* generated/minloc0_4_i8.c: Regenerated.
* generated/minloc0_4_r4.c: Regenerated.
* generated/minloc0_4_r8.c: Regenerated.
* generated/minloc0_8_i4.c: Regenerated.
* generated/minloc0_8_i8.c: Regenerated.
* generated/minloc0_8_r4.c: Regenerated.
* generated/minloc0_8_r8.c: Regenerated.
* generated/minloc1_4_i4.c: Regenerated.
* generated/minloc1_4_i8.c: Regenerated.
* generated/minloc1_4_r4.c: Regenerated.
* generated/minloc1_4_r8.c: Regenerated.
* generated/minloc1_8_i4.c: Regenerated.
* generated/minloc1_8_i8.c: Regenerated.
* generated/minloc1_8_r4.c: Regenerated.
* generated/minloc1_8_r8.c: Regenerated.
* generated/minval_i4.c: Regenerated.
* generated/minval_i8.c: Regenerated.
* generated/minval_r4.c: Regenerated.
* generated/minval_r8.c: Regenerated.
* generated/product_c4.c: Regenerated.
* generated/product_c8.c: Regenerated.
* generated/product_i4.c: Regenerated.
* generated/product_i8.c: Regenerated.
* generated/product_r4.c: Regenerated.
* generated/product_r8.c: Regenerated.
* generated/sum_c4.c: Regenerated.
* generated/sum_c8.c: Regenerated.
* generated/sum_i4.c: Regenerated.
* generated/sum_i8.c: Regenerated.
* generated/sum_r4.c: Regenerated.
* generated/sum_r8.c: Regenerated.
2005-04-09 Thomas Koenig <Thomas.Koenig@online.de> 2005-04-09 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/20163 PR libfortran/20163

View File

@ -55,11 +55,8 @@ all_l4 (gfc_array_l4 *retarray, gfc_array_l4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ all_l4 (gfc_array_l4 *retarray, gfc_array_l4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ all_l8 (gfc_array_l8 *retarray, gfc_array_l8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ all_l8 (gfc_array_l8 *retarray, gfc_array_l8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ any_l4 (gfc_array_l4 *retarray, gfc_array_l4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ any_l4 (gfc_array_l4 *retarray, gfc_array_l4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ any_l8 (gfc_array_l8 *retarray, gfc_array_l8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ any_l8 (gfc_array_l8 *retarray, gfc_array_l8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ count_4_l4 (gfc_array_i4 *retarray, gfc_array_l4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ count_4_l4 (gfc_array_i4 *retarray, gfc_array_l4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ count_4_l8 (gfc_array_i4 *retarray, gfc_array_l8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ count_4_l8 (gfc_array_i4 *retarray, gfc_array_l8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ count_8_l4 (gfc_array_i8 *retarray, gfc_array_l4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ count_8_l4 (gfc_array_i8 *retarray, gfc_array_l4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ count_8_l8 (gfc_array_i8 *retarray, gfc_array_l8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ count_8_l8 (gfc_array_i8 *retarray, gfc_array_l8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -53,13 +53,31 @@ maxloc0_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mmaxloc0_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ maxloc0_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mmaxloc0_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ maxloc0_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mmaxloc0_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ maxloc0_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mmaxloc0_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ maxloc0_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mmaxloc0_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ maxloc0_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mmaxloc0_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ maxloc0_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mmaxloc0_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ maxloc0_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mmaxloc0_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -57,11 +57,8 @@ maxloc1_4_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ maxloc1_4_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mmaxloc1_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mmaxloc1_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ maxloc1_4_i8 (gfc_array_i4 *retarray, gfc_array_i8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ maxloc1_4_i8 (gfc_array_i4 *retarray, gfc_array_i8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mmaxloc1_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mmaxloc1_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ maxloc1_4_r4 (gfc_array_i4 *retarray, gfc_array_r4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ maxloc1_4_r4 (gfc_array_i4 *retarray, gfc_array_r4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mmaxloc1_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mmaxloc1_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ maxloc1_4_r8 (gfc_array_i4 *retarray, gfc_array_r8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ maxloc1_4_r8 (gfc_array_i4 *retarray, gfc_array_r8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mmaxloc1_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mmaxloc1_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ maxloc1_8_i4 (gfc_array_i8 *retarray, gfc_array_i4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ maxloc1_8_i4 (gfc_array_i8 *retarray, gfc_array_i4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mmaxloc1_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mmaxloc1_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ maxloc1_8_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ maxloc1_8_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mmaxloc1_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ maxloc1_8_r4 (gfc_array_i8 *retarray, gfc_array_r4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ maxloc1_8_r4 (gfc_array_i8 *retarray, gfc_array_r4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mmaxloc1_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mmaxloc1_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ maxloc1_8_r8 (gfc_array_i8 *retarray, gfc_array_r8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ maxloc1_8_r8 (gfc_array_i8 *retarray, gfc_array_r8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mmaxloc1_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mmaxloc1_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -56,11 +56,8 @@ maxval_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -94,8 +91,17 @@ maxval_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -185,11 +191,8 @@ mmaxval_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -211,6 +214,34 @@ mmaxval_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -56,11 +56,8 @@ maxval_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -94,8 +91,17 @@ maxval_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -185,11 +191,8 @@ mmaxval_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -211,6 +214,34 @@ mmaxval_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -56,11 +56,8 @@ maxval_r4 (gfc_array_r4 *retarray, gfc_array_r4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -94,8 +91,17 @@ maxval_r4 (gfc_array_r4 *retarray, gfc_array_r4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -185,11 +191,8 @@ mmaxval_r4 (gfc_array_r4 * retarray, gfc_array_r4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -211,6 +214,34 @@ mmaxval_r4 (gfc_array_r4 * retarray, gfc_array_r4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_REAL_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -56,11 +56,8 @@ maxval_r8 (gfc_array_r8 *retarray, gfc_array_r8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -94,8 +91,17 @@ maxval_r8 (gfc_array_r8 *retarray, gfc_array_r8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -185,11 +191,8 @@ mmaxval_r8 (gfc_array_r8 * retarray, gfc_array_r8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -211,6 +214,34 @@ mmaxval_r8 (gfc_array_r8 * retarray, gfc_array_r8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_REAL_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -53,13 +53,31 @@ minloc0_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mminloc0_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ minloc0_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mminloc0_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ minloc0_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mminloc0_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ minloc0_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mminloc0_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ minloc0_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mminloc0_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ minloc0_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mminloc0_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ minloc0_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mminloc0_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -53,13 +53,31 @@ minloc0_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -150,17 +168,32 @@ mminloc0_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 *array,
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 0;
retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -57,11 +57,8 @@ minloc1_4_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ minloc1_4_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mminloc1_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mminloc1_4_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ minloc1_4_i8 (gfc_array_i4 *retarray, gfc_array_i8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ minloc1_4_i8 (gfc_array_i4 *retarray, gfc_array_i8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mminloc1_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mminloc1_4_i8 (gfc_array_i4 * retarray, gfc_array_i8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ minloc1_4_r4 (gfc_array_i4 *retarray, gfc_array_r4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ minloc1_4_r4 (gfc_array_i4 *retarray, gfc_array_r4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mminloc1_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mminloc1_4_r4 (gfc_array_i4 * retarray, gfc_array_r4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ minloc1_4_r8 (gfc_array_i4 *retarray, gfc_array_r8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ minloc1_4_r8 (gfc_array_i4 *retarray, gfc_array_r8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mminloc1_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mminloc1_4_r8 (gfc_array_i4 * retarray, gfc_array_r8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ minloc1_8_i4 (gfc_array_i8 *retarray, gfc_array_i4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ minloc1_8_i4 (gfc_array_i8 *retarray, gfc_array_i4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mminloc1_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mminloc1_8_i4 (gfc_array_i8 * retarray, gfc_array_i4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ minloc1_8_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ minloc1_8_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mminloc1_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mminloc1_8_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ minloc1_8_r4 (gfc_array_i8 *retarray, gfc_array_r4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ minloc1_8_r4 (gfc_array_i8 *retarray, gfc_array_r4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mminloc1_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mminloc1_8_r4 (gfc_array_i8 * retarray, gfc_array_r4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -57,11 +57,8 @@ minloc1_8_r8 (gfc_array_i8 *retarray, gfc_array_r8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -95,8 +92,17 @@ minloc1_8_r8 (gfc_array_i8 *retarray, gfc_array_r8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -191,11 +197,8 @@ mminloc1_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -217,6 +220,34 @@ mminloc1_8_r8 (gfc_array_i8 * retarray, gfc_array_r8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -56,11 +56,8 @@ minval_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -94,8 +91,17 @@ minval_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -185,11 +191,8 @@ mminval_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -211,6 +214,34 @@ mminval_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -56,11 +56,8 @@ minval_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -94,8 +91,17 @@ minval_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -185,11 +191,8 @@ mminval_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -211,6 +214,34 @@ mminval_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -56,11 +56,8 @@ minval_r4 (gfc_array_r4 *retarray, gfc_array_r4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -94,8 +91,17 @@ minval_r4 (gfc_array_r4 *retarray, gfc_array_r4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -185,11 +191,8 @@ mminval_r4 (gfc_array_r4 * retarray, gfc_array_r4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -211,6 +214,34 @@ mminval_r4 (gfc_array_r4 * retarray, gfc_array_r4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_REAL_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -56,11 +56,8 @@ minval_r8 (gfc_array_r8 *retarray, gfc_array_r8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -94,8 +91,17 @@ minval_r8 (gfc_array_r8 *retarray, gfc_array_r8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -185,11 +191,8 @@ mminval_r8 (gfc_array_r8 * retarray, gfc_array_r8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -211,6 +214,34 @@ mminval_r8 (gfc_array_r8 * retarray, gfc_array_r8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_REAL_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ product_c4 (gfc_array_c4 *retarray, gfc_array_c4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ product_c4 (gfc_array_c4 *retarray, gfc_array_c4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ mproduct_c4 (gfc_array_c4 * retarray, gfc_array_c4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ mproduct_c4 (gfc_array_c4 * retarray, gfc_array_c4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_COMPLEX_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ product_c8 (gfc_array_c8 *retarray, gfc_array_c8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ product_c8 (gfc_array_c8 *retarray, gfc_array_c8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ mproduct_c8 (gfc_array_c8 * retarray, gfc_array_c8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ mproduct_c8 (gfc_array_c8 * retarray, gfc_array_c8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_COMPLEX_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ product_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ product_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ mproduct_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ mproduct_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ product_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ product_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ mproduct_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ mproduct_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ product_r4 (gfc_array_r4 *retarray, gfc_array_r4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ product_r4 (gfc_array_r4 *retarray, gfc_array_r4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ mproduct_r4 (gfc_array_r4 * retarray, gfc_array_r4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ mproduct_r4 (gfc_array_r4 * retarray, gfc_array_r4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_REAL_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ product_r8 (gfc_array_r8 *retarray, gfc_array_r8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ product_r8 (gfc_array_r8 *retarray, gfc_array_r8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ mproduct_r8 (gfc_array_r8 * retarray, gfc_array_r8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ mproduct_r8 (gfc_array_r8 * retarray, gfc_array_r8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_REAL_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ sum_c4 (gfc_array_c4 *retarray, gfc_array_c4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ sum_c4 (gfc_array_c4 *retarray, gfc_array_c4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ msum_c4 (gfc_array_c4 * retarray, gfc_array_c4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ msum_c4 (gfc_array_c4 * retarray, gfc_array_c4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_COMPLEX_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ sum_c8 (gfc_array_c8 *retarray, gfc_array_c8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ sum_c8 (gfc_array_c8 *retarray, gfc_array_c8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ msum_c8 (gfc_array_c8 * retarray, gfc_array_c8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ msum_c8 (gfc_array_c8 * retarray, gfc_array_c8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_COMPLEX_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ sum_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ sum_i4 (gfc_array_i4 *retarray, gfc_array_i4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ msum_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ msum_i4 (gfc_array_i4 * retarray, gfc_array_i4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ sum_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ sum_i8 (gfc_array_i8 *retarray, gfc_array_i8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ msum_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ msum_i8 (gfc_array_i8 * retarray, gfc_array_i8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_INTEGER_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ sum_r4 (gfc_array_r4 *retarray, gfc_array_r4 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ sum_r4 (gfc_array_r4 *retarray, gfc_array_r4 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ msum_r4 (gfc_array_r4 * retarray, gfc_array_r4 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ msum_r4 (gfc_array_r4 * retarray, gfc_array_r4 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_REAL_4)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -55,11 +55,8 @@ sum_r8 (gfc_array_r8 *retarray, gfc_array_r8 *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -93,8 +90,17 @@ sum_r8 (gfc_array_r8 *retarray, gfc_array_r8 *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -183,11 +189,8 @@ msum_r8 (gfc_array_r8 * retarray, gfc_array_r8 * array,
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -209,6 +212,34 @@ msum_r8 (gfc_array_r8 * retarray, gfc_array_r8 * array,
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (GFC_REAL_8)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;

View File

@ -20,13 +20,31 @@ name`'rtype_qual`_'atype_code (rtype * retarray, atype *array)
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
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->base = 0;
retarray->data = internal_malloc_size (sizeof (rtype_name) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;
@ -109,17 +127,32 @@ void
index_type n; index_type n;
rank = GFC_DESCRIPTOR_RANK (array); rank = GFC_DESCRIPTOR_RANK (array);
assert (rank > 0); if (rank <= 0)
assert (GFC_DESCRIPTOR_RANK (retarray) == 1); runtime_error ("Rank of array needs to be > 0");
assert (retarray->dim[0].ubound + 1 - retarray->dim[0].lbound == rank);
assert (GFC_DESCRIPTOR_RANK (mask) == rank); 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->base = 0;
retarray->data = internal_malloc_size (sizeof (rtype_name) * 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");
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
}
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
dstride = retarray->dim[0].stride; dstride = retarray->dim[0].stride;
dest = retarray->data; dest = retarray->data;

View File

@ -40,11 +40,8 @@ name`'rtype_qual`_'atype_code (rtype *retarray, atype *array, index_type *pdim)
/* Make dim zero based to avoid confusion. */ /* Make dim zero based to avoid confusion. */
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
delta = array->dim[dim].stride; delta = array->dim[dim].stride;
@ -78,8 +75,17 @@ name`'rtype_qual`_'atype_code (rtype *retarray, atype *array, index_type *pdim)
* retarray->dim[rank-1].stride * retarray->dim[rank-1].stride
* extent[rank-1]); * extent[rank-1]);
retarray->base = 0; retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
} }
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;
@ -168,11 +174,8 @@ void
dim = (*pdim) - 1; dim = (*pdim) - 1;
rank = GFC_DESCRIPTOR_RANK (array) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1;
assert (rank == GFC_DESCRIPTOR_RANK (retarray));
if (array->dim[0].stride == 0) if (array->dim[0].stride == 0)
array->dim[0].stride = 1; array->dim[0].stride = 1;
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
if (len <= 0) if (len <= 0)
@ -194,6 +197,34 @@ void
array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
} }
if (retarray->data == NULL)
{
for (n = 0; n < rank; n++)
{
retarray->dim[n].lbound = 0;
retarray->dim[n].ubound = extent[n]-1;
if (n == 0)
retarray->dim[n].stride = 1;
else
retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1];
}
retarray->data
= internal_malloc_size (sizeof (rtype_name)
* retarray->dim[rank-1].stride
* extent[rank-1]);
retarray->base = 0;
retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
}
else
{
if (retarray->dim[0].stride == 0)
retarray->dim[0].stride = 1;
if (rank != GFC_DESCRIPTOR_RANK (retarray))
runtime_error ("rank of return array incorrect");
}
for (n = 0; n < rank; n++) for (n = 0; n < rank; n++)
{ {
count[n] = 0; count[n] = 0;