Subject: Re: About configure of Adlib

From: Zheng Gengbin <[email-masked]>
Date: Thu, 17 Apr 1997 09:06:33 +0800 (EAT)

On Wed, 16 Apr 1997, Guansong Zhang wrote:

> On Apr 16, 11:31am, Zheng Gengbin wrote:
> > Subject: About configure of Adlib
> >
> >
> >
> > 	I have check your Adlib-1.09 , and modified your configure.in ,
> > My major work is to decide the externel name of fortran and set the
> > WDEF .  pcrc.C is modified also accroding to this macro variable.
> > Also I add the configure for Linux in it . So now this version can be
> > compiled on Liunx well , but the node program cannot run well while it
> > can run well on IBM RS6000 .  The old version work well  however .
> >
> >
> > Zheng
> >
> > [ Attachment (text/plain): "configure" 83504 bytes
> >   Character set: US-ASCII
> >   Configure
> >   Encoded with "base64" ]
> >
> > [ Attachment (text/plain): "pcrc.C" 62557 bytes
> >   Character set: US-ASCII
> >   pcrc.C
> >   Encoded with "base64" ]
> >-- End of excerpt from Zheng Gengbin
> 
> Since you attached a configure, instead of a configure.in, I can not see the
> difference, Please send the configure.in to me.
>

	Sorry , I made a mistake .

> By the way what is WDEF?

	Four cases are tested , 
1 . 2 underscore after fortran externel name , set WDEF as -DFORT2UNDERSCORE
2.  1 underscore  , set WDEF as -DFORT1UNDERSCORE 
3.  no underscore , set WDEF as -DFORT0UNDERSCORE
4.  Uppercase , set WDEF as -DFORTCAPS

> I don't expect you find the new Adlib :-) Now, you can do something for the
> test, it is still too slow for remote telnet.
> 
> In configure.in, (the one I sent to you should be line 92) there is:
> 
>     if [[ $CXX = c++ ]]
>     then
>       LIBKEY="-lmpi"
>     else
> 
> Please change "-lmpi" to "-lmpi -lm" and see if make check can pass on HP.
> 
> Guansong
> 

	Some compiler will complain about -lm , since they have no libm.a .
You'd better test if m exists .

Zheng 

dnl ####################################################################
dnl #   Copyright (c)
dnl #
dnl #   You may copy, distribute, and modify it freely as long as you  #
dnl #   preserve distribute, and modify it freely as long as you       # 
dnl #   preserve this copyright and permission notice.                 #
dnl #                                                                  #
dnl #
dnl ####################################################################
dnl 
dnl Process this file and acconfig.h by autoconf to produce a configure script.
dnl 

AC_INIT(./configure)

AC_PREFIX_DEFAULT(`pwd`)

AC_CONFIG_AUX_DIR(./config)

AC_CONFIG_HEADER(./src/include/config.h)

AC_CANONICAL_SYSTEM

AC_ARG_PROGRAM

AC_HEADER_STDC

dnl AC_CHECK_TYPE(u_short,unsigned short)

AC_HEADER_SYS_WAIT

AC_PROG_RANLIB

VERSION=1.09
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(VERSION)

dnl current working directory

CWD=`pwd`
AC_SUBST(CWD)

dnl deciding mpi package

AC_MSG_CHECKING(the MPI package)

MPI=

AC_ARG_WITH(MPI, [
--with-MPI=mpich          Using mpich MPI (the defualt setting)
--with-MPI=chimp          Using chimp MPI 
--with-MPI=sp2            Using sp2 MPI from IBM ], MPI=${withval}, MPI=mpich )

AC_CACHE_VAL(adlib_cv_mpipackage, adlib_cv_mpipackage=$MPI) 

AC_MSG_RESULT(as $adlib_cv_mpipackage)

MPI=$adlib_cv_mpipackage

AC_SUBST(MPI)

