Logo AND Algorithmique Numérique Distribuée

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