This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Fortran-dev][Patch] Add "rank" field and use it


This patch adds a "rank" field to the descriptor and uses it. Before the information was in the dtype. At the same time, it bumps the maximal rank from 7 to 15 as required by Fortran 2008.

RFC: Should the rank be an "int" or some other variable like int8_t, int16_t, int32_t or some other data type, signed or unsigned?

Currently, the descriptor is as follows, where CFI_rank_t is an "int"; "offset" is specific to gfortran and will have to go, "dtype" will become CFI_type_t and attribute of type CFI_attribute_t will have to be added.

#define CFI_GFC_CDESC_T(r, type) \
struct {\
  type *base_addr;\
  size_t elem_len;\
  int version; \
  CFI_rank_t rank; \
  size_t offset;\
  CFI_index_t dtype;\
  CFI_dim_t dim[r];\
}


For the required fields (there can be more), see TS29113. "void *", "size_t" and "int" are the required types for the first three fields. See section 8.3.3 of ftp://ftp.nag.co.uk/sc22wg5/N1901-N1950/N1942.pdf


The patch builds and regtestes without new failures.
I would be happy if someone could glance at the patch and tell me whether it is okay.


Future plans: Split off the element length (size) from dtype and set "elem_len" instead; additionally, "version" has to be set. Offset has to be removed, and the remaining test-case failures have to be fixed. The type, version, and elem_len can be moved directly after the declaration (instead of setting it at allocatation time); except for BT_CLASS and deferred-length chars/DT - for them elem_len and type can only be set at ptr assignment and realloc. Some more cleanup should be done for the algorithms. And probably we should also change how static arrays are handled and how DWARF symbols are generated (extend instead of ubound). When that all works, we have to think about additional field, whether the vptr has to be in the descriptor, and about merging to the 4.9 trunk. As follow up, the ABI cleanup, TS29113 additions and other things should be done. - Assuming, the array-descriptor will be ready early enough during stage 1 of GCC 4.9.

Tobiash
 gcc/dwarf2out.h                                   |  2 +-
 gcc/fortran/libgfortran.h                         |  6 +---
 gcc/fortran/trans-array.c                         | 44 +++++++++++++++--------
 gcc/fortran/trans-expr.c                          | 16 +++++++--
 gcc/fortran/trans-intrinsic.c                     |  4 ++-
 gcc/fortran/trans-io.c                            | 10 +++---
 gcc/fortran/trans-types.c                         | 13 ++++---
 gcc/testsuite/gfortran.dg/assign_10.f90           |  4 +--
 gcc/testsuite/gfortran.dg/coarray_18.f90          | 19 +++++-----
 gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90 |  4 +--
 gcc/testsuite/gfortran.dg/inline_sum_1.f90        |  2 +-
 gcc/testsuite/gfortran.dg/rank_1.f90              |  5 ++-
 libgfortran/ISO_Fortran_binding.h                 |  3 +-
 libgfortran/intrinsics/reshape_generic.c          |  4 +--
 libgfortran/intrinsics/spread_generic.c           |  3 +-
 libgfortran/io/transfer.c                         |  7 ++--
 libgfortran/libgfortran.h                         |  2 +-
 libgfortran/m4/iforeach.m4                        |  9 +++--
 libgfortran/m4/ifunction.m4                       |  9 +++--
 libgfortran/m4/ifunction_logical.m4               |  3 +-
 libgfortran/m4/reshape.m4                         |  3 +-
 libgfortran/m4/spread.m4                          |  3 +-
 22 files changed, 110 insertions(+), 65 deletions(-)

 (Plus generated files)


2013-03-31  Tobias Burnus  <burnus@net-b.de>

	* dwarf2out.h (array_descr_info): Change dim to 15.

2013-03-31  Tobias Burnus  <burnus@net-b.de>

	* libgfortran.h (GFC_MAX_DIMENSIONS): Change to 15.
	(GFC_DTYPE_RANK_MASK): Remove.
	* trans-array.c (RANK_FIELD): New define.
	(gfc_conv_descriptor_rank): Use rank field.
	(gfc_trans_create_temp_array, gfc_array_init_size,
	gfc_conv_expr_descriptor,
	gfc_alloc_allocatable_for_assignment): Set rank field.
	* trans-expr.c (gfc_conv_scalar_to_descriptor,
	class_array_data_assign, gfc_conv_derived_to_class,
	gfc_conv_class_to_class, gfc_trans_pointer_assignment,
	fcncall_realloc_result): Ditto.
	* trans-intrinsic.c (conv_isocbinding_subroutine): Ditto.
	* trans-io.c (gfc_build_io_library_fndecls,
	transfer_namelist_element): Pass rank as extra argument.
	* trans-types.c (gfc_get_element_type, gfc_get_dtype): Don't
	add the rank to dtype.
	(gfc_get_array_descriptor_base): New "rank" field.

2013-03-31  Tobias Burnus  <burnus@net-b.de>

	* gfortran.dg/assign_10.f90: Update scan-tree-dump-times.
	* gfortran.dg/coarray_18.f90: Update dg-error for max rank.
	* gfortran.dg/coarray_lib_token_4.f90: update scan pattern.
	* gfortran.dg/inline_sum_1.f90: Ditto.
	* gfortran.dg/rank_1.f90: Update dg-error for max rank.

2013-03-31  Tobias Burnus  <burnus@net-b.de>

	* ISO_Fortran_binding.h (CFI_rank_t): Change to int.
	(CFI_GFC_CDESC_T): Add rank field.
	* intrinsics/reshape_generic.c (reshape_internal): Set rank field.
	* intrinsics/spread_generic.c: Ditto.
	* io/transfer.c (st_set_nml_var): Add rank argument.
	* libgfortran.h (GFC_DESCRIPTOR_RANK): Use rank field.
	* m4/iforeach.m4: Set rank field.
	* m4/ifunction.m4: Ditto.
	* m4/ifunction_logical.m4: Ditto.
	* m4/reshape.m4: Ditto.
	* m4/spread.m4: Ditto.
	* generated/all_l1.c: Regenerated.
	* generated/all_l16.c: Regenerated.
	* generated/all_l2.c: Regenerated.
	* generated/all_l4.c: Regenerated.
	* generated/all_l8.c: Regenerated.
	* generated/any_l1.c: Regenerated.
	* generated/any_l16.c: Regenerated.
	* generated/any_l2.c: Regenerated.
	* generated/any_l4.c: Regenerated.
	* generated/any_l8.c: Regenerated.
	* generated/count_16_l.c: Regenerated.
	* generated/count_1_l.c: Regenerated.
	* generated/count_2_l.c: Regenerated.
	* generated/count_4_l.c: Regenerated.
	* generated/count_8_l.c: Regenerated.
	* generated/iall_i1.c: Regenerated.
	* generated/iall_i16.c: Regenerated.
	* generated/iall_i2.c: Regenerated.
	* generated/iall_i4.c: Regenerated.
	* generated/iall_i8.c: Regenerated.
	* generated/iany_i1.c: Regenerated.
	* generated/iany_i16.c: Regenerated.
	* generated/iany_i2.c: Regenerated.
	* generated/iany_i4.c: Regenerated.
	* generated/iany_i8.c: Regenerated.
	* generated/iparity_i1.c: Regenerated.
	* generated/iparity_i16.c: Regenerated.
	* generated/iparity_i2.c: Regenerated.
	* generated/iparity_i4.c: Regenerated.
	* generated/iparity_i8.c: Regenerated.
	* generated/maxloc0_16_i1.c: Regenerated.
	* generated/maxloc0_16_i16.c: Regenerated.
	* generated/maxloc0_16_i2.c: Regenerated.
	* generated/maxloc0_16_i4.c: Regenerated.
	* generated/maxloc0_16_i8.c: Regenerated.
	* generated/maxloc0_16_r10.c: Regenerated.
	* generated/maxloc0_16_r16.c: Regenerated.
	* generated/maxloc0_16_r4.c: Regenerated.
	* generated/maxloc0_16_r8.c: Regenerated.
	* generated/maxloc0_4_i1.c: Regenerated.
	* generated/maxloc0_4_i16.c: Regenerated.
	* generated/maxloc0_4_i2.c: Regenerated.
	* generated/maxloc0_4_i4.c: Regenerated.
	* generated/maxloc0_4_i8.c: Regenerated.
	* generated/maxloc0_4_r10.c: Regenerated.
	* generated/maxloc0_4_r16.c: Regenerated.
	* generated/maxloc0_4_r4.c: Regenerated.
	* generated/maxloc0_4_r8.c: Regenerated.
	* generated/maxloc0_8_i1.c: Regenerated.
	* generated/maxloc0_8_i16.c: Regenerated.
	* generated/maxloc0_8_i2.c: Regenerated.
	* generated/maxloc0_8_i4.c: Regenerated.
	* generated/maxloc0_8_i8.c: Regenerated.
	* generated/maxloc0_8_r10.c: Regenerated.
	* generated/maxloc0_8_r16.c: Regenerated.
	* generated/maxloc0_8_r4.c: Regenerated.
	* generated/maxloc0_8_r8.c: Regenerated.
	* generated/maxloc1_16_i1.c: Regenerated.
	* generated/maxloc1_16_i16.c: Regenerated.
	* generated/maxloc1_16_i2.c: Regenerated.
	* generated/maxloc1_16_i4.c: Regenerated.
	* generated/maxloc1_16_i8.c: Regenerated.
	* generated/maxloc1_16_r10.c: Regenerated.
	* generated/maxloc1_16_r16.c: Regenerated.
	* generated/maxloc1_16_r4.c: Regenerated.
	* generated/maxloc1_16_r8.c: Regenerated.
	* generated/maxloc1_4_i1.c: Regenerated.
	* generated/maxloc1_4_i16.c: Regenerated.
	* generated/maxloc1_4_i2.c: Regenerated.
	* generated/maxloc1_4_i4.c: Regenerated.
	* generated/maxloc1_4_i8.c: Regenerated.
	* generated/maxloc1_4_r10.c: Regenerated.
	* generated/maxloc1_4_r16.c: Regenerated.
	* generated/maxloc1_4_r4.c: Regenerated.
	* generated/maxloc1_4_r8.c: Regenerated.
	* generated/maxloc1_8_i1.c: Regenerated.
	* generated/maxloc1_8_i16.c: Regenerated.
	* generated/maxloc1_8_i2.c: Regenerated.
	* generated/maxloc1_8_i4.c: Regenerated.
	* generated/maxloc1_8_i8.c: Regenerated.
	* generated/maxloc1_8_r10.c: Regenerated.
	* generated/maxloc1_8_r16.c: Regenerated.
	* generated/maxloc1_8_r4.c: Regenerated.
	* generated/maxloc1_8_r8.c: Regenerated.
	* generated/maxval_i1.c: Regenerated.
	* generated/maxval_i16.c: Regenerated.
	* generated/maxval_i2.c: Regenerated.
	* generated/maxval_i4.c: Regenerated.
	* generated/maxval_i8.c: Regenerated.
	* generated/maxval_r10.c: Regenerated.
	* generated/maxval_r16.c: Regenerated.
	* generated/maxval_r4.c: Regenerated.
	* generated/maxval_r8.c: Regenerated.
	* generated/minloc0_16_i1.c: Regenerated.
	* generated/minloc0_16_i16.c: Regenerated.
	* generated/minloc0_16_i2.c: Regenerated.
	* generated/minloc0_16_i4.c: Regenerated.
	* generated/minloc0_16_i8.c: Regenerated.
	* generated/minloc0_16_r10.c: Regenerated.
	* generated/minloc0_16_r16.c: Regenerated.
	* generated/minloc0_16_r4.c: Regenerated.
	* generated/minloc0_16_r8.c: Regenerated.
	* generated/minloc0_4_i1.c: Regenerated.
	* generated/minloc0_4_i16.c: Regenerated.
	* generated/minloc0_4_i2.c: Regenerated.
	* generated/minloc0_4_i4.c: Regenerated.
	* generated/minloc0_4_i8.c: Regenerated.
	* generated/minloc0_4_r10.c: Regenerated.
	* generated/minloc0_4_r16.c: Regenerated.
	* generated/minloc0_4_r4.c: Regenerated.
	* generated/minloc0_4_r8.c: Regenerated.
	* generated/minloc0_8_i1.c: Regenerated.
	* generated/minloc0_8_i16.c: Regenerated.
	* generated/minloc0_8_i2.c: Regenerated.
	* generated/minloc0_8_i4.c: Regenerated.
	* generated/minloc0_8_i8.c: Regenerated.
	* generated/minloc0_8_r10.c: Regenerated.
	* generated/minloc0_8_r16.c: Regenerated.
	* generated/minloc0_8_r4.c: Regenerated.
	* generated/minloc0_8_r8.c: Regenerated.
	* generated/minloc1_16_i1.c: Regenerated.
	* generated/minloc1_16_i16.c: Regenerated.
	* generated/minloc1_16_i2.c: Regenerated.
	* generated/minloc1_16_i4.c: Regenerated.
	* generated/minloc1_16_i8.c: Regenerated.
	* generated/minloc1_16_r10.c: Regenerated.
	* generated/minloc1_16_r16.c: Regenerated.
	* generated/minloc1_16_r4.c: Regenerated.
	* generated/minloc1_16_r8.c: Regenerated.
	* generated/minloc1_4_i1.c: Regenerated.
	* generated/minloc1_4_i16.c: Regenerated.
	* generated/minloc1_4_i2.c: Regenerated.
	* generated/minloc1_4_i4.c: Regenerated.
	* generated/minloc1_4_i8.c: Regenerated.
	* generated/minloc1_4_r10.c: Regenerated.
	* generated/minloc1_4_r16.c: Regenerated.
	* generated/minloc1_4_r4.c: Regenerated.
	* generated/minloc1_4_r8.c: Regenerated.
	* generated/minloc1_8_i1.c: Regenerated.
	* generated/minloc1_8_i16.c: Regenerated.
	* generated/minloc1_8_i2.c: Regenerated.
	* generated/minloc1_8_i4.c: Regenerated.
	* generated/minloc1_8_i8.c: Regenerated.
	* generated/minloc1_8_r10.c: Regenerated.
	* generated/minloc1_8_r16.c: Regenerated.
	* generated/minloc1_8_r4.c: Regenerated.
	* generated/minloc1_8_r8.c: Regenerated.
	* generated/minval_i1.c: Regenerated.
	* generated/minval_i16.c: Regenerated.
	* generated/minval_i2.c: Regenerated.
	* generated/minval_i4.c: Regenerated.
	* generated/minval_i8.c: Regenerated.
	* generated/minval_r10.c: Regenerated.
	* generated/minval_r16.c: Regenerated.
	* generated/minval_r4.c: Regenerated.
	* generated/minval_r8.c: Regenerated.
	* generated/norm2_r10.c: Regenerated.
	* generated/norm2_r16.c: Regenerated.
	* generated/norm2_r4.c: Regenerated.
	* generated/norm2_r8.c: Regenerated.
	* generated/parity_l1.c: Regenerated.
	* generated/parity_l16.c: Regenerated.
	* generated/parity_l2.c: Regenerated.
	* generated/parity_l4.c: Regenerated.
	* generated/parity_l8.c: Regenerated.
	* generated/product_c10.c: Regenerated.
	* generated/product_c16.c: Regenerated.
	* generated/product_c4.c: Regenerated.
	* generated/product_c8.c: Regenerated.
	* generated/product_i1.c: Regenerated.
	* generated/product_i16.c: Regenerated.
	* generated/product_i2.c: Regenerated.
	* generated/product_i4.c: Regenerated.
	* generated/product_i8.c: Regenerated.
	* generated/product_r10.c: Regenerated.
	* generated/product_r16.c: Regenerated.
	* generated/product_r4.c: Regenerated.
	* generated/product_r8.c: Regenerated.
	* generated/reshape_c10.c: Regenerated.
	* generated/reshape_c16.c: Regenerated.
	* generated/reshape_c4.c: Regenerated.
	* generated/reshape_c8.c: Regenerated.
	* generated/reshape_i16.c: Regenerated.
	* generated/reshape_i4.c: Regenerated.
	* generated/reshape_i8.c: Regenerated.
	* generated/reshape_r10.c: Regenerated.
	* generated/reshape_r16.c: Regenerated.
	* generated/reshape_r4.c: Regenerated.
	* generated/reshape_r8.c: Regenerated.
	* generated/spread_c10.c: Regenerated.
	* generated/spread_c16.c: Regenerated.
	* generated/spread_c4.c: Regenerated.
	* generated/spread_c8.c: Regenerated.
	* generated/spread_i1.c: Regenerated.
	* generated/spread_i16.c: Regenerated.
	* generated/spread_i2.c: Regenerated.
	* generated/spread_i4.c: Regenerated.
	* generated/spread_i8.c: Regenerated.
	* generated/spread_r10.c: Regenerated.
	* generated/spread_r16.c: Regenerated.
	* generated/spread_r4.c: Regenerated.
	* generated/spread_r8.c: Regenerated.
	* generated/sum_c10.c: Regenerated.
	* generated/sum_c16.c: Regenerated.
	* generated/sum_c4.c: Regenerated.
	* generated/sum_c8.c: Regenerated.
	* generated/sum_i1.c: Regenerated.
	* generated/sum_i16.c: Regenerated.
	* generated/sum_i2.c: Regenerated.
	* generated/sum_i4.c: Regenerated.
	* generated/sum_i8.c: Regenerated.
	* generated/sum_r10.c: Regenerated.
	* generated/sum_r16.c: Regenerated.
	* generated/sum_r4.c: Regenerated.
	* generated/sum_r8.c: Regenerated.

 diff --git a/gcc/dwarf2out.h b/gcc/dwarf2out.h
