Logo AND Algorithmique Numérique Distribuée

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