Index: palm/trunk/SCRIPTS/mbuild
===================================================================
--- palm/trunk/SCRIPTS/mbuild	(revision 75)
+++ palm/trunk/SCRIPTS/mbuild	(revision 82)
@@ -87,4 +87,7 @@
      #                    adjustments for running under pdksh, local ip-addres
      #                    is not determined any more
+     # 30/03/07 - Siggi - cpp-directives/options + netcdf-options are read
+     #                    from configuration file
+     #                    host identifier (local_host) is read from config file
 
 
@@ -159,32 +162,4 @@
 
 
-    # LOKALEN RECHNER ERMITTELN
- local_host_real_name=$(hostname)
-# local_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
-
- case  $local_host_real_name  in
-     (atmos)                    local_host=lcide;;
-     (berte)                    local_host=t3eb;;
-     (bora|breva|gregale|irifi|levanto|maestro|orkan|ostria|quanero|scirocco)  local_host=lcmuk;;
-     (fimm.bccs.uib.no)         local_host=lcmuk;;
-     (gate)                     local_host=neck;;
-     (gfdl3.yonsei.ac.kr)       local_host=decalpha;;
-     (gfdl5)                    local_host=ibmy;;
-     (gwdk081.gwdg.de)          local_host=ibm;;
-     (hreg01a-en0|hreg02a-en0)  local_host=ibmh;;
-     (nobel|nobela)             local_host=ibms;;
-     (tgg*)                     local_host=lctit;;
-     (t3e)                      local_host=t3eh;;
-     (zam003)                   local_host=t3ej2;;
-     (zam005)                   local_host=t3ej5;;
-     (*)       printf "\n  +++ local host \"$local_host_real_name\" not admitted for mbuild \n"
-               locat=local_host; exit;;
- esac
-
- [[ $local_host_real_name = scirocco ]]  &&  scirocco=true
- [[ $local_host_real_name = fimm.bccs.uib.no ]]  &&  fimm=true
-
-
-
     # PRUEFEN, OB KONFIGURATIONS-DATEI VORHANDEN
  if [[ ! -f $config_file ]]
@@ -195,4 +170,65 @@
     locat=configuration; exit  
  fi
+
+
+
+    # LOKALEN RECHNER ERMITTELN
+ local_host_real_name=$(hostname)
+# local_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
+
+
+
+    # HOST-IDENTIFIER (local_host) AUS KONFIGURATIONSDATEI BESTIMMEN
+ line=""
+ grep  "%host_identifier"  $config_file  >  tmp_mbuild
+ while read line
+ do
+    if [[ "$line" != ""  ||  $(echo $line | cut -c1) != "#" ]]
+    then
+       HOSTNAME=`echo $line | cut -d" " -s -f2`
+       host_identifier=`echo $line | cut -d" " -s -f3`
+       if [[ "$HOSTNAME" = $local_host_real_name ]]
+       then
+          local_host=$host_identifier
+          break
+       fi
+    fi
+ done < tmp_mbuild
+
+ if [[ "$local_host" = "" ]]
+ then
+    printf "\n  +++ no host identifier found in configuration file \"$config_file\""
+    printf "\n      for local host \"$local_host_real_name\"."
+    printf "\n      Please add line"
+    printf "\n      \"\%host_identifier $local_host_real_name <identifier>\""
+    printf "\n      to the configuration file."
+    locat=local_host; exit
+ fi
+
+
+# case  $local_host_real_name  in
+#     (atmos)                    local_host=lcide;;
+#     (berte)                    local_host=t3eb;;
+#     (bora|breva|gregale|irifi|levanto|maestro|orkan|ostria|quanero|scirocco)  local_host=lcmuk;;
+#     (fimm.bccs.uib.no)         local_host=lcmuk;;
+#     (gate)                     local_host=neck;;
+#     (gfdl3.yonsei.ac.kr)       local_host=decalpha;;
+#     (gfdl5)                    local_host=ibmy;;
+#     (gwdk081.gwdg.de)          local_host=ibm;;
+#     (hreg01a-en0|hreg02a-en0)  local_host=ibmh;;
+#     (nobel|nobela)             local_host=ibms;;
+#     (tgg*)                     local_host=lctit;;
+#     (t3e)                      local_host=t3eh;;
+#     (zam003)                   local_host=t3ej2;;
+#     (zam005)                   local_host=t3ej5;;
+#    (*)       printf "\n  +++ local host \"$local_host_real_name\" not admitted for mbuild \n"
+#               locat=local_host; exit;;
+# esac
+
+ [[ $local_host_real_name = scirocco ]]  &&  scirocco=true
+ [[ $local_host_real_name = fimm.bccs.uib.no ]]  &&  fimm=true
+
+
+
  if [[ $local_host != ibms ]]
  then