index ad03a34..fb14633 100644
--- a/gcc/dwarf2out.h
+++ b/gcc/dwarf2out.h
@@ -277,7 +277,7 @@ struct array_descr_info
       tree lower_bound;
       tree upper_bound;
       tree stride;
-    } dimen[10];
+    } dimen[15];
 };
 
 #endif /* GCC_DWARF2OUT_H */
diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h
index 30b3b7b..331ca6f 100644
--- a/gcc/fortran/libgfortran.h
+++ b/gcc/fortran/libgfortran.h
@@ -113,12 +113,8 @@ libgfortran_stat_codes;
 #define GFC_STDOUT_UNIT_NUMBER 6
 #define GFC_STDERR_UNIT_NUMBER 0
 
+#define GFC_MAX_DIMENSIONS 15
 
-/* FIXME: Increase to 15 for Fortran 2008. Also needs changes to
-   GFC_DTYPE_RANK_MASK. See PR 36825.  */
-#define GFC_MAX_DIMENSIONS 7
-
-#define GFC_DTYPE_RANK_MASK 0x07
 #define GFC_DTYPE_TYPE_SHIFT 3
 #define GFC_DTYPE_TYPE_MASK 0x38
 #define GFC_DTYPE_SIZE_SHIFT 6
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 7228bf4..b3c87a7 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -126,10 +126,11 @@ gfc_array_dataptr_type (tree desc)
 #define DATA_FIELD 0
 #define ELEM_LEN_FIELD 1
 #define VERSION_FIELD 2
-#define OFFSET_FIELD 3
-#define DTYPE_FIELD 4
-#define DIMENSION_FIELD 5
-#define CAF_TOKEN_FIELD 6
+#define RANK_FIELD 3
+#define OFFSET_FIELD 4
+#define DTYPE_FIELD 5
+#define DIMENSION_FIELD 6
+#define CAF_TOKEN_FIELD 7
 
 #define LBOUND_SUBFIELD 0
 #define EXTENT_SUBFIELD 1
@@ -266,14 +267,17 @@ gfc_dimension_field_from_base_field (tree field)
 tree
 gfc_conv_descriptor_rank (tree desc)
 {
-  tree tmp;
-  tree dtype;
+  tree field;
+  tree type;
 
-  dtype = gfc_conv_descriptor_dtype (desc);
-  tmp = build_int_cst (TREE_TYPE (dtype), GFC_DTYPE_RANK_MASK);
-  tmp = fold_build2_loc (input_location, BIT_AND_EXPR, TREE_TYPE (dtype),
-			 dtype, tmp);
-  return fold_convert (gfc_get_int_type (gfc_default_integer_kind), tmp);
+  type = TREE_TYPE (desc);
+  gcc_assert (GFC_DESCRIPTOR_TYPE_P (type));
+
+  field = gfc_advance_chain (TYPE_FIELDS (type), RANK_FIELD);
+  gcc_assert (field != NULL_TREE && TREE_TYPE (field) == integer_type_node);
+
+  return fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (field),
+			  desc, field, NULL_TREE);
 }
 
 
@@ -546,6 +550,7 @@ gfc_conv_shift_descriptor_lbound (stmtblock_t* block, tree desc,
 #undef DATA_FIELD
 #undef ELEM_LEN_FIELD
 #undef VERSION_FIELD
+#undef RANK_FIELD
 #undef OFFSET_FIELD
 #undef DTYPE_FIELD
 #undef DIMENSION_FIELD
@@ -1172,7 +1177,9 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
   info->descriptor = desc;
   size = gfc_index_one_node;
 
-  /* Fill in the array dtype.  */
+  /* Fill in the array rank and dtype.  */
+  tmp = gfc_conv_descriptor_rank (desc);
+  gfc_add_modify (pre, tmp, build_int_cst (integer_type_node, total_dim));
   tmp = gfc_conv_descriptor_dtype (desc);
   gfc_add_modify (pre, tmp, gfc_get_dtype (TREE_TYPE (desc)));
 
@@ -4984,7 +4991,10 @@ gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset,
   stride = gfc_index_one_node;
   offset = gfc_index_zero_node;
 
-  /* Set the dtype.  */
+  /* Set the rank and dtype.  */
+  tmp = gfc_conv_descriptor_rank (descriptor);
+  gfc_add_modify (descriptor_block, tmp, build_int_cst (integer_type_node,
+							rank));
   tmp = gfc_conv_descriptor_dtype (descriptor);
   gfc_add_modify (descriptor_block, tmp, gfc_get_dtype (TREE_TYPE (descriptor)));
 
@@ -6868,7 +6878,10 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr)
          We don't have to worry about numeric overflows when calculating
          the offsets because all elements are within the array data.  */
 
-      /* Set the dtype.  */
+      /* Set the rank and dtype.  */
+      tmp = gfc_conv_descriptor_rank (parm);
+      gfc_add_modify (&loop.pre, tmp, build_int_cst (integer_type_node,
+						     loop.dimen));
       tmp = gfc_conv_descriptor_dtype (parm);
       gfc_add_modify (&loop.pre, tmp, gfc_get_dtype (parmtype));
 
@@ -8370,6 +8383,9 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
 			     1, size2);
   gfc_conv_descriptor_data_set (&alloc_block,
 				desc, tmp);
+  tmp = gfc_conv_descriptor_rank (desc);
+  gfc_add_modify (&alloc_block, tmp, build_int_cst (integer_type_node,
+                                                    expr1->rank));
   tmp = gfc_conv_descriptor_dtype (desc);
   gfc_add_modify (&alloc_block, tmp, gfc_get_dtype (TREE_TYPE (desc)));
   if ((expr1->ts.type == BT_DERIVED)
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 454755b..7b811e4 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -67,6 +67,8 @@ gfc_conv_scalar_to_descriptor (gfc_se *se, tree scalar, symbol_attribute attr)
   type = get_scalar_to_descriptor_type (scalar, attr);
   desc = gfc_create_var (type, "desc");
   DECL_ARTIFICIAL (desc) = 1;
+  gfc_add_modify (&se->pre, gfc_conv_descriptor_rank (desc),
+		  build_int_cst (integer_type_node, 0));
   gfc_add_modify (&se->pre, gfc_conv_descriptor_dtype (desc),
 		  gfc_get_dtype (type));
   gfc_conv_descriptor_data_set (&se->pre, desc, scalar);
@@ -235,6 +237,8 @@ class_array_data_assign (stmtblock_t *block, tree lhs_desc, tree rhs_desc,
   gfc_conv_descriptor_offset_set (block, lhs_desc,
 				  gfc_conv_descriptor_offset_get (rhs_desc));
 
+  gfc_add_modify (block, gfc_conv_descriptor_rank (lhs_desc),
+		  gfc_conv_descriptor_rank (rhs_desc));
   gfc_add_modify (block, gfc_conv_descriptor_dtype (lhs_desc),
 		  gfc_conv_descriptor_dtype (rhs_desc));
 
@@ -325,6 +329,8 @@ gfc_conv_derived_to_class (gfc_se *parmse, gfc_expr *e,
 	      tree type;
 	      type = get_scalar_to_descriptor_type (parmse->expr,
 						    gfc_expr_attr (e));
+	      gfc_add_modify (&parmse->pre, gfc_conv_descriptor_rank (ctree),
+			      build_int_cst (integer_type_node, 0));
 	      gfc_add_modify (&parmse->pre, gfc_conv_descriptor_dtype (ctree),
 			      gfc_get_dtype (type));
 	      if (optional)
@@ -593,6 +599,8 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts,
 	{
 	  tree type = get_scalar_to_descriptor_type (parmse->expr,
 						     gfc_expr_attr (e));
+	  gfc_add_modify (&block, gfc_conv_descriptor_rank (ctree),
+			  build_int_cst (integer_type_node, 0));
 	  gfc_add_modify (&block, gfc_conv_descriptor_dtype (ctree),
 			  gfc_get_dtype (type));
 
@@ -6485,7 +6493,9 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2)
 	      tree offs, stride;
 	      tree lbound, ubound;
 
-	      /* Set dtype.  */
+	      /* Set rank and dtype.  */
+	      gfc_add_modify (&block, gfc_conv_descriptor_rank (desc),
+			      build_int_cst (integer_type_node, expr1->rank));
 	      dtype = gfc_conv_descriptor_dtype (desc);
 	      tmp = gfc_get_dtype (TREE_TYPE (desc));
 	      gfc_add_modify (&block, dtype, tmp);
@@ -6978,7 +6988,9 @@ fcncall_realloc_result (gfc_se *se, int rank)
   if (POINTER_TYPE_P (TREE_TYPE (desc)))
     desc = build_fold_indirect_ref_loc (input_location, desc);
 
-  /* Unallocated, the descriptor does not have a dtype.  */
+  /* Unallocated, the descriptor does not have a rank and dtype.  */
+  gfc_add_modify (&se->pre, gfc_conv_descriptor_rank (desc),
+                  build_int_cst (integer_type_node, rank));
   tmp = gfc_conv_descriptor_dtype (desc);
   gfc_add_modify (&se->pre, tmp, gfc_get_dtype (TREE_TYPE (desc)));
 
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 9258913..c488696 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -6420,9 +6420,11 @@ conv_isocbinding_subroutine (gfc_code *code)
   gfc_add_block_to_block (&block, &fptrse.pre);
   desc = fptrse.expr;
 
-  /* Set data value, dtype, and offset.  */
+  /* Set data value, rank, dtype, and offset.  */
   tmp = GFC_TYPE_ARRAY_DATAPTR_TYPE (TREE_TYPE (desc));
   gfc_conv_descriptor_data_set (&block, desc, fold_convert (tmp, cptrse.expr));
+  gfc_add_modify (&block, gfc_conv_descriptor_rank (desc),
+		  build_int_cst (integer_type_node, arg->next->expr->rank));
   gfc_add_modify (&block, gfc_conv_descriptor_dtype (desc),
 		  gfc_get_dtype (TREE_TYPE (desc)));
 
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index ff8143a..597d39b 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -457,8 +457,9 @@ gfc_build_io_library_fndecls (void)
 
   iocall[IOCALL_SET_NML_VAL] = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("st_set_nml_var")), ".w.R",
-	void_type_node, 6, dt_parm_type, pvoid_type_node, pvoid_type_node,
-	void_type_node, gfc_charlen_type_node, gfc_int4_type_node);
+	void_type_node, 7, dt_parm_type, pvoid_type_node, pvoid_type_node,
+	void_type_node, gfc_charlen_type_node, integer_type_node,
+	gfc_int4_type_node);
 
   iocall[IOCALL_SET_NML_VAL_DIM] = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("st_set_nml_var_dim")), ".w",
