Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
60d8d59b9a01d160dabd7aa1ce15724841a9c9b8
[simgrid.git] / src / smpi / smpif90.in
1 #! /bin/sh
2
3 F90=@GFORTRAN_EXE@
4
5 INCLUDEARGS="@includeflag@"
6 CMAKE_LINKARGS="-L@libdir@"
7
8 @SMPITOOLS_SH@
9
10 list_set FFLAGS "-ff2c" "-fno-second-underscore"
11 list_set LINKARGS "-lsimgrid" "-lm" "-lgfortran"
12 list_set TMPFILES
13 main_name=main
14
15 cleanup () {
16     eval $(list_get TMPFILES)
17     rm -f "$@"
18 }
19 trap 'cleanup' EXIT
20
21 list_set CMDLINE
22 while [ $# -gt 0 ]; do
23     ARG="$1"
24     shift
25     case "${ARG}" in
26         -c)
27             CMAKE_LINKARGS=""
28             LINKARGS=""
29             list_add CMDLINE "-c"
30             ;;
31         *.f90|*.F90)
32             TMPFILE=$(mymktemp "${ARG}" ".f90")
33             list_add TMPFILES "${TMPFILE}"
34       #replace "program main_name by subroutine user\_main (and the end clause as well)"
35             sed 's/[[:space:]]*program[[:space:]]*\([a-zA-Z0-9\-\_]*\)/subroutine user\_main /gI;s/[[:space:]]*use[[:space:]]*mpi/\include \"mpif\.h\" /gI' "${ARG}" > "${TMPFILE}"
36             SRCFILE="${TMPFILE}"
37             list_add CMDLINE "${SRCFILE}"
38             ;;
39         *)
40             list_add CMDLINE "${ARG}"
41             ;;
42     esac
43 done
44
45 list_set CMDLINE "${FFLAGS}" "${CMDLINE}" ${INCLUDEARGS} ${CMAKE_LINKARGS} "${LINKARGS}"
46 eval $(list_get CMDLINE)
47
48 "${F90}" "$@"