Index: palm/trunk/SCRIPTS/mrun
===================================================================
--- palm/trunk/SCRIPTS/mrun	(revision 210)
+++ palm/trunk/SCRIPTS/mrun	(revision 211)
@@ -157,4 +157,12 @@
      # 21/10/08 - Siggi  - bugfix for the case that -K has more than one
      #                     argument
+     # 08/11/08 - Siggi  - bugfix for depository path settings in configuration
+     #                     file
+     # 11/11/08 - Siggi  - rules for using user code files changed: user
+     #                     code splitted into one file per subroutine,
+     #                     user can provide his/her own makefile, only
+     #                     default source-code filenames are allowed
+
+
  
     # VARIABLENVEREINBARUNGEN + DEFAULTWERTE
@@ -1622,4 +1630,19 @@
 
 
+       # MAKEFILE AUF VORHANDENSEIN PRUEFEN UND KOPIEREN
+       # BEI RESTART-LAEUFEN LIEGT ES SCHON IM VERZEICHNIS SOURCES_FOR_RUN...
+    if [[ "$restart_run" != true ]]
+    then
+       [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
+       if [[ ! -f $makefile ]]
+       then
+          printf "\n  +++ file \"$makefile\" does not exist"
+          locat=make; exit
+       else
+          cp  $makefile  SOURCES_FOR_RUN_$fname/Makefile 
+       fi
+    fi
+
+
        # DATEIEN AUS ZUSAETZLICHEM QUELLVERZEICHNIS HINZUFUEGEN
     if [[ $restart_run != true  &&  "$add_source_path" != "" ]]
@@ -1638,4 +1661,5 @@
 
           cd $add_source_path
+          found=false
 
           Names=$(ls -1 *.f90 2>&1)
@@ -1653,4 +1677,13 @@
           cd  SOURCES_FOR_RUN_$fname
 
+             # COPY MAKEFILE IF EXISTING
+          if [[ -f $add_source_path/Makefile ]]
+          then
+             printf "\n\n  *** user Makefile from directory"
+             printf "\n      \"$add_source_path\" is used \n"
+             sleep 1
+             cp  $add_source_path/Makefile  .
+          fi
+
           for  dateiname  in  $AddFilenames
           do
@@ -1659,5 +1692,6 @@
                 printf "\n  +++ source code file \"$dateiname\" found in additional"
                 printf "\n      source code directory \"$add_source_path\" "
-                printf "\n      as well as in directory \"$source_path\"."
+                printf "\n      but was also given with option \"-s\" which means that it should be taken"
+                printf "\n      from directory \"$source_path\"."
                 locat=source; exit
              fi
@@ -1666,24 +1700,36 @@
              source_list="$source_list $dateiname"
 
+                # CHECK IF FILE IS CONTAINED IN MAKEFILE
+             if [[ $(grep -c $dateiname Makefile) = 0 ]]
+             then
+                printf "\n\n  +++ user file \"$dateiname\" "
+                printf "\n      is not listed in Makefile \n"
+                locat=source; exit
+             else
+
                 # Default User-Interface von der Liste entfernen, falls Datei
                 # ein User-Interface enthaelt
-             if [[ $( cat $dateiname | grep -c "END SUBROUTINE user_parin" ) != 0 ]]
-             then
-                if [[ $dateiname != user_interface.f90  &&  -f user_interface.f90 ]]
+#             if [[ $( cat $dateiname | grep -c "END SUBROUTINE user_parin" ) != 0 ]]
+#             then
+#                if [[ $dateiname != user_interface.f90  &&  -f user_interface.f90 ]]
+#                then
+#                   rm -rf  user_interface.f90
+#                   source_list=`echo $source_list | sed -e 's/user_interface.f90//'`
+#                   printf "\n\n  *** default \"user_interface.f90\" removed from the files to be translated"
+#                   printf "\n      since a user-interface is found in file"
+#                   printf "\n      \"$add_source_path/$dateiname\" \n"
+#                   sleep 3
+#                else
+                if [[ $found = false ]]
                 then
-                   rm -rf  user_interface.f90
-                   source_list=`echo $source_list | sed -e 's/user_interface.f90//'`
-                   printf "\n\n  *** default \"user_interface.f90\" removed from the files to be translated"
-                   printf "\n      since a user-interface is found in file"
-                   printf "\n      \"$add_source_path/$dateiname\" \n"
-                   sleep 3
-                else
-                   printf "\n\n  *** user-interface file \"$dateiname\" "
-                   printf "\n      added to the files to be translated \n"
-                   sleep 3
+                   found=true
+                   printf "\n\n  *** following user file(s) added to the"
+                   printf " files to be translated:\n      "
                 fi
+                printf "$dateiname  "
+                sleep 0.5
              fi
           done
-
+          [[ $found = true ]]  &&  printf "\n"
           cd -  > /dev/null
        fi
@@ -1733,15 +1779,15 @@
        # MAKEFILE AUF VORHANDENSEIN PRUEFEN UND KOPIEREN
        # BEI RESTART-LAEUFEN LIEGT ES SCHON IM VERZEICHNIS SOURCES_FOR_RUN...
-    if [[ "$restart_run" != true ]]
-    then
-       [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
-       if [[ ! -f $makefile ]]
-       then
-          printf "\n  +++ file \"$makefile\" does not exist"
-          locat=make; exit
-       else
-          cp  $makefile  SOURCES_FOR_RUN_$fname/Makefile 
-       fi
-    fi
+#    if [[ "$restart_run" != true ]]
+#    then
+#       [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
+#       if [[ ! -f $makefile ]]
+#       then
+#          printf "\n  +++ file \"$makefile\" does not exist"
+#          locat=make; exit
+#       else
+#          cp  $makefile  SOURCES_FOR_RUN_$fname/Makefile 
+#       fi
+#    fi
 
  fi  # do_compile=true
@@ -2220,5 +2266,8 @@
           if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
           then
-             local_depository_path=`echo $line | cut -d" " -s -f2`
+             if [[ "$(echo $line | cut -d" " -s -f4)" = "$cond1"  &&  "$(echo $line | cut -d" " -s -f5)" = "$cond2" ]]
+             then
+                local_depository_path=`echo $line | cut -d" " -s -f2`
+             fi
           fi
        done < tmp_mrun
@@ -2257,13 +2306,13 @@
           # ALS user_interface.f90 LIEGT, DIESEN GEAENDERTEN NAMEN INS
           # MAKEFILE EINTRAGEN
-       cd  $TEMPDIR_COMPILE
-       interface_file=`grep -l "END SUBROUTINE user_parin" $source_list`
-       if [[ "$interface_file" != "" ]]
-       then
-          interface_file=`echo $interface_file | cut -d"." -f1`
-          mv  Makefile  Makefile_old
-          sed "s/user_interface/$interface_file/g"  Makefile_old  >  Makefile
-       fi
-       cd -  > /dev/null
+#       cd  $TEMPDIR_COMPILE
+#       interface_file=`grep -l "END SUBROUTINE user_parin" $source_list`
+#       if [[ "$interface_file" != "" ]]
+#       then
+#          interface_file=`echo $interface_file | cut -d"." -f1`
+#          mv  Makefile  Makefile_old
+#          sed "s/user_interface/$interface_file/g"  Makefile_old  >  Makefile
+#       fi
+#       cd -  > /dev/null
     else
        cp  $executable   ${TEMPDIR}/a.out
@@ -2301,4 +2350,5 @@
        printf "\n\n\n  *** compilation starts \n$striche\n"
        printf "  *** compilation with make using following options:\n"
+       printf "      make depository:          $make_depository"
        printf "      compilername:             $compiler_name\n"
        printf "      options:                  $fopts\n"
@@ -2715,7 +2765,10 @@
        if [[ "$ENVIRONMENT" = BATCH ]]
        then
-          printf "\n  +++ debug is allowed in interactive mode only"
-          locat=debug
-          exit
+          if [[ $(echo $localhost | cut -c1-5) != lcsgi ]]
+          then
+             printf "\n  +++ debug is allowed in interactive mode only"
+             locat=debug
+             exit
+          fi
        fi
        if [[ $localhost = decalpha ]]
@@ -2756,4 +2809,28 @@
              totalview   poe  -a a.out  -procs $numprocs  -rmpool 0  -nodes 1   $ROPTS
           fi
+       elif [[ $(echo $localhost | cut -c1-5) = lcsgi ]]
+       then
+             # CURRENTLY NO DEBUGGER ON LCSGI
+          if [[ $run_coupled_model = true ]]
+          then
+             printf "\n  +++ no debug in coupled mode available on \"$localhost\" "
+             locat=debug
+             exit
+          fi
+          (( ii = $numprocs / $threads_per_task ))
+          export OMP_NUM_THREADS=$threads_per_task
+          echo "OMP_NUM_THREADS=$OMP_NUM_THREADS"
+          if [[ $threads_per_task != 1 ]]
+          then
+             printf "\n      threads per task: $threads_per_task"
+          fi
+          printf "\n\n"
+#          ulimit -s 300000   # A too large stack size causes problems
+#          export MV2_NUM_PORTS=2
+#          export MV2_CPU_MAPPING=0:1:2:3
+#          mpiexec    ./a.out  $ROPTS
+#          export MPI_LAUNCH_TIMEOUT=360
+           echo "no_coupling"  >  runfile_atmos
+           mpiexec_mpt -np $ii   ./a.out  $ROPTS
        else 
           printf "\n  +++ no debug available on \"$localhost\" "
