Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / smpi / smpiff.in
1 #! /bin/sh
2
3 # Copyright (c) 2012-2014. The SimGrid Team.
4 # All rights reserved.
5
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
8
9 <<<<<<< HEAD
10 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
11
12 prefix="@exec_prefix@"
13 smpicc="$prefix/bin/smpicc"
14 smpif2c="$prefix/bin/smpif2c"
15 =======
16 F77=@GFORTRAN_EXE@
17
18 INCLUDEARGS="@includeflag@"
19 CMAKE_LINKARGS="-L@libdir@"
20 >>>>>>> 167177a9f2980982c1bb3f89ec90fc1937395cd5
21
22 @SMPITOOLS_SH@
23
24 list_set FFLAGS "-ff2c" "-fno-second-underscore"
25 list_set LINKARGS "-lsimgrid" "-lm" "-lgfortran"
26 list_set TMPFILES
27 main_name=main
28
29 cleanup () {
30     eval $(list_get TMPFILES)
31    # rm -f "$@"
32 }
33 trap 'cleanup' EXIT
34
35 list_set CMDLINE "${F77}"
36 list_add_not_empty CMDLINE "${FFLAGS}"
37 while [ $# -gt 0 ]; do
38     ARG="$1"
39     shift
40     case "${ARG}" in
41         -c)
42             CMAKE_LINKARGS=""
43             LINKARGS=""
44             list_add CMDLINE "-c"
45             ;;
46         *.f|*.F)
47             TMPFILE=$(mymktemp "${ARG}" ".f")
48             list_add TMPFILES "${TMPFILE}"
49       #replace "program main_name by subroutine user\_main (and the end clause as well)"
50             sed 's/[[:space:]]\{6\}[[:space:]]*\(end \)\{0,1\}program[[:space:]]*\([a-zA-Z0-9\-\_]*\)/      \1subroutine user_main /gI;s/[[:space:]]*use[[:space:]]*mpi/\include \"mpif\.h\" /gI' "${ARG}" > "${TMPFILE}"
51             SRCFILE="${TMPFILE}"
52             list_add CMDLINE "${SRCFILE}"
53             ;;
54         '-version' | '--version' | '-v')
55             # -e is not recognised by MS-DOS...
56             echo -e $SIMGRID_VERSION
57             exit 0
58             ;;           
59         *)
60             list_add CMDLINE "${ARG}"
61             ;;
62     esac
63 done
64
65 list_add_not_empty CMDLINE ${INCLUDEARGS}
66 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
67 list_add_not_empty CMDLINE "${LINKARGS}"
68
69 eval $(list_get CMDLINE)
70 "$@"