case "$MPI" in
  mpich )

  dnl check if mpi installed.
  if test ! -x `which mpirun`
  then 
    echo "Please install mpich first ..."
    exit
  fi

  dnl decide whether there is MPICC

  AC_CHECK_PROG(MPICC, mpCC, yes, no)

  dnl deciding compiler and linker

  if [[ "$MPICC" = "yes" ]]
  then
    CXX=mpCC
    AC_SUBST(CXX)

    LIBKEY=
  else
    dnl    AC_PROG_CC
    dnl    AC_PROG_CPP

    AC_PROG_CXX

    dnl deciding lib according to machine.

    if [[ $CXX = c++ ]]
    then
      LIBKEY="-lmpi"
    else
      case $target in

        *ibm* )
        LIBKEY="-lmpi"
        ;;

        *solaris* )
        LIBKEY="-lmpi -lsocket -lnsl" 
        ;;

        *dec* )
        LIBKEY="-lmpi -lcomplex -lm" 
        ;;

        * ) 
        echo "C++ compiler on $target is not supported yet"
        exit
        ;; 

      esac

    fi

  fi

  AC_SUBST(LIBKEY)

  dnl get mpi prefix

  AC_MSG_CHECKING(MPI include dir)

  MPI_PREFIX=`which mpirun | sed 's%/bin/mpirun%%'`
  if [[ ! -f $MPI_PREFIX/include/mpi.h ]]
  then 
    echo "Please input the mpich install prefix:"
  read MPI_PREFIX
  fi  

  if [[ ! -f $MPI_PREFIX/include/mpi.h ]]
  then 
    echo "Please install mpich first ..."
    exit
  fi

  MPI_INC=$MPI_PREFIX/include/

  AC_CACHE_VAL(adlib_cv_mpi_inc, adlib_cv_mpi_inc=$MPI_INC) 

  AC_MSG_RESULT($adlib_cv_mpi_inc)

  MPI_INC=-I$adlib_cv_mpi_inc

  AC_SUBST(MPI_INC)

  dnl get mpich exec_prefix

  AC_MSG_CHECKING(MPI lib dir)

  ARCH=`tarch`

  DEVICE=`tdevice $ARCH`

  dnl use prefix here, not quite good
  MPI_LIB=$MPI_PREFIX/lib/$ARCH/$DEVICE

  AC_CACHE_VAL(adlib_cv_mpi_lib, adlib_cv_mpi_lib=$MPI_LIB) 

  AC_MSG_RESULT($adlib_cv_mpi_lib)

  MPI_LIB=-L$adlib_cv_mpi_lib

  AC_SUBST(MPI_LIB) 

  ;;

  chimp )

  echo Not supported 
  ;;

  sp2 )

  AC_CHECK_PROG(MPICC, mpCC, yes, no)

  if [[ "$MPICC" = "yes" ]]
  then 
    CXX=mpCC
  fi

  if [[ "$CXX" = "" ]]
  then
    echo "Please install SP2 mpCC first ..."
    exit
  fi

  MPI_INC=
  AC_SUBST(MPI_INC)

  MPI_LIB=
  AC_SUBST(MPI_LIB) 

  LIBKEY=
  AC_SUBST(LIBKEY)
  ;;

  * )

  echo The package does not support MPI=$MPI.
  exit
  ;;

esac

dnl compiler option

AC_MSG_CHECKING(compiler option)

COMPILER_OPT=

AC_ARG_ENABLE(STRONG, 
--enable-STRONG           Package building flag (default as disabled),
COMPILER_OPT=-Dstrong,
COMPILER_OPT= )

AC_MSG_RESULT(as $COMPILER_OPT)

AC_SUBST(COMPILER_OPT)

dnl for Fortran interface

case $target in
	
  *ibm* )

  if [[ $MPICC = yes ]]
  then
    AC_CHECK_PROG(FCL, mpxlf, mpxlf)
  fi
  if [[ "$FCL" = "" ]]
  then 
    AC_CHECK_PROG(FCL, xlf, xlf)
  fi
  if [[ "$FCL" = "" ]]
  then 
    AC_CHECK_PROG(FCL, f77, f77)
  fi
  if [[ "$FCL" != "" ]]
  then 
    FC_OPT=-qextname
  fi

  PLATFORM=AIX

  ;;

  *dec* )
  AC_CHECK_PROG(FCL, f90, f90)
  if [[ "$FCL" = "" ]]
  then 
    AC_CHECK_PROG(FCL, f77, f77)
  fi

  PLATFORM=DEC

  ;;

  *linux* )
  AC_CHECK_PROG(FCL, g77, g77)
  if [[ "$FCL" = "" ]]
  then 
    AC_CHECK_PROG(FCL, fort77, fort77)
  fi
  PLATFORM=EPC

  ;;

  * ) 
  AC_CHECK_PROG(FCL, f77, f77)

  ;; 

esac

AC_CHECK_LIB(C,main,CXXLIBKEY="-lC",CXXLIBKEY="")

