Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add MPI_Win_post, MPI_Win_start, MPI_Win_complete, and MPI_Win_wait support.
[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
30 NEEDS_OUTPUT=1
31
32 list_set CMDLINE "${F77}"
33 list_add_not_empty CMDLINE "${FFLAGS}"
34 while [ $# -gt 0 ]; do
35     ARG="$1"
36     shift
37     case "${ARG}" in
38         -c)
39             CMAKE_LINKARGS=""
40             LINKARGS=""
41             list_add CMDLINE "-c"
42             ;;
43         *.f|*.F)
44             TMPFILE=$(mymktemp "${ARG}" ".f")
45             list_add TMPFILES "${TMPFILE}"
46       #replace "program main_name by subroutine user\_main (and the end clause as well)"
47             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}"
48             ORIGFILE="${ARG}"
49             SRCFILE="${TMPFILE}"
50             list_add CMDLINE "${SRCFILE}"
51             ;;
52         '-version' | '--version')
53             printf '%b\n' "$SIMGRID_VERSION"
54             exit 0
55             ;;
56         '-compiler-version' | '--compiler-version')
57             ${F77} --version
58             ;;
59         -o)
60             NEEDS_OUTPUT=0
61             list_add CMDLINE "-o"   
62             ;;        
63         *)
64             list_add CMDLINE "${ARG}"
65             ;;
66     esac
67 done
68
69 if [ $NEEDS_OUTPUT -ne 0 ]; then
70    list_add CMDLINE "-o${ORIGFILE%.f}.o"     
71 fi
72
73 list_add_not_empty CMDLINE ${INCLUDEARGS}
74 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
75 list_add_not_empty CMDLINE "${LINKARGS}"
76
77 eval $(list_get CMDLINE)
78 "$@"