[MITgcm-devel] testreport and cross compiling

Martin Losch Martin.Losch at awi.de
Tue Feb 12 03:25:25 EST 2008


Hi Ed,
can you help me with this? As you know, this is the code that tests  
"Can we call simple C routines (here, "cloc()") using sxmpif90 ...":
> check_HAVE_CLOC()  {
>     get_fortran_c_namemangling
>     cat <<EOF > genmake_tc_1.c
> $FC_NAMEMANGLE
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <assert.h>
> #include <sys/time.h>
> void FC_NAMEMANGLE(cloc) ( double *curtim )
> {
>  struct timeval tv1;
>  gettimeofday(&tv1 , (void *)NULL );
>  *curtim =  (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6);
>  *curtim = *curtim/1.E6;
> }
> EOF
>     make genmake_tc_1.o >> genmake_warnings 2>&1
>     RET_C=$?
>     cat <<EOF > genmake_tc_2.$FS
>       program hello
>       REAL*8 wtime
>       external cloc
>       call cloc(wtime)
>       print *," HELLO WORLD", wtime
>       end
> EOF
>     COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
>     echo $COMM >> genmake_warnings
>     $COMM >> genmake_warnings 2>&1
>     RET_F=$?
>     test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
>     RETVAL=$?
>     if test "x$RETVAL" = x0 ; then
> 	HAVE_CLOC=t
> 	DEFINES="$DEFINES -DHAVE_CLOC"
>     fi
>     rm -f genmake_tc*
> }

This is how the c-code is compiled:
	make genmake_tc_1.o >> genmake_warnings 2>&1
this is how the fortran code is compiled:	
	COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
	echo $COMM >> genmake_warnings
	$COMM >> genmake_warnings 2>&1

why don't you use something like $CC -c genmake_tc_1.f >>  
genmake_warnings 2>&1 for the C-code. Is "make" supposed to know  
about  the value of CC?

This is what happens (frequently) on the SX8: on prestine directory I  
run genmake2 and the script hangs during this test (actually during  
the link step), with Ctrl-C I can interrupt this test, the script  
continues with a lot of failures (because cc is used instead of  
CC='sxcc -sx8r'), and a Makefile is generated. Now I can either  
repeat the genmake command or run "make makefile" and this second  
time around genmake uses the correct compilers etc. Really strange,  
but true. I am attaching the genmake_warning-files from these two  
rounds and you see that in the second case the sxcc compiler is used.

But, wouldn't it be more robust not to use make but rather some form  
similar to the fortran command line to compile the c-code?

Martin



-------------- next part --------------
A non-text attachment was scrubbed...
Name: genmake_warnings.1.gz
Type: application/x-gzip
Size: 1549 bytes
Desc: not available
URL: <http://mitgcm.org/pipermail/mitgcm-devel/attachments/20080212/592f4952/attachment.gz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: genmake_warnings.2.gz
Type: application/x-gzip
Size: 861 bytes
Desc: not available
URL: <http://mitgcm.org/pipermail/mitgcm-devel/attachments/20080212/592f4952/attachment-0001.gz>
-------------- next part --------------





More information about the MITgcm-devel mailing list