[Users] Problem calling varargs function from Fortran on Opteron x86_64/PGF90 compiler
Roberto De Pietri
depietri at fis.unipr.it
Wed Sep 29 12:20:39 CDT 2004
Dear all:
I would like to point to the attention that the call from fortran
the subroutine "CCTK_Reduce(....)" [Real name cctk_reduce_(...)]
fails on opteron 64bits system. This is due to an incompatibility
between fortarn calling convention and the way "varargs" functions
operate on this platform. This problem should not effect "C" or
"C++" thorns.
That means that on the Opetron platform the following flesh calls
are broken:
CCTK_Reduce(...) "C" Name: cctk_reduce_ (....)
CCTK_ReduceArray(...) "C" Name: cctk_reducearray_ (....)
CCTK_VInfo(...) "C" Name: cctk_vinfo_ (....)
A simple search on all the thorns locally available show that
no call to "cctk_reducearray_" or "cctk_vinfo_" are present and
only the following module:
arrangements/EUHydro/Whisky/src/Whisky_Shift.F90
arrangements/EUHydro/Whisky/src/Whisky_Analysis.F90
arrangements/EUHydro_Dev/Whisky/src/Whisky_Analysis.F90
arrangements/EUHydro_Dev/Whisky_IVP/src/Whisky_IVP.F90
arrangements/EUHydro_Dev/Whisky/src/Whisky_Shift.F90
arrangements/AEIThorns/EHFinder/src/EHFinder_Integrate.F90
arrangements/AEIThorns/EHFinder/src/EHFinder_ReInitialize.F90
arrangements/CactusTest/TestReduce/src/Reduce_Sum.F77
arrangements/CactusTest/TestReduce/src/Reduce_Maximum.F77
make any reference to "cctk_reduce_". In all this module
the "cctk_reduce_(...)" subroutine is invoked with just one
elements. The compilation and functionality of Cactus
may be recover by a simple patch to the flash file
"src/comm/Reduction.c" (see below for the diff).
I am suggesting to change the ***Fortran*** interface to the few
flesh subroutine effect by this bug. We already found a platform
that this is not working and it is potentially not working on any
platform
that use register to pass arguments. I propose to drop this *potential*
cause of trouble. This could require to change just few Fortran file
and it is a definite solution.
A propose the following **fortran** interface for the broken fortran
interface
routine:
void CCTK_FCALL CCTK_FNAME(CCTK_Reduce)
(int *fortranreturn,
const cGH **GH,
const int *proc,
const int *operation_handle,
const int *num_out_vals,
const int *type_out_vals,
void *out_vals,
const int *num_in_fields,
int *varindex);
and to drop: void CCTK_FCALL CCTK_FNAME(CCTK_ReduceArray).
Moreover:void CCTK_FCALL CCTK_FNAME (CCTK_VInfo) should be dropped
or replaced
Sincerely
Roberto De Pietri
========================================================================
===
diff -u src/comm/Reduction.c ../Cactus/src/comm/Reduction.c
--- src/comm/Reduction.c 2004-09-29 16:24:02.197898213 +0200
+++ ../Cactus/src/comm/Reduction.c 2004-09-17 19:26:18.000000000
+0200
@@ -46,7 +46,7 @@
const int *type_out_vals,
void *out_vals,
const int *num_in_fields,
- int *address);
+ ... );
void CCTK_FCALL CCTK_FNAME(CCTK_ReduceArray)
(int *fortran_return,
const cGH **GH,
@@ -411,10 +411,12 @@
const int *type_out_vals,
void *out_vals,
const int *num_in_fields,
- int *address)
+ ... )
{
+ va_list indices;
int retval;
- int in_fields;
+ int i;
+ int *in_fields;
t_reduce_operator *operator;
/* initialize return code to indicate an error */
@@ -443,11 +445,19 @@
/* Fill in the array of variable indices from the variable
argument list */
- in_fields = *address;
+ in_fields = malloc (*num_in_fields * sizeof (int));
+ va_start(indices, num_in_fields);
+ for (i=0; i<*num_in_fields; i++)
+ {
+ in_fields[i] = *va_arg(indices,int *);
+ }
+ va_end(indices);
+
retval = operator->reduce_operator (*GH, *proc, *num_out_vals,
*type_out_vals, out_vals,
- 1,&in_fields);
+ *num_in_fields,in_fields);
+ free(in_fields);
}
}
*fortranreturn = retval;
========================================================================
===
--------------------------------------------------------------
Roberto De Pietri
Dipartimento di Fisica e-mail:depietri at fis.unipr.it
Universita di Parma tel: +39 (0521) 906068
Parco Area delle Scienze 7/A fax: +39 (0521) 905223
I-43100 PARMA --- ITALY http://www.fis.unipr.it/~depietri
More information about the Users
mailing list