@@ -214,4 +250,5 @@
     fi
  done < tmp_mbuild
+
 
  if [[ "$local_username" = "" ]]
@@ -673,4 +710,6 @@
     fi
 
+    netcdf_inc=""
+    netcdf_lib=""
 
        # AUF HLRN-RECHNER NUR EINMAL UEBERSETZEN
@@ -700,5 +739,5 @@
     netcdf_support=false
     case  $remote_host  in
-        (lcmuk)          remote_addres=130.75.105.3; cpp_options=""
+        (lcmuk)          remote_addres=130.75.105.3
                          netcdf_support=true
                          if [[ $scirocco = true ]]
@@ -939,4 +978,70 @@
 
 
+       # PRAEPROZESSOR-OPTIONEN/DIREKTIVEN ERMITTELN
+    line=""
+    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
+    done < tmp_mbuild
+    if [[ "$line" = ""  ||  $(echo $line | cut -c1) = "#" ]]
+    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
+
+       # RECHNERSPEZIFISCHE CPP-DIREKTIVEN HINZUFUEGEN
+    for  string  in  $remote_host_string
+    do
+       if [[ $(echo $remote_host | cut -c1-2) = lc  &&  $(echo $string | cut -c1-2) = lc ]]
+       then
+          cpp_options="$cpp_options -D__lc "
+       else
+          cpp_options="$cpp_options -D__$string "
+       fi
+    done
+
+
+
+       # NETCDF-OPTIONEN ERMITTELN
+    line=""
+    grep  "$remote_host_string" $config_file | grep "%netcdf_inc"  >  tmp_mbuild
+    while read line1
+    do
+       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
+       then
+          line="$line1"
+       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=""
+    grep  "$remote_host_string" $config_file | grep "%netcdf_lib"  >  tmp_mbuild
+    while read line1
+    do
+       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
+       then
+          line="$line1"
+       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
+
+
+
        # COMPILEROPTIONEN ERMITTELN
     line=""
@@ -957,5 +1062,9 @@
           # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
        compiler_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
-    fi
+
+          # NETCDF-INCLUDEVERZEICHNIS HINZUFUEGEN
+       compiler_options="$compiler_options $netcdf_inc"
+    fi
+
     if [[ $netcdf_support = true ]]
     then
@@ -965,10 +1074,8 @@
           (ibms)      compiler_options="-I /applic/netcdf64/src/f90  $compiler_options";;
           (ibmy)      compiler_options="-I ${netcdf_path}/include  $compiler_options";;
-          (lcmuk)     compiler_options="-I ${netcdf_path}/include  $compiler_options";;
           (lctit)     compiler_options="-I ${netcdf_path}/include  $compiler_options";;
           (nech|neck) compiler_options="-I ${netcdf_path}/include  $compiler_options";;
        esac
     fi
-
 
 
@@ -992,13 +1099,17 @@
           # EVENTUELLE DOPPELPUNKTE AUS DIREKTIVENSTRING ENTFERNEN
        loader_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
-    fi
+
+          # NETCDF-LIBRARY HINZUFUEGEN
+       loader_options="$loader_options $netcdf_lib"
+    fi
+
     if [[ $netcdf_support = true ]]
     then
        case  $remote_host  in
-          (decalpha)                   loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
-          (ibmb|ibmh|lcmuk|nech|neck)  loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
-          (ibms)                       loader_options="$loader_options -L${netcdf_path} -lnetcdf";;
-          (ibmy)                       loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
-          (lctit)                      loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
+          (decalpha)             loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
+          (ibmb|ibmh|nech|neck)  loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
+          (ibms)                 loader_options="$loader_options -L${netcdf_path} -lnetcdf";;
+          (ibmy)                 loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
+          (lctit)                loader_options="$loader_options -L${netcdf_path}/lib -lnetcdf";;
        esac
     fi
