Route ampif77 and ampif90 through ampiCC, factoring out duplicated code
[charm.git] / src / libs / ck-libs / ampi / ampiCC
1 #!/bin/sh
2 CHARMBIN=`dirname $0`
3
4 [ -z "$AMPICC_MODE" ] && AMPICC_MODE='ampi'
5 STANDALONE=""
6
7 processArgs() {
8 while [ ! $# -eq 0 ]
9 do
10   arg="$1"
11   case "$arg" in
12   -show)
13      echo "charmc"
14      exit 0
15      ;;
16   -standalone)
17      STANDALONE="true"
18      ;;
19   *)
20      ;;
21   esac
22   shift
23 done
24 }
25
26 eval processArgs "$@"
27
28 AMPICC_EXTRA_OPTIONS=""
29
30 if test "$AMPICC_MODE" = 'ampi'
31 then
32   charmarch=$(cat $CHARMBIN/../tmp/.gdir)
33
34   if test "$charmarch" = "mpi"
35   then
36     dirName=ampicc.inc.$$
37     mkdir $dirName
38     cp -n $CHARMBIN/../include/mpi.h $dirName/mpi.h   2>/dev/null
39     AMPICC_EXTRA_OPTIONS="$AMPICC_EXTRA_OPTIONS -I./$dirName"
40   fi
41 fi
42
43 [ -f $CHARMBIN/../lib/libampiromio.a -a -z "$STANDALONE" ] && ROMIO=-lampiromio
44
45 $CHARMBIN/charmc -language $AMPICC_MODE -default-to-aout $AMPICC_EXTRA_OPTIONS $@ $ROMIO
46 status=$?
47
48 if test "$AMPICC_MODE" = 'ampi'
49 then
50   if test "$charmarch" = "mpi"
51   then
52     /bin/rm -f $dirName/mpi.h 2>/dev/null
53     rmdir $dirName
54   fi
55 fi
56
57 # Copy ampirun, but do not overwrite it if it already exists.
58 [ $status -eq 0 ] && cp -n $CHARMBIN/ampirun .
59
60 exit $status