Index: palm/trunk/SCRIPTS/mbuild
===================================================================
--- palm/trunk/SCRIPTS/mbuild	(revision 114)
+++ palm/trunk/SCRIPTS/mbuild	(revision 116)
@@ -90,4 +90,5 @@
      #                    from configuration file
      #                    host identifier (local_host) is read from config file
+     # 10/10/07 - Siggi - bugfix: handling of comment lines
 
 
@@ -185,5 +186,5 @@
  while read line
  do
-    if [[ "$line" != ""  ||  $(echo $line | cut -c1) != "#" ]]
+    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
     then
        HOSTNAME=`echo $line | cut -d" " -s -f2`
@@ -228,5 +229,5 @@
  while read line
  do
-    if [[ "$line" != ""  ||  $(echo $line | cut -c1) != "#" ]]
+    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
     then
        local_username=`echo $line | cut -d" " -s -f2`
@@ -252,5 +253,5 @@
  while read line
  do
-    if [[ "$line" != ""  &&  "$(echo $line | cut -d" " -s -f3)" = "" ]]
+    if [[ "$line" != ""  &&  "$(echo $line | cut -d" " -s -f3)" = ""  &&  $(echo $line | cut -c1) != "#" ]]
     then
        var=`echo $line | cut -d" " -s -f1 | cut -c2-`
@@ -721,5 +722,5 @@
        # IP-ADRESSE DES REMOTE-RECHNERS BESTIMMEN
     case  $remote_host  in
-        (lcmuk)          remote_addres=130.75.105.3;;
+        (lcmuk)          remote_addres=130.75.105.2;;
         (lctit)          remote_addres=172.17.75.161;;
         (decalpha)       remote_addres=165.132.26.56;;
@@ -741,20 +742,27 @@
        # REMOTE-USERNAMEN ERMITTELN
     line=""
+    found=false
     grep  "$remote_host_string" $config_file | grep "%remote_username"  >  tmp_mbuild
     while read line1
     do
+
        if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
        then
           line="$line1"
        fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+          remote_username=`echo $line | cut -d" " -s -f2`
+          found=true
+       fi
+
     done < tmp_mbuild
 
-    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
+    if [[ $found = false ]]
     then
        printf "\n  +++ no remote username found in configuration file"
        printf "\n      for \"$remote_host_string\" "
        locat=config_file; exit
-    else
-       remote_username=`echo $line | cut -d" " -s -f2`
     fi
 
@@ -766,14 +774,17 @@
     while read line1
     do
+
        if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
        then
           line="$line1"
        fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+          remote_source_path=`echo $line | cut -d" " -s -f2`
+       fi
+
     done < tmp_mbuild
 
-    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
-    then
-       remote_source_path=`echo $line | cut -d" " -s -f2`
-    fi
     if [[ "$remote_source_path" = "" ]]
     then
@@ -798,14 +809,17 @@
     while read line1
     do
+
        if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
        then
           line="$line1"
        fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+          remote_md=`echo $line | cut -d" " -s -f2`
+       fi
+
     done < tmp_mbuild
 
-    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
-    then
-       remote_md=`echo $line | cut -d" " -s -f2`
-    fi
     if [[ "$remote_md" = "" ]]
     then
@@ -826,20 +840,27 @@
        # COMPILERNAMEN ERMITTELN
     line=""
+    found=false
     grep  "$remote_host_string" $config_file | grep "%compiler_name "  >  tmp_mbuild
     while read line1
     do
+
        if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
        then
           line="$line1"
        fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+          compiler_name=`echo $line | cut -d" " -s -f2`
+          found=true
+       fi
+
     done < tmp_mbuild
 
-    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
+    if [[ $found = false ]]
     then
        printf "\n  +++ no compiler name found in configuration file"
        printf "\n      for \"$remote_host_string\" "
        locat=config_file; exit
-    else
-       compiler_name=`echo $line | cut -d" " -s -f2`
     fi
 
