Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use an ActorPtr as parameter to smpi_switch_data_segemnt.
[simgrid.git] / src / smpi / smpif90.in
1 #!/usr/bin/env sh
2
3 # Copyright (c) 2012-2018. The SimGrid Team. All rights reserved.
4
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the license (GNU LGPL) which comes with this package.
7
8 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
9 SIMGRID_GITHASH="@SIMGRID_GITHASH@"
10
11 F90=@SMPI_Fortran_COMPILER@
12
13 INCLUDEARGS="@includeflag@"
14 CMAKE_LINKARGS="-L@libdir@"
15
16 @SMPITOOLS_SH@
17
18 list_set FFLAGS @SMPI_Fortran_FLAGS@
19 list_set LINKARGS "-shared" "-lsimgrid" @SMPI_Fortran_LIBS@ "-lm"
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 filter_and_compile() {
30     list_add TMPFILES "${TMPFILE}"
31 #replace "program main_name by subroutine user\_main (and the end clause as well)"
32     sed 's/[[:space:]]*[pP][rR][oO][gG][rR][aA][mM][[:space:]]*\([a-zA-Z0-9\-\_]*\)/ subroutine user\_main /g;s/[[:space:]]*[uU][sS][eE][[:space:]]*[mM][pP][iI]/\include \"mpif\.h\" /g' "${ARG}" > "${TMPFILE}"
33     SRCFILE="${TMPFILE}"
34     list_add CMDLINE "${SRCFILE}"
35 }
36
37 NEEDS_OUTPUT=1
38
39 list_set CMDLINE "${F90}"
40 list_add_not_empty CMDLINE "${FFLAGS}"
41 while [ $# -gt 0 ]; do
42     ARG="$1"
43     shift
44     case "${ARG}" in
45         -c)
46             CMAKE_LINKARGS=""
47             LINKARGS=""
48             list_add CMDLINE "-c"
49             ;;
50         *.f90)
51             ORIGFILE="${ARG%.f90}"
52             TMPFILE=$(mymktemp "${ARG}" ".f90")
53             filter_and_compile
54             ;;
55         *.F90)
56             ORIGFILE="${ARG%.F90}"
57             TMPFILE=$(mymktemp "${ARG}" ".F90")
58             filter_and_compile
59             ;;
60         '-version' | '--version')
61             printf '%b\n' "$SIMGRID_VERSION"
62             exit 0
63             ;;
64         "-git-version" | "--git-version")
65             printf '%b\n' "$SIMGRID_GITHASH"
66             exit 0
67             ;;
68         '-compiler-version' | '--compiler-version')
69             ${F90} --version
70             ;;
71         -o)
72             list_add CMDLINE "-o$1"
73             NEEDS_OUTPUT=0
74             shift
75             ;;
76         *)
77             list_add CMDLINE "${ARG}"
78             ;;
79     esac
80 done
81
82
83 if [ $NEEDS_OUTPUT -ne 0 ]; then
84    list_add CMDLINE "-o${ORIGFILE}.o"
85 fi
86
87 list_add_not_empty CMDLINE ${INCLUDEARGS}
88 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
89 list_add_not_empty CMDLINE "${LINKARGS}"
90
91 eval $(list_get CMDLINE)
92 "$@"