if [ ! test "$FCL" = "" -a -d ./src/pcrcFortran ]
then
  pcrcFortran=pcrcFortran
else
  pcrcFortran=
fi

dnl check the strange behavior of fortran . 
AC_MSG_CHECKING(Fortran externels name)
AC_CACHE_VAL(ac_fort_name_flag,
ac_fort_name_flag=
(cd src/pcrcFortran ; /bin/rm -f pcrc_stack.o ; \
        $FCL $FC_OPT -c pcrc_stack.f > /dev/null 2>&1 )
nameform1=`strings -a src/pcrcFortran/pcrc_stack.o | grep pcrc_integer_alloc_  | head -1`
nameform2=`strings -a src/pcrcFortran/pcrc_stack.o | grep PCRC_INTEGER_ALLOC   | head -1`
nameform3=`strings -a src/pcrcFortran/pcrc_stack.o | grep pcrc_integer_alloc   | head -1`
nameform4=`strings -a src/pcrcFortran/pcrc_stack.o | grep pcrc_integer_alloc__ | head -1`

/bin/rm -f src/pcrcFortran/pcrc_stack.o
if test -n "$nameform4" ; then
	WDEF='-DFORT2UNDERSCORE'
elif test -n "$nameform1" ; then
        WDEF='-DFORT1UNDERSCORE'
elif test -n "$nameform2" ; then
	WDEF='-DFORTCAPS'
elif test -n "$nameform3" ; then
        WDEF='-DFORT0UNDERSCORE'
else
	echo "Unable to determine the form of Fortran external names"
fi
ac_fort_name_flag=$WDEF
)
AC_MSG_RESULT($WDEF)
case "$WDEF" in
-DFORT2UNDERSCORE)    
	echo "Fortran externals are lower case and have 1 or 2 trailing underscores" 
	;;
-DFORT1UNDERSCORE)
	echo "Fortran externals have a trailing underscore and are lowercase"
	;;
-DFORTCAPS)
	echo "Fortran externals are uppercase"
	;;
-DFORT0UNDERSCORE)
	echo "Fortran externals are lower case"
	;;
esac
	
AC_SUBST(WDEF)

AC_SUBST(FC_OPT)
AC_SUBST(PLATFORM)
AC_SUBST(CXXLIBKEY)
AC_SUBST(pcrcFortran)

AC_OUTPUT(
Makefile 
src/Makefile 
src/include/Makefile src/kernel/Makefile src/script/Makefile src/pcrcFortran/Makefile
man/Makefile
man/man1/Makefile
test/Makefile test/kernel/Makefile test/pcrcFortran/Makefile
src/script/ad++:src/script/ad++.in
src/script/prun:src/script/prun.in
src/pcrcFortran/pcrcf:src/pcrcFortran/pcrcf.in 
test/kernel/runtests:test/kernel/runtests.in
test/pcrcFortran/runtests:test/pcrcFortran/runtests.in
)

chmod a+x src/script/ad++
chmod a+x src/script/prun
chmod a+x test/kernel/runtests
chmod a+x test/pcrcFortran/runtests
if [[ "$pcrcFortran" != "" ]]
then
  chmod a+x src/pcrcFortran/pcrcf
fi

echo Done!

---

From: Zheng Gengbin <[email-masked]>
Date: Tue, 22 Apr 1997 09:27:12 +0800 (EAT)

On Thu, 17 Apr 1997, Guansong Zhang wrote:

> I met this problem before. Bryan, the Adlib designer, want to use compiler flag
> to solve this problem and put one trailing under-line in each case.

	I think this method is not so good , because on Linux there is no
such flag , and 2 underscore is added .

> Now since you put this problem back again, I still think this is a better way,
> it gets ride of the constains brought by the compiler flag.
> 
> Before I discuss this with Bryan again, I want to know if it is possible for
> you to solve this problem in another way, using Fortran compiler flag, like in
> the case of AIX, using -qextname to solve this problme.
> 

	I have notice this , this flag is useful only to xlf on RS6000 .

> Also I don't know why you need to consern this, the default seting seems OK on
> HP.

	Our work now is mainly on Linux .

> 
> Another thing concerned with the codes:
> 
> 
> Does libm.a always come with gcc? Bryan told me so.
>

	I have tried this , HP seems cannot accept this .
 
> Why you need to rm .o first? What does it mean in B shell "2>&1" ?
> 
>

	In case if the compilation failed , existing pcrc_stack.o is used for 
