Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
proper check for the -std=gnu++11 standard, and take in on clang too
[simgrid.git] / src / smpi / smpif90.in
1 #! /bin/sh
2
3 # Copyright (c) 2012-2015. 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 SIMGRID_GITHASH="@SIMGRID_GITHASH@"
11
12 F90=@GFORTRAN_EXE@
13
14 INCLUDEARGS="@includeflag@"
15 CMAKE_LINKARGS="-L@libdir@"
16
17 @SMPITOOLS_SH@
18
19 list_set FFLAGS "-ff2c" "-fno-second-underscore"
20 list_set LINKARGS "-lsimgrid" "-lm" "-lgfortran"
21 list_set TMPFILES
22 main_name=main
23
24 cleanup () {
25     eval $(list_get TMPFILES)
26     rm -f "$@"
27 }
28 trap 'cleanup' EXIT
29
30 list_set CMDLINE "${F90}"
31 list_add_not_empty CMDLINE "${FFLAGS}"
32 while [ $# -gt 0 ]; do
33     ARG="$1"
34     shift
35     case "${ARG}" in
36         -c)
37             CMAKE_LINKARGS=""
38             LINKARGS=""
39             list_add CMDLINE "-c"
40             ;;
41         *.f90|*.F90)
42             TMPFILE=$(mymktemp "${ARG}" ".f90")
43             list_add TMPFILES "${TMPFILE}"
44       #replace "program main_name by subroutine user\_main (and the end clause as well)"
45             sed 's/[[:space:]]*program[[:space:]]*\([a-zA-Z0-9\-\_]*\)/ subroutine user\_main /gI;s/[[:space:]]*use[[:space:]]*mpi/\include \"mpif\.h\" /gI' "${ARG}" > "${TMPFILE}"
46             SRCFILE="${TMPFILE}"
47             list_add CMDLINE "${SRCFILE}"
48             ;;
49         '-version' | '--version')
50             printf '%b\n' "$SIMGRID_VERSION"
51             exit 0
52             ;;
53         "-git-version" | "--git-version")
54             printf '%b\n' "$SIMGRID_GITHASH"
55             exit 0
56             ;;
57         '-compiler-version' | '--compiler-version')
58             ${F90} --version
59             ;;
60         *)
61             list_add CMDLINE "${ARG}"
62             ;;
63     esac
64 done
65
66 list_add_not_empty CMDLINE ${INCLUDEARGS}
67 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
68 list_add_not_empty CMDLINE "${LINKARGS}"
69
70 eval $(list_get CMDLINE)
71 "$@"