Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Well, that happens sometime (bad merge)
[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 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
10
11 F77=@GFORTRAN_EXE@
12
13 INCLUDEARGS="@includeflag@"
14 CMAKE_LINKARGS="-L@libdir@"
15
16 @SMPITOOLS_SH@
17
18 list_set FFLAGS "-ff2c" "-fno-second-underscore"
19 list_set LINKARGS "-lsimgrid" "-lm" "-lgfortran"
20 list_set TMPFILES
21 main_name=main
22
23 cleanup () {
24     eval $(list_get TMPFILES)
25    # rm -f "$@"
26 }
27 trap 'cleanup' EXIT
28
29 list_set CMDLINE "${F77}"
30 list_add_not_empty CMDLINE "${FFLAGS}"
31 while [ $# -gt 0 ]; do
32     ARG="$1"
33     shift
34     case "${ARG}" in
35         -c)
36             CMAKE_LINKARGS=""
37             LINKARGS=""
38             list_add CMDLINE "-c"
39             ;;
40         *.f|*.F)
41             TMPFILE=$(mymktemp "${ARG}" ".f")
42             list_add TMPFILES "${TMPFILE}"
43       #replace "program main_name by subroutine user\_main (and the end clause as well)"
44             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}"
45             SRCFILE="${TMPFILE}"
46             list_add CMDLINE "${SRCFILE}"
47             ;;
48         '-version' | '--version' | '-v')
49             # -e is not recognised by MS-DOS...
50             echo -e $SIMGRID_VERSION
51             exit 0
52             ;;           
53         *)
54             list_add CMDLINE "${ARG}"
55             ;;
56     esac
57 done
58
59 list_add_not_empty CMDLINE ${INCLUDEARGS}
60 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
61 list_add_not_empty CMDLINE "${LINKARGS}"
62
63 eval $(list_get CMDLINE)
64 "$@"