Index: palm/trunk/SCRIPTS/mbuild
===================================================================
--- palm/trunk/SCRIPTS/mbuild	(revision 492)
+++ palm/trunk/SCRIPTS/mbuild	(revision 493)
@@ -113,4 +113,7 @@
      #                    removed, t3e related parts removed
      # 26/02/10 - BjornM- re-adjustments for lcxt4 (new modules)
+     # 01/03/10 - Siggi - mpilib replaced by modules: explicit module settings
+     #                    removed; modules should now be given in the
+     #                    configuration file
 
 
@@ -124,4 +127,5 @@
  locat=normal
  makefile=""
+ module_calls=""
  scirocco=false
  silent=false
@@ -460,4 +464,5 @@
     fi
 
+    modules=""
     netcdf_inc=""
     netcdf_lib=""
@@ -798,8 +803,7 @@
 
 
-       # MPI LIBRARY ERMITTELN
+       # get modules to be load
     line=""
-    found=false
-    grep  "$remote_host_string" $config_file | grep "%mpilib"  >  $tmp_mbuild
+    grep  "$remote_host_string" $config_file | grep "%modules"  >  $tmp_mbuild
     while read line1
     do
@@ -813,11 +817,8 @@
        then
              # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
-          mpilib=`echo $line | cut -d" " -s -f2`
-          found=true
+          modules=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
        fi
 
     done < $tmp_mbuild
-
-    [[ $found = false ]]  &&  mpilib=mpt
 
 
@@ -918,9 +919,4 @@
        line=$(echo "$line" | cut -c51-)
     done
-    if [[ $( echo $remote_host | cut -c1-5 ) = lcsgi ]]
-    then
-       column1="mpi library:"; column2=$mpilib
-       printf "| $column1$column2 | \n"
-    fi
     column1="loader options:"; column2=$loader_options
     printf "| $column1$column2 | \n"
@@ -933,4 +929,17 @@
        line=$(echo "$line" | cut -c51-)
     done
+    if [[ $modules != "" ]]
+    then
+       column1="modules to be load:"; column2=$modules
+       printf "| $column1$column2 | \n"
+       line=$(echo "$modules" | cut -c51-)
+       while [[ "$line" != "" ]]
+       do
+          column1=""
+          column2=$line
+          printf "| $column1$column2 | \n"
+          line=$(echo "$line" | cut -c51-)
+       done
+    fi
     printf "#------------------------------------------------------------------------# \n"
 
@@ -1020,4 +1029,6 @@
           echo "  *** execute \"make\" on remote host"
 
+
+             # generate make call with make options
           if [[ $remote_host = nech ]]
           then
@@ -1027,20 +1038,24 @@
           fi
 
+             # generate command to load modules, if modules are given
+          if [[ "$modules" != "" ]]
+          then
+             module_calls="module load ${modules};"
+          fi
+
           if [[ $remote_host = ibms  ||  $remote_host = ibmy ]]
           then
 
-             ssh  ${remote_username}@${remote_addres}  "cd ${remote_md}; echo '$make_call_string' > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" 2>&1 | tee ${remote_host}_last_make_protokoll
+             ssh  ${remote_username}@${remote_addres}  "$module_calls cd ${remote_md}; echo '$make_call_string' > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" 2>&1 | tee ${remote_host}_last_make_protokoll
 
           elif [[ $remote_host = ibmh ]]
           then
 
-             print "export OBJECT_MODE=64; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
+             print "$module_calls export OBJECT_MODE=64; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
 
           elif [[ $remote_host = lcsgib  ||  $remote_host = lcsgih ]]
           then
 
-             print ". /usr/share/modules/init/bash; module load ifort/11.0.069; module load $mpilib; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
-#             print ". /usr/share/modules/init/bash; module load mvapich2/1.2rc1-intel; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
-#             print ". /usr/share/modules/init/bash; module load mvapich2; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
+             print ". /usr/share/modules/init/bash; $module_calls  cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
 
           elif [[ $remote_host = lctit ]]
@@ -1056,9 +1071,9 @@
           then
 
-             print ". /opt/modules/default/init/ksh; module load Base-opts; module load modules; module load pmi; module load pgi; module load PrgEnv-pgi; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
+             print ". /opt/modules/default/init/ksh; $module_calls  cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
 
           else
 
-             print "cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
+             print "cd $module_calls ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
 
           fi
@@ -1171,13 +1186,19 @@
           fi
 
+             # generate command to load modules, if modules are given
+          if [[ "$modules" != "" ]]
+          then
+             module_calls="module load ${modules};"
+          fi
+
           if [[ $remote_host = ibms  ||  $remote_host = ibmy ]]
           then
 
-             ssh  ${remote_username}@${remote_addres}  "cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
+             ssh  ${remote_username}@${remote_addres}  "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR"
 
           elif [[ $remote_host = ibmh ]]
           then
 
-             print "export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres}
+             print "$module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres}
 
           elif [[ $remote_host = lctit ]]
@@ -1187,5 +1208,5 @@
              while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
              do
-                print "cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
+                print "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
              done
 
@@ -1193,9 +1214,9 @@
           then
 
-             print ". /opt/modules/default/init/ksh; module load Base-opts; module load modules; module load pmi; module load pgi; module load PrgEnv-pgi; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
+             print ". /opt/modules/default/init/ksh; $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
 
           else
 
-             print "cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
+             print "$module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll
 
           fi
@@ -1238,4 +1259,10 @@
           echo " "
           echo "  *** execute \"make\" on local host"
+
+             # first load modules, if given
+          if [[ "$modules" != "" ]]
+          then
+             module load ${modules}
+          fi
 
           make  $make_options  PROG=$mainprog  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"  2>&1 | tee ${remote_host}_last_make_protokoll