@@ -850,20 +871,27 @@
     then
        line=""
+       found=false
        grep  "$remote_host_string" $config_file | grep "%compiler_name_ser"  >  tmp_mbuild
        while read line1
        do
+
           if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
           then
              line="$line1"
           fi
+
+          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+          then
+             compiler_name_ser=`echo $line | cut -d" " -s -f2`
+             found=true
+          fi
+
        done < tmp_mbuild
 
-       if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
+       if [[ $found = false ]]
        then
           printf "\n  +++ no serial compiler name found in configuration file"
           printf "\n      for \"$remote_host_string\" "
           locat=config_file; exit
-       else
-          compiler_name_ser=`echo $line | cut -d" " -s -f2`
        fi
     else
@@ -875,21 +903,30 @@
        # PRAEPROZESSOR-OPTIONEN/DIREKTIVEN ERMITTELN
     line=""
+    found=false
     grep  "$remote_host_string" $config_file | grep "%cpp_options"  >  tmp_mbuild
     while read line1
     do
+
        if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
        then
           line="$line1"
        fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
+          cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
+          found=true
+       fi
+
     done < tmp_mbuild
-    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
+
+    if [[ $found = false ]]
     then
        printf "\n  +++ no preprocessor options found in configuration file"
        printf "\n      for \"$remote_host_string\" "
        locat=config_file; exit
-    else
-          # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
-       cpp_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
-    fi
+    fi
+
 
        # RECHNERSPEZIFISCHE CPP-DIREKTIVEN HINZUFUEGEN
@@ -922,14 +959,17 @@
     while read line1
     do
+
        if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
        then
           line="$line1"
        fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
+          netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
+       fi
+
     done < tmp_mbuild
-    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
-    then
-          # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
-       netcdf_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
-    fi
 
     line=""
@@ -937,14 +977,17 @@
     while read line1
     do
+
        if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
        then
           line="$line1"
        fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
+          netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
+       fi
+
     done < tmp_mbuild
-    if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
-    then
-          # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
-       netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
-    fi
 
 
@@ -952,23 +995,31 @@
        # COMPILEROPTIONEN ERMITTELN
     line=""
+    found=false
     grep  "$remote_host_string" $config_file | grep "%fopts"  >  tmp_mbuild
     while read line1
     do
+
        if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
        then
           line="$line1"
        fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
+          compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
+          found=true
+
+             # NETCDF-INCLUDEVERZEICHNIS HINZUFUEGEN
+          compiler_options="$compiler_options $netcdf_inc"
+       fi
+
     done < tmp_mbuild
-    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
+
+    if [[ $found = false ]]
     then
        printf "\n  +++ no compiler options found in configuration file"
        printf "\n      for \"$remote_host_string\" "
        locat=config_file; exit
-    else
-          # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
-       compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
-
-          # NETCDF-INCLUDEVERZEICHNIS HINZUFUEGEN
-       compiler_options="$compiler_options $netcdf_inc"
     fi
 
@@ -977,24 +1028,31 @@
        # LADER-OPTIONEN ERMITTELN
     line=""
+    found=false
     grep  "$remote_host_string" $config_file | grep "%lopts"  >  tmp_mbuild
     while read line1
     do
+
        if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
        then
           line="$line1"
        fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+             # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
+          loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
+          found=true
+
+             # NETCDF-LIBRARY HINZUFUEGEN
+          loader_options="$loader_options $netcdf_lib"
+       fi
+
     done < tmp_mbuild
 
-    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
+    if [[ $found = false ]]
     then
        printf "\n  +++ no loader options found in configuration file"
        printf "\n      for \"$remote_host_string\" "
        locat=config_file; exit
-    else
-          # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
-       loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
-
-          # NETCDF-LIBRARY HINZUFUEGEN
-       loader_options="$loader_options $netcdf_lib"
     fi
 
