Patchwork [Fortran] PR 33197 Add NORM2 and PARITY

login
register
mail settings
Submitter Tobias Burnus
Date Aug. 27, 2010, 7:18 p.m.
Message ID <4C780F80.3050200@net-b.de>
Download mbox | patch
Permalink /patch/62866/
State New
Headers show

Comments

Tobias Burnus - Aug. 27, 2010, 7:18 p.m.
Daniel Kraft wrote:
> Tobias Burnus wrote:
>>  This patch adds NORM2 (= sqrt(sum(array**2))) and 
>> PARITY(logical_array) - and thus the last F2008 math intrinsics, 
>> which means that PR 33197 can be closed afterwards. (Though, there 
>> are still lots of bits-related intrinsics missing.)
>> [...]
>> Build and regtested on x86-64-linux.
>> OK for the trunk?
>
>    else
> -    gfc_init_block (&block);
>
> +    gfc_init_block (&block);
>    /* Do the actual summation/product.  */
>
> I'd rather have the blank line *after* than *before* the gfc_init_block.

Corrected.

> +      gfc_add_expr_to_block (&block, tmp);
>
> Are you sure you want the gfc_add_expr_to_block here?  tmp is only 
> used last a long way above...  What does this do?

Removed.

> +Calculates the Euclidean vector norm (@math{L_2} norm of
> This seems to miss a closing parenthesis.

Corrected.

> And most importantly:
>
> +         if (absX > scale)
> +           {
> +         result = 1.0 + result * (scale*scale) / (absX * absX);
> +         scale = absX;
> +           }
> +         else
> +           result += absX * absX / (scale*scale)
>
> I think you should not use (scale*scale)/(absX*absX) here (or the 
> other way round) but rather (scale/absX)**2.  This may lead to an 
> overflow.

Corrected (was approved by Daniel on IRC).

I have now committed the attached patch as Rev. 163595.

Thanks for the review, Daniel!

Tobias
gcc/fortran/
2010-08-27  Tobias Burnus  <burnus@net-b.de>

	PR fortran/33197
	* gcc/fortran/intrinsic.c (add_functions): Add norm2 and parity.
	* gcc/fortran/intrinsic.h (gfc_check_norm2, gfc_check_parity):
	gfc_simplify_norm2, gfc_simplify_parity, gfc_resolve_norm2,
	gfc_resolve_parity): New prototypes.
	* gcc/fortran/gfortran.h (gfc_isym_id): New enum items
	GFC_ISYM_NORM2 and GFC_ISYM_PARITY.
	* gcc/fortran/iresolve.c (gfc_resolve_norm2,
	gfc_resolve_parity): New functions.
	* gcc/fortran/check.c (gfc_check_norm2, gfc_check_parity):
	New functions.
	* gcc/fortran/trans-intrinsic.c (gfc_conv_intrinsic_arith,
	gfc_conv_intrinsic_function): Handle NORM2 and PARITY.
	* gcc/fortran/intrinsic.texi (NORM2, PARITY): Add.
	* gcc/fortran/simplify.c (simplify_transformation_to_array):
	Add post-processing opterator.
	(gfc_simplify_all, gfc_simplify_any, gfc_simplify_count,
	gfc_simplify_product, gfc_simplify_sum): Update call.
	(add_squared, do_sqrt, gfc_simplify_norm2, do_xor,
	gfc_simplify_parity): New functions.

gcc/testsuite/
2010-08-27  Tobias Burnus  <burnus@net-b.de>

	PR fortran/33197
	* gcc/testsuite/gfortran.dg/norm2_1.f90: New.
	* gcc/testsuite/gfortran.dg/norm2_2.f90: New.
	* gcc/testsuite/gfortran.dg/norm2_3.f90: New.
	* gcc/testsuite/gfortran.dg/norm2_4.f90: New.
	* gcc/testsuite/gfortran.dg/parity_1.f90: New.
	* gcc/testsuite/gfortran.dg/parity_2.f90: New.
	* gcc/testsuite/gfortran.dg/parity_3.f90: New.

libgfortran/
2010-08-27  Tobias Burnus  <burnus@net-b.de>

	PR fortran/33197
	* libgfortran/m4/ifunction.m4 (FINISH_ARRAY_FUNCTION,
	ARRAY_FUNCTION): Allow expression after loop.
	* libgfortran/m4/norm2.m4: New for _gfortran_norm2_r{4,8,10,16}.
	* libgfortran/m4/parity.m4: New for _gfortran_parity_l{1,2,4,8,16}.
	* libgfortran/gfortran.map: Add new functions.
	* libgfortran/Makefile.am: Ditto.
	* libgfortran/m4/minloc1.m4: Add empty argument for ARRAY_FUNCTION.
	* libgfortran/m4/maxloc1.m4: Ditto.
	* libgfortran/m4/all.m4: Ditto.
	* libgfortran/m4/minval.m4: Ditto.
	* libgfortran/m4/maxval.m4: Ditto.
	* libgfortran/m4/count.m4: Ditto.
	* libgfortran/m4/product.m4: Ditto.
	* libgfortran/m4/any.m4: Ditto.

	* Makefile.in: Regenerated.
	* generated/minval_r8.c: Regenerated.
	* generated/maxloc1_4_r8.c: Regenerated.
	* generated/minloc1_16_r16.c: Regenerated.
	* generated/norm2_r4.c: Regenerated.
	* generated/sum_i8.c: Regenerated.
	* generated/parity_l2.c: Regenerated.
	* generated/any_l16.c: Regenerated.
	* generated/maxval_i2.c: Regenerated.
	* generated/any_l2.c: Regenerated.
	* generated/product_r4.c: Regenerated.
	* generated/maxloc1_8_i4.c: Regenerated.
	* generated/parity_l16.c: Regenerated.
	* generated/all_l1.c: Regenerated.
	* generated/product_i2.c: Regenerated.
	* generated/minloc1_8_r16.c: Regenerated.
	* generated/maxloc1_8_r16.c: Regenerated.
	* generated/sum_r16.c: Regenerated.
	* generated/sum_i1.c: Regenerated.
	* generated/minloc1_4_r8.c: Regenerated.
	* generated/maxloc1_16_r16.c: Regenerated.
	* generated/minloc1_16_i4.c: Regenerated.
	* generated/maxloc1_16_i4.c: Regenerated.
	* generated/maxval_r16.c: Regenerated.
	* generated/product_c10.c: Regenerated.
	* generated/minloc1_8_i4.c: Regenerated.
	* generated/all_l2.c: Regenerated.
	* generated/product_c4.c: Regenerated.
	* generated/sum_r4.c: Regenerated.
	* generated/all_l16.c: Regenerated.
	* generated/minloc1_16_r10.c: Regenerated.
	* generated/sum_i2.c: Regenerated.
	* generated/maxloc1_8_r8.c: Regenerated.
	* generated/minval_i16.c: Regenerated.
	* generated/parity_l4.c: Regenerated.
	* generated/maxval_i4.c: Regenerated.
	* generated/any_l4.c: Regenerated.
	* generated/minval_i8.c: Regenerated.
	* generated/maxloc1_4_i8.c: Regenerated.
	* generated/minloc1_4_i16.c: Regenerated.
	* generated/maxloc1_4_i16.c: Regenerated.
	* generated/minloc1_8_r10.c: Regenerated.
	* generated/product_i4.c: Regenerated.
	* generated/maxloc1_8_r10.c: Regenerated.
	* generated/sum_c16.c: Regenerated.
	* generated/minloc1_16_r8.c: Regenerated.
	* generated/maxloc1_16_r8.c: Regenerated.
	* generated/count_4_l.c: Regenerated.
	* generated/sum_r10.c: Regenerated.
	* generated/count_8_l.c: Regenerated.
	* generated/sum_c4.c: Regenerated.
	* generated/maxloc1_16_r10.c: Regenerated.
	* generated/minloc1_8_r8.c: Regenerated.
	* generated/maxval_r10.c: Regenerated.
	* generated/minval_i1.c: Regenerated.
	* generated/maxloc1_4_i1.c: Regenerated.
	* generated/minloc1_4_i8.c: Regenerated.
	* generated/product_i16.c: Regenerated.
	* generated/all_l4.c: Regenerated.
	* generated/norm2_r16.c: Regenerated.
	* generated/minval_r4.c: Regenerated.
	* generated/maxloc1_4_r4.c: Regenerated.
	* generated/sum_i4.c: Regenerated.
	* generated/maxval_r8.c: Regenerated.
	* generated/norm2_r8.c: Regenerated.
	* generated/minloc1_4_i1.c: Regenerated.
	* generated/minval_r16.c: Regenerated.
	* generated/minval_i2.c: Regenerated.
	* generated/maxloc1_4_i2.c: Regenerated.
	* generated/product_r8.c: Regenerated.
	* generated/maxloc1_8_i8.c: Regenerated.
	* generated/sum_c10.c: Regenerated.
	* generated/minloc1_4_r16.c: Regenerated.
	* generated/maxloc1_4_r16.c: Regenerated.
	* generated/count_1_l.c: Regenerated.
	* generated/minloc1_4_r4.c: Regenerated.
	* generated/minloc1_16_i8.c: Regenerated.
	* generated/maxloc1_16_i8.c: Regenerated.
	* generated/minloc1_4_i2.c: Regenerated.
	* generated/maxloc1_8_i1.c: Regenerated.
	* generated/minloc1_8_i8.c: Regenerated.
	* generated/product_r16.c: Regenerated.
	* generated/product_c8.c: Regenerated.
	* generated/sum_r8.c: Regenerated.
	* generated/norm2_r10.c: Regenerated.
	* generated/minloc1_16_i16.c: Regenerated.
	* generated/maxloc1_8_r4.c: Regenerated.
	* generated/minloc1_16_i1.c: Regenerated.
	* generated/maxloc1_16_i1.c: Regenerated.
	* generated/minval_r10.c: Regenerated.
	* generated/count_16_l.c: Regenerated.
	* generated/parity_l8.c: Regenerated.
	* generated/minloc1_8_i1.c: Regenerated.
	* generated/minval_i4.c: Regenerated.
	* generated/maxloc1_4_i4.c: Regenerated.
	* generated/maxloc1_8_i2.c: Regenerated.
	* generated/maxval_i8.c: Regenerated.
	* generated/any_l8.c: Regenerated.
	* generated/minloc1_4_r10.c: Regenerated.
	* generated/minloc1_8_i16.c: Regenerated.
	* generated/maxloc1_4_r10.c: Regenerated.
	* generated/maxloc1_8_i16.c: Regenerated.
	* generated/minloc1_16_r4.c: Regenerated.
	* generated/maxloc1_16_r4.c: Regenerated.
	* generated/product_i8.c: Regenerated.
	* generated/sum_i16.c: Regenerated.
	* generated/count_2_l.c: Regenerated.
	* generated/maxloc1_16_i16.c: Regenerated.
	* generated/minloc1_8_r4.c: Regenerated.
	* generated/sum_c8.c: Regenerated.
	* generated/minloc1_16_i2.c: Regenerated.
	* generated/maxloc1_16_i2.c: Regenerated.
	* generated/parity_l1.c: Regenerated.
	* generated/maxval_i16.c: Regenerated.
	* generated/maxval_i1.c: Regenerated.
	* generated/minloc1_4_i4.c: Regenerated.
	* generated/any_l1.c: Regenerated.
	* generated/minloc1_8_i2.c: Regenerated.
	* generated/product_c16.c: Regenerated.
	* generated/product_r10.c: Regenerated.
	* generated/product_i1.c: Regenerated.
	* generated/all_l8.c: Regenerated.
	* generated/maxval_r4.c: Regenerated.

Patch

