Fortran: Intel vs G77
David Lecomber
david@streamline-computing.com
Wed Jan 15 21:51:00 GMT 2003
The current situation with g77 and Intel meets gdb is as follows for
multi-dim arrays
Intel compiled code:
whatis -- wrong way round real(4 * 5 ) is reported as real (5 * 4)
indexing -- correct
print elements -- boundaries not aligned properly ( it prints a 5 * 4
as a 4 * 5 )
g77 fortran compilers compiled code:
whatis -- correct
print elements -- correct
indexing -- 'print A(1,2)' will get the wrong answer.
So, unless there is a method to check what the compiler was used, we are
left with
1. status quo
or
2. compile up two different versions -- one for gdb + intel, the
other for gdb + g77
Does anyone know of the existence of such a check?
Patches to fix the three issues are attached, but of course they
cannot all be applied at once; the fix to make g77 work will bust
intel, and vice-versa..
David
-------------- next part --------------
*** eval.c Fri Jan 4 17:51:38 2002
--- eval.c Wed Oct 16 14:08:04 2002
*************** evaluate_subexp_standard (struct type *e
*** 1358,1364 ****
if (retcode == BOUND_FETCH_ERROR)
error ("Cannot obtain dynamic lower bound");
! array_size_array[i] = upper - lower + 1;
/* Zero-normalize subscripts so that offsetting will work. */
--- 1358,1364 ----
if (retcode == BOUND_FETCH_ERROR)
error ("Cannot obtain dynamic lower bound");
! array_size_array[nargs - i + 1] = upper - lower + 1;
/* Zero-normalize subscripts so that offsetting will work. */
-------------- next part --------------
*** f-valprint.c Mon Oct 21 17:47:36 2002
--- /tmp/gdb-5.2/gdb/f-valprint.c Mon Oct 21 16:14:33 2002
*************** f77_create_arrayprint_offset_tbl (struct
*** 234,239 ****
--- 234,241 ----
int eltlen;
int ndimen = 1;
int upper, lower, retcode;
+ int i, j;
+ int t;
tmp_type = type;
*************** f77_create_arrayprint_offset_tbl (struct
*** 256,270 ****
ndimen++;
}
/* Now we multiply eltlen by all the offsets, so that later we
can print out array elements correctly. Up till now we
know an offset to apply to get the item but we also
have to know how much to add to get to the next item */
ndimen--;
eltlen = TYPE_LENGTH (tmp_type);
F77_DIM_OFFSET (ndimen) = eltlen;
! while (--ndimen > 0)
{
eltlen *= F77_DIM_SIZE (ndimen + 1);
F77_DIM_OFFSET (ndimen) = eltlen;
--- 258,285 ----
ndimen++;
}
+
/* Now we multiply eltlen by all the offsets, so that later we
can print out array elements correctly. Up till now we
know an offset to apply to get the item but we also
have to know how much to add to get to the next item */
ndimen--;
+
+ /**
+ intel compiler, reckon this to be wrong way round.. so here's a quick in-place swap.
+ */
+
+ for (i = 1, j = ndimen; i < j; i++,j--) {
+ t = F77_DIM_SIZE(i);
+ F77_DIM_SIZE(i) = F77_DIM_SIZE(j);
+ F77_DIM_SIZE(j) = t;
+ }
+
eltlen = TYPE_LENGTH (tmp_type);
F77_DIM_OFFSET (ndimen) = eltlen;
!
! while (--ndimen > 0)
{
eltlen *= F77_DIM_SIZE (ndimen + 1);
F77_DIM_OFFSET (ndimen) = eltlen;
-------------- next part --------------
*** f-typeprint.c Sun Jan 20 19:42:04 2002
--- f-typeprint.c Mon Oct 21 16:18:12 2002
*************** f_type_print_varspec_suffix (struct type
*** 175,183 ****
if (arrayprint_recurse_level == 1)
fprintf_filtered (stream, "(");
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
- f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
retcode = f77_get_dynamic_lowerbound (type, &lower_bound);
--- 175,183 ----
if (arrayprint_recurse_level == 1)
fprintf_filtered (stream, "(");
+ else
+ fprintf_filtered (stream, ",");
retcode = f77_get_dynamic_lowerbound (type, &lower_bound);
*************** f_type_print_varspec_suffix (struct type
*** 212,221 ****
if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
if (arrayprint_recurse_level == 1)
fprintf_filtered (stream, ")");
- else
- fprintf_filtered (stream, ",");
arrayprint_recurse_level--;
break;
--- 212,223 ----
if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
+ f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+
if (arrayprint_recurse_level == 1)
fprintf_filtered (stream, ")");
arrayprint_recurse_level--;
break;
More information about the Gdb-patches
mailing list