test. 2>&1 means direct standard error output to standand output .  

Zheng

---

From: Zheng Gengbin <[email-masked]>
Date: Sun, 27 Apr 1997 09:55:51 +0800 (EAT)

On Sat, 26 Apr 1997, Guansong Zhang wrote:

> On Apr 22,  9:27am, Zheng Gengbin wrote:
> >
> >
> I tried something on linux, it seems both g77 and f77 (I don't know where this
> f77 is from, it do is on linux.) add one underscore after the name. Could you
> please told me which machine need two underscores? and need to capitalize the
> name?
> 

	But our g77 here do add 2 underscore after the name . 
I learned from an example that some compiler add capitalize the name , but
I have not met such machine .

Zheng

---

From: Zheng Gengbin <[email-masked]>
Date: Mon, 28 Apr 1997 09:34:18 +0800 (EAT)

On Sun, 27 Apr 1997, Guansong Zhang wrote:

> On Apr 27,  9:55am, Zheng Gengbin wrote:
> > Subject: Re: About configure of Adlib
> Please tell me the g77 version, use "g77 -v" or something. and the machine
> type. The reason for using compilier flag to solve this _ problem is that adlib
> need to add more functions in (100? according to Bryan). So it is more neat
> compared with renaming all those functions in different case. But it is not a
> big issue, so I just want to know every thing about it, and decide later.
> 
> Is the working of 90to77 continuing? I am more concerned with this one.
> 
> Guansong
> 
> 

	g77 -v make a lot of output ;
 gcc -v -fnull-version -o /tmp/gfa00286 -xf77-cpp-input /dev/null -xnone
Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.2/specs
gcc version 2.7.2
 /usr/lib/gcc-lib/i486-linux/2.7.2/cpp -lang-c -v -undef -D__GNUC__=2 
-D__GNUC_MINOR__=7 -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix 
-D__i386 -D__linux -Asystem(unix) -Asystem(posix) -Acpu(i386) 
-Amachine(i386) -D_LANGUAGE_FORTRAN -traditional -D__i486__ /dev/null 
/tmp/cca00286.i
GNU CPP version 2.7.2 (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/i486-linux/include
 /usr/lib/gcc-lib/i486-linux/2.7.2/include
 /usr/include
End of search list.
/usr/lib/gcc-lib/i486-linux/2.7.2/f771 /tmp/cca00286.i -fset-g77-defaults 
-quiet -dumpbase null.F -version -fversion -fnull-version -o /tmp/cca00286.s
GNU F77 version 2.7.2 (i386 Linux/ELF) compiled by GNU C version 2.7.2.
GNU Fortran Front End version 0.5.18 compiled: May 18 1996 16:29:38
 /usr/i486-linux/bin/as -V -Qy -o /tmp/cca002861.o /tmp/cca00286.s
GNU assembler version 960425 (i486-linux), using BFD version 2.6.0.14
 /usr/i486-linux/bin/ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.1 -o 
/tmp/gfa00286 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o 
-L/usr/lib/gcc-lib/i486-linux/2.7.2 -L/usr/i486-linux/lib 
/tmp/cca002861.o -lgcc -lc -lgcc /usr/lib/crtend.o /usr/lib/crtn.o
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x57): undefined reference to `main'

	tof77 now is ccontinuing . Now she is concerning about  translate
do  statement to f77 . This  issue is  not only in f90 , HPF also have such
problem  .
	In do , many work done in forall must also be done , such as 
global to local index caculation . And communocation dedtection .

Zheng.

---

From: Zheng Gengbin <[email-masked]>
Date: Tue, 29 Apr 1997 10:40:50 +0800 (EAT)

On Mon, 28 Apr 1997, Guansong Zhang wrote:

> On Apr 28,  9:34am, Zheng Gengbin wrote:
> > > > > I tried something on linux, it seems both g77 and f77 (I don't know
> where
> > > this
> > > > > f77 is from, it do is on linux.) add one underscore after the name.
> Could
> > > you
> > > > > please told me which machine need two underscores? and need to
> capitalize
> > > the
> > > > > name?
> > > > >
> > > >
> Are you sure the g77 and gcc is well installed on this linux? It seems produce
> some thing more than expected.
> 

	I think it should be ok . g77 and gcc work fine . I install it from
Linux from Slackware 3.1 , kernel 2.0.27 . The g77 and gcc is already here
after installed Linux , I need not install them separately .

Zheng