Index: libgfortran/Makefile.in
===================================================================
--- libgfortran/Makefile.in	(Revision 163593)
+++ libgfortran/Makefile.in	(Arbeitskopie)
@@ -144,40 +144,43 @@  am__objects_12 = sum_i1.lo sum_i2.lo sum
 	sum_r4.lo sum_r8.lo sum_r10.lo sum_r16.lo sum_c4.lo sum_c8.lo \
 	sum_c10.lo sum_c16.lo
 am__objects_13 = bessel_r4.lo bessel_r8.lo bessel_r10.lo bessel_r16.lo
-am__objects_14 = matmul_i1.lo matmul_i2.lo matmul_i4.lo matmul_i8.lo \
+am__objects_14 = norm2_r4.lo norm2_r8.lo norm2_r10.lo norm2_r16.lo
+am__objects_15 = parity_l1.lo parity_l2.lo parity_l4.lo parity_l8.lo \
+	parity_l16.lo
+am__objects_16 = matmul_i1.lo matmul_i2.lo matmul_i4.lo matmul_i8.lo \
 	matmul_i16.lo matmul_r4.lo matmul_r8.lo matmul_r10.lo \
 	matmul_r16.lo matmul_c4.lo matmul_c8.lo matmul_c10.lo \
 	matmul_c16.lo
-am__objects_15 = matmul_l4.lo matmul_l8.lo matmul_l16.lo
-am__objects_16 = transpose_i4.lo transpose_i8.lo transpose_i16.lo \
+am__objects_17 = matmul_l4.lo matmul_l8.lo matmul_l16.lo
+am__objects_18 = transpose_i4.lo transpose_i8.lo transpose_i16.lo \
 	transpose_r4.lo transpose_r8.lo transpose_r10.lo \
 	transpose_r16.lo transpose_c4.lo transpose_c8.lo \
 	transpose_c10.lo transpose_c16.lo
-am__objects_17 = shape_i4.lo shape_i8.lo shape_i16.lo
-am__objects_18 = eoshift1_4.lo eoshift1_8.lo eoshift1_16.lo
-am__objects_19 = eoshift3_4.lo eoshift3_8.lo eoshift3_16.lo
-am__objects_20 = cshift1_4.lo cshift1_8.lo cshift1_16.lo
-am__objects_21 = reshape_i4.lo reshape_i8.lo reshape_i16.lo \
+am__objects_19 = shape_i4.lo shape_i8.lo shape_i16.lo
+am__objects_20 = eoshift1_4.lo eoshift1_8.lo eoshift1_16.lo
+am__objects_21 = eoshift3_4.lo eoshift3_8.lo eoshift3_16.lo
+am__objects_22 = cshift1_4.lo cshift1_8.lo cshift1_16.lo
+am__objects_23 = reshape_i4.lo reshape_i8.lo reshape_i16.lo \
 	reshape_r4.lo reshape_r8.lo reshape_r10.lo reshape_r16.lo \
 	reshape_c4.lo reshape_c8.lo reshape_c10.lo reshape_c16.lo
-am__objects_22 = in_pack_i1.lo in_pack_i2.lo in_pack_i4.lo \
+am__objects_24 = in_pack_i1.lo in_pack_i2.lo in_pack_i4.lo \
 	in_pack_i8.lo in_pack_i16.lo in_pack_r4.lo in_pack_r8.lo \
 	in_pack_r10.lo in_pack_r16.lo in_pack_c4.lo in_pack_c8.lo \
 	in_pack_c10.lo in_pack_c16.lo
-am__objects_23 = in_unpack_i1.lo in_unpack_i2.lo in_unpack_i4.lo \
+am__objects_25 = in_unpack_i1.lo in_unpack_i2.lo in_unpack_i4.lo \
 	in_unpack_i8.lo in_unpack_i16.lo in_unpack_r4.lo \
 	in_unpack_r8.lo in_unpack_r10.lo in_unpack_r16.lo \
 	in_unpack_c4.lo in_unpack_c8.lo in_unpack_c10.lo \
 	in_unpack_c16.lo
-am__objects_24 = exponent_r4.lo exponent_r8.lo exponent_r10.lo \
+am__objects_26 = exponent_r4.lo exponent_r8.lo exponent_r10.lo \
 	exponent_r16.lo
-am__objects_25 = fraction_r4.lo fraction_r8.lo fraction_r10.lo \
+am__objects_27 = fraction_r4.lo fraction_r8.lo fraction_r10.lo \
 	fraction_r16.lo
-am__objects_26 = nearest_r4.lo nearest_r8.lo nearest_r10.lo \
+am__objects_28 = nearest_r4.lo nearest_r8.lo nearest_r10.lo \
 	nearest_r16.lo
-am__objects_27 = set_exponent_r4.lo set_exponent_r8.lo \
+am__objects_29 = set_exponent_r4.lo set_exponent_r8.lo \
 	set_exponent_r10.lo set_exponent_r16.lo
-am__objects_28 = pow_i4_i4.lo pow_i8_i4.lo pow_i16_i4.lo pow_c4_i4.lo \
+am__objects_30 = pow_i4_i4.lo pow_i8_i4.lo pow_i16_i4.lo pow_c4_i4.lo \
 	pow_c8_i4.lo pow_c10_i4.lo pow_c16_i4.lo pow_i4_i8.lo \
 	pow_i8_i8.lo pow_i16_i8.lo pow_r4_i8.lo pow_r8_i8.lo \
 	pow_r10_i8.lo pow_r16_i8.lo pow_c4_i8.lo pow_c8_i8.lo \
@@ -185,26 +188,26 @@  am__objects_28 = pow_i4_i4.lo pow_i8_i4.
 	pow_i16_i16.lo pow_r4_i16.lo pow_r8_i16.lo pow_r10_i16.lo \
 	pow_r16_i16.lo pow_c4_i16.lo pow_c8_i16.lo pow_c10_i16.lo \
 	pow_c16_i16.lo
-am__objects_29 = rrspacing_r4.lo rrspacing_r8.lo rrspacing_r10.lo \
+am__objects_31 = rrspacing_r4.lo rrspacing_r8.lo rrspacing_r10.lo \
 	rrspacing_r16.lo
-am__objects_30 = spacing_r4.lo spacing_r8.lo spacing_r10.lo \
+am__objects_32 = spacing_r4.lo spacing_r8.lo spacing_r10.lo \
 	spacing_r16.lo
-am__objects_31 = pack_i1.lo pack_i2.lo pack_i4.lo pack_i8.lo \
+am__objects_33 = pack_i1.lo pack_i2.lo pack_i4.lo pack_i8.lo \
 	pack_i16.lo pack_r4.lo pack_r8.lo pack_r10.lo pack_r16.lo \
 	pack_c4.lo pack_c8.lo pack_c10.lo pack_c16.lo
-am__objects_32 = unpack_i1.lo unpack_i2.lo unpack_i4.lo unpack_i8.lo \
+am__objects_34 = unpack_i1.lo unpack_i2.lo unpack_i4.lo unpack_i8.lo \
 	unpack_i16.lo unpack_r4.lo unpack_r8.lo unpack_r10.lo \
 	unpack_r16.lo unpack_c4.lo unpack_c8.lo unpack_c10.lo \
 	unpack_c16.lo
-am__objects_33 = spread_i1.lo spread_i2.lo spread_i4.lo spread_i8.lo \
+am__objects_35 = spread_i1.lo spread_i2.lo spread_i4.lo spread_i8.lo \
 	spread_i16.lo spread_r4.lo spread_r8.lo spread_r10.lo \
 	spread_r16.lo spread_c4.lo spread_c8.lo spread_c10.lo \
 	spread_c16.lo
-am__objects_34 = cshift0_i1.lo cshift0_i2.lo cshift0_i4.lo \
+am__objects_36 = cshift0_i1.lo cshift0_i2.lo cshift0_i4.lo \
 	cshift0_i8.lo cshift0_i16.lo cshift0_r4.lo cshift0_r8.lo \
 	cshift0_r10.lo cshift0_r16.lo cshift0_c4.lo cshift0_c8.lo \
 	cshift0_c10.lo cshift0_c16.lo
-am__objects_35 = $(am__objects_2) $(am__objects_3) $(am__objects_4) \
+am__objects_37 = $(am__objects_2) $(am__objects_3) $(am__objects_4) \
 	$(am__objects_5) $(am__objects_6) $(am__objects_7) \
 	$(am__objects_8) $(am__objects_9) $(am__objects_10) \
 	$(am__objects_11) $(am__objects_12) $(am__objects_13) \