@@ -1587,9 +1588,10 @@ transfer_namelist_element (stmtblock_t * block, const char * var_name,
   else
     tmp = build_int_cst (gfc_charlen_type_node, 0);
   tmp = build_call_expr_loc (input_location,
-			 iocall[IOCALL_SET_NML_VAL], 6,
+			 iocall[IOCALL_SET_NML_VAL], 7,
 			 dt_parm_addr, addr_expr, string,
-			 IARG (ts->kind), tmp, dtype);
+			 IARG (ts->kind), tmp,
+			 build_int_cst (integer_type_node, rank), dtype);
   gfc_add_expr_to_block (block, tmp);
 
   /* If the object is an array, transfer rank times:
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index c6f52ff..4e10139 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -1217,7 +1217,7 @@ gfc_get_element_type (tree type)
    data.  See below for the handling of character types.
 
    The dtype member is formatted as follows:
-    rank = dtype & GFC_DTYPE_RANK_MASK // 3 bits
+    // 3 unused bits (used to be the rank)
     type = (dtype & GFC_DTYPE_TYPE_MASK) >> GFC_DTYPE_TYPE_SHIFT // 3 bits
     size = dtype >> GFC_DTYPE_SIZE_SHIFT
 
@@ -1394,14 +1394,12 @@ gfc_get_dtype (tree type)
   tree tmp;
   tree dtype;
   tree etype;
-  int rank;
 
   gcc_assert (GFC_DESCRIPTOR_TYPE_P (type) || GFC_ARRAY_TYPE_P (type));
 
   if (GFC_TYPE_ARRAY_DTYPE (type))
     return GFC_TYPE_ARRAY_DTYPE (type);
 
-  rank = GFC_TYPE_ARRAY_RANK (type);
   etype = gfc_get_element_type (type);
 
   switch (TREE_CODE (etype))
@@ -1441,10 +1439,9 @@ gfc_get_dtype (tree type)
       return gfc_index_zero_node;
     }
 
-  gcc_assert (rank <= GFC_DTYPE_RANK_MASK);
   size = TYPE_SIZE_UNIT (etype);
 
-  i = rank | (n << GFC_DTYPE_TYPE_SHIFT);
+  i = (n << GFC_DTYPE_TYPE_SHIFT);
   if (size && INTEGER_CST_P (size))
     {
       if (tree_int_cst_lt (gfc_max_array_element_size, size))
@@ -1737,6 +1734,12 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted,
 				    integer_type_node, &chain);
   TREE_NO_WARNING (decl) = 1;
 
+  /* Add the rank component.  */
+  decl = gfc_add_field_to_struct_1 (fat_type,
+				    get_identifier ("rank"),
+				    integer_type_node, &chain);
+  TREE_NO_WARNING (decl) = 1;
+
   /* Add the offset component.  */
   decl = gfc_add_field_to_struct_1 (fat_type,
 				    get_identifier ("offset"),
diff --git a/gcc/testsuite/gfortran.dg/assign_10.f90 b/gcc/testsuite/gfortran.dg/assign_10.f90
index bf1d0e0..99dc077 100644
--- a/gcc/testsuite/gfortran.dg/assign_10.f90
+++ b/gcc/testsuite/gfortran.dg/assign_10.f90
@@ -23,6 +23,6 @@ end
 ! cases will all yield a temporary, so that atmp appears 18 times.
 ! Note that it is the kind conversion that generates the temp.
 !
-! { dg-final { scan-tree-dump-times "parm" 20 "original" } }
-! { dg-final { scan-tree-dump-times "atmp" 20 "original" } }
+! { dg-final { scan-tree-dump-times "parm" 22 "original" } }
+! { dg-final { scan-tree-dump-times "atmp" 22 "original" } }
 ! { dg-final { cleanup-tree-dump "original" } }
diff --git a/gcc/testsuite/gfortran.dg/coarray_18.f90 b/gcc/testsuite/gfortran.dg/coarray_18.f90
index 474e939..18a0fb8 100644
--- a/gcc/testsuite/gfortran.dg/coarray_18.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_18.f90
@@ -19,14 +19,17 @@ program ar
   integer :: ic(2)[*]
   integer :: id(2,2)[2,*]
   integer :: ie(2,2,2)[2,2,*]
-  integer :: ig(2,2,2,2)[2,2,2,*] ! { dg-error "has more than 7 dimensions" }
-  integer :: ih(2,2,2,2,2)[2,2,2,2,*] ! { dg-error "has more than 7 dimensions" }
-  integer :: ij(2,2,2,2,2,2)[2,2,2,2,2,*] ! { dg-error "has more than 7 dimensions" }
-  integer :: ik(2,2,2,2,2,2,2)[2,2,2,2,2,2,*] ! { dg-error "has more than 7 dimensions" }
-  integer :: il[2,2,2,2,2,2,2,*] ! { dg-error "has more than 7 dimensions" }
-  integer :: im[2,2,2,2,2,2,2,2,*] ! { dg-error "has more than 7 dimensions" }
-  integer :: in[2,2,2,2,2,2,2,2,2,*] ! { dg-error "has more than 7 dimensions" }
-  integer :: io[2,2,2,2,2,2,2,2,2,2,*] ! { dg-error "has more than 7 dimensions" }
+  integer :: ig(2,2,2,2)[2,2,2,*]
+  integer :: ih(2,2,2,2,2)[2,2,2,2,*]
+  integer :: ij(2,2,2,2,2,2)[2,2,2,2,2,*]
+  integer :: ik(2,2,2,2,2,2,2)[2,2,2,2,2,2,*]
+  integer :: i2(2,2,2,2,2,2,2)[2,2,2,2,2,2,2,2,*] ! { dg-error "has more than 15 dimensions" }
+  integer :: il[2,2,2,2,2,2,2,*]
+  integer :: im[2,2,2,2,2,2,2,2,*]
+  integer :: in[2,2,2,2,2,2,2,2,2,*]
+  integer :: io[2,2,2,2,2,2,2,2,2,2,*]
+  integer :: ip[2,2,2,2,2,2,2,2,2,2,2,2,2,2,*]
+  integer :: ip[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,*] ! { dg-error "has more than 15 dimensions" }
    real :: x2(2,2,4)[2,*]
    complex :: c2(4,2)[2,*]
    double precision :: d2(1,5,9)[2,*]
diff --git a/gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90 b/gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90
index 14f12c4..fe7590b 100644
--- a/gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90
@@ -35,9 +35,9 @@ end program test_caf
 
 ! { dg-final { scan-tree-dump-times "expl \\(integer\\(kind=4\\).0:. . restrict z, void . restrict caf_token.\[0-9\]+, integer\\(kind=.\\) caf_offset.\[0-9\]+\\)" 1 "original" } }
 !
-! { dg-final { scan-tree-dump-times "bar \\(struct array2_integer\\(kind=4\\) & restrict y, void . restrict caf_token.\[0-9\]+, integer\\(kind=.\\) caf_offset.\[0-9\]+\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times "bar \\(struct array02_integer\\(kind=4\\) & restrict y, void . restrict caf_token.\[0-9\]+, integer\\(kind=.\\) caf_offset.\[0-9\]+\\)" 1 "original" } }
 !
-! { dg-final { scan-tree-dump-times "foo \\(struct array2_integer\\(kind=4\\) & restrict x, struct array2_integer\\(kind=4\\) & restrict y, integer\\(kind=4\\) & restrict test, void . restrict caf_token.\[0-9\]+, integer\\(kind=.\\) caf_offset.\[0-9\]+, void . restrict caf_token.\[0-9\]+, integer\\(kind=.\\) caf_offset.\[0-9\]+\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times "foo \\(struct array02_integer\\(kind=4\\) & restrict x, struct array02_integer\\(kind=4\\) & restrict y, integer\\(kind=4\\) & restrict test, void . restrict caf_token.\[0-9\]+, integer\\(kind=.\\) caf_offset.\[0-9\]+, void . restrict caf_token.\[0-9\]+, integer\\(kind=.\\) caf_offset.\[0-9\]+\\)" 1 "original" } }
 !
 ! { dg-final { scan-tree-dump-times "bar \\(&parm.\[0-9\]+, caf_token.\[0-9\]+, \\(\\(integer\\(kind=.\\)\\) parm.\[0-9\]+.base_addr - \\(integer\\(kind=.\\)\\) x.\[0-9\]+\\) \\+ caf_offset.\[0-9\]+\\);" 1 "original" } }
 !
diff --git a/gcc/testsuite/gfortran.dg/inline_sum_1.f90 b/gcc/testsuite/gfortran.dg/inline_sum_1.f90
index 4538e5e..9957001 100644
--- a/gcc/testsuite/gfortran.dg/inline_sum_1.f90
+++ b/gcc/testsuite/gfortran.dg/inline_sum_1.f90
@@ -188,7 +188,7 @@ contains
     o = i
   end subroutine tes
 end
-! { dg-final { scan-tree-dump-times "struct array._integer\\(kind=4\\) atmp" 13 "original" } }
+! { dg-final { scan-tree-dump-times "struct array0._integer\\(kind=4\\) atmp" 13 "original" } }
 ! { dg-final { scan-tree-dump-times "struct array\[^\\n\]*atmp" 13 "original" } }
 ! { dg-final { scan-tree-dump-times "_gfortran_sum_" 0 "original" } }
 ! { dg-final { cleanup-tree-dump "original" } }
diff --git a/gcc/testsuite/gfortran.dg/rank_1.f90 b/gcc/testsuite/gfortran.dg/rank_1.f90
index 6a81e410..3467fad 100644
--- a/gcc/testsuite/gfortran.dg/rank_1.f90
+++ b/gcc/testsuite/gfortran.dg/rank_1.f90
@@ -4,7 +4,6 @@
 ! Fortran < 2008 allows 7  dimensions
 ! Fortran   2008 allows 15 dimensions (including co-array ranks)
 !
-! FIXME: Rank patch was reverted because of PR 36825.
-integer :: a(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) ! { dg-error "has more than 7 dimensions" }
-integer :: b(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) ! { dg-error "has more than 7 dimensions" }
+integer :: a(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)
+integer :: b(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) ! { dg-error "has more than 15 dimensions" }
 end
diff --git a/libgfortran/ISO_Fortran_binding.h b/libgfortran/ISO_Fortran_binding.h
index f8ccbac..314eb79 100644
--- a/libgfortran/ISO_Fortran_binding.h
+++ b/libgfortran/ISO_Fortran_binding.h
@@ -108,7 +108,7 @@ extern "C" {
 typedef ptrdiff_t CFI_index_t;
 typedef int32_t CFI_attribute_t;
 typedef int32_t CFI_type_t;
-typedef int32_t CFI_rank_t;
+typedef int CFI_rank_t;
 
 typedef struct CFI_dim_t
 {
@@ -141,6 +141,7 @@ struct {\
   type *base_addr;\
   size_t elem_len;\
   int version; \
+  CFI_rank_t rank; \
   size_t offset;\
   CFI_index_t dtype;\
   CFI_dim_t dim[r];\
diff --git a/libgfortran/intrinsics/reshape_generic.c b/libgfortran/intrinsics/reshape_generic.c
index 33088e7..5493b06 100644
--- a/libgfortran/intrinsics/reshape_generic.c
+++ b/libgfortran/intrinsics/reshape_generic.c
@@ -104,8 +104,8 @@ reshape_internal (parray *ret, parray *source, shape_type *shape,
 	alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/intrinsics/spread_generic.c b/libgfortran/intrinsics/spread_generic.c
index f08b1b1..3950a53 100644
--- a/libgfortran/intrinsics/spread_generic.c
+++ b/libgfortran/intrinsics/spread_generic.c
@@ -73,7 +73,8 @@ spread_internal (gfc_array_char *ret, const gfc_array_char *source,
 
       size_t ext, sm;
 
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = size;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index dfb3b9c..82291cd 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -3745,14 +3745,15 @@ st_wait (st_parameter_wait *wtp __attribute__((unused)))
    in a linked list of namelist_info types.  */
 
 extern void st_set_nml_var (st_parameter_dt *dtp, void *, char *,
-			    GFC_INTEGER_4, gfc_charlen_type, GFC_INTEGER_4);
+			    GFC_INTEGER_4, gfc_charlen_type, int,
+			    GFC_INTEGER_4);
 export_proto(st_set_nml_var);
 
 
 void
 st_set_nml_var (st_parameter_dt *dtp, void * var_addr, char * var_name,
 		GFC_INTEGER_4 len, gfc_charlen_type string_length,
-		GFC_INTEGER_4 dtype)
+		int rank, GFC_INTEGER_4 dtype)
 {
   namelist_info *t1 = NULL;
   namelist_info *nml;
@@ -3769,7 +3770,7 @@ st_set_nml_var (st_parameter_dt *dtp, void * var_addr, char * var_name,
   nml->len = (int) len;
   nml->string_length = (index_type) string_length;
 
-  nml->var_rank = (int) (dtype & GFC_DTYPE_RANK_MASK);
+  nml->var_rank = rank;
   nml->size = (index_type) (dtype >> GFC_DTYPE_SIZE_SHIFT);
   nml->type = (bt) ((dtype & GFC_DTYPE_TYPE_MASK) >> GFC_DTYPE_TYPE_SHIFT);
 
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index 6813475..0a94ec8 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -361,7 +361,7 @@ typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_16) gfc_array_l16;
 #endif
 
 
-#define GFC_DESCRIPTOR_RANK(desc) ((desc)->dtype & GFC_DTYPE_RANK_MASK)
+#define GFC_DESCRIPTOR_RANK(desc) ((desc)->rank)
 #define GFC_DESCRIPTOR_TYPE(desc) (((desc)->dtype & GFC_DTYPE_TYPE_MASK) \
                                    >> GFC_DTYPE_TYPE_SHIFT)
 #define GFC_DESCRIPTOR_SIZE(desc) ((desc)->dtype >> GFC_DTYPE_SIZE_SHIFT)
diff --git a/libgfortran/m4/iforeach.m4 b/libgfortran/m4/iforeach.m4
index eb69702..ffee799 100644
--- a/libgfortran/m4/iforeach.m4
+++ b/libgfortran/m4/iforeach.m4
@@ -28,7 +28,8 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (rtype_name));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (rtype_name) * rank);
     }
@@ -131,7 +132,8 @@ void
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (rtype_name));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (rtype_name) * rank);
     }
@@ -262,7 +264,8 @@ void
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (rtype_name));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (rtype_name) * rank);
     }
diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4
index 41e6920..0ddcd79 100644
--- a/libgfortran/m4/ifunction.m4
+++ b/libgfortran/m4/ifunction.m4
@@ -83,7 +83,8 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -264,7 +265,8 @@ void
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -414,7 +416,8 @@ void
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/m4/ifunction_logical.m4 b/libgfortran/m4/ifunction_logical.m4
index a5fe07d..13ce130 100644
--- a/libgfortran/m4/ifunction_logical.m4
+++ b/libgfortran/m4/ifunction_logical.m4
@@ -86,7 +86,8 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4
index c5c8dd7..1e247a3 100644
--- a/libgfortran/m4/reshape.m4
+++ b/libgfortran/m4/reshape.m4
@@ -120,7 +120,8 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/m4/spread.m4 b/libgfortran/m4/spread.m4
index 456fb49..80b5058 100644
--- a/libgfortran/m4/spread.m4
+++ b/libgfortran/m4/spread.m4
@@ -75,7 +75,8 @@ spread_'rtype_code` ('rtype` *ret, const 'rtype` *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/all_l1.c b/libgfortran/generated/all_l1.c
index 1d516ee..3eb638b 100644
--- a/libgfortran/generated/all_l1.c
+++ b/libgfortran/generated/all_l1.c
@@ -98,7 +98,8 @@ all_l1 (gfc_array_l1 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/all_l16.c b/libgfortran/generated/all_l16.c
index cc4b4a7..0117c51 100644
--- a/libgfortran/generated/all_l16.c
+++ b/libgfortran/generated/all_l16.c
@@ -98,7 +98,8 @@ all_l16 (gfc_array_l16 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/all_l2.c b/libgfortran/generated/all_l2.c
index f86bbbf..cf8d210 100644
--- a/libgfortran/generated/all_l2.c
+++ b/libgfortran/generated/all_l2.c
@@ -98,7 +98,8 @@ all_l2 (gfc_array_l2 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/all_l4.c b/libgfortran/generated/all_l4.c
index 5ab1d9e..f9fb444 100644
--- a/libgfortran/generated/all_l4.c
+++ b/libgfortran/generated/all_l4.c
@@ -98,7 +98,8 @@ all_l4 (gfc_array_l4 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/all_l8.c b/libgfortran/generated/all_l8.c
index 30f7344..c0715b3 100644
--- a/libgfortran/generated/all_l8.c
+++ b/libgfortran/generated/all_l8.c
@@ -98,7 +98,8 @@ all_l8 (gfc_array_l8 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/any_l1.c b/libgfortran/generated/any_l1.c
index 14270d8..5e1d536 100644
--- a/libgfortran/generated/any_l1.c
+++ b/libgfortran/generated/any_l1.c
@@ -98,7 +98,8 @@ any_l1 (gfc_array_l1 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/any_l16.c b/libgfortran/generated/any_l16.c
index 982ddac..8b2ad52 100644
--- a/libgfortran/generated/any_l16.c
+++ b/libgfortran/generated/any_l16.c
@@ -98,7 +98,8 @@ any_l16 (gfc_array_l16 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/any_l2.c b/libgfortran/generated/any_l2.c
index efbbf92..e87d2c6 100644
--- a/libgfortran/generated/any_l2.c
+++ b/libgfortran/generated/any_l2.c
@@ -98,7 +98,8 @@ any_l2 (gfc_array_l2 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/any_l4.c b/libgfortran/generated/any_l4.c
index 97c464b..42bc465 100644
--- a/libgfortran/generated/any_l4.c
+++ b/libgfortran/generated/any_l4.c
@@ -98,7 +98,8 @@ any_l4 (gfc_array_l4 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/any_l8.c b/libgfortran/generated/any_l8.c
index 2b33f45..bf45e3b 100644
--- a/libgfortran/generated/any_l8.c
+++ b/libgfortran/generated/any_l8.c
@@ -98,7 +98,8 @@ any_l8 (gfc_array_l8 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/count_16_l.c b/libgfortran/generated/count_16_l.c
index 76ff04a..3c7e8e5b 100644
--- a/libgfortran/generated/count_16_l.c
+++ b/libgfortran/generated/count_16_l.c
@@ -98,7 +98,8 @@ count_16_l (gfc_array_i16 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/count_1_l.c b/libgfortran/generated/count_1_l.c
index 845b2af..bbe504b 100644
--- a/libgfortran/generated/count_1_l.c
+++ b/libgfortran/generated/count_1_l.c
@@ -98,7 +98,8 @@ count_1_l (gfc_array_i1 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/count_2_l.c b/libgfortran/generated/count_2_l.c
index 079861c..86a6231 100644
--- a/libgfortran/generated/count_2_l.c
+++ b/libgfortran/generated/count_2_l.c
@@ -98,7 +98,8 @@ count_2_l (gfc_array_i2 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/count_4_l.c b/libgfortran/generated/count_4_l.c
index 810128e..db92b85 100644
--- a/libgfortran/generated/count_4_l.c
+++ b/libgfortran/generated/count_4_l.c
@@ -98,7 +98,8 @@ count_4_l (gfc_array_i4 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/count_8_l.c b/libgfortran/generated/count_8_l.c
index 082dca1..fdae364 100644
--- a/libgfortran/generated/count_8_l.c
+++ b/libgfortran/generated/count_8_l.c
@@ -98,7 +98,8 @@ count_8_l (gfc_array_i8 * const restrict retarray,
         }
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iall_i1.c b/libgfortran/generated/iall_i1.c
index 825a530..c74014b 100644
--- a/libgfortran/generated/iall_i1.c
+++ b/libgfortran/generated/iall_i1.c
@@ -95,7 +95,8 @@ iall_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miall_i1 (gfc_array_i1 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siall_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iall_i16.c b/libgfortran/generated/iall_i16.c
index da55132..0dd324d 100644
--- a/libgfortran/generated/iall_i16.c
+++ b/libgfortran/generated/iall_i16.c
@@ -95,7 +95,8 @@ iall_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miall_i16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siall_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iall_i2.c b/libgfortran/generated/iall_i2.c
index 94a2a5f..a045b91 100644
--- a/libgfortran/generated/iall_i2.c
+++ b/libgfortran/generated/iall_i2.c
@@ -95,7 +95,8 @@ iall_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miall_i2 (gfc_array_i2 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siall_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iall_i4.c b/libgfortran/generated/iall_i4.c
index 952ae04..8baa666 100644
--- a/libgfortran/generated/iall_i4.c
+++ b/libgfortran/generated/iall_i4.c
@@ -95,7 +95,8 @@ iall_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miall_i4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siall_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iall_i8.c b/libgfortran/generated/iall_i8.c
index 0103631..128ffeb 100644
--- a/libgfortran/generated/iall_i8.c
+++ b/libgfortran/generated/iall_i8.c
@@ -95,7 +95,8 @@ iall_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miall_i8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siall_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iany_i1.c b/libgfortran/generated/iany_i1.c
index dfe7958..04e9ab6 100644
--- a/libgfortran/generated/iany_i1.c
+++ b/libgfortran/generated/iany_i1.c
@@ -95,7 +95,8 @@ iany_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miany_i1 (gfc_array_i1 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siany_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iany_i16.c b/libgfortran/generated/iany_i16.c
index f5a444b..509425d 100644
--- a/libgfortran/generated/iany_i16.c
+++ b/libgfortran/generated/iany_i16.c
@@ -95,7 +95,8 @@ iany_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miany_i16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siany_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iany_i2.c b/libgfortran/generated/iany_i2.c
index 0266bc5..c1cf647 100644
--- a/libgfortran/generated/iany_i2.c
+++ b/libgfortran/generated/iany_i2.c
@@ -95,7 +95,8 @@ iany_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miany_i2 (gfc_array_i2 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siany_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iany_i4.c b/libgfortran/generated/iany_i4.c
index 28a7bca..567216d 100644
--- a/libgfortran/generated/iany_i4.c
+++ b/libgfortran/generated/iany_i4.c
@@ -95,7 +95,8 @@ iany_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miany_i4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siany_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iany_i8.c b/libgfortran/generated/iany_i8.c
index dd7ec22..cc51b39 100644
--- a/libgfortran/generated/iany_i8.c
+++ b/libgfortran/generated/iany_i8.c
@@ -95,7 +95,8 @@ iany_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miany_i8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siany_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iparity_i1.c b/libgfortran/generated/iparity_i1.c
index 892cd8d..ed3415f 100644
--- a/libgfortran/generated/iparity_i1.c
+++ b/libgfortran/generated/iparity_i1.c
@@ -95,7 +95,8 @@ iparity_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miparity_i1 (gfc_array_i1 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siparity_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iparity_i16.c b/libgfortran/generated/iparity_i16.c
index 38282a8..54e417b 100644
--- a/libgfortran/generated/iparity_i16.c
+++ b/libgfortran/generated/iparity_i16.c
@@ -95,7 +95,8 @@ iparity_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miparity_i16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siparity_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iparity_i2.c b/libgfortran/generated/iparity_i2.c
index 70fee4f..1cee54d 100644
--- a/libgfortran/generated/iparity_i2.c
+++ b/libgfortran/generated/iparity_i2.c
@@ -95,7 +95,8 @@ iparity_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miparity_i2 (gfc_array_i2 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siparity_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iparity_i4.c b/libgfortran/generated/iparity_i4.c
index aeb31cc..30a07cb 100644
--- a/libgfortran/generated/iparity_i4.c
+++ b/libgfortran/generated/iparity_i4.c
@@ -95,7 +95,8 @@ iparity_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miparity_i4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siparity_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/iparity_i8.c b/libgfortran/generated/iparity_i8.c
index d0dcc17..3831184 100644
--- a/libgfortran/generated/iparity_i8.c
+++ b/libgfortran/generated/iparity_i8.c
@@ -95,7 +95,8 @@ iparity_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ miparity_i8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ siparity_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc0_16_i1.c b/libgfortran/generated/maxloc0_16_i1.c
index 79dd2d9..2b46daa 100644
--- a/libgfortran/generated/maxloc0_16_i1.c
+++ b/libgfortran/generated/maxloc0_16_i1.c
@@ -56,7 +56,8 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_16_i16.c b/libgfortran/generated/maxloc0_16_i16.c
index dcdc5d9..0c49ed9 100644
--- a/libgfortran/generated/maxloc0_16_i16.c
+++ b/libgfortran/generated/maxloc0_16_i16.c
@@ -56,7 +56,8 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_16_i2.c b/libgfortran/generated/maxloc0_16_i2.c
index 602085f..e32b24e 100644
--- a/libgfortran/generated/maxloc0_16_i2.c
+++ b/libgfortran/generated/maxloc0_16_i2.c
@@ -56,7 +56,8 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_16_i4.c b/libgfortran/generated/maxloc0_16_i4.c
index ccb7628..d1e9b24 100644
--- a/libgfortran/generated/maxloc0_16_i4.c
+++ b/libgfortran/generated/maxloc0_16_i4.c
@@ -56,7 +56,8 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_16_i8.c b/libgfortran/generated/maxloc0_16_i8.c
index b5d47b7..ea4aa10 100644
--- a/libgfortran/generated/maxloc0_16_i8.c
+++ b/libgfortran/generated/maxloc0_16_i8.c
@@ -56,7 +56,8 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_16_r10.c b/libgfortran/generated/maxloc0_16_r10.c
index 6e6c0ea..cc5e1cc 100644
--- a/libgfortran/generated/maxloc0_16_r10.c
+++ b/libgfortran/generated/maxloc0_16_r10.c
@@ -56,7 +56,8 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_16_r16.c b/libgfortran/generated/maxloc0_16_r16.c
index 2551e5c..a6b2dc7 100644
--- a/libgfortran/generated/maxloc0_16_r16.c
+++ b/libgfortran/generated/maxloc0_16_r16.c
@@ -56,7 +56,8 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_16_r4.c b/libgfortran/generated/maxloc0_16_r4.c
index a69e763..667e401 100644
--- a/libgfortran/generated/maxloc0_16_r4.c
+++ b/libgfortran/generated/maxloc0_16_r4.c
@@ -56,7 +56,8 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_16_r8.c b/libgfortran/generated/maxloc0_16_r8.c
index 0bfa768..3738672 100644
--- a/libgfortran/generated/maxloc0_16_r8.c
+++ b/libgfortran/generated/maxloc0_16_r8.c
@@ -56,7 +56,8 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_4_i1.c b/libgfortran/generated/maxloc0_4_i1.c
index 90fbef0..a178d1c 100644
--- a/libgfortran/generated/maxloc0_4_i1.c
+++ b/libgfortran/generated/maxloc0_4_i1.c
@@ -56,7 +56,8 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_4_i16.c b/libgfortran/generated/maxloc0_4_i16.c
index c6872c2..469d47d 100644
--- a/libgfortran/generated/maxloc0_4_i16.c
+++ b/libgfortran/generated/maxloc0_4_i16.c
@@ -56,7 +56,8 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_4_i2.c b/libgfortran/generated/maxloc0_4_i2.c
index a547f83..8232a92 100644
--- a/libgfortran/generated/maxloc0_4_i2.c
+++ b/libgfortran/generated/maxloc0_4_i2.c
@@ -56,7 +56,8 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_4_i4.c b/libgfortran/generated/maxloc0_4_i4.c
index 48c59d0..aa0d75f 100644
--- a/libgfortran/generated/maxloc0_4_i4.c
+++ b/libgfortran/generated/maxloc0_4_i4.c
@@ -56,7 +56,8 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_4_i8.c b/libgfortran/generated/maxloc0_4_i8.c
index b03bcd8..99720c37 100644
--- a/libgfortran/generated/maxloc0_4_i8.c
+++ b/libgfortran/generated/maxloc0_4_i8.c
@@ -56,7 +56,8 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_4_r10.c b/libgfortran/generated/maxloc0_4_r10.c
index ffd79e9..2d5c196 100644
--- a/libgfortran/generated/maxloc0_4_r10.c
+++ b/libgfortran/generated/maxloc0_4_r10.c
@@ -56,7 +56,8 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_4_r16.c b/libgfortran/generated/maxloc0_4_r16.c
index 621f25f..c0261e5 100644
--- a/libgfortran/generated/maxloc0_4_r16.c
+++ b/libgfortran/generated/maxloc0_4_r16.c
@@ -56,7 +56,8 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_4_r4.c b/libgfortran/generated/maxloc0_4_r4.c
index 616684f..304b84a 100644
--- a/libgfortran/generated/maxloc0_4_r4.c
+++ b/libgfortran/generated/maxloc0_4_r4.c
@@ -56,7 +56,8 @@ maxloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_4_r8.c b/libgfortran/generated/maxloc0_4_r8.c
index 8a4f94a..08857fd 100644
--- a/libgfortran/generated/maxloc0_4_r8.c
+++ b/libgfortran/generated/maxloc0_4_r8.c
@@ -56,7 +56,8 @@ maxloc0_4_r8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_4_r8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_4_r8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_8_i1.c b/libgfortran/generated/maxloc0_8_i1.c
index f17de20..fd14354 100644
--- a/libgfortran/generated/maxloc0_8_i1.c
+++ b/libgfortran/generated/maxloc0_8_i1.c
@@ -56,7 +56,8 @@ maxloc0_8_i1 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_8_i1 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_8_i1 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_8_i16.c b/libgfortran/generated/maxloc0_8_i16.c
index 38ca6fa..6be3644 100644
--- a/libgfortran/generated/maxloc0_8_i16.c
+++ b/libgfortran/generated/maxloc0_8_i16.c
@@ -56,7 +56,8 @@ maxloc0_8_i16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_8_i16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_8_i16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_8_i2.c b/libgfortran/generated/maxloc0_8_i2.c
index 3a2100e..edd3e81 100644
--- a/libgfortran/generated/maxloc0_8_i2.c
+++ b/libgfortran/generated/maxloc0_8_i2.c
@@ -56,7 +56,8 @@ maxloc0_8_i2 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_8_i2 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_8_i2 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_8_i4.c b/libgfortran/generated/maxloc0_8_i4.c
index 956bcb8..03202b1 100644
--- a/libgfortran/generated/maxloc0_8_i4.c
+++ b/libgfortran/generated/maxloc0_8_i4.c
@@ -56,7 +56,8 @@ maxloc0_8_i4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_8_i4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_8_i4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_8_i8.c b/libgfortran/generated/maxloc0_8_i8.c
index 47b32c3..6f74a38 100644
--- a/libgfortran/generated/maxloc0_8_i8.c
+++ b/libgfortran/generated/maxloc0_8_i8.c
@@ -56,7 +56,8 @@ maxloc0_8_i8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_8_i8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_8_i8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_8_r10.c b/libgfortran/generated/maxloc0_8_r10.c
index 54f743a..734e4c5 100644
--- a/libgfortran/generated/maxloc0_8_r10.c
+++ b/libgfortran/generated/maxloc0_8_r10.c
@@ -56,7 +56,8 @@ maxloc0_8_r10 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_8_r10 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_8_r10 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_8_r16.c b/libgfortran/generated/maxloc0_8_r16.c
index 9873896..8b6914f 100644
--- a/libgfortran/generated/maxloc0_8_r16.c
+++ b/libgfortran/generated/maxloc0_8_r16.c
@@ -56,7 +56,8 @@ maxloc0_8_r16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_8_r16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_8_r16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_8_r4.c b/libgfortran/generated/maxloc0_8_r4.c
index cee1821..aa589ce 100644
--- a/libgfortran/generated/maxloc0_8_r4.c
+++ b/libgfortran/generated/maxloc0_8_r4.c
@@ -56,7 +56,8 @@ maxloc0_8_r4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_8_r4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_8_r4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/maxloc0_8_r8.c b/libgfortran/generated/maxloc0_8_r8.c
index 8dd1fe1..0295340 100644
--- a/libgfortran/generated/maxloc0_8_r8.c
+++ b/libgfortran/generated/maxloc0_8_r8.c
@@ -56,7 +56,8 @@ maxloc0_8_r8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mmaxloc0_8_r8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ smaxloc0_8_r8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/maxloc1_16_i1.c b/libgfortran/generated/maxloc1_16_i1.c
index d0ec632..c090cb2 100644
--- a/libgfortran/generated/maxloc1_16_i1.c
+++ b/libgfortran/generated/maxloc1_16_i1.c
@@ -96,7 +96,8 @@ maxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_16_i16.c b/libgfortran/generated/maxloc1_16_i16.c
index a46ebc1..e9bfb10 100644
--- a/libgfortran/generated/maxloc1_16_i16.c
+++ b/libgfortran/generated/maxloc1_16_i16.c
@@ -96,7 +96,8 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_16_i2.c b/libgfortran/generated/maxloc1_16_i2.c
index 3350427..419eef6 100644
--- a/libgfortran/generated/maxloc1_16_i2.c
+++ b/libgfortran/generated/maxloc1_16_i2.c
@@ -96,7 +96,8 @@ maxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_16_i4.c b/libgfortran/generated/maxloc1_16_i4.c
index 1fcfc18..672b5cd 100644
--- a/libgfortran/generated/maxloc1_16_i4.c
+++ b/libgfortran/generated/maxloc1_16_i4.c
@@ -96,7 +96,8 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_16_i8.c b/libgfortran/generated/maxloc1_16_i8.c
index 64e2473..ff460d4 100644
--- a/libgfortran/generated/maxloc1_16_i8.c
+++ b/libgfortran/generated/maxloc1_16_i8.c
@@ -96,7 +96,8 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_16_r10.c b/libgfortran/generated/maxloc1_16_r10.c
index 0dd06c2..72f01c6 100644
--- a/libgfortran/generated/maxloc1_16_r10.c
+++ b/libgfortran/generated/maxloc1_16_r10.c
@@ -96,7 +96,8 @@ maxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_16_r16.c b/libgfortran/generated/maxloc1_16_r16.c
index 88118a8..b4e6737 100644
--- a/libgfortran/generated/maxloc1_16_r16.c
+++ b/libgfortran/generated/maxloc1_16_r16.c
@@ -96,7 +96,8 @@ maxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_16_r4.c b/libgfortran/generated/maxloc1_16_r4.c
index fbc32d9..51dfcee 100644
--- a/libgfortran/generated/maxloc1_16_r4.c
+++ b/libgfortran/generated/maxloc1_16_r4.c
@@ -96,7 +96,8 @@ maxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_16_r8.c b/libgfortran/generated/maxloc1_16_r8.c
index 54e1ad2..4f50977 100644
--- a/libgfortran/generated/maxloc1_16_r8.c
+++ b/libgfortran/generated/maxloc1_16_r8.c
@@ -96,7 +96,8 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_4_i1.c b/libgfortran/generated/maxloc1_4_i1.c
index 7530756..a918a75 100644
--- a/libgfortran/generated/maxloc1_4_i1.c
+++ b/libgfortran/generated/maxloc1_4_i1.c
@@ -96,7 +96,8 @@ maxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_4_i16.c b/libgfortran/generated/maxloc1_4_i16.c
index 631d380..117b445 100644
--- a/libgfortran/generated/maxloc1_4_i16.c
+++ b/libgfortran/generated/maxloc1_4_i16.c
@@ -96,7 +96,8 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_4_i2.c b/libgfortran/generated/maxloc1_4_i2.c
index 6f81c40..b9dd2b0 100644
--- a/libgfortran/generated/maxloc1_4_i2.c
+++ b/libgfortran/generated/maxloc1_4_i2.c
@@ -96,7 +96,8 @@ maxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_4_i4.c b/libgfortran/generated/maxloc1_4_i4.c
index 811f2fa..08d0d87 100644
--- a/libgfortran/generated/maxloc1_4_i4.c
+++ b/libgfortran/generated/maxloc1_4_i4.c
@@ -96,7 +96,8 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c
index 31c369a..3b01df3 100644
--- a/libgfortran/generated/maxloc1_4_i8.c
+++ b/libgfortran/generated/maxloc1_4_i8.c
@@ -96,7 +96,8 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_4_r10.c b/libgfortran/generated/maxloc1_4_r10.c
index 36327c5..6e846af 100644
--- a/libgfortran/generated/maxloc1_4_r10.c
+++ b/libgfortran/generated/maxloc1_4_r10.c
@@ -96,7 +96,8 @@ maxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_4_r16.c b/libgfortran/generated/maxloc1_4_r16.c
index d352bc4..fef9282 100644
--- a/libgfortran/generated/maxloc1_4_r16.c
+++ b/libgfortran/generated/maxloc1_4_r16.c
@@ -96,7 +96,8 @@ maxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_4_r4.c b/libgfortran/generated/maxloc1_4_r4.c
index 9e839d5..6b86863 100644
--- a/libgfortran/generated/maxloc1_4_r4.c
+++ b/libgfortran/generated/maxloc1_4_r4.c
@@ -96,7 +96,8 @@ maxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_4_r8.c b/libgfortran/generated/maxloc1_4_r8.c
index ababad5..4b48f9c 100644
--- a/libgfortran/generated/maxloc1_4_r8.c
+++ b/libgfortran/generated/maxloc1_4_r8.c
@@ -96,7 +96,8 @@ maxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_8_i1.c b/libgfortran/generated/maxloc1_8_i1.c
index a2075ca..4efeb32 100644
--- a/libgfortran/generated/maxloc1_8_i1.c
+++ b/libgfortran/generated/maxloc1_8_i1.c
@@ -96,7 +96,8 @@ maxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_8_i16.c b/libgfortran/generated/maxloc1_8_i16.c
index 13002ac..f9b8194 100644
--- a/libgfortran/generated/maxloc1_8_i16.c
+++ b/libgfortran/generated/maxloc1_8_i16.c
@@ -96,7 +96,8 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_8_i2.c b/libgfortran/generated/maxloc1_8_i2.c
index 8cfdde7..c4848d2 100644
--- a/libgfortran/generated/maxloc1_8_i2.c
+++ b/libgfortran/generated/maxloc1_8_i2.c
@@ -96,7 +96,8 @@ maxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_8_i4.c b/libgfortran/generated/maxloc1_8_i4.c
index 2f7c5eb..ccdf946 100644
--- a/libgfortran/generated/maxloc1_8_i4.c
+++ b/libgfortran/generated/maxloc1_8_i4.c
@@ -96,7 +96,8 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c
index 6678f0b..ffe1cca 100644
--- a/libgfortran/generated/maxloc1_8_i8.c
+++ b/libgfortran/generated/maxloc1_8_i8.c
@@ -96,7 +96,8 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_8_r10.c b/libgfortran/generated/maxloc1_8_r10.c
index 029ba35..46d81b4 100644
--- a/libgfortran/generated/maxloc1_8_r10.c
+++ b/libgfortran/generated/maxloc1_8_r10.c
@@ -96,7 +96,8 @@ maxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_8_r16.c b/libgfortran/generated/maxloc1_8_r16.c
index 56c79f0..9ab65ee 100644
--- a/libgfortran/generated/maxloc1_8_r16.c
+++ b/libgfortran/generated/maxloc1_8_r16.c
@@ -96,7 +96,8 @@ maxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_8_r4.c b/libgfortran/generated/maxloc1_8_r4.c
index 94d085d..7877d26 100644
--- a/libgfortran/generated/maxloc1_8_r4.c
+++ b/libgfortran/generated/maxloc1_8_r4.c
@@ -96,7 +96,8 @@ maxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxloc1_8_r8.c b/libgfortran/generated/maxloc1_8_r8.c
index fc330fd..bfdc027 100644
--- a/libgfortran/generated/maxloc1_8_r8.c
+++ b/libgfortran/generated/maxloc1_8_r8.c
@@ -96,7 +96,8 @@ maxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ smaxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxval_i1.c b/libgfortran/generated/maxval_i1.c
index ac39cfa..4b580e3 100644
--- a/libgfortran/generated/maxval_i1.c
+++ b/libgfortran/generated/maxval_i1.c
@@ -95,7 +95,8 @@ maxval_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ smaxval_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxval_i16.c b/libgfortran/generated/maxval_i16.c
index b5e463b..bdb665d 100644
--- a/libgfortran/generated/maxval_i16.c
+++ b/libgfortran/generated/maxval_i16.c
@@ -95,7 +95,8 @@ maxval_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ smaxval_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxval_i2.c b/libgfortran/generated/maxval_i2.c
index a3fa7ba..54b2f29 100644
--- a/libgfortran/generated/maxval_i2.c
+++ b/libgfortran/generated/maxval_i2.c
@@ -95,7 +95,8 @@ maxval_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ smaxval_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c
index 50275e6..3cc3289 100644
--- a/libgfortran/generated/maxval_i4.c
+++ b/libgfortran/generated/maxval_i4.c
@@ -95,7 +95,8 @@ maxval_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ smaxval_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxval_i8.c b/libgfortran/generated/maxval_i8.c
index 7a033b4..70cf12d 100644
--- a/libgfortran/generated/maxval_i8.c
+++ b/libgfortran/generated/maxval_i8.c
@@ -95,7 +95,8 @@ maxval_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ smaxval_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxval_r10.c b/libgfortran/generated/maxval_r10.c
index 70971ed..8ab4518 100644
--- a/libgfortran/generated/maxval_r10.c
+++ b/libgfortran/generated/maxval_r10.c
@@ -95,7 +95,8 @@ maxval_r10 (gfc_array_r10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ smaxval_r10 (gfc_array_r10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxval_r16.c b/libgfortran/generated/maxval_r16.c
index bb339e4..6458394 100644
--- a/libgfortran/generated/maxval_r16.c
+++ b/libgfortran/generated/maxval_r16.c
@@ -95,7 +95,8 @@ maxval_r16 (gfc_array_r16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ smaxval_r16 (gfc_array_r16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxval_r4.c b/libgfortran/generated/maxval_r4.c
index 160aff6..908df9e 100644
--- a/libgfortran/generated/maxval_r4.c
+++ b/libgfortran/generated/maxval_r4.c
@@ -95,7 +95,8 @@ maxval_r4 (gfc_array_r4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ smaxval_r4 (gfc_array_r4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/maxval_r8.c b/libgfortran/generated/maxval_r8.c
index 0334461..18a3fd9 100644
--- a/libgfortran/generated/maxval_r8.c
+++ b/libgfortran/generated/maxval_r8.c
@@ -95,7 +95,8 @@ maxval_r8 (gfc_array_r8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ smaxval_r8 (gfc_array_r8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc0_16_i1.c b/libgfortran/generated/minloc0_16_i1.c
index a21e84f..d5cf3dd 100644
--- a/libgfortran/generated/minloc0_16_i1.c
+++ b/libgfortran/generated/minloc0_16_i1.c
@@ -56,7 +56,8 @@ minloc0_16_i1 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_16_i1 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_16_i1 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/minloc0_16_i16.c b/libgfortran/generated/minloc0_16_i16.c
index e5d3a14..f9f67f4 100644
--- a/libgfortran/generated/minloc0_16_i16.c
+++ b/libgfortran/generated/minloc0_16_i16.c
@@ -56,7 +56,8 @@ minloc0_16_i16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_16_i16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_16_i16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/minloc0_16_i2.c b/libgfortran/generated/minloc0_16_i2.c
index 63444b9..508f00f 100644
--- a/libgfortran/generated/minloc0_16_i2.c
+++ b/libgfortran/generated/minloc0_16_i2.c
@@ -56,7 +56,8 @@ minloc0_16_i2 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_16_i2 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_16_i2 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/minloc0_16_i4.c b/libgfortran/generated/minloc0_16_i4.c
index 870b548..ad3ce6e 100644
--- a/libgfortran/generated/minloc0_16_i4.c
+++ b/libgfortran/generated/minloc0_16_i4.c
@@ -56,7 +56,8 @@ minloc0_16_i4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_16_i4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_16_i4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/minloc0_16_i8.c b/libgfortran/generated/minloc0_16_i8.c
index d06f4e0..d2d8094 100644
--- a/libgfortran/generated/minloc0_16_i8.c
+++ b/libgfortran/generated/minloc0_16_i8.c
@@ -56,7 +56,8 @@ minloc0_16_i8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_16_i8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_16_i8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/minloc0_16_r10.c b/libgfortran/generated/minloc0_16_r10.c
index 30301a9..be8bb67 100644
--- a/libgfortran/generated/minloc0_16_r10.c
+++ b/libgfortran/generated/minloc0_16_r10.c
@@ -56,7 +56,8 @@ minloc0_16_r10 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_16_r10 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_16_r10 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/minloc0_16_r16.c b/libgfortran/generated/minloc0_16_r16.c
index d5ef2ae..480c1ef 100644
--- a/libgfortran/generated/minloc0_16_r16.c
+++ b/libgfortran/generated/minloc0_16_r16.c
@@ -56,7 +56,8 @@ minloc0_16_r16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_16_r16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_16_r16 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/minloc0_16_r4.c b/libgfortran/generated/minloc0_16_r4.c
index ca33889..65a5caa 100644
--- a/libgfortran/generated/minloc0_16_r4.c
+++ b/libgfortran/generated/minloc0_16_r4.c
@@ -56,7 +56,8 @@ minloc0_16_r4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_16_r4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_16_r4 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/minloc0_16_r8.c b/libgfortran/generated/minloc0_16_r8.c
index 922aa16..a40fda8 100644
--- a/libgfortran/generated/minloc0_16_r8.c
+++ b/libgfortran/generated/minloc0_16_r8.c
@@ -56,7 +56,8 @@ minloc0_16_r8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_16_r8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_16_r8 (gfc_array_i16 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_16));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_16) * rank);
     }
diff --git a/libgfortran/generated/minloc0_4_i1.c b/libgfortran/generated/minloc0_4_i1.c
index 6f9ae5c..2297aa0 100644
--- a/libgfortran/generated/minloc0_4_i1.c
+++ b/libgfortran/generated/minloc0_4_i1.c
@@ -56,7 +56,8 @@ minloc0_4_i1 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_4_i1 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_4_i1 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/minloc0_4_i16.c b/libgfortran/generated/minloc0_4_i16.c
index b422166..5649a51 100644
--- a/libgfortran/generated/minloc0_4_i16.c
+++ b/libgfortran/generated/minloc0_4_i16.c
@@ -56,7 +56,8 @@ minloc0_4_i16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_4_i16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_4_i16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/minloc0_4_i2.c b/libgfortran/generated/minloc0_4_i2.c
index 8a9613c..0f23328 100644
--- a/libgfortran/generated/minloc0_4_i2.c
+++ b/libgfortran/generated/minloc0_4_i2.c
@@ -56,7 +56,8 @@ minloc0_4_i2 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_4_i2 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_4_i2 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/minloc0_4_i4.c b/libgfortran/generated/minloc0_4_i4.c
index 5991e4e..db77b65 100644
--- a/libgfortran/generated/minloc0_4_i4.c
+++ b/libgfortran/generated/minloc0_4_i4.c
@@ -56,7 +56,8 @@ minloc0_4_i4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_4_i4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_4_i4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/minloc0_4_i8.c b/libgfortran/generated/minloc0_4_i8.c
index a6bb414..9d888cf 100644
--- a/libgfortran/generated/minloc0_4_i8.c
+++ b/libgfortran/generated/minloc0_4_i8.c
@@ -56,7 +56,8 @@ minloc0_4_i8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_4_i8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_4_i8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/minloc0_4_r10.c b/libgfortran/generated/minloc0_4_r10.c
index 9f8458d..c49fa2f 100644
--- a/libgfortran/generated/minloc0_4_r10.c
+++ b/libgfortran/generated/minloc0_4_r10.c
@@ -56,7 +56,8 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/minloc0_4_r16.c b/libgfortran/generated/minloc0_4_r16.c
index 16c62a2..90d2c2d 100644
--- a/libgfortran/generated/minloc0_4_r16.c
+++ b/libgfortran/generated/minloc0_4_r16.c
@@ -56,7 +56,8 @@ minloc0_4_r16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_4_r16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_4_r16 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/minloc0_4_r4.c b/libgfortran/generated/minloc0_4_r4.c
index 1d04031..6a1e49b 100644
--- a/libgfortran/generated/minloc0_4_r4.c
+++ b/libgfortran/generated/minloc0_4_r4.c
@@ -56,7 +56,8 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/minloc0_4_r8.c b/libgfortran/generated/minloc0_4_r8.c
index 4facd9e..083b6f1 100644
--- a/libgfortran/generated/minloc0_4_r8.c
+++ b/libgfortran/generated/minloc0_4_r8.c
@@ -56,7 +56,8 @@ minloc0_4_r8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_4_r8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_4_r8 (gfc_array_i4 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_4));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_4) * rank);
     }
diff --git a/libgfortran/generated/minloc0_8_i1.c b/libgfortran/generated/minloc0_8_i1.c
index 8a88333..3dd954f 100644
--- a/libgfortran/generated/minloc0_8_i1.c
+++ b/libgfortran/generated/minloc0_8_i1.c
@@ -56,7 +56,8 @@ minloc0_8_i1 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_8_i1 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_8_i1 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/minloc0_8_i16.c b/libgfortran/generated/minloc0_8_i16.c
index 09159d3..5ab083e 100644
--- a/libgfortran/generated/minloc0_8_i16.c
+++ b/libgfortran/generated/minloc0_8_i16.c
@@ -56,7 +56,8 @@ minloc0_8_i16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_8_i16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_8_i16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/minloc0_8_i2.c b/libgfortran/generated/minloc0_8_i2.c
index 8a62e1b..c213360 100644
--- a/libgfortran/generated/minloc0_8_i2.c
+++ b/libgfortran/generated/minloc0_8_i2.c
@@ -56,7 +56,8 @@ minloc0_8_i2 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_8_i2 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_8_i2 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/minloc0_8_i4.c b/libgfortran/generated/minloc0_8_i4.c
index 5691f7e..45ecd24 100644
--- a/libgfortran/generated/minloc0_8_i4.c
+++ b/libgfortran/generated/minloc0_8_i4.c
@@ -56,7 +56,8 @@ minloc0_8_i4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_8_i4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_8_i4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/minloc0_8_i8.c b/libgfortran/generated/minloc0_8_i8.c
index 7ccc429..c10c6f5 100644
--- a/libgfortran/generated/minloc0_8_i8.c
+++ b/libgfortran/generated/minloc0_8_i8.c
@@ -56,7 +56,8 @@ minloc0_8_i8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_8_i8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_8_i8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/minloc0_8_r10.c b/libgfortran/generated/minloc0_8_r10.c
index a8198cb..695aa83 100644
--- a/libgfortran/generated/minloc0_8_r10.c
+++ b/libgfortran/generated/minloc0_8_r10.c
@@ -56,7 +56,8 @@ minloc0_8_r10 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_8_r10 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_8_r10 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/minloc0_8_r16.c b/libgfortran/generated/minloc0_8_r16.c
index e417475..ceb9f2a 100644
--- a/libgfortran/generated/minloc0_8_r16.c
+++ b/libgfortran/generated/minloc0_8_r16.c
@@ -56,7 +56,8 @@ minloc0_8_r16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_8_r16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_8_r16 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/minloc0_8_r4.c b/libgfortran/generated/minloc0_8_r4.c
index 657baac..d57da66 100644
--- a/libgfortran/generated/minloc0_8_r4.c
+++ b/libgfortran/generated/minloc0_8_r4.c
@@ -56,7 +56,8 @@ minloc0_8_r4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_8_r4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_8_r4 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/minloc0_8_r8.c b/libgfortran/generated/minloc0_8_r8.c
index 864e61f..21a1da3 100644
--- a/libgfortran/generated/minloc0_8_r8.c
+++ b/libgfortran/generated/minloc0_8_r8.c
@@ -56,7 +56,8 @@ minloc0_8_r8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -197,7 +198,8 @@ mminloc0_8_r8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
@@ -365,7 +367,8 @@ sminloc0_8_r8 (gfc_array_i8 * const restrict retarray,
   if (retarray->base_addr == NULL)
     {
       GFC_DIMENSION_SET (retarray->dim[0], 0, rank, sizeof (GFC_INTEGER_8));
-      retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
+      retarray->rank = 1;
+      retarray->dtype = retarray->dtype;
       retarray->offset = 0;
       retarray->base_addr = xmalloc (sizeof (GFC_INTEGER_8) * rank);
     }
diff --git a/libgfortran/generated/minloc1_16_i1.c b/libgfortran/generated/minloc1_16_i1.c
index 0380b2b..e2a52bc 100644
--- a/libgfortran/generated/minloc1_16_i1.c
+++ b/libgfortran/generated/minloc1_16_i1.c
@@ -96,7 +96,8 @@ minloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_16_i16.c b/libgfortran/generated/minloc1_16_i16.c
index 63e891a..353bf74 100644
--- a/libgfortran/generated/minloc1_16_i16.c
+++ b/libgfortran/generated/minloc1_16_i16.c
@@ -96,7 +96,8 @@ minloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_16_i2.c b/libgfortran/generated/minloc1_16_i2.c
index 8c3248d..e63f0a3 100644
--- a/libgfortran/generated/minloc1_16_i2.c
+++ b/libgfortran/generated/minloc1_16_i2.c
@@ -96,7 +96,8 @@ minloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_16_i4.c b/libgfortran/generated/minloc1_16_i4.c
index 02aa51b..4d3e339 100644
--- a/libgfortran/generated/minloc1_16_i4.c
+++ b/libgfortran/generated/minloc1_16_i4.c
@@ -96,7 +96,8 @@ minloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_16_i8.c b/libgfortran/generated/minloc1_16_i8.c
index cabf133..958257b 100644
--- a/libgfortran/generated/minloc1_16_i8.c
+++ b/libgfortran/generated/minloc1_16_i8.c
@@ -96,7 +96,8 @@ minloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_16_r10.c b/libgfortran/generated/minloc1_16_r10.c
index 8129598..0c3948a 100644
--- a/libgfortran/generated/minloc1_16_r10.c
+++ b/libgfortran/generated/minloc1_16_r10.c
@@ -96,7 +96,8 @@ minloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_16_r16.c b/libgfortran/generated/minloc1_16_r16.c
index 9f66d48..47efc9b 100644
--- a/libgfortran/generated/minloc1_16_r16.c
+++ b/libgfortran/generated/minloc1_16_r16.c
@@ -96,7 +96,8 @@ minloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_16_r4.c b/libgfortran/generated/minloc1_16_r4.c
index 7b6b2b0..f552249 100644
--- a/libgfortran/generated/minloc1_16_r4.c
+++ b/libgfortran/generated/minloc1_16_r4.c
@@ -96,7 +96,8 @@ minloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_16_r8.c b/libgfortran/generated/minloc1_16_r8.c
index 9d7d70f..285b027 100644
--- a/libgfortran/generated/minloc1_16_r8.c
+++ b/libgfortran/generated/minloc1_16_r8.c
@@ -96,7 +96,8 @@ minloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_4_i1.c b/libgfortran/generated/minloc1_4_i1.c
index 2ada8b3..9b8bc65 100644
--- a/libgfortran/generated/minloc1_4_i1.c
+++ b/libgfortran/generated/minloc1_4_i1.c
@@ -96,7 +96,8 @@ minloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_4_i16.c b/libgfortran/generated/minloc1_4_i16.c
index 9728d75..e3323cc 100644
--- a/libgfortran/generated/minloc1_4_i16.c
+++ b/libgfortran/generated/minloc1_4_i16.c
@@ -96,7 +96,8 @@ minloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_4_i2.c b/libgfortran/generated/minloc1_4_i2.c
index 7ae3110..5b0457e 100644
--- a/libgfortran/generated/minloc1_4_i2.c
+++ b/libgfortran/generated/minloc1_4_i2.c
@@ -96,7 +96,8 @@ minloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_4_i4.c b/libgfortran/generated/minloc1_4_i4.c
index 3b06b6b..8b8692e 100644
--- a/libgfortran/generated/minloc1_4_i4.c
+++ b/libgfortran/generated/minloc1_4_i4.c
@@ -96,7 +96,8 @@ minloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_4_i8.c b/libgfortran/generated/minloc1_4_i8.c
index 96da3ba..061a899 100644
--- a/libgfortran/generated/minloc1_4_i8.c
+++ b/libgfortran/generated/minloc1_4_i8.c
@@ -96,7 +96,8 @@ minloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_4_r10.c b/libgfortran/generated/minloc1_4_r10.c
index ae848aa..33a48c3 100644
--- a/libgfortran/generated/minloc1_4_r10.c
+++ b/libgfortran/generated/minloc1_4_r10.c
@@ -96,7 +96,8 @@ minloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_4_r16.c b/libgfortran/generated/minloc1_4_r16.c
index c93835e..21c4b97 100644
--- a/libgfortran/generated/minloc1_4_r16.c
+++ b/libgfortran/generated/minloc1_4_r16.c
@@ -96,7 +96,8 @@ minloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_4_r4.c b/libgfortran/generated/minloc1_4_r4.c
index 58cab55..6aedcad 100644
--- a/libgfortran/generated/minloc1_4_r4.c
+++ b/libgfortran/generated/minloc1_4_r4.c
@@ -96,7 +96,8 @@ minloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_4_r8.c b/libgfortran/generated/minloc1_4_r8.c
index 22ac6f8..a48b5e0 100644
--- a/libgfortran/generated/minloc1_4_r8.c
+++ b/libgfortran/generated/minloc1_4_r8.c
@@ -96,7 +96,8 @@ minloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_8_i1.c b/libgfortran/generated/minloc1_8_i1.c
index 1caaf10..ca0b80f 100644
--- a/libgfortran/generated/minloc1_8_i1.c
+++ b/libgfortran/generated/minloc1_8_i1.c
@@ -96,7 +96,8 @@ minloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_8_i16.c b/libgfortran/generated/minloc1_8_i16.c
index 2fb0311..333897d 100644
--- a/libgfortran/generated/minloc1_8_i16.c
+++ b/libgfortran/generated/minloc1_8_i16.c
@@ -96,7 +96,8 @@ minloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_8_i2.c b/libgfortran/generated/minloc1_8_i2.c
index 2c81e93..cc29cb1 100644
--- a/libgfortran/generated/minloc1_8_i2.c
+++ b/libgfortran/generated/minloc1_8_i2.c
@@ -96,7 +96,8 @@ minloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_8_i4.c b/libgfortran/generated/minloc1_8_i4.c
index 6fa45de..d7b4bb2 100644
--- a/libgfortran/generated/minloc1_8_i4.c
+++ b/libgfortran/generated/minloc1_8_i4.c
@@ -96,7 +96,8 @@ minloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_8_i8.c b/libgfortran/generated/minloc1_8_i8.c
index ffa18dd..9c8509d 100644
--- a/libgfortran/generated/minloc1_8_i8.c
+++ b/libgfortran/generated/minloc1_8_i8.c
@@ -96,7 +96,8 @@ minloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_8_r10.c b/libgfortran/generated/minloc1_8_r10.c
index df30f1f..77ce092 100644
--- a/libgfortran/generated/minloc1_8_r10.c
+++ b/libgfortran/generated/minloc1_8_r10.c
@@ -96,7 +96,8 @@ minloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_8_r16.c b/libgfortran/generated/minloc1_8_r16.c
index 2e1a040..bc5afec 100644
--- a/libgfortran/generated/minloc1_8_r16.c
+++ b/libgfortran/generated/minloc1_8_r16.c
@@ -96,7 +96,8 @@ minloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_8_r4.c b/libgfortran/generated/minloc1_8_r4.c
index 5e509bb..71e1344 100644
--- a/libgfortran/generated/minloc1_8_r4.c
+++ b/libgfortran/generated/minloc1_8_r4.c
@@ -96,7 +96,8 @@ minloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minloc1_8_r8.c b/libgfortran/generated/minloc1_8_r8.c
index 6abe24d..3444ee1 100644
--- a/libgfortran/generated/minloc1_8_r8.c
+++ b/libgfortran/generated/minloc1_8_r8.c
@@ -96,7 +96,8 @@ minloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -298,7 +299,8 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -482,7 +484,8 @@ sminloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minval_i1.c b/libgfortran/generated/minval_i1.c
index 2e428e9..589c704 100644
--- a/libgfortran/generated/minval_i1.c
+++ b/libgfortran/generated/minval_i1.c
@@ -95,7 +95,8 @@ minval_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mminval_i1 (gfc_array_i1 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ sminval_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minval_i16.c b/libgfortran/generated/minval_i16.c
index 68d1249..599a270 100644
--- a/libgfortran/generated/minval_i16.c
+++ b/libgfortran/generated/minval_i16.c
@@ -95,7 +95,8 @@ minval_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mminval_i16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ sminval_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minval_i2.c b/libgfortran/generated/minval_i2.c
index 7b9a1f7..14804b9 100644
--- a/libgfortran/generated/minval_i2.c
+++ b/libgfortran/generated/minval_i2.c
@@ -95,7 +95,8 @@ minval_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mminval_i2 (gfc_array_i2 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ sminval_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minval_i4.c b/libgfortran/generated/minval_i4.c
index 47870db..99967cc 100644
--- a/libgfortran/generated/minval_i4.c
+++ b/libgfortran/generated/minval_i4.c
@@ -95,7 +95,8 @@ minval_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mminval_i4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ sminval_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minval_i8.c b/libgfortran/generated/minval_i8.c
index 0154cd4..4f4178d 100644
--- a/libgfortran/generated/minval_i8.c
+++ b/libgfortran/generated/minval_i8.c
@@ -95,7 +95,8 @@ minval_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mminval_i8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ sminval_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minval_r10.c b/libgfortran/generated/minval_r10.c
index 61b809f..d7707ef 100644
--- a/libgfortran/generated/minval_r10.c
+++ b/libgfortran/generated/minval_r10.c
@@ -95,7 +95,8 @@ minval_r10 (gfc_array_r10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mminval_r10 (gfc_array_r10 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ sminval_r10 (gfc_array_r10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minval_r16.c b/libgfortran/generated/minval_r16.c
index 85d5435..4406ca5 100644
--- a/libgfortran/generated/minval_r16.c
+++ b/libgfortran/generated/minval_r16.c
@@ -95,7 +95,8 @@ minval_r16 (gfc_array_r16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mminval_r16 (gfc_array_r16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ sminval_r16 (gfc_array_r16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minval_r4.c b/libgfortran/generated/minval_r4.c
index 47633cd..2fa86e2 100644
--- a/libgfortran/generated/minval_r4.c
+++ b/libgfortran/generated/minval_r4.c
@@ -95,7 +95,8 @@ minval_r4 (gfc_array_r4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mminval_r4 (gfc_array_r4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ sminval_r4 (gfc_array_r4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/minval_r8.c b/libgfortran/generated/minval_r8.c
index 660e972..8bc7db1 100644
--- a/libgfortran/generated/minval_r8.c
+++ b/libgfortran/generated/minval_r8.c
@@ -95,7 +95,8 @@ minval_r8 (gfc_array_r8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -290,7 +291,8 @@ mminval_r8 (gfc_array_r8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -469,7 +471,8 @@ sminval_r8 (gfc_array_r8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/norm2_r10.c b/libgfortran/generated/norm2_r10.c
index 7f1d353..cc02a2a 100644
--- a/libgfortran/generated/norm2_r10.c
+++ b/libgfortran/generated/norm2_r10.c
@@ -99,7 +99,8 @@ norm2_r10 (gfc_array_r10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/norm2_r16.c b/libgfortran/generated/norm2_r16.c
index 7c05c6a..f68d362 100644
--- a/libgfortran/generated/norm2_r16.c
+++ b/libgfortran/generated/norm2_r16.c
@@ -103,7 +103,8 @@ norm2_r16 (gfc_array_r16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/norm2_r4.c b/libgfortran/generated/norm2_r4.c
index b0476ca..6b0c1c3 100644
--- a/libgfortran/generated/norm2_r4.c
+++ b/libgfortran/generated/norm2_r4.c
@@ -99,7 +99,8 @@ norm2_r4 (gfc_array_r4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/norm2_r8.c b/libgfortran/generated/norm2_r8.c
index 8546e49..37e2701 100644
--- a/libgfortran/generated/norm2_r8.c
+++ b/libgfortran/generated/norm2_r8.c
@@ -99,7 +99,8 @@ norm2_r8 (gfc_array_r8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/parity_l1.c b/libgfortran/generated/parity_l1.c
index 8217bf2..da80ad5 100644
--- a/libgfortran/generated/parity_l1.c
+++ b/libgfortran/generated/parity_l1.c
@@ -96,7 +96,8 @@ parity_l1 (gfc_array_l1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/parity_l16.c b/libgfortran/generated/parity_l16.c
index 4b122a7..ec57227 100644
--- a/libgfortran/generated/parity_l16.c
+++ b/libgfortran/generated/parity_l16.c
@@ -96,7 +96,8 @@ parity_l16 (gfc_array_l16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/parity_l2.c b/libgfortran/generated/parity_l2.c
index 80ac828..4dac05f 100644
--- a/libgfortran/generated/parity_l2.c
+++ b/libgfortran/generated/parity_l2.c
@@ -96,7 +96,8 @@ parity_l2 (gfc_array_l2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/parity_l4.c b/libgfortran/generated/parity_l4.c
index ae151fd..fb245af 100644
--- a/libgfortran/generated/parity_l4.c
+++ b/libgfortran/generated/parity_l4.c
@@ -96,7 +96,8 @@ parity_l4 (gfc_array_l4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/parity_l8.c b/libgfortran/generated/parity_l8.c
index eb55ad4..622e76b 100644
--- a/libgfortran/generated/parity_l8.c
+++ b/libgfortran/generated/parity_l8.c
@@ -96,7 +96,8 @@ parity_l8 (gfc_array_l8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_c10.c b/libgfortran/generated/product_c10.c
index 960dadd..0430df6 100644
--- a/libgfortran/generated/product_c10.c
+++ b/libgfortran/generated/product_c10.c
@@ -95,7 +95,8 @@ product_c10 (gfc_array_c10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_c10 (gfc_array_c10 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_c10 (gfc_array_c10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_c16.c b/libgfortran/generated/product_c16.c
index 7684bc5..915019d 100644
--- a/libgfortran/generated/product_c16.c
+++ b/libgfortran/generated/product_c16.c
@@ -95,7 +95,8 @@ product_c16 (gfc_array_c16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_c16 (gfc_array_c16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_c16 (gfc_array_c16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_c4.c b/libgfortran/generated/product_c4.c
index ef25a62..6238f72 100644
--- a/libgfortran/generated/product_c4.c
+++ b/libgfortran/generated/product_c4.c
@@ -95,7 +95,8 @@ product_c4 (gfc_array_c4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_c4 (gfc_array_c4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_c4 (gfc_array_c4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_c8.c b/libgfortran/generated/product_c8.c
index b5ab7c4..b8c4b24 100644
--- a/libgfortran/generated/product_c8.c
+++ b/libgfortran/generated/product_c8.c
@@ -95,7 +95,8 @@ product_c8 (gfc_array_c8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_c8 (gfc_array_c8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_c8 (gfc_array_c8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_i1.c b/libgfortran/generated/product_i1.c
index 41b6738..1b26166 100644
--- a/libgfortran/generated/product_i1.c
+++ b/libgfortran/generated/product_i1.c
@@ -95,7 +95,8 @@ product_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_i1 (gfc_array_i1 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_i16.c b/libgfortran/generated/product_i16.c
index 58e6d45..3db2c53 100644
--- a/libgfortran/generated/product_i16.c
+++ b/libgfortran/generated/product_i16.c
@@ -95,7 +95,8 @@ product_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_i2.c b/libgfortran/generated/product_i2.c
index d016bb2..f28e902 100644
--- a/libgfortran/generated/product_i2.c
+++ b/libgfortran/generated/product_i2.c
@@ -95,7 +95,8 @@ product_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_i2 (gfc_array_i2 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_i4.c b/libgfortran/generated/product_i4.c
index 8fa94d5..6ac3117 100644
--- a/libgfortran/generated/product_i4.c
+++ b/libgfortran/generated/product_i4.c
@@ -95,7 +95,8 @@ product_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_i4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_i8.c b/libgfortran/generated/product_i8.c
index c40dd05..439e100 100644
--- a/libgfortran/generated/product_i8.c
+++ b/libgfortran/generated/product_i8.c
@@ -95,7 +95,8 @@ product_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_i8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_r10.c b/libgfortran/generated/product_r10.c
index 1d3493e..06ec685 100644
--- a/libgfortran/generated/product_r10.c
+++ b/libgfortran/generated/product_r10.c
@@ -95,7 +95,8 @@ product_r10 (gfc_array_r10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_r10 (gfc_array_r10 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_r10 (gfc_array_r10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_r16.c b/libgfortran/generated/product_r16.c
index f6704ba..abb753a 100644
--- a/libgfortran/generated/product_r16.c
+++ b/libgfortran/generated/product_r16.c
@@ -95,7 +95,8 @@ product_r16 (gfc_array_r16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_r16 (gfc_array_r16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_r16 (gfc_array_r16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_r4.c b/libgfortran/generated/product_r4.c
index eae45ba..81dc0ef 100644
--- a/libgfortran/generated/product_r4.c
+++ b/libgfortran/generated/product_r4.c
@@ -95,7 +95,8 @@ product_r4 (gfc_array_r4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_r4 (gfc_array_r4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_r4 (gfc_array_r4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/product_r8.c b/libgfortran/generated/product_r8.c
index 50ccf8a..57a1998 100644
--- a/libgfortran/generated/product_r8.c
+++ b/libgfortran/generated/product_r8.c
@@ -95,7 +95,8 @@ product_r8 (gfc_array_r8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ mproduct_r8 (gfc_array_r8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ sproduct_r8 (gfc_array_r8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/reshape_c10.c b/libgfortran/generated/reshape_c10.c
index c288fcc..d33a1f1 100644
--- a/libgfortran/generated/reshape_c10.c
+++ b/libgfortran/generated/reshape_c10.c
@@ -116,7 +116,8 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_c16.c b/libgfortran/generated/reshape_c16.c
index 05e5cf5..9024fad 100644
--- a/libgfortran/generated/reshape_c16.c
+++ b/libgfortran/generated/reshape_c16.c
@@ -116,7 +116,8 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_c4.c b/libgfortran/generated/reshape_c4.c
index 3b9b962..1fde49c 100644
--- a/libgfortran/generated/reshape_c4.c
+++ b/libgfortran/generated/reshape_c4.c
@@ -116,7 +116,8 @@ reshape_c4 (gfc_array_c4 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_c8.c b/libgfortran/generated/reshape_c8.c
index cea838e..5978a6c 100644
--- a/libgfortran/generated/reshape_c8.c
+++ b/libgfortran/generated/reshape_c8.c
@@ -116,7 +116,8 @@ reshape_c8 (gfc_array_c8 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_i16.c b/libgfortran/generated/reshape_i16.c
index cbaa5c1..3a61537 100644
--- a/libgfortran/generated/reshape_i16.c
+++ b/libgfortran/generated/reshape_i16.c
@@ -116,7 +116,8 @@ reshape_16 (gfc_array_i16 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_i4.c b/libgfortran/generated/reshape_i4.c
index b35cd12..58dbab2 100644
--- a/libgfortran/generated/reshape_i4.c
+++ b/libgfortran/generated/reshape_i4.c
@@ -116,7 +116,8 @@ reshape_4 (gfc_array_i4 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_i8.c b/libgfortran/generated/reshape_i8.c
index 63bc429..bf3d279 100644
--- a/libgfortran/generated/reshape_i8.c
+++ b/libgfortran/generated/reshape_i8.c
@@ -116,7 +116,8 @@ reshape_8 (gfc_array_i8 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_r10.c b/libgfortran/generated/reshape_r10.c
index 192b05b..315cfa5 100644
--- a/libgfortran/generated/reshape_r10.c
+++ b/libgfortran/generated/reshape_r10.c
@@ -116,7 +116,8 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_r16.c b/libgfortran/generated/reshape_r16.c
index af3c042..7af0abb 100644
--- a/libgfortran/generated/reshape_r16.c
+++ b/libgfortran/generated/reshape_r16.c
@@ -116,7 +116,8 @@ reshape_r16 (gfc_array_r16 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_r4.c b/libgfortran/generated/reshape_r4.c
index d56e2ea..c9e1f95 100644
--- a/libgfortran/generated/reshape_r4.c
+++ b/libgfortran/generated/reshape_r4.c
@@ -116,7 +116,8 @@ reshape_r4 (gfc_array_r4 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_r8.c b/libgfortran/generated/reshape_r8.c
index e2b12de..9dc8a83 100644
--- a/libgfortran/generated/reshape_r8.c
+++ b/libgfortran/generated/reshape_r8.c
@@ -116,7 +116,8 @@ reshape_r8 (gfc_array_r8 * const restrict ret,
         alloc_size = rs;
 
       ret->base_addr = xmalloc (alloc_size);
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+      ret->rank = rdim;
+      ret->dtype = source->dtype;
     }
 
   if (shape_empty)
diff --git a/libgfortran/generated/spread_c10.c b/libgfortran/generated/spread_c10.c
index 348e2e9..15941dc 100644
--- a/libgfortran/generated/spread_c10.c
+++ b/libgfortran/generated/spread_c10.c
@@ -74,7 +74,8 @@ spread_c10 (gfc_array_c10 *ret, const gfc_array_c10 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_c16.c b/libgfortran/generated/spread_c16.c
index a540ac1..a9774c9 100644
--- a/libgfortran/generated/spread_c16.c
+++ b/libgfortran/generated/spread_c16.c
@@ -74,7 +74,8 @@ spread_c16 (gfc_array_c16 *ret, const gfc_array_c16 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_c4.c b/libgfortran/generated/spread_c4.c
index a605a97..e09e18e 100644
--- a/libgfortran/generated/spread_c4.c
+++ b/libgfortran/generated/spread_c4.c
@@ -74,7 +74,8 @@ spread_c4 (gfc_array_c4 *ret, const gfc_array_c4 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_c8.c b/libgfortran/generated/spread_c8.c
index 8762cc7..ab39682 100644
--- a/libgfortran/generated/spread_c8.c
+++ b/libgfortran/generated/spread_c8.c
@@ -74,7 +74,8 @@ spread_c8 (gfc_array_c8 *ret, const gfc_array_c8 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_i1.c b/libgfortran/generated/spread_i1.c
index c62f27e..cc49020 100644
--- a/libgfortran/generated/spread_i1.c
+++ b/libgfortran/generated/spread_i1.c
@@ -74,7 +74,8 @@ spread_i1 (gfc_array_i1 *ret, const gfc_array_i1 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_i16.c b/libgfortran/generated/spread_i16.c
index 52d0770..8accb40 100644
--- a/libgfortran/generated/spread_i16.c
+++ b/libgfortran/generated/spread_i16.c
@@ -74,7 +74,8 @@ spread_i16 (gfc_array_i16 *ret, const gfc_array_i16 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_i2.c b/libgfortran/generated/spread_i2.c
index 276d82c..99277a8 100644
--- a/libgfortran/generated/spread_i2.c
+++ b/libgfortran/generated/spread_i2.c
@@ -74,7 +74,8 @@ spread_i2 (gfc_array_i2 *ret, const gfc_array_i2 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_i4.c b/libgfortran/generated/spread_i4.c
index 27809ac..1c6082e 100644
--- a/libgfortran/generated/spread_i4.c
+++ b/libgfortran/generated/spread_i4.c
@@ -74,7 +74,8 @@ spread_i4 (gfc_array_i4 *ret, const gfc_array_i4 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_i8.c b/libgfortran/generated/spread_i8.c
index 62180a0..75f0f5f 100644
--- a/libgfortran/generated/spread_i8.c
+++ b/libgfortran/generated/spread_i8.c
@@ -74,7 +74,8 @@ spread_i8 (gfc_array_i8 *ret, const gfc_array_i8 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_r10.c b/libgfortran/generated/spread_r10.c
index cb82d06..6a8443c 100644
--- a/libgfortran/generated/spread_r10.c
+++ b/libgfortran/generated/spread_r10.c
@@ -74,7 +74,8 @@ spread_r10 (gfc_array_r10 *ret, const gfc_array_r10 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_r16.c b/libgfortran/generated/spread_r16.c
index 693077c..d8b5dd1 100644
--- a/libgfortran/generated/spread_r16.c
+++ b/libgfortran/generated/spread_r16.c
@@ -74,7 +74,8 @@ spread_r16 (gfc_array_r16 *ret, const gfc_array_r16 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_r4.c b/libgfortran/generated/spread_r4.c
index 955e235..0b9c157 100644
--- a/libgfortran/generated/spread_r4.c
+++ b/libgfortran/generated/spread_r4.c
@@ -74,7 +74,8 @@ spread_r4 (gfc_array_r4 *ret, const gfc_array_r4 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/spread_r8.c b/libgfortran/generated/spread_r8.c
index 6d010d6..e0c8fb3 100644
--- a/libgfortran/generated/spread_r8.c
+++ b/libgfortran/generated/spread_r8.c
@@ -74,7 +74,8 @@ spread_r8 (gfc_array_r8 *ret, const gfc_array_r8 *source,
 
       /* The front end has signalled that we need to populate the
 	 return array descriptor.  */
-      ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rrank;
+      ret->rank = rrank;
+      ret->dtype = source->dtype;
       dim = 0;
       rs = 1;
       for (n = 0; n < rrank; n++)
diff --git a/libgfortran/generated/sum_c10.c b/libgfortran/generated/sum_c10.c
index 1783d70..c638af9 100644
--- a/libgfortran/generated/sum_c10.c
+++ b/libgfortran/generated/sum_c10.c
@@ -95,7 +95,8 @@ sum_c10 (gfc_array_c10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_c10 (gfc_array_c10 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_c10 (gfc_array_c10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_c16.c b/libgfortran/generated/sum_c16.c
index 623a97e..2e57375 100644
--- a/libgfortran/generated/sum_c16.c
+++ b/libgfortran/generated/sum_c16.c
@@ -95,7 +95,8 @@ sum_c16 (gfc_array_c16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_c16 (gfc_array_c16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_c16 (gfc_array_c16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_c4.c b/libgfortran/generated/sum_c4.c
index e87ff45..1693203 100644
--- a/libgfortran/generated/sum_c4.c
+++ b/libgfortran/generated/sum_c4.c
@@ -95,7 +95,8 @@ sum_c4 (gfc_array_c4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_c4 (gfc_array_c4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_c4 (gfc_array_c4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_c8.c b/libgfortran/generated/sum_c8.c
index f6d0e86..00c9047 100644
--- a/libgfortran/generated/sum_c8.c
+++ b/libgfortran/generated/sum_c8.c
@@ -95,7 +95,8 @@ sum_c8 (gfc_array_c8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_c8 (gfc_array_c8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_c8 (gfc_array_c8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_i1.c b/libgfortran/generated/sum_i1.c
index 08ef049..e7bd697 100644
--- a/libgfortran/generated/sum_i1.c
+++ b/libgfortran/generated/sum_i1.c
@@ -95,7 +95,8 @@ sum_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_i1 (gfc_array_i1 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_i1 (gfc_array_i1 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_i16.c b/libgfortran/generated/sum_i16.c
index cb4115b..193b775 100644
--- a/libgfortran/generated/sum_i16.c
+++ b/libgfortran/generated/sum_i16.c
@@ -95,7 +95,8 @@ sum_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_i16 (gfc_array_i16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_i16 (gfc_array_i16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_i2.c b/libgfortran/generated/sum_i2.c
index da94835..5abcfb7 100644
--- a/libgfortran/generated/sum_i2.c
+++ b/libgfortran/generated/sum_i2.c
@@ -95,7 +95,8 @@ sum_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_i2 (gfc_array_i2 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_i2 (gfc_array_i2 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_i4.c b/libgfortran/generated/sum_i4.c
index 67619f3..667bf65 100644
--- a/libgfortran/generated/sum_i4.c
+++ b/libgfortran/generated/sum_i4.c
@@ -95,7 +95,8 @@ sum_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_i4 (gfc_array_i4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_i4 (gfc_array_i4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_i8.c b/libgfortran/generated/sum_i8.c
index 72b8c54..7671181 100644
--- a/libgfortran/generated/sum_i8.c
+++ b/libgfortran/generated/sum_i8.c
@@ -95,7 +95,8 @@ sum_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_i8 (gfc_array_i8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_i8 (gfc_array_i8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_r10.c b/libgfortran/generated/sum_r10.c
index 840f4d1..f2e5037 100644
--- a/libgfortran/generated/sum_r10.c
+++ b/libgfortran/generated/sum_r10.c
@@ -95,7 +95,8 @@ sum_r10 (gfc_array_r10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_r10 (gfc_array_r10 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_r10 (gfc_array_r10 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_r16.c b/libgfortran/generated/sum_r16.c
index f27642e..a1ed9f9 100644
--- a/libgfortran/generated/sum_r16.c
+++ b/libgfortran/generated/sum_r16.c
@@ -95,7 +95,8 @@ sum_r16 (gfc_array_r16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_r16 (gfc_array_r16 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_r16 (gfc_array_r16 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_r4.c b/libgfortran/generated/sum_r4.c
index 22f3c67..8534b44 100644
--- a/libgfortran/generated/sum_r4.c
+++ b/libgfortran/generated/sum_r4.c
@@ -95,7 +95,8 @@ sum_r4 (gfc_array_r4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_r4 (gfc_array_r4 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_r4 (gfc_array_r4 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
diff --git a/libgfortran/generated/sum_r8.c b/libgfortran/generated/sum_r8.c
index 9cfe5c9..c58ed1e 100644
--- a/libgfortran/generated/sum_r8.c
+++ b/libgfortran/generated/sum_r8.c
@@ -95,7 +95,8 @@ sum_r8 (gfc_array_r8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];
@@ -276,7 +277,8 @@ msum_r8 (gfc_array_r8 * const restrict retarray,
     		   * extent[rank-1];
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       if (alloc_size == 0)
 	{
@@ -427,7 +429,8 @@ ssum_r8 (gfc_array_r8 * const restrict retarray,
 	}
 
       retarray->offset = 0;
-      retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
+      retarray->rank = rank;
+      retarray->dtype = array->dtype;
 
       alloc_size = GFC_DESCRIPTOR_SM (retarray, rank-1)
     		   * extent[rank-1];

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]