Logo AND Algorithmique Numérique Distribuée

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