@@ -214,11 +217,12 @@  am__objects_35 = $(am__objects_2) $(am__
 	$(am__objects_23) $(am__objects_24) $(am__objects_25) \
 	$(am__objects_26) $(am__objects_27) $(am__objects_28) \
 	$(am__objects_29) $(am__objects_30) $(am__objects_31) \
-	$(am__objects_32) $(am__objects_33) $(am__objects_34)
-am__objects_36 = close.lo file_pos.lo format.lo inquire.lo \
+	$(am__objects_32) $(am__objects_33) $(am__objects_34) \
+	$(am__objects_35) $(am__objects_36)
+am__objects_38 = close.lo file_pos.lo format.lo inquire.lo \
 	intrinsics.lo list_read.lo lock.lo open.lo read.lo \
 	size_from_kind.lo transfer.lo unit.lo unix.lo write.lo fbuf.lo
-am__objects_37 = associated.lo abort.lo access.lo args.lo \
+am__objects_39 = associated.lo abort.lo access.lo args.lo \
 	bit_intrinsics.lo c99_functions.lo chdir.lo chmod.lo clock.lo \
 	cpu_time.lo cshift0.lo ctime.lo date_and_time.lo dtime.lo \
 	env.lo eoshift0.lo eoshift2.lo erfc_scaled.lo etime.lo exit.lo \
@@ -233,8 +237,8 @@  am__objects_37 = associated.lo abort.lo
 	system_clock.lo time.lo transpose_generic.lo umask.lo \
 	unlink.lo unpack_generic.lo in_pack_generic.lo \
 	in_unpack_generic.lo
-am__objects_38 =
-am__objects_39 = _abs_c4.lo _abs_c8.lo _abs_c10.lo _abs_c16.lo \
+am__objects_40 =
+am__objects_41 = _abs_c4.lo _abs_c8.lo _abs_c10.lo _abs_c16.lo \
 	_abs_i4.lo _abs_i8.lo _abs_i16.lo _abs_r4.lo _abs_r8.lo \
 	_abs_r10.lo _abs_r16.lo _aimag_c4.lo _aimag_c8.lo \
 	_aimag_c10.lo _aimag_c16.lo _exp_r4.lo _exp_r8.lo _exp_r10.lo \
@@ -258,18 +262,18 @@  am__objects_39 = _abs_c4.lo _abs_c8.lo _
 	_conjg_c4.lo _conjg_c8.lo _conjg_c10.lo _conjg_c16.lo \
 	_aint_r4.lo _aint_r8.lo _aint_r10.lo _aint_r16.lo _anint_r4.lo \
 	_anint_r8.lo _anint_r10.lo _anint_r16.lo
-am__objects_40 = _sign_i4.lo _sign_i8.lo _sign_i16.lo _sign_r4.lo \
+am__objects_42 = _sign_i4.lo _sign_i8.lo _sign_i16.lo _sign_r4.lo \
 	_sign_r8.lo _sign_r10.lo _sign_r16.lo _dim_i4.lo _dim_i8.lo \
 	_dim_i16.lo _dim_r4.lo _dim_r8.lo _dim_r10.lo _dim_r16.lo \
 	_atan2_r4.lo _atan2_r8.lo _atan2_r10.lo _atan2_r16.lo \
 	_mod_i4.lo _mod_i8.lo _mod_i16.lo _mod_r4.lo _mod_r8.lo \
 	_mod_r10.lo _mod_r16.lo
-am__objects_41 = misc_specifics.lo
-am__objects_42 = $(am__objects_39) $(am__objects_40) $(am__objects_41) \
+am__objects_43 = misc_specifics.lo
+am__objects_44 = $(am__objects_41) $(am__objects_42) $(am__objects_43) \
 	dprod_r8.lo f2c_specifics.lo
-am__objects_43 = $(am__objects_1) $(am__objects_35) $(am__objects_36) \
-	$(am__objects_37) $(am__objects_38) $(am__objects_42)
-@onestep_FALSE@am_libgfortran_la_OBJECTS = $(am__objects_43)
+am__objects_45 = $(am__objects_1) $(am__objects_37) $(am__objects_38) \
+	$(am__objects_39) $(am__objects_40) $(am__objects_44)
+@onestep_FALSE@am_libgfortran_la_OBJECTS = $(am__objects_45)
 @onestep_TRUE@am_libgfortran_la_OBJECTS = libgfortran_c.lo
 libgfortran_la_OBJECTS = $(am_libgfortran_la_OBJECTS)
 libgfortranbegin_la_LIBADD =
@@ -742,6 +746,19 @@  $(srcdir)/generated/minval_r8.c \
 $(srcdir)/generated/minval_r10.c \
 $(srcdir)/generated/minval_r16.c
 
+i_norm2_c = \
+$(srcdir)/generated/norm2_r4.c \
+$(srcdir)/generated/norm2_r8.c \
+$(srcdir)/generated/norm2_r10.c \
+$(srcdir)/generated/norm2_r16.c
+
+i_parity_c = \
+$(srcdir)/generated/parity_l1.c \
+$(srcdir)/generated/parity_l2.c \
+$(srcdir)/generated/parity_l4.c \
+$(srcdir)/generated/parity_l8.c \
+$(srcdir)/generated/parity_l16.c
+
 i_sum_c = \
 $(srcdir)/generated/sum_i1.c \
 $(srcdir)/generated/sum_i2.c \
@@ -1004,11 +1021,11 @@  m4_files = m4/iparm.m4 m4/ifunction.m4 m
     m4/transpose.m4 m4/eoshift1.m4 m4/eoshift3.m4 m4/exponent.m4 \
     m4/fraction.m4 m4/nearest.m4 m4/set_exponent.m4 m4/pow.m4 \
     m4/misc_specifics.m4 m4/rrspacing.m4 m4/spacing.m4 m4/pack.m4 \
-    m4/unpack.m4 m4/spread.m4 m4/bessel.m4
+    m4/unpack.m4 m4/spread.m4 m4/bessel.m4 m4/norm2.m4 m4/parity.m4
 
 gfor_built_src = $(i_all_c) $(i_any_c) $(i_count_c) $(i_maxloc0_c) \
     $(i_maxloc1_c) $(i_maxval_c) $(i_minloc0_c) $(i_minloc1_c) $(i_minval_c) \
-    $(i_product_c) $(i_sum_c) $(i_bessel_c) \
+    $(i_product_c) $(i_sum_c) $(i_bessel_c) $(i_norm2_c) $(i_parity_c) \
     $(i_matmul_c) $(i_matmull_c) $(i_transpose_c) $(i_shape_c) $(i_eoshift1_c) \
     $(i_eoshift3_c) $(i_cshift1_c) $(i_reshape_c) $(in_pack_c) $(in_unpack_c) \
     $(i_exponent_c) $(i_fraction_c) $(i_nearest_c) $(i_set_exponent_c) \
@@ -1598,6 +1615,10 @@  distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nearest_r16.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nearest_r4.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nearest_r8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/norm2_r10.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/norm2_r16.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/norm2_r4.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/norm2_r8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pack_c10.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pack_c16.Plo@am__quote@
@@ -1613,6 +1634,11 @@  distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pack_r16.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pack_r4.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pack_r8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parity_l1.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parity_l16.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parity_l2.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parity_l4.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parity_l8.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pause.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perror.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_c10_i16.Plo@am__quote@
@@ -3495,6 +3521,69 @@  bessel_r16.lo: $(srcdir)/generated/besse
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bessel_r16.lo `test -f '$(srcdir)/generated/bessel_r16.c' || echo '$(srcdir)/'`$(srcdir)/generated/bessel_r16.c
 
+norm2_r4.lo: $(srcdir)/generated/norm2_r4.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT norm2_r4.lo -MD -MP -MF $(DEPDIR)/norm2_r4.Tpo -c -o norm2_r4.lo `test -f '$(srcdir)/generated/norm2_r4.c' || echo '$(srcdir)/'`$(srcdir)/generated/norm2_r4.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/norm2_r4.Tpo $(DEPDIR)/norm2_r4.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/generated/norm2_r4.c' object='norm2_r4.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o norm2_r4.lo `test -f '$(srcdir)/generated/norm2_r4.c' || echo '$(srcdir)/'`$(srcdir)/generated/norm2_r4.c
+
+norm2_r8.lo: $(srcdir)/generated/norm2_r8.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT norm2_r8.lo -MD -MP -MF $(DEPDIR)/norm2_r8.Tpo -c -o norm2_r8.lo `test -f '$(srcdir)/generated/norm2_r8.c' || echo '$(srcdir)/'`$(srcdir)/generated/norm2_r8.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/norm2_r8.Tpo $(DEPDIR)/norm2_r8.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/generated/norm2_r8.c' object='norm2_r8.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o norm2_r8.lo `test -f '$(srcdir)/generated/norm2_r8.c' || echo '$(srcdir)/'`$(srcdir)/generated/norm2_r8.c
+
+norm2_r10.lo: $(srcdir)/generated/norm2_r10.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT norm2_r10.lo -MD -MP -MF $(DEPDIR)/norm2_r10.Tpo -c -o norm2_r10.lo `test -f '$(srcdir)/generated/norm2_r10.c' || echo '$(srcdir)/'`$(srcdir)/generated/norm2_r10.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/norm2_r10.Tpo $(DEPDIR)/norm2_r10.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/generated/norm2_r10.c' object='norm2_r10.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o norm2_r10.lo `test -f '$(srcdir)/generated/norm2_r10.c' || echo '$(srcdir)/'`$(srcdir)/generated/norm2_r10.c
+
+norm2_r16.lo: $(srcdir)/generated/norm2_r16.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT norm2_r16.lo -MD -MP -MF $(DEPDIR)/norm2_r16.Tpo -c -o norm2_r16.lo `test -f '$(srcdir)/generated/norm2_r16.c' || echo '$(srcdir)/'`$(srcdir)/generated/norm2_r16.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/norm2_r16.Tpo $(DEPDIR)/norm2_r16.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/generated/norm2_r16.c' object='norm2_r16.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o norm2_r16.lo `test -f '$(srcdir)/generated/norm2_r16.c' || echo '$(srcdir)/'`$(srcdir)/generated/norm2_r16.c
+
+parity_l1.lo: $(srcdir)/generated/parity_l1.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT parity_l1.lo -MD -MP -MF $(DEPDIR)/parity_l1.Tpo -c -o parity_l1.lo `test -f '$(srcdir)/generated/parity_l1.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l1.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/parity_l1.Tpo $(DEPDIR)/parity_l1.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/generated/parity_l1.c' object='parity_l1.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o parity_l1.lo `test -f '$(srcdir)/generated/parity_l1.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l1.c
+
+parity_l2.lo: $(srcdir)/generated/parity_l2.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT parity_l2.lo -MD -MP -MF $(DEPDIR)/parity_l2.Tpo -c -o parity_l2.lo `test -f '$(srcdir)/generated/parity_l2.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l2.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/parity_l2.Tpo $(DEPDIR)/parity_l2.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/generated/parity_l2.c' object='parity_l2.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o parity_l2.lo `test -f '$(srcdir)/generated/parity_l2.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l2.c
+
+parity_l4.lo: $(srcdir)/generated/parity_l4.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT parity_l4.lo -MD -MP -MF $(DEPDIR)/parity_l4.Tpo -c -o parity_l4.lo `test -f '$(srcdir)/generated/parity_l4.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l4.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/parity_l4.Tpo $(DEPDIR)/parity_l4.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/generated/parity_l4.c' object='parity_l4.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o parity_l4.lo `test -f '$(srcdir)/generated/parity_l4.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l4.c
+
+parity_l8.lo: $(srcdir)/generated/parity_l8.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT parity_l8.lo -MD -MP -MF $(DEPDIR)/parity_l8.Tpo -c -o parity_l8.lo `test -f '$(srcdir)/generated/parity_l8.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l8.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/parity_l8.Tpo $(DEPDIR)/parity_l8.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/generated/parity_l8.c' object='parity_l8.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o parity_l8.lo `test -f '$(srcdir)/generated/parity_l8.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l8.c
+
+parity_l16.lo: $(srcdir)/generated/parity_l16.c
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT parity_l16.lo -MD -MP -MF $(DEPDIR)/parity_l16.Tpo -c -o parity_l16.lo `test -f '$(srcdir)/generated/parity_l16.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l16.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/parity_l16.Tpo $(DEPDIR)/parity_l16.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/generated/parity_l16.c' object='parity_l16.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o parity_l16.lo `test -f '$(srcdir)/generated/parity_l16.c' || echo '$(srcdir)/'`$(srcdir)/generated/parity_l16.c
+
 matmul_i1.lo: $(srcdir)/generated/matmul_i1.c
 @am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT matmul_i1.lo -MD -MP -MF $(DEPDIR)/matmul_i1.Tpo -c -o matmul_i1.lo `test -f '$(srcdir)/generated/matmul_i1.c' || echo '$(srcdir)/'`$(srcdir)/generated/matmul_i1.c
 @am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/matmul_i1.Tpo $(DEPDIR)/matmul_i1.Plo
@@ -5603,6 +5692,12 @@  fpu-target.h: $(srcdir)/$(FPU_HOST_HEADE
 @MAINTAINER_MODE_TRUE@$(i_matmull_c): m4/matmull.m4 $(I_M4_DEPS)
 @MAINTAINER_MODE_TRUE@	$(M4) -Dfile=$@ -I$(srcdir)/m4 matmull.m4 > $@
 
+@MAINTAINER_MODE_TRUE@$(i_norm2_c): m4/norm2.m4 $(I_M4_DEPS)
+@MAINTAINER_MODE_TRUE@	$(M4) -Dfile=$@ -I$(srcdir)/m4 norm2.m4 > $@
+
+@MAINTAINER_MODE_TRUE@$(i_parity_c): m4/parity.m4 $(I_M4_DEPS)
+@MAINTAINER_MODE_TRUE@	$(M4) -Dfile=$@ -I$(srcdir)/m4 parity.m4 > $@
+
 @MAINTAINER_MODE_TRUE@$(i_transpose_c): m4/transpose.m4 $(I_M4_DEPS)
 @MAINTAINER_MODE_TRUE@	$(M4) -Dfile=$@ -I$(srcdir)/m4 transpose.m4 > $@
 
Index: libgfortran/generated/minval_r8.c
===================================================================
--- libgfortran/generated/minval_r8.c	(Revision 163593)
+++ libgfortran/generated/minval_r8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  minval_r8 (gfc_array_r8 * const restrict
 		if (*src < result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_16_r16.c
===================================================================
--- libgfortran/generated/minloc1_16_r16.c	(Revision 163593)
+++ libgfortran/generated/minloc1_16_r16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_16_r16 (gfc_array_i16 * const re
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_4_r8.c
===================================================================
--- libgfortran/generated/maxloc1_4_r8.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_4_r8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_4_r8 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/norm2_r4.c
===================================================================
--- libgfortran/generated/norm2_r4.c	(Revision 0)
+++ libgfortran/generated/norm2_r4.c	(Revision 0)
@@ -0,0 +1,208 @@ 
+/* Implementation of the NORM2 intrinsic
+   Copyright 2010 Free Software Foundation, Inc.
+   Contributed by Tobias Burnus  <burnus@net-b.de>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+
+#if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_REAL_4)
+
+
+extern void norm2_r4 (gfc_array_r4 * const restrict, 
+	gfc_array_r4 * const restrict, const index_type * const restrict);
+export_proto(norm2_r4);
+
+void
+norm2_r4 (gfc_array_r4 * const restrict retarray, 
+	gfc_array_r4 * const restrict array, 
+	const index_type * const restrict pdim)
+{
+  index_type count[GFC_MAX_DIMENSIONS];
+  index_type extent[GFC_MAX_DIMENSIONS];
+  index_type sstride[GFC_MAX_DIMENSIONS];
+  index_type dstride[GFC_MAX_DIMENSIONS];
+  const GFC_REAL_4 * restrict base;
+  GFC_REAL_4 * restrict dest;
+  index_type rank;
+  index_type n;
+  index_type len;
+  index_type delta;
+  index_type dim;
+  int continue_loop;
+
+  /* Make dim zero based to avoid confusion.  */
+  dim = (*pdim) - 1;
+  rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
+  if (len < 0)
+    len = 0;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+
+  for (n = 0; n < dim; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+  for (n = dim; n < rank; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+
+  if (retarray->data == NULL)
+    {
+      size_t alloc_size, str;
+
+      for (n = 0; n < rank; n++)
+	{
+	  if (n == 0)
+	    str = 1;
+	  else
+	    str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
+	}
+
+      retarray->offset = 0;
+      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+
+      alloc_size = sizeof (GFC_REAL_4) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
+    		   * extent[rank-1];
+
+      if (alloc_size == 0)
+	{
+	  /* Make sure we have a zero-sized array.  */
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
+	  return;
+
+	}
+      else
+	retarray->data = internal_malloc_size (alloc_size);
+    }
+  else
+    {
+      if (rank != GFC_DESCRIPTOR_RANK (retarray))
+	runtime_error ("rank of return array incorrect in"
+		       " NORM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
+
+      if (unlikely (compile_options.bounds_check))
+	bounds_ifunction_return ((array_t *) retarray, extent,
+				 "return value", "NORM");
+    }
+
+  for (n = 0; n < rank; n++)
+    {
+      count[n] = 0;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      if (extent[n] <= 0)
+	len = 0;
+    }
+
+  base = array->data;
+  dest = retarray->data;
+
+  continue_loop = 1;
+  while (continue_loop)
+    {
+      const GFC_REAL_4 * restrict src;
+      GFC_REAL_4 result;
+      src = base;
+      {
+
+	GFC_REAL_4 scale;
+	result = 0.0F;
+	scale = 1.0F;
+	if (len <= 0)
+	  *dest = 0.0F;
+	else
+	  {
+	    for (n = 0; n < len; n++, src += delta)
+	      {
+
+	  if (*src != 0.0F)
+	    {
+	      GFC_REAL_4 absX, val;
+	      absX = fabsf (*src);
+	      if (scale < absX)
+		{
+		  val = scale / absX;
+		  result = 1.0F + result * val * val;
+		  scale = absX;
+		}
+	      else
+		{
+		  val = absX / scale;
+		  result += val * val;
+		}
+	    }
+	      }
+	    result = scale * sqrtf (result);
+	    *dest = result;
+	  }
+      }
+      /* Advance to the next element.  */
+      count[0]++;
+      base += sstride[0];
+      dest += dstride[0];
+      n = 0;
+      while (count[n] == extent[n])
+	{
+	  /* When we get to the end of a dimension, reset it and increment
+	     the next dimension.  */
+	  count[n] = 0;
+	  /* We could precalculate these products, but this is a less
+	     frequently used path so probably not worth it.  */
+	  base -= sstride[n] * extent[n];
+	  dest -= dstride[n] * extent[n];
+	  n++;
+	  if (n == rank)
+	    {
+	      /* Break out of the look.  */
+	      continue_loop = 0;
+	      break;
+	    }
+	  else
+	    {
+	      count[n]++;
+	      base += sstride[n];
+	      dest += dstride[n];
+	    }
+	}
+    }
+}
+
+#endif
Index: libgfortran/generated/sum_i8.c
===================================================================
--- libgfortran/generated/sum_i8.c	(Revision 163593)
+++ libgfortran/generated/sum_i8.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_i8 (gfc_array_i8 * const restrict re
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/parity_l2.c
===================================================================
--- libgfortran/generated/parity_l2.c	(Revision 0)
+++ libgfortran/generated/parity_l2.c	(Revision 0)
@@ -0,0 +1,191 @@ 
+/* Implementation of the NORM2 intrinsic
+   Copyright 2010 Free Software Foundation, Inc.
+   Contributed by Tobias Burnus  <burnus@net-b.de>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+
+#if defined (HAVE_GFC_LOGICAL_2) && defined (HAVE_GFC_LOGICAL_2)
+
+
+extern void parity_l2 (gfc_array_l2 * const restrict, 
+	gfc_array_l2 * const restrict, const index_type * const restrict);
+export_proto(parity_l2);
+
+void
+parity_l2 (gfc_array_l2 * const restrict retarray, 
+	gfc_array_l2 * const restrict array, 
+	const index_type * const restrict pdim)
+{
+  index_type count[GFC_MAX_DIMENSIONS];
+  index_type extent[GFC_MAX_DIMENSIONS];
+  index_type sstride[GFC_MAX_DIMENSIONS];
+  index_type dstride[GFC_MAX_DIMENSIONS];
+  const GFC_LOGICAL_2 * restrict base;
+  GFC_LOGICAL_2 * restrict dest;
+  index_type rank;
+  index_type n;
+  index_type len;
+  index_type delta;
+  index_type dim;
+  int continue_loop;
+
+  /* Make dim zero based to avoid confusion.  */
+  dim = (*pdim) - 1;
+  rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
+  if (len < 0)
+    len = 0;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+
+  for (n = 0; n < dim; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+  for (n = dim; n < rank; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+
+  if (retarray->data == NULL)
+    {
+      size_t alloc_size, str;
+
+      for (n = 0; n < rank; n++)
+	{
+	  if (n == 0)
+	    str = 1;
+	  else
+	    str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
+	}
+
+      retarray->offset = 0;
+      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+
+      alloc_size = sizeof (GFC_LOGICAL_2) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
+    		   * extent[rank-1];
+
+      if (alloc_size == 0)
+	{
+	  /* Make sure we have a zero-sized array.  */
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
+	  return;
+
+	}
+      else
+	retarray->data = internal_malloc_size (alloc_size);
+    }
+  else
+    {
+      if (rank != GFC_DESCRIPTOR_RANK (retarray))
+	runtime_error ("rank of return array incorrect in"
+		       " PARITY intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
+
+      if (unlikely (compile_options.bounds_check))
+	bounds_ifunction_return ((array_t *) retarray, extent,
+				 "return value", "PARITY");
+    }
+
+  for (n = 0; n < rank; n++)
+    {
+      count[n] = 0;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      if (extent[n] <= 0)
+	len = 0;
+    }
+
+  base = array->data;
+  dest = retarray->data;
+
+  continue_loop = 1;
+  while (continue_loop)
+    {
+      const GFC_LOGICAL_2 * restrict src;
+      GFC_LOGICAL_2 result;
+      src = base;
+      {
+
+  result = 0;
+	if (len <= 0)
+	  *dest = 0;
+	else
+	  {
+	    for (n = 0; n < len; n++, src += delta)
+	      {
+
+  result = result != *src;
+	      }
+	    
+	    *dest = result;
+	  }
+      }
+      /* Advance to the next element.  */
+      count[0]++;
+      base += sstride[0];
+      dest += dstride[0];
+      n = 0;
+      while (count[n] == extent[n])
+	{
+	  /* When we get to the end of a dimension, reset it and increment
+	     the next dimension.  */
+	  count[n] = 0;
+	  /* We could precalculate these products, but this is a less
+	     frequently used path so probably not worth it.  */
+	  base -= sstride[n] * extent[n];
+	  dest -= dstride[n] * extent[n];
+	  n++;
+	  if (n == rank)
+	    {
+	      /* Break out of the look.  */
+	      continue_loop = 0;
+	      break;
+	    }
+	  else
+	    {
+	      count[n]++;
+	      base += sstride[n];
+	      dest += dstride[n];
+	    }
+	}
+    }
+}
+
+#endif
Index: libgfortran/generated/any_l16.c
===================================================================
--- libgfortran/generated/any_l16.c	(Revision 163593)
+++ libgfortran/generated/any_l16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ANY intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/maxval_i2.c
===================================================================
--- libgfortran/generated/maxval_i2.c	(Revision 163593)
+++ libgfortran/generated/maxval_i2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  maxval_i2 (gfc_array_i2 * const restrict
 		if (*src > result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/any_l2.c
===================================================================
--- libgfortran/generated/any_l2.c	(Revision 163593)
+++ libgfortran/generated/any_l2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ANY intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/product_r4.c
===================================================================
--- libgfortran/generated/product_r4.c	(Revision 163593)
+++ libgfortran/generated/product_r4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_r4 (gfc_array_r4 * const restric
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_8_i4.c
===================================================================
--- libgfortran/generated/maxloc1_8_i4.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_8_i4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_8_i4 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/parity_l16.c
===================================================================
--- libgfortran/generated/parity_l16.c	(Revision 0)
+++ libgfortran/generated/parity_l16.c	(Revision 0)
@@ -0,0 +1,191 @@ 
+/* Implementation of the NORM2 intrinsic
+   Copyright 2010 Free Software Foundation, Inc.
+   Contributed by Tobias Burnus  <burnus@net-b.de>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+
+#if defined (HAVE_GFC_LOGICAL_16) && defined (HAVE_GFC_LOGICAL_16)
+
+
+extern void parity_l16 (gfc_array_l16 * const restrict, 
+	gfc_array_l16 * const restrict, const index_type * const restrict);
+export_proto(parity_l16);
+
+void
+parity_l16 (gfc_array_l16 * const restrict retarray, 
+	gfc_array_l16 * const restrict array, 
+	const index_type * const restrict pdim)
+{
+  index_type count[GFC_MAX_DIMENSIONS];
+  index_type extent[GFC_MAX_DIMENSIONS];
+  index_type sstride[GFC_MAX_DIMENSIONS];
+  index_type dstride[GFC_MAX_DIMENSIONS];
+  const GFC_LOGICAL_16 * restrict base;
+  GFC_LOGICAL_16 * restrict dest;
+  index_type rank;
+  index_type n;
+  index_type len;
+  index_type delta;
+  index_type dim;
+  int continue_loop;
+
+  /* Make dim zero based to avoid confusion.  */
+  dim = (*pdim) - 1;
+  rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
+  if (len < 0)
+    len = 0;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+
+  for (n = 0; n < dim; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+  for (n = dim; n < rank; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+
+  if (retarray->data == NULL)
+    {
+      size_t alloc_size, str;
+
+      for (n = 0; n < rank; n++)
+	{
+	  if (n == 0)
+	    str = 1;
+	  else
+	    str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
+	}
+
+      retarray->offset = 0;
+      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+
+      alloc_size = sizeof (GFC_LOGICAL_16) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
+    		   * extent[rank-1];
+
+      if (alloc_size == 0)
+	{
+	  /* Make sure we have a zero-sized array.  */
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
+	  return;
+
+	}
+      else
+	retarray->data = internal_malloc_size (alloc_size);
+    }
+  else
+    {
+      if (rank != GFC_DESCRIPTOR_RANK (retarray))
+	runtime_error ("rank of return array incorrect in"
+		       " PARITY intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
+
+      if (unlikely (compile_options.bounds_check))
+	bounds_ifunction_return ((array_t *) retarray, extent,
+				 "return value", "PARITY");
+    }
+
+  for (n = 0; n < rank; n++)
+    {
+      count[n] = 0;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      if (extent[n] <= 0)
+	len = 0;
+    }
+
+  base = array->data;
+  dest = retarray->data;
+
+  continue_loop = 1;
+  while (continue_loop)
+    {
+      const GFC_LOGICAL_16 * restrict src;
+      GFC_LOGICAL_16 result;
+      src = base;
+      {
+
+  result = 0;
+	if (len <= 0)
+	  *dest = 0;
+	else
+	  {
+	    for (n = 0; n < len; n++, src += delta)
+	      {
+
+  result = result != *src;
+	      }
+	    
+	    *dest = result;
+	  }
+      }
+      /* Advance to the next element.  */
+      count[0]++;
+      base += sstride[0];
+      dest += dstride[0];
+      n = 0;
+      while (count[n] == extent[n])
+	{
+	  /* When we get to the end of a dimension, reset it and increment
+	     the next dimension.  */
+	  count[n] = 0;
+	  /* We could precalculate these products, but this is a less
+	     frequently used path so probably not worth it.  */
+	  base -= sstride[n] * extent[n];
+	  dest -= dstride[n] * extent[n];
+	  n++;
+	  if (n == rank)
+	    {
+	      /* Break out of the look.  */
+	      continue_loop = 0;
+	      break;
+	    }
+	  else
+	    {
+	      count[n]++;
+	      base += sstride[n];
+	      dest += dstride[n];
+	    }
+	}
+    }
+}
+
+#endif
Index: libgfortran/generated/all_l1.c
===================================================================
--- libgfortran/generated/all_l1.c	(Revision 163593)
+++ libgfortran/generated/all_l1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ALL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/product_i2.c
===================================================================
--- libgfortran/generated/product_i2.c	(Revision 163593)
+++ libgfortran/generated/product_i2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_i2 (gfc_array_i2 * const restric
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_8_r16.c
===================================================================
--- libgfortran/generated/minloc1_8_r16.c	(Revision 163593)
+++ libgfortran/generated/minloc1_8_r16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_8_r16 (gfc_array_i8 * const rest
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_8_r16.c
===================================================================
--- libgfortran/generated/maxloc1_8_r16.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_8_r16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_8_r16 (gfc_array_i8 * const rest
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_r16.c
===================================================================
--- libgfortran/generated/sum_r16.c	(Revision 163593)
+++ libgfortran/generated/sum_r16.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_r16 (gfc_array_r16 * const restrict
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_i1.c
===================================================================
--- libgfortran/generated/sum_i1.c	(Revision 163593)
+++ libgfortran/generated/sum_i1.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_i1 (gfc_array_i1 * const restrict re
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_4_r8.c
===================================================================
--- libgfortran/generated/minloc1_4_r8.c	(Revision 163593)
+++ libgfortran/generated/minloc1_4_r8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_4_r8 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_16_r16.c
===================================================================
--- libgfortran/generated/maxloc1_16_r16.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_16_r16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_16_r16 (gfc_array_i16 * const re
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_16_i4.c
===================================================================
--- libgfortran/generated/minloc1_16_i4.c	(Revision 163593)
+++ libgfortran/generated/minloc1_16_i4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_16_i4 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_16_i4.c
===================================================================
--- libgfortran/generated/maxloc1_16_i4.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_16_i4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_16_i4 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxval_r16.c
===================================================================
--- libgfortran/generated/maxval_r16.c	(Revision 163593)
+++ libgfortran/generated/maxval_r16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  maxval_r16 (gfc_array_r16 * const restri
 		if (*src > result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_c10.c
===================================================================
--- libgfortran/generated/product_c10.c	(Revision 163593)
+++ libgfortran/generated/product_c10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_c10 (gfc_array_c10 * const restr
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_8_i4.c
===================================================================
--- libgfortran/generated/minloc1_8_i4.c	(Revision 163593)
+++ libgfortran/generated/minloc1_8_i4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_8_i4 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/all_l2.c
===================================================================
--- libgfortran/generated/all_l2.c	(Revision 163593)
+++ libgfortran/generated/all_l2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ALL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/product_c4.c
===================================================================
--- libgfortran/generated/product_c4.c	(Revision 163593)
+++ libgfortran/generated/product_c4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_c4 (gfc_array_c4 * const restric
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_r4.c
===================================================================
--- libgfortran/generated/sum_r4.c	(Revision 163593)
+++ libgfortran/generated/sum_r4.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_r4 (gfc_array_r4 * const restrict re
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_16_r10.c
===================================================================
--- libgfortran/generated/minloc1_16_r10.c	(Revision 163593)
+++ libgfortran/generated/minloc1_16_r10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_16_r10 (gfc_array_i16 * const re
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/all_l16.c
===================================================================
--- libgfortran/generated/all_l16.c	(Revision 163593)
+++ libgfortran/generated/all_l16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ALL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/sum_i2.c
===================================================================
--- libgfortran/generated/sum_i2.c	(Revision 163593)
+++ libgfortran/generated/sum_i2.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_i2 (gfc_array_i2 * const restrict re
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_8_r8.c
===================================================================
--- libgfortran/generated/maxloc1_8_r8.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_8_r8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_8_r8 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minval_i16.c
===================================================================
--- libgfortran/generated/minval_i16.c	(Revision 163593)
+++ libgfortran/generated/minval_i16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  minval_i16 (gfc_array_i16 * const restri
 		if (*src < result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/parity_l4.c
===================================================================
--- libgfortran/generated/parity_l4.c	(Revision 0)
+++ libgfortran/generated/parity_l4.c	(Revision 0)
@@ -0,0 +1,191 @@ 
+/* Implementation of the NORM2 intrinsic
+   Copyright 2010 Free Software Foundation, Inc.
+   Contributed by Tobias Burnus  <burnus@net-b.de>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+
+#if defined (HAVE_GFC_LOGICAL_4) && defined (HAVE_GFC_LOGICAL_4)
+
+
+extern void parity_l4 (gfc_array_l4 * const restrict, 
+	gfc_array_l4 * const restrict, const index_type * const restrict);
+export_proto(parity_l4);
+
+void
+parity_l4 (gfc_array_l4 * const restrict retarray, 
+	gfc_array_l4 * const restrict array, 
+	const index_type * const restrict pdim)
+{
+  index_type count[GFC_MAX_DIMENSIONS];
+  index_type extent[GFC_MAX_DIMENSIONS];
+  index_type sstride[GFC_MAX_DIMENSIONS];
+  index_type dstride[GFC_MAX_DIMENSIONS];
+  const GFC_LOGICAL_4 * restrict base;
+  GFC_LOGICAL_4 * restrict dest;
+  index_type rank;
+  index_type n;
+  index_type len;
+  index_type delta;
+  index_type dim;
+  int continue_loop;
+
+  /* Make dim zero based to avoid confusion.  */
+  dim = (*pdim) - 1;
+  rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
+  if (len < 0)
+    len = 0;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+
+  for (n = 0; n < dim; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+  for (n = dim; n < rank; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+
+  if (retarray->data == NULL)
+    {
+      size_t alloc_size, str;
+
+      for (n = 0; n < rank; n++)
+	{
+	  if (n == 0)
+	    str = 1;
+	  else
+	    str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
+	}
+
+      retarray->offset = 0;
+      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+
+      alloc_size = sizeof (GFC_LOGICAL_4) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
+    		   * extent[rank-1];
+
+      if (alloc_size == 0)
+	{
+	  /* Make sure we have a zero-sized array.  */
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
+	  return;
+
+	}
+      else
+	retarray->data = internal_malloc_size (alloc_size);
+    }
+  else
+    {
+      if (rank != GFC_DESCRIPTOR_RANK (retarray))
+	runtime_error ("rank of return array incorrect in"
+		       " PARITY intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
+
+      if (unlikely (compile_options.bounds_check))
+	bounds_ifunction_return ((array_t *) retarray, extent,
+				 "return value", "PARITY");
+    }
+
+  for (n = 0; n < rank; n++)
+    {
+      count[n] = 0;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      if (extent[n] <= 0)
+	len = 0;
+    }
+
+  base = array->data;
+  dest = retarray->data;
+
+  continue_loop = 1;
+  while (continue_loop)
+    {
+      const GFC_LOGICAL_4 * restrict src;
+      GFC_LOGICAL_4 result;
+      src = base;
+      {
+
+  result = 0;
+	if (len <= 0)
+	  *dest = 0;
+	else
+	  {
+	    for (n = 0; n < len; n++, src += delta)
+	      {
+
+  result = result != *src;
+	      }
+	    
+	    *dest = result;
+	  }
+      }
+      /* Advance to the next element.  */
+      count[0]++;
+      base += sstride[0];
+      dest += dstride[0];
+      n = 0;
+      while (count[n] == extent[n])
+	{
+	  /* When we get to the end of a dimension, reset it and increment
+	     the next dimension.  */
+	  count[n] = 0;
+	  /* We could precalculate these products, but this is a less
+	     frequently used path so probably not worth it.  */
+	  base -= sstride[n] * extent[n];
+	  dest -= dstride[n] * extent[n];
+	  n++;
+	  if (n == rank)
+	    {
+	      /* Break out of the look.  */
+	      continue_loop = 0;
+	      break;
+	    }
+	  else
+	    {
+	      count[n]++;
+	      base += sstride[n];
+	      dest += dstride[n];
+	    }
+	}
+    }
+}
+
+#endif
Index: libgfortran/generated/maxval_i4.c
===================================================================
--- libgfortran/generated/maxval_i4.c	(Revision 163593)
+++ libgfortran/generated/maxval_i4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  maxval_i4 (gfc_array_i4 * const restrict
 		if (*src > result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minval_i8.c
===================================================================
--- libgfortran/generated/minval_i8.c	(Revision 163593)
+++ libgfortran/generated/minval_i8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  minval_i8 (gfc_array_i8 * const restrict
 		if (*src < result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/any_l4.c
===================================================================
--- libgfortran/generated/any_l4.c	(Revision 163593)
+++ libgfortran/generated/any_l4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ANY intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/maxloc1_4_i8.c
===================================================================
--- libgfortran/generated/maxloc1_4_i8.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_4_i8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_4_i8 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_4_i16.c
===================================================================
--- libgfortran/generated/minloc1_4_i16.c	(Revision 163593)
+++ libgfortran/generated/minloc1_4_i16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_4_i16 (gfc_array_i4 * const rest
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_4_i16.c
===================================================================
--- libgfortran/generated/maxloc1_4_i16.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_4_i16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_4_i16 (gfc_array_i4 * const rest
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_8_r10.c
===================================================================
--- libgfortran/generated/minloc1_8_r10.c	(Revision 163593)
+++ libgfortran/generated/minloc1_8_r10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_8_r10 (gfc_array_i8 * const rest
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_i4.c
===================================================================
--- libgfortran/generated/product_i4.c	(Revision 163593)
+++ libgfortran/generated/product_i4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_i4 (gfc_array_i4 * const restric
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_c16.c
===================================================================
--- libgfortran/generated/sum_c16.c	(Revision 163593)
+++ libgfortran/generated/sum_c16.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_c16 (gfc_array_c16 * const restrict
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_8_r10.c
===================================================================
--- libgfortran/generated/maxloc1_8_r10.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_8_r10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_8_r10 (gfc_array_i8 * const rest
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_16_r8.c
===================================================================
--- libgfortran/generated/minloc1_16_r8.c	(Revision 163593)
+++ libgfortran/generated/minloc1_16_r8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_16_r8 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_16_r8.c
===================================================================
--- libgfortran/generated/maxloc1_16_r8.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_16_r8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_16_r8 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_r10.c
===================================================================
--- libgfortran/generated/sum_r10.c	(Revision 163593)
+++ libgfortran/generated/sum_r10.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_r10 (gfc_array_r10 * const restrict
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/count_4_l.c
===================================================================
--- libgfortran/generated/count_4_l.c	(Revision 163593)
+++ libgfortran/generated/count_4_l.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the COUNT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/sum_c4.c
===================================================================
--- libgfortran/generated/sum_c4.c	(Revision 163593)
+++ libgfortran/generated/sum_c4.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_c4 (gfc_array_c4 * const restrict re
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/count_8_l.c
===================================================================
--- libgfortran/generated/count_8_l.c	(Revision 163593)
+++ libgfortran/generated/count_8_l.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the COUNT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/maxloc1_16_r10.c
===================================================================
--- libgfortran/generated/maxloc1_16_r10.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_16_r10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_16_r10 (gfc_array_i16 * const re
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_8_r8.c
===================================================================
--- libgfortran/generated/minloc1_8_r8.c	(Revision 163593)
+++ libgfortran/generated/minloc1_8_r8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_8_r8 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxval_r10.c
===================================================================
--- libgfortran/generated/maxval_r10.c	(Revision 163593)
+++ libgfortran/generated/maxval_r10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  maxval_r10 (gfc_array_r10 * const restri
 		if (*src > result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minval_i1.c
===================================================================
--- libgfortran/generated/minval_i1.c	(Revision 163593)
+++ libgfortran/generated/minval_i1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  minval_i1 (gfc_array_i1 * const restrict
 		if (*src < result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_4_i1.c
===================================================================
--- libgfortran/generated/maxloc1_4_i1.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_4_i1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_4_i1 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_4_i8.c
===================================================================
--- libgfortran/generated/minloc1_4_i8.c	(Revision 163593)
+++ libgfortran/generated/minloc1_4_i8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_4_i8 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_i16.c
===================================================================
--- libgfortran/generated/product_i16.c	(Revision 163593)
+++ libgfortran/generated/product_i16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_i16 (gfc_array_i16 * const restr
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/all_l4.c
===================================================================
--- libgfortran/generated/all_l4.c	(Revision 163593)
+++ libgfortran/generated/all_l4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ALL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/norm2_r16.c
===================================================================
--- libgfortran/generated/norm2_r16.c	(Revision 0)
+++ libgfortran/generated/norm2_r16.c	(Revision 0)
@@ -0,0 +1,208 @@ 
+/* Implementation of the NORM2 intrinsic
+   Copyright 2010 Free Software Foundation, Inc.
+   Contributed by Tobias Burnus  <burnus@net-b.de>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+
+#if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_REAL_16)
+
+
+extern void norm2_r16 (gfc_array_r16 * const restrict, 
+	gfc_array_r16 * const restrict, const index_type * const restrict);
+export_proto(norm2_r16);
+
+void
+norm2_r16 (gfc_array_r16 * const restrict retarray, 
+	gfc_array_r16 * const restrict array, 
+	const index_type * const restrict pdim)
+{
+  index_type count[GFC_MAX_DIMENSIONS];
+  index_type extent[GFC_MAX_DIMENSIONS];
+  index_type sstride[GFC_MAX_DIMENSIONS];
+  index_type dstride[GFC_MAX_DIMENSIONS];
+  const GFC_REAL_16 * restrict base;
+  GFC_REAL_16 * restrict dest;
+  index_type rank;
+  index_type n;
+  index_type len;
+  index_type delta;
+  index_type dim;
+  int continue_loop;
+
+  /* Make dim zero based to avoid confusion.  */
+  dim = (*pdim) - 1;
+  rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
+  if (len < 0)
+    len = 0;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+
+  for (n = 0; n < dim; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+  for (n = dim; n < rank; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+
+  if (retarray->data == NULL)
+    {
+      size_t alloc_size, str;
+
+      for (n = 0; n < rank; n++)
+	{
+	  if (n == 0)
+	    str = 1;
+	  else
+	    str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
+	}
+
+      retarray->offset = 0;
+      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+
+      alloc_size = sizeof (GFC_REAL_16) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
+    		   * extent[rank-1];
+
+      if (alloc_size == 0)
+	{
+	  /* Make sure we have a zero-sized array.  */
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
+	  return;
+
+	}
+      else
+	retarray->data = internal_malloc_size (alloc_size);
+    }
+  else
+    {
+      if (rank != GFC_DESCRIPTOR_RANK (retarray))
+	runtime_error ("rank of return array incorrect in"
+		       " NORM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
+
+      if (unlikely (compile_options.bounds_check))
+	bounds_ifunction_return ((array_t *) retarray, extent,
+				 "return value", "NORM");
+    }
+
+  for (n = 0; n < rank; n++)
+    {
+      count[n] = 0;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      if (extent[n] <= 0)
+	len = 0;
+    }
+
+  base = array->data;
+  dest = retarray->data;
+
+  continue_loop = 1;
+  while (continue_loop)
+    {
+      const GFC_REAL_16 * restrict src;
+      GFC_REAL_16 result;
+      src = base;
+      {
+
+	GFC_REAL_16 scale;
+	result = 0.0L;
+	scale = 1.0L;
+	if (len <= 0)
+	  *dest = 0.0L;
+	else
+	  {
+	    for (n = 0; n < len; n++, src += delta)
+	      {
+
+	  if (*src != 0.0L)
+	    {
+	      GFC_REAL_16 absX, val;
+	      absX = fabsl (*src);
+	      if (scale < absX)
+		{
+		  val = scale / absX;
+		  result = 1.0L + result * val * val;
+		  scale = absX;
+		}
+	      else
+		{
+		  val = absX / scale;
+		  result += val * val;
+		}
+	    }
+	      }
+	    result = scale * sqrtl (result);
+	    *dest = result;
+	  }
+      }
+      /* Advance to the next element.  */
+      count[0]++;
+      base += sstride[0];
+      dest += dstride[0];
+      n = 0;
+      while (count[n] == extent[n])
+	{
+	  /* When we get to the end of a dimension, reset it and increment
+	     the next dimension.  */
+	  count[n] = 0;
+	  /* We could precalculate these products, but this is a less
+	     frequently used path so probably not worth it.  */
+	  base -= sstride[n] * extent[n];
+	  dest -= dstride[n] * extent[n];
+	  n++;
+	  if (n == rank)
+	    {
+	      /* Break out of the look.  */
+	      continue_loop = 0;
+	      break;
+	    }
+	  else
+	    {
+	      count[n]++;
+	      base += sstride[n];
+	      dest += dstride[n];
+	    }
+	}
+    }
+}
+
+#endif
Index: libgfortran/generated/minval_r4.c
===================================================================
--- libgfortran/generated/minval_r4.c	(Revision 163593)
+++ libgfortran/generated/minval_r4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  minval_r4 (gfc_array_r4 * const restrict
 		if (*src < result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_4_r4.c
===================================================================
--- libgfortran/generated/maxloc1_4_r4.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_4_r4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_4_r4 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_i4.c
===================================================================
--- libgfortran/generated/sum_i4.c	(Revision 163593)
+++ libgfortran/generated/sum_i4.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_i4 (gfc_array_i4 * const restrict re
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxval_r8.c
===================================================================
--- libgfortran/generated/maxval_r8.c	(Revision 163593)
+++ libgfortran/generated/maxval_r8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  maxval_r8 (gfc_array_r8 * const restrict
 		if (*src > result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/norm2_r8.c
===================================================================
--- libgfortran/generated/norm2_r8.c	(Revision 0)
+++ libgfortran/generated/norm2_r8.c	(Revision 0)
@@ -0,0 +1,208 @@ 
+/* Implementation of the NORM2 intrinsic
+   Copyright 2010 Free Software Foundation, Inc.
+   Contributed by Tobias Burnus  <burnus@net-b.de>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+
+#if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_REAL_8)
+
+
+extern void norm2_r8 (gfc_array_r8 * const restrict, 
+	gfc_array_r8 * const restrict, const index_type * const restrict);
+export_proto(norm2_r8);
+
+void
+norm2_r8 (gfc_array_r8 * const restrict retarray, 
+	gfc_array_r8 * const restrict array, 
+	const index_type * const restrict pdim)
+{
+  index_type count[GFC_MAX_DIMENSIONS];
+  index_type extent[GFC_MAX_DIMENSIONS];
+  index_type sstride[GFC_MAX_DIMENSIONS];
+  index_type dstride[GFC_MAX_DIMENSIONS];
+  const GFC_REAL_8 * restrict base;
+  GFC_REAL_8 * restrict dest;
+  index_type rank;
+  index_type n;
+  index_type len;
+  index_type delta;
+  index_type dim;
+  int continue_loop;
+
+  /* Make dim zero based to avoid confusion.  */
+  dim = (*pdim) - 1;
+  rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
+  if (len < 0)
+    len = 0;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+
+  for (n = 0; n < dim; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+  for (n = dim; n < rank; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+
+  if (retarray->data == NULL)
+    {
+      size_t alloc_size, str;
+
+      for (n = 0; n < rank; n++)
+	{
+	  if (n == 0)
+	    str = 1;
+	  else
+	    str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
+	}
+
+      retarray->offset = 0;
+      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+
+      alloc_size = sizeof (GFC_REAL_8) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
+    		   * extent[rank-1];
+
+      if (alloc_size == 0)
+	{
+	  /* Make sure we have a zero-sized array.  */
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
+	  return;
+
+	}
+      else
+	retarray->data = internal_malloc_size (alloc_size);
+    }
+  else
+    {
+      if (rank != GFC_DESCRIPTOR_RANK (retarray))
+	runtime_error ("rank of return array incorrect in"
+		       " NORM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
+
+      if (unlikely (compile_options.bounds_check))
+	bounds_ifunction_return ((array_t *) retarray, extent,
+				 "return value", "NORM");
+    }
+
+  for (n = 0; n < rank; n++)
+    {
+      count[n] = 0;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      if (extent[n] <= 0)
+	len = 0;
+    }
+
+  base = array->data;
+  dest = retarray->data;
+
+  continue_loop = 1;
+  while (continue_loop)
+    {
+      const GFC_REAL_8 * restrict src;
+      GFC_REAL_8 result;
+      src = base;
+      {
+
+	GFC_REAL_8 scale;
+	result = 0.0;
+	scale = 1.0;
+	if (len <= 0)
+	  *dest = 0.0;
+	else
+	  {
+	    for (n = 0; n < len; n++, src += delta)
+	      {
+
+	  if (*src != 0.0)
+	    {
+	      GFC_REAL_8 absX, val;
+	      absX = fabs (*src);
+	      if (scale < absX)
+		{
+		  val = scale / absX;
+		  result = 1.0 + result * val * val;
+		  scale = absX;
+		}
+	      else
+		{
+		  val = absX / scale;
+		  result += val * val;
+		}
+	    }
+	      }
+	    result = scale * sqrt (result);
+	    *dest = result;
+	  }
+      }
+      /* Advance to the next element.  */
+      count[0]++;
+      base += sstride[0];
+      dest += dstride[0];
+      n = 0;
+      while (count[n] == extent[n])
+	{
+	  /* When we get to the end of a dimension, reset it and increment
+	     the next dimension.  */
+	  count[n] = 0;
+	  /* We could precalculate these products, but this is a less
+	     frequently used path so probably not worth it.  */
+	  base -= sstride[n] * extent[n];
+	  dest -= dstride[n] * extent[n];
+	  n++;
+	  if (n == rank)
+	    {
+	      /* Break out of the look.  */
+	      continue_loop = 0;
+	      break;
+	    }
+	  else
+	    {
+	      count[n]++;
+	      base += sstride[n];
+	      dest += dstride[n];
+	    }
+	}
+    }
+}
+
+#endif
Index: libgfortran/generated/minloc1_4_i1.c
===================================================================
--- libgfortran/generated/minloc1_4_i1.c	(Revision 163593)
+++ libgfortran/generated/minloc1_4_i1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_4_i1 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minval_r16.c
===================================================================
--- libgfortran/generated/minval_r16.c	(Revision 163593)
+++ libgfortran/generated/minval_r16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  minval_r16 (gfc_array_r16 * const restri
 		if (*src < result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minval_i2.c
===================================================================
--- libgfortran/generated/minval_i2.c	(Revision 163593)
+++ libgfortran/generated/minval_i2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  minval_i2 (gfc_array_i2 * const restrict
 		if (*src < result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_4_i2.c
===================================================================
--- libgfortran/generated/maxloc1_4_i2.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_4_i2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_4_i2 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_r8.c
===================================================================
--- libgfortran/generated/product_r8.c	(Revision 163593)
+++ libgfortran/generated/product_r8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_r8 (gfc_array_r8 * const restric
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_8_i8.c
===================================================================
--- libgfortran/generated/maxloc1_8_i8.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_8_i8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_8_i8 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_c10.c
===================================================================
--- libgfortran/generated/sum_c10.c	(Revision 163593)
+++ libgfortran/generated/sum_c10.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_c10 (gfc_array_c10 * const restrict
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_4_r16.c
===================================================================
--- libgfortran/generated/minloc1_4_r16.c	(Revision 163593)
+++ libgfortran/generated/minloc1_4_r16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_4_r16 (gfc_array_i4 * const rest
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_4_r16.c
===================================================================
--- libgfortran/generated/maxloc1_4_r16.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_4_r16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_4_r16 (gfc_array_i4 * const rest
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/count_1_l.c
===================================================================
--- libgfortran/generated/count_1_l.c	(Revision 163593)
+++ libgfortran/generated/count_1_l.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the COUNT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/minloc1_4_r4.c
===================================================================
--- libgfortran/generated/minloc1_4_r4.c	(Revision 163593)
+++ libgfortran/generated/minloc1_4_r4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_4_r4 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_16_i8.c
===================================================================
--- libgfortran/generated/minloc1_16_i8.c	(Revision 163593)
+++ libgfortran/generated/minloc1_16_i8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_16_i8 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_16_i8.c
===================================================================
--- libgfortran/generated/maxloc1_16_i8.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_16_i8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_16_i8 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_4_i2.c
===================================================================
--- libgfortran/generated/minloc1_4_i2.c	(Revision 163593)
+++ libgfortran/generated/minloc1_4_i2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_4_i2 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_8_i1.c
===================================================================
--- libgfortran/generated/maxloc1_8_i1.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_8_i1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_8_i1 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_8_i8.c
===================================================================
--- libgfortran/generated/minloc1_8_i8.c	(Revision 163593)
+++ libgfortran/generated/minloc1_8_i8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_8_i8 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_r16.c
===================================================================
--- libgfortran/generated/product_r16.c	(Revision 163593)
+++ libgfortran/generated/product_r16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_r16 (gfc_array_r16 * const restr
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_c8.c
===================================================================
--- libgfortran/generated/product_c8.c	(Revision 163593)
+++ libgfortran/generated/product_c8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_c8 (gfc_array_c8 * const restric
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_r8.c
===================================================================
--- libgfortran/generated/sum_r8.c	(Revision 163593)
+++ libgfortran/generated/sum_r8.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_r8 (gfc_array_r8 * const restrict re
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/norm2_r10.c
===================================================================
--- libgfortran/generated/norm2_r10.c	(Revision 0)
+++ libgfortran/generated/norm2_r10.c	(Revision 0)
@@ -0,0 +1,208 @@ 
+/* Implementation of the NORM2 intrinsic
+   Copyright 2010 Free Software Foundation, Inc.
+   Contributed by Tobias Burnus  <burnus@net-b.de>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+
+#if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_REAL_10)
+
+
+extern void norm2_r10 (gfc_array_r10 * const restrict, 
+	gfc_array_r10 * const restrict, const index_type * const restrict);
+export_proto(norm2_r10);
+
+void
+norm2_r10 (gfc_array_r10 * const restrict retarray, 
+	gfc_array_r10 * const restrict array, 
+	const index_type * const restrict pdim)
+{
+  index_type count[GFC_MAX_DIMENSIONS];
+  index_type extent[GFC_MAX_DIMENSIONS];
+  index_type sstride[GFC_MAX_DIMENSIONS];
+  index_type dstride[GFC_MAX_DIMENSIONS];
+  const GFC_REAL_10 * restrict base;
+  GFC_REAL_10 * restrict dest;
+  index_type rank;
+  index_type n;
+  index_type len;
+  index_type delta;
+  index_type dim;
+  int continue_loop;
+
+  /* Make dim zero based to avoid confusion.  */
+  dim = (*pdim) - 1;
+  rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
+  if (len < 0)
+    len = 0;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+
+  for (n = 0; n < dim; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+  for (n = dim; n < rank; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+
+  if (retarray->data == NULL)
+    {
+      size_t alloc_size, str;
+
+      for (n = 0; n < rank; n++)
+	{
+	  if (n == 0)
+	    str = 1;
+	  else
+	    str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
+	}
+
+      retarray->offset = 0;
+      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+
+      alloc_size = sizeof (GFC_REAL_10) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
+    		   * extent[rank-1];
+
+      if (alloc_size == 0)
+	{
+	  /* Make sure we have a zero-sized array.  */
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
+	  return;
+
+	}
+      else
+	retarray->data = internal_malloc_size (alloc_size);
+    }
+  else
+    {
+      if (rank != GFC_DESCRIPTOR_RANK (retarray))
+	runtime_error ("rank of return array incorrect in"
+		       " NORM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
+
+      if (unlikely (compile_options.bounds_check))
+	bounds_ifunction_return ((array_t *) retarray, extent,
+				 "return value", "NORM");
+    }
+
+  for (n = 0; n < rank; n++)
+    {
+      count[n] = 0;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      if (extent[n] <= 0)
+	len = 0;
+    }
+
+  base = array->data;
+  dest = retarray->data;
+
+  continue_loop = 1;
+  while (continue_loop)
+    {
+      const GFC_REAL_10 * restrict src;
+      GFC_REAL_10 result;
+      src = base;
+      {
+
+	GFC_REAL_10 scale;
+	result = 0.0L;
+	scale = 1.0L;
+	if (len <= 0)
+	  *dest = 0.0L;
+	else
+	  {
+	    for (n = 0; n < len; n++, src += delta)
+	      {
+
+	  if (*src != 0.0L)
+	    {
+	      GFC_REAL_10 absX, val;
+	      absX = fabsl (*src);
+	      if (scale < absX)
+		{
+		  val = scale / absX;
+		  result = 1.0L + result * val * val;
+		  scale = absX;
+		}
+	      else
+		{
+		  val = absX / scale;
+		  result += val * val;
+		}
+	    }
+	      }
+	    result = scale * sqrtl (result);
+	    *dest = result;
+	  }
+      }
+      /* Advance to the next element.  */
+      count[0]++;
+      base += sstride[0];
+      dest += dstride[0];
+      n = 0;
+      while (count[n] == extent[n])
+	{
+	  /* When we get to the end of a dimension, reset it and increment
+	     the next dimension.  */
+	  count[n] = 0;
+	  /* We could precalculate these products, but this is a less
+	     frequently used path so probably not worth it.  */
+	  base -= sstride[n] * extent[n];
+	  dest -= dstride[n] * extent[n];
+	  n++;
+	  if (n == rank)
+	    {
+	      /* Break out of the look.  */
+	      continue_loop = 0;
+	      break;
+	    }
+	  else
+	    {
+	      count[n]++;
+	      base += sstride[n];
+	      dest += dstride[n];
+	    }
+	}
+    }
+}
+
+#endif
Index: libgfortran/generated/minloc1_16_i16.c
===================================================================
--- libgfortran/generated/minloc1_16_i16.c	(Revision 163593)
+++ libgfortran/generated/minloc1_16_i16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_16_i16 (gfc_array_i16 * const re
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_8_r4.c
===================================================================
--- libgfortran/generated/maxloc1_8_r4.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_8_r4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_8_r4 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_16_i1.c
===================================================================
--- libgfortran/generated/minloc1_16_i1.c	(Revision 163593)
+++ libgfortran/generated/minloc1_16_i1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_16_i1 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_16_i1.c
===================================================================
--- libgfortran/generated/maxloc1_16_i1.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_16_i1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_16_i1 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minval_r10.c
===================================================================
--- libgfortran/generated/minval_r10.c	(Revision 163593)
+++ libgfortran/generated/minval_r10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  minval_r10 (gfc_array_r10 * const restri
 		if (*src < result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/count_16_l.c
===================================================================
--- libgfortran/generated/count_16_l.c	(Revision 163593)
+++ libgfortran/generated/count_16_l.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the COUNT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/parity_l8.c
===================================================================
--- libgfortran/generated/parity_l8.c	(Revision 0)
+++ libgfortran/generated/parity_l8.c	(Revision 0)
@@ -0,0 +1,191 @@ 
+/* Implementation of the NORM2 intrinsic
+   Copyright 2010 Free Software Foundation, Inc.
+   Contributed by Tobias Burnus  <burnus@net-b.de>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+
+#if defined (HAVE_GFC_LOGICAL_8) && defined (HAVE_GFC_LOGICAL_8)
+
+
+extern void parity_l8 (gfc_array_l8 * const restrict, 
+	gfc_array_l8 * const restrict, const index_type * const restrict);
+export_proto(parity_l8);
+
+void
+parity_l8 (gfc_array_l8 * const restrict retarray, 
+	gfc_array_l8 * const restrict array, 
+	const index_type * const restrict pdim)
+{
+  index_type count[GFC_MAX_DIMENSIONS];
+  index_type extent[GFC_MAX_DIMENSIONS];
+  index_type sstride[GFC_MAX_DIMENSIONS];
+  index_type dstride[GFC_MAX_DIMENSIONS];
+  const GFC_LOGICAL_8 * restrict base;
+  GFC_LOGICAL_8 * restrict dest;
+  index_type rank;
+  index_type n;
+  index_type len;
+  index_type delta;
+  index_type dim;
+  int continue_loop;
+
+  /* Make dim zero based to avoid confusion.  */
+  dim = (*pdim) - 1;
+  rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
+  if (len < 0)
+    len = 0;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+
+  for (n = 0; n < dim; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+  for (n = dim; n < rank; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+
+  if (retarray->data == NULL)
+    {
+      size_t alloc_size, str;
+
+      for (n = 0; n < rank; n++)
+	{
+	  if (n == 0)
+	    str = 1;
+	  else
+	    str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
+	}
+
+      retarray->offset = 0;
+      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+
+      alloc_size = sizeof (GFC_LOGICAL_8) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
+    		   * extent[rank-1];
+
+      if (alloc_size == 0)
+	{
+	  /* Make sure we have a zero-sized array.  */
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
+	  return;
+
+	}
+      else
+	retarray->data = internal_malloc_size (alloc_size);
+    }
+  else
+    {
+      if (rank != GFC_DESCRIPTOR_RANK (retarray))
+	runtime_error ("rank of return array incorrect in"
+		       " PARITY intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
+
+      if (unlikely (compile_options.bounds_check))
+	bounds_ifunction_return ((array_t *) retarray, extent,
+				 "return value", "PARITY");
+    }
+
+  for (n = 0; n < rank; n++)
+    {
+      count[n] = 0;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      if (extent[n] <= 0)
+	len = 0;
+    }
+
+  base = array->data;
+  dest = retarray->data;
+
+  continue_loop = 1;
+  while (continue_loop)
+    {
+      const GFC_LOGICAL_8 * restrict src;
+      GFC_LOGICAL_8 result;
+      src = base;
+      {
+
+  result = 0;
+	if (len <= 0)
+	  *dest = 0;
+	else
+	  {
+	    for (n = 0; n < len; n++, src += delta)
+	      {
+
+  result = result != *src;
+	      }
+	    
+	    *dest = result;
+	  }
+      }
+      /* Advance to the next element.  */
+      count[0]++;
+      base += sstride[0];
+      dest += dstride[0];
+      n = 0;
+      while (count[n] == extent[n])
+	{
+	  /* When we get to the end of a dimension, reset it and increment
+	     the next dimension.  */
+	  count[n] = 0;
+	  /* We could precalculate these products, but this is a less
+	     frequently used path so probably not worth it.  */
+	  base -= sstride[n] * extent[n];
+	  dest -= dstride[n] * extent[n];
+	  n++;
+	  if (n == rank)
+	    {
+	      /* Break out of the look.  */
+	      continue_loop = 0;
+	      break;
+	    }
+	  else
+	    {
+	      count[n]++;
+	      base += sstride[n];
+	      dest += dstride[n];
+	    }
+	}
+    }
+}
+
+#endif
Index: libgfortran/generated/minloc1_8_i1.c
===================================================================
--- libgfortran/generated/minloc1_8_i1.c	(Revision 163593)
+++ libgfortran/generated/minloc1_8_i1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_8_i1 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minval_i4.c
===================================================================
--- libgfortran/generated/minval_i4.c	(Revision 163593)
+++ libgfortran/generated/minval_i4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  minval_i4 (gfc_array_i4 * const restrict
 		if (*src < result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_4_i4.c
===================================================================
--- libgfortran/generated/maxloc1_4_i4.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_4_i4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_4_i4 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_8_i2.c
===================================================================
--- libgfortran/generated/maxloc1_8_i2.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_8_i2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_8_i2 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxval_i8.c
===================================================================
--- libgfortran/generated/maxval_i8.c	(Revision 163593)
+++ libgfortran/generated/maxval_i8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  maxval_i8 (gfc_array_i8 * const restrict
 		if (*src > result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/any_l8.c
===================================================================
--- libgfortran/generated/any_l8.c	(Revision 163593)
+++ libgfortran/generated/any_l8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ANY intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/minloc1_4_r10.c
===================================================================
--- libgfortran/generated/minloc1_4_r10.c	(Revision 163593)
+++ libgfortran/generated/minloc1_4_r10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_4_r10 (gfc_array_i4 * const rest
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_8_i16.c
===================================================================
--- libgfortran/generated/minloc1_8_i16.c	(Revision 163593)
+++ libgfortran/generated/minloc1_8_i16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_8_i16 (gfc_array_i8 * const rest
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_4_r10.c
===================================================================
--- libgfortran/generated/maxloc1_4_r10.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_4_r10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_4_r10 (gfc_array_i4 * const rest
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_8_i16.c
===================================================================
--- libgfortran/generated/maxloc1_8_i16.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_8_i16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_8_i16 (gfc_array_i8 * const rest
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_16_r4.c
===================================================================
--- libgfortran/generated/minloc1_16_r4.c	(Revision 163593)
+++ libgfortran/generated/minloc1_16_r4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_16_r4 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_16_r4.c
===================================================================
--- libgfortran/generated/maxloc1_16_r4.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_16_r4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_16_r4 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_i8.c
===================================================================
--- libgfortran/generated/product_i8.c	(Revision 163593)
+++ libgfortran/generated/product_i8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_i8 (gfc_array_i8 * const restric
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_i16.c
===================================================================
--- libgfortran/generated/sum_i16.c	(Revision 163593)
+++ libgfortran/generated/sum_i16.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_i16 (gfc_array_i16 * const restrict
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/count_2_l.c
===================================================================
--- libgfortran/generated/count_2_l.c	(Revision 163593)
+++ libgfortran/generated/count_2_l.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the COUNT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/maxloc1_16_i16.c
===================================================================
--- libgfortran/generated/maxloc1_16_i16.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_16_i16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_16_i16 (gfc_array_i16 * const re
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_8_r4.c
===================================================================
--- libgfortran/generated/minloc1_8_r4.c	(Revision 163593)
+++ libgfortran/generated/minloc1_8_r4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_8_r4 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/sum_c8.c
===================================================================
--- libgfortran/generated/sum_c8.c	(Revision 163593)
+++ libgfortran/generated/sum_c8.c	(Arbeitskopie)
@@ -152,6 +152,7 @@  sum_c8 (gfc_array_c8 * const restrict re
 
   result += *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_16_i2.c
===================================================================
--- libgfortran/generated/minloc1_16_i2.c	(Revision 163593)
+++ libgfortran/generated/minloc1_16_i2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_16_i2 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxloc1_16_i2.c
===================================================================
--- libgfortran/generated/maxloc1_16_i2.c	(Revision 163593)
+++ libgfortran/generated/maxloc1_16_i2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  maxloc1_16_i2 (gfc_array_i16 * const res
 		    result = (GFC_INTEGER_16)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/parity_l1.c
===================================================================
--- libgfortran/generated/parity_l1.c	(Revision 0)
+++ libgfortran/generated/parity_l1.c	(Revision 0)
@@ -0,0 +1,191 @@ 
+/* Implementation of the NORM2 intrinsic
+   Copyright 2010 Free Software Foundation, Inc.
+   Contributed by Tobias Burnus  <burnus@net-b.de>
+
+This file is part of the GNU Fortran runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 3 of the License, or (at your option) any later version.
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#include "libgfortran.h"
+#include <stdlib.h>
+#include <math.h>
+#include <assert.h>
+
+
+#if defined (HAVE_GFC_LOGICAL_1) && defined (HAVE_GFC_LOGICAL_1)
+
+
+extern void parity_l1 (gfc_array_l1 * const restrict, 
+	gfc_array_l1 * const restrict, const index_type * const restrict);
+export_proto(parity_l1);
+
+void
+parity_l1 (gfc_array_l1 * const restrict retarray, 
+	gfc_array_l1 * const restrict array, 
+	const index_type * const restrict pdim)
+{
+  index_type count[GFC_MAX_DIMENSIONS];
+  index_type extent[GFC_MAX_DIMENSIONS];
+  index_type sstride[GFC_MAX_DIMENSIONS];
+  index_type dstride[GFC_MAX_DIMENSIONS];
+  const GFC_LOGICAL_1 * restrict base;
+  GFC_LOGICAL_1 * restrict dest;
+  index_type rank;
+  index_type n;
+  index_type len;
+  index_type delta;
+  index_type dim;
+  int continue_loop;
+
+  /* Make dim zero based to avoid confusion.  */
+  dim = (*pdim) - 1;
+  rank = GFC_DESCRIPTOR_RANK (array) - 1;
+
+  len = GFC_DESCRIPTOR_EXTENT(array,dim);
+  if (len < 0)
+    len = 0;
+  delta = GFC_DESCRIPTOR_STRIDE(array,dim);
+
+  for (n = 0; n < dim; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+  for (n = dim; n < rank; n++)
+    {
+      sstride[n] = GFC_DESCRIPTOR_STRIDE(array, n + 1);
+      extent[n] = GFC_DESCRIPTOR_EXTENT(array, n + 1);
+
+      if (extent[n] < 0)
+	extent[n] = 0;
+    }
+
+  if (retarray->data == NULL)
+    {
+      size_t alloc_size, str;
+
+      for (n = 0; n < rank; n++)
+	{
+	  if (n == 0)
+	    str = 1;
+	  else
+	    str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
+
+	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+
+	}
+
+      retarray->offset = 0;
+      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+
+      alloc_size = sizeof (GFC_LOGICAL_1) * GFC_DESCRIPTOR_STRIDE(retarray,rank-1)
+    		   * extent[rank-1];
+
+      if (alloc_size == 0)
+	{
+	  /* Make sure we have a zero-sized array.  */
+	  GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
+	  return;
+
+	}
+      else
+	retarray->data = internal_malloc_size (alloc_size);
+    }
+  else
+    {
+      if (rank != GFC_DESCRIPTOR_RANK (retarray))
+	runtime_error ("rank of return array incorrect in"
+		       " PARITY intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
+
+      if (unlikely (compile_options.bounds_check))
+	bounds_ifunction_return ((array_t *) retarray, extent,
+				 "return value", "PARITY");
+    }
+
+  for (n = 0; n < rank; n++)
+    {
+      count[n] = 0;
+      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      if (extent[n] <= 0)
+	len = 0;
+    }
+
+  base = array->data;
+  dest = retarray->data;
+
+  continue_loop = 1;
+  while (continue_loop)
+    {
+      const GFC_LOGICAL_1 * restrict src;
+      GFC_LOGICAL_1 result;
+      src = base;
+      {
+
+  result = 0;
+	if (len <= 0)
+	  *dest = 0;
+	else
+	  {
+	    for (n = 0; n < len; n++, src += delta)
+	      {
+
+  result = result != *src;
+	      }
+	    
+	    *dest = result;
+	  }
+      }
+      /* Advance to the next element.  */
+      count[0]++;
+      base += sstride[0];
+      dest += dstride[0];
+      n = 0;
+      while (count[n] == extent[n])
+	{
+	  /* When we get to the end of a dimension, reset it and increment
+	     the next dimension.  */
+	  count[n] = 0;
+	  /* We could precalculate these products, but this is a less
+	     frequently used path so probably not worth it.  */
+	  base -= sstride[n] * extent[n];
+	  dest -= dstride[n] * extent[n];
+	  n++;
+	  if (n == rank)
+	    {
+	      /* Break out of the look.  */
+	      continue_loop = 0;
+	      break;
+	    }
+	  else
+	    {
+	      count[n]++;
+	      base += sstride[n];
+	      dest += dstride[n];
+	    }
+	}
+    }
+}
+
+#endif
Index: libgfortran/generated/maxval_i16.c
===================================================================
--- libgfortran/generated/maxval_i16.c	(Revision 163593)
+++ libgfortran/generated/maxval_i16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  maxval_i16 (gfc_array_i16 * const restri
 		if (*src > result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/maxval_i1.c
===================================================================
--- libgfortran/generated/maxval_i1.c	(Revision 163593)
+++ libgfortran/generated/maxval_i1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  maxval_i1 (gfc_array_i1 * const restrict
 		if (*src > result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/minloc1_4_i4.c
===================================================================
--- libgfortran/generated/minloc1_4_i4.c	(Revision 163593)
+++ libgfortran/generated/minloc1_4_i4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_4_i4 (gfc_array_i4 * const restr
 		    result = (GFC_INTEGER_4)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/any_l1.c
===================================================================
--- libgfortran/generated/any_l1.c	(Revision 163593)
+++ libgfortran/generated/any_l1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ANY intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/minloc1_8_i2.c
===================================================================
--- libgfortran/generated/minloc1_8_i2.c	(Revision 163593)
+++ libgfortran/generated/minloc1_8_i2.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MINLOC intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -174,6 +174,7 @@  minloc1_8_i2 (gfc_array_i8 * const restr
 		    result = (GFC_INTEGER_8)n + 1;
 		  }
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_c16.c
===================================================================
--- libgfortran/generated/product_c16.c	(Revision 163593)
+++ libgfortran/generated/product_c16.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_c16 (gfc_array_c16 * const restr
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_r10.c
===================================================================
--- libgfortran/generated/product_r10.c	(Revision 163593)
+++ libgfortran/generated/product_r10.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_r10 (gfc_array_r10 * const restr
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/product_i1.c
===================================================================
--- libgfortran/generated/product_i1.c	(Revision 163593)
+++ libgfortran/generated/product_i1.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the PRODUCT intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -152,6 +152,7 @@  product_i1 (gfc_array_i1 * const restric
 
   result *= *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }
Index: libgfortran/generated/all_l8.c
===================================================================
--- libgfortran/generated/all_l8.c	(Revision 163593)
+++ libgfortran/generated/all_l8.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the ALL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
Index: libgfortran/generated/maxval_r4.c
===================================================================
--- libgfortran/generated/maxval_r4.c	(Revision 163593)
+++ libgfortran/generated/maxval_r4.c	(Arbeitskopie)
@@ -1,8 +1,8 @@ 
 /* Implementation of the MAXVAL intrinsic
-   Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2002, 2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>
 
-This file is part of the GNU Fortran 95 runtime library (libgfortran).
+This file is part of the GNU Fortran runtime library (libgfortran).
 
 Libgfortran is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
@@ -166,6 +166,7 @@  maxval_r4 (gfc_array_r4 * const restrict
 		if (*src > result)
 		  result = *src;
 	      }
+	    
 	    *dest = result;
 	  }
       }