#!/bin/ksh # mbuild - Programmuebersetzungsscript Version: @(#)MBUILD 1.0 10/02/07 # Prozedur zur Uebersetzung von Programmteilen mittels make-Mechanismus # auf einem Remote-Rechner, ausgehend von Quellcode auf einem lokalen # Rechner # Folgende Probleme existieren unter Linux, wenn keine AT&T-Korn-Shell # verwendet wird: # Wertzuweisungen an Variablen innerhalb von DO-Schleifen werden nicht # nach aussen weitergegeben. "while read line" funktioniert nicht # innerhalb einer Pipe. # letzte Aenderung: # 06/05/02 - Siggi - Beginn der Entwicklung # 12/06/02 - Siggi - Abschluss der Entwicklungsarbeiten # 23/06/02 - Siggi - voerst kein make-clean, Abbruch bei batch-mode # 24/07/02 - Siggi - Keine Verwendung der temporaeren Datei tmp_mbuild # unter linux mehr noetig, da nun AT&T-Korn-Shell # benutzt wird # 12/09/02 - Siggi - ibmh (hanni.hlrn.de) validiert # 19/12/02 - Siggi - ibmb validiert # 05/02/03 - Siggi - hostname nobela included # 04/03/03 - Siggi - host nech included # 06/03/03 - Siggi - make_call_string is echoed without '' to # file LAST_MAKE_CALL (otherwise error on NEC, because # '' are part of compiler options # 16/03/03 - Siggi - Two underscores are placed in front of every define # string, in case that palm.f90 version contains # such strings # 16/04/03 - Siggi - First extensions for linux machines # 24/06/03 - Siggi - host orkan included # 17/07/03 - Siggi - IP adress set to new "cross" machine at DKRZ # 24/07/03 - Siggi - host maestro admitted # 06/08/03 - Siggi - host gregale admitted # 05/11/03 - Siggi - hosts irifi and quanero are now belonging to lcmuk # 19/11/03 - Heiko - on lcmuk, mbuild does not tar the *.i files # 08/01/04 - Siggi - additional preprocessor directive for ibm included # (-D$OMP=OMP) in order to avoid problems with # OMP_NUM_THREADS # 09/01/04 - Siggi - action above cancelled # 28/01/04 - Siggi - action above re-cancelled # 08/03/04 - Siggi - host scirocco admitted # 26/03/04 - Siggi - .o and .mod files are also deleted in depository, if # the respective .f90 file is not listed in the makefile # and deletion is demanded by the user # 12/04/04 - Siggi - scp2 instead of scp used for transfer from decalpha # due to error in ssh installation (otherwise a prompt # for the password appears) # 23/07/04 - Siggi - changes due to the new berni configuration # (federation switch) # 08/09/04 - Siggi - hanni IP address changed to 130.75.4.10 # 23/09/04 - Joerg - correction of IP-Address for 'cross' (DKRZ) # 09/03/05 - Siggi - on nech, mbuild does not tar the *.i files # 31/03/05 - Siggi - mbuild does not tar *.i files any more # 24/04/05 - Siggi - netcdf support on lcmuk # 25/04/05 - Siggi - netcdf support on gfdl3 (decalpha) # 12/05/05 - Siggi - netcdf support on ibm # set OBJECT_MODE=64 for compiling on ibmb, ibmh # 18/05/05 - Siggi - netcdf support on nec # 19/05/05 - Siggi - IP addres 134.75.155.74 changed to 165.132.26.56 # 23/05/05 - Siggi - netcdf support on ibms # 01/06/05 - Siggi - reset of cpp_options to "" on lcmuk # 30/06/05 - Siggi - netcdf support on bora # 20/10/05 - Siggi - update of netcdf-version on decalpha (gfdl3) # 04/11/05 - Siggi - netcdf 3.6.0-p1 on ibmh/ibmb # 30/12/05 - Siggi - change of IP adresses in subnet 130.75.105 # host gfdl5 (ibmy) admitted # 10/01/06 - Siggi - cpp directive for NetCDF 64bit support # 20/01/06 - Siggi - cpp directive for ibmy # 09/02/06 - Marcus- compile only once on lcmuk (as on ibmh/ibmb) # 10/02/06 - Siggi - modifications for scp on decalpha # 13/04/06 - Siggi - ostria admitted # 19/04/06 - Siggi - preprocessor directive -D$OMP=OMP for ibm removed # 23/05/05 - Siggi - lctit (SUN Fire X4600) admitted # 29/05/05 - Siggi - atmos (lcide) admitted # 23/08/06 - Siggi - netcdf support for scirocco (notebook) # 24/11/06 - Siggi - breva and levanto admitted # 07/02/07 - Siggi - adapted for RIAM (neck) # 10/02/07 - Siggi - all hpmuk-related code removed # VARIABLENVEREINBARUNGEN + DEFAULTWERTE config_file=.mrun.config host=all host_found=false ibm_hb_done=false lcmuk_done=false locat=normal makefile="" remote_mode=interactive scirocco=false silent=false suf=f90 update=false typeset -i ih ihost=0 typeset -R50 calltime typeset -L20 column1 typeset -L50 column2 typeset -L70 column3 typeset -L20 version="MBUILD 1.0" # FEHLERBEHANDLUNG # BEI EXIT: trap 'if [[ $locat != normal ]] then printf "\n\n +++ mbuild killed \n\n" else printf "\n\n *** mbuild finished \n\n" fi' exit # BEI TERMINAL-BREAK: trap 'printf "\n\n +++ mbuild killed by \"^C\" \n\n" exit ' 2 # SHELLSCRIPT-OPTIONEN EINLESEN while getopts :c:h:m:rs: option do case $option in (c) config_file=$OPTARG;; (h) host=$OPTARG;; (m) makefile=$OPTARG;; (r) remote_mode=batch;; (s) suf=$OPTARG;; (\?) printf "\n +++ unknown option $OPTARG \n"; locat=parameter; exit;; esac done # BATCH-MODE IST ZUR ZEIT NICHT FUNKTIONSFAEHIG if [[ $remote_mode = batch ]] then printf "\n +++ sorry, batch mode does not work! \n" locat=parameter; exit fi # 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;; (gate) local_host=neck;; (gfdl3.yonsei.ac.kr) local_host=decalpha; local_addres=165.132.26.56;; (gfdl5) local_host=ibmy; local_addres=165.132.26.58;; (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 # PRUEFEN, OB KONFIGURATIONS-DATEI VORHANDEN if [[ ! -f $config_file ]] then printf "\n +++ configuration file: " printf "\n $config_file" printf "\n does not exist" locat=configuration; exit fi if [[ $local_host != ibms ]] then config_file=$PWD/$config_file else config_file=`pwd`/$config_file fi # BENUTZERNAMEN AUF LOKALEM RECHNER AUS KONFIGURATIONSDATEI ERMITTELN line="" grep " $local_host" $config_file | grep "%remote_username" | while read line do if [[ "$line" != "" || $(echo $line | cut -c1) != "#" ]] then local_username=`echo $line | cut -d" " -s -f2` fi done if [[ "$local_username" = "" ]] then printf "\n +++ no user name found in configuration file" printf "\n for local host \"$local_host\" " locat=config_file; exit fi # LOKALEN QUELLTEXTPFAD ERMITTELN. # ZUERST PRUEFEN, OB EIN GLOBALER QUELLTEXTPFAD FUER ALLE RECHNER # VEREINBART WURDE. # DAZU ZUNAECHST ALLE IN DER KONFIGURATIONSDATEI VEREINBARTEN GLOBALEN # VARIABLEN SETZEN, WEIL DIESE EVTL. IN PFADNAMEN VERWENDET WERDEN line="" grep "%" $config_file | while read line do if [[ "$line" != "" && "$(echo $line | cut -d" " -s -f3)" = "" ]] then var=`echo $line | cut -d" " -s -f1 | cut -c2-` value=`echo $line | cut -d" " -s -f2` eval export $var=\$value eval echo \" $var=\$$var \" fi done # NUN PRUEFEN, OB EIN GLOBALER QUELLTEXTPFAD VEREINBART WURDE line="" grep "%source_path" $config_file | while read line do if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] then if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]] then global_source_path=`echo $line | cut -d" " -s -f2` fi fi done line="" grep " $local_host" $config_file | grep "%source_path" | while read line do if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] then local_source_path=`echo $line | cut -d" " -s -f2` fi done if [[ "$local_source_path" = "" ]] then if [[ "$global_source_path" != "" ]] then local_source_path=$global_source_path else printf "\n +++ no source path found in configuration file" printf "\n for local host \"$local_host\" " printf "\n please set \"\%source_path\" in configuration file" locat=config_file; exit fi fi eval local_source_path=$local_source_path eval local_source_path=$local_source_path # EBENSO PFAD FUER DAS MAKE-DEPOSITORY ERMITTELN line="" grep "%depository_path" $config_file | while read line do if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] then if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]] then global_depository_path=`echo $line | cut -d" " -s -f2` fi fi done line="" grep " $local_host" $config_file | grep "%depository_path" | while read line do if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] then local_depository_path=`echo $line | cut -d" " -s -f2` fi done if [[ "$local_depository_path" = "" ]] then if [[ "$global_depository_path" != "" ]] then local_depository_path=$global_depository_path else printf "\n +++ no depository path found in configuration file" printf "\n for local host \"$local_host\" " printf "\n please set \"\%depository_path\" in configuration file" locat=config_file; exit fi fi eval local_depository_path=$local_depository_path eval local_depository_path=$local_depository_path # PRUEFEN, OB IN KONFIGURATIONSDATEI EIN HAUPTPROGRAMM # VEREINBART WURDE if [[ $(grep -c "%mainprog" $config_file) != 1 ]] then printf "\n +++ no main program or more than one main program defined" printf "\n in configuration file" locat=configuration; exit else line=`grep "%mainprog" $config_file` if [[ "$line" = "" || $(echo $line | cut -c1) = "#" ]] then printf "\n +++ no main program defined in configuration file" locat=configuration; exit fi mainprog=`echo $line | cut -d" " -s -f2 | cut -d"." -f1` fi # MAKEFILE vorhanden [[ "$makefile" = "" ]] && makefile=$local_source_path/Makefile if [[ ! -f $makefile ]] then printf "\n +++ makefile: " printf "\n $makefile" printf "\n does not exist" locat=makefile; exit fi # HEADER-AUSGABE (TEIL1: MELDUNGEN UEBER LOKALEN RECHNER) calltime=$(date) printf "\n" printf "#------------------------------------------------------------------------# \n" printf "| $version$calltime | \n" printf "| | \n" column1="called on:"; column2=$local_host_real_name printf "| $column1$column2 | \n" column1="local username:"; column2=$local_username printf "| $column1$column2 | \n" column1="local IP-addres:"; column2=$local_addres printf "| $column1$column2 | \n" column1="config file:"; column2=$config_file printf "| $column1$column2 | \n" column1="makefile:"; column2=$makefile printf "| $column1$column2 | \n" column1="local source path:"; column2=$local_source_path printf "| $column1$column2 | \n" column1="make depository:"; column2=$local_depository_path printf "| $column1$column2 | \n" printf "#------------------------------------------------------------------------# \n" # printf "| | \n" cd $local_source_path # LISTE DER ZU PRUEFENDEN QUELLTEXTDATEIEN ERSTELLEN source_code_files=`ls -1 *.$suf` # VERZEICHNIS FUER DAS MAKE-DEPOSITORY ERZEUGEN, # FALLS NOCH NICHT VORHANDEN. ANSONSTEN ALLE DATEIEN # NEUEREN DATUMS IN DIESES VERZEICHNIS KOPIEREN if [[ ! -d $local_depository_path ]] then if mkdir $local_depository_path then printf "\n\n *** directory for make depository:" printf "\n $local_depository_path" printf "\n was created\n" # MAKEFILE UND QUELLTEXTDATEIEN UNTER BEIBEHALTUNG # IHRES DATUMS INS VERZEICHNIS KOPIEREN printf "\n *** makefile and source code files are copied to" printf "\n $local_depository_path\n" printf "\n copying makefile \"$makefile\" ..." cp -p $makefile $local_depository_path/Makefile # QUELLTEXTDATEIEN MUESSEN IM MAKEFILE AUFGEFUEHRT # SEIN for filename in $source_code_files do if [[ $(grep -c $filename $makefile) = 0 ]] then printf "\n +++ source code file:" printf "\n $filename" printf "\n is not listed in makefile" locat=makefile; exit else printf "\n copying source code file \"$filename\" ..." cp -p $filename $local_depository_path fi done printf "\n" else printf "\n +++ directory for make depository:" printf "\n $local_depository_path" printf "\n cannot be created" locat=local_depository_path; exit fi else printf "\n *** checking file status ..." # MAKEFILE KOPIEREN, FALLS NEUEREN DATUMS if [[ $makefile -nt $local_depository_path/Makefile ]] then printf "\n *** update of \"$makefile\" " cp -f -p $makefile $local_depository_path/Makefile update=true # PRUEFEN, OB ALLE DATEIEN IM DEPOSITORY AUCH IM NEUEN MAKEFILE # VERZEICHNET SIND UND GEGEBENENFALLS DATEIEN LOESCHEN cd $local_depository_path source_code_files_in_depository=`ls -1 *.$suf` for filename in $source_code_files_in_depository do if [[ $(grep -c $filename Makefile) = 0 ]] then printf "\n *** source code file in \"$local_depository_path\":" printf "\n $filename" printf "\n is not listed in makefile" if [[ $silent = false ]] then answer=dummy printf "\n\n" while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] do printf " >>> delete \"$filename\" in \"$local_depository_path\" (y/n) ? " read answer done if [[ $answer = y || $answer = Y ]] then base=`echo $filename | cut -d. -f2` rm -f $filename rm -f ${base}.o ${base}.mod printf "\n *** \"$filename\" deleted in \"$local_depository_path\" " else printf "\n *** \"$filename\" not deleted in \"$local_depository_path\" " fi fi fi done cd - > /dev/null 2>&1 elif [[ $local_depository_path/Makefile -nt $makefile ]] then printf "\n *** makefile in depository is newer than" printf "\n \"$makefile\" " if [[ $silent = false ]] then answer=dummy printf "\n\n" while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] do printf " >>> update \"$makefile\" (y/n) ? " read answer done if [[ $answer = y || $answer = Y ]] then cp -f -p $local_depository_path/Makefile $makefile printf "\n *** \"$makefile\" updated" else printf "\n *** \"$makefile\" not updated" fi fi fi # QUELLTEXTDATEIEN KOPIEREN, FALLS NEUEREN DATUMS # SIE MUESSEN IM MAKEFILE AUFGEFUEHRT SEIN for filename in $source_code_files do if [[ $(grep -c $filename $makefile) = 0 ]] then printf "\n +++ source code file:" printf "\n $filename" printf "\n is not listed in makefile" locat=makefile; exit else if [[ ! -f $local_depository_path/$filename ]] then cp -p $filename $local_depository_path printf "\n *** source code file \"$filename\" created in \"$local_depository_path\" " fi if [[ $filename -nt $local_depository_path/$filename ]] then printf "\n *** update of source code file \"$filename\" " cp -f -p $filename $local_depository_path update=true fi fi done # PRUEFEN, OB ALLE DATEIEN IM DEPOSITORY IM AKTUELLEN ARBEITSVERZEICHNIS VORHANDEN # ODER EVTL. NEUEREN DATUMS SIND cd $local_depository_path source_code_files_in_depository=`ls -1 *.$suf` cd - > /dev/null 2>&1 for filename in $source_code_files_in_depository do if [[ ! -f $filename ]] then printf "\n *** source code file \"$filename\" does not exist in current directory" if [[ $silent = false ]] then answer=dummy printf "\n\n" while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] do printf " >>> create \"$filename\" in current directory (y/n) ? " read answer done if [[ $answer = y || $answer = Y ]] then cp -p $local_depository_path/$filename $filename printf "\n *** source code file \"$filename\" created in current directory" else printf "\n *** source code file \"$filename\" not created in current directory" fi fi elif [[ $local_depository_path/$filename -nt $filename ]] then ls -al $local_depository_path/$filename ls -al $filename printf "\n *** source code file \"$filename\" in depository is newer than in current directory" if [[ $silent = false ]] then answer=dummy printf "\n\n" while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] do printf " >>> update \"$filename\" in current directory (y/n) ? " read answer done if [[ $answer = y || $answer = Y ]] then cp -f -p $local_depository_path/$filename $filename printf "\n *** source code file \"$filename\" updated in current directory" else printf "\n *** source code file \"$filename\" not updated in current directory" fi fi fi done if [[ $update = false ]] then printf "\n *** no updates necessary in \"$local_depository_path\" " if [[ $silent = false ]] then answer=dummy printf "\n\n" while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] do printf " >>> continue with updates on remote hosts (y/n) ? " read answer done if [[ $answer = n || $answer = N ]] then locat=user_abort; exit fi fi fi fi # QUELLTEXTDATEIEN UND MAKEFILE MIT TAR ZUSAMMENBINDEN # IN JEDEM FALL ALLEN DATEIEN WRITE-PERMIT GEBEN, DAMIT ES AUF # DEN REMOTE-RECHNERN NICHT EVTL. ZU PROBLEMEN BEIM UEBERSCHREIBEN KOMMT printf "\n\n *** tar of makefile and source files in depository ..." cd $local_depository_path chmod u+w Makefile *.$suf tar -cf ${mainprog}_sources.tar Makefile *.$suf printf "\n" # BESTAETIGUNG ZUM WEITERMACHEN EINHOLEN if [[ $host = all ]] then printf "\n *** updates will be made for ALL hosts found in" printf "\n the configuration file" else printf "\n *** update will be made for host \"$host\" " fi if [[ $silent = false ]] then answer=dummy printf "\n\n" while [[ "$answer" != y && "$answer" != Y && "$answer" != n && "$answer" != N ]] do printf " >>> continue (y/n) ? " read answer done if [[ $answer = n || $answer = N ]] then locat=user_abort; exit fi fi # GENERIERUNG DER AKTUELLEN MODELLVERSION FUER ALLE RECHNER-/UEBERSETZUNGS- # VERSIONEN, DIE IN DER KONFIGURATIONSDATEI GEFUNDEN WERDEN printf "\n *** scanning configuration file for host(s) ..." grep %fopts $config_file | while read line do # KOMMENTARZEILEN UEBERSPRINGEN [[ $(echo $line | cut -c1) = "#" ]] && continue (( ihost = ihost + 1 )) hostline[$ihost]="$line" done while (( ih < ihost )) do (( ih = ih + 1 )) # REMOTE-RECHNER UND UEBERSETZUNGS-VERSION FESTSTELLEN # NUR WEITERMACHEN, WENN ENTSPRECHENDER REMOTE-RECHNER MITTELS # SHELLSCRIPT-OPTION AUCH AUSGEWAEHLT WURDE remote_host_string=`echo ${hostline[$ih]} | cut -d" " -s -f3-` remote_host=`echo $remote_host_string | cut -d" " -f1` if [[ $host != all ]] then [[ $remote_host != $host ]] && continue fi host_found=true condition1=`echo $remote_host_string | cut -d" " -s -f2` if [[ $condition1 = $remote_host ]] then condition1="" else condition2=`echo $remote_host_string | cut -d" " -s -f3` fi # AUF HLRN-RECHNER NUR EINMAL UEBERSETZEN if [[ $remote_host = ibmb || $remote_host = ibmh ]] then if [[ $ibm_hb_done = true ]] then printf "\n *** remote host \"$remote_host\" skipped since compilation has already" printf "\n been carried out on one of the HLRN machines\n" continue fi fi # AUF LCMUK-RECHNER NUR EINMAL UEBERSETZEN if [[ $remote_host = lcmuk ]] then if [[ $lcmuk_done = true ]] then printf "\n *** local host \"$remote_host\" skipped since compilation has already" printf "\n been carried out on this host\n" continue fi fi # IP-ADRESSE DES REMOTE-RECHNERS BESTIMMEN netcdf_support=false case $remote_host in (lcmuk) remote_addres=130.75.105.3; cpp_options="" netcdf_support=true if [[ $scirocco = true ]] then netcdf_path=/opt/netcdf/3.6.2-beta4 else netcdf_path=/muksoft/packages/netcdf/linux fi;; (lctit) remote_addres=172.17.75.161; netcdf_support=true netcdf_path=/home/usr5/mkanda/netcdf-3.6.1/src; cpp_options="-Mpreprocess";; (decalpha) remote_addres=165.132.26.56; cpp_options="-cpp"; netcdf_support=true netcdf_path=/usr/local/netcdf-3.5.1;; (ibm) remote_addres=134.76.99.81; cpp_options="-qsuffix=cpp=f90";; (ibmb) remote_addres=130.73.230.10; cpp_options="-qsuffix=cpp=f90"; netcdf_support=true netcdf_path=/aws/dataformats/netcdf-3.6.0-p1/64-32;; (ibmh) remote_addres=130.75.4.10; cpp_options="-qsuffix=cpp=f90"; netcdf_support=true netcdf_path=/aws/dataformats/netcdf-3.6.0-p1/64-32;; (ibms) remote_addres=150.183.5.101; cpp_options="-qsuffix=cpp=f90"; netcdf_support=true netcdf_path=/applic/lib/NETCDF64;; (ibmy) remote_addres=165.132.26.58; cpp_options="-qsuffix=cpp=f90"; netcdf_support=true netcdf_path=/usr1/users/raasch/pub/netcdf-3.6.0-p1;; (nech) remote_addres=136.172.44.192; cpp_options="-Ep"; netcdf_support=true netcdf_path=/pool/SX-6/netcdf/netcdf-3.6.0-p1;; (neck) remote_addres=133.5.178.11; cpp_options="-Ep"; netcdf_support=true netcdf_path=/home/DSRC/NC/tatuyama/pub/netcdf-3.6.0-p1;; (t3eb) remote_addres=130.73.206.21; cpp_options="-eZ";; (t3eh) remote_addres=130.75.4.131; cpp_options="-eZ";; (t3ej2) remote_addres=134.94.100.22; cpp_options="-eZ";; (t3ej5) remote_addres=134.94.100.49; cpp_options="-eZ";; (ground.yonsei.ac.kr) remote_addres=134.75.155.33;; (*) printf "\n +++ remote host \"$remote_host\" unknown"; printf "\n please inform S. Raasch!"; locat=config_file; exit;; esac # REMOTE-USERNAMEN ERMITTELN line="" grep "$remote_host_string" $config_file | grep "%remote_username" | while read line1 do if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] then line="$line1" fi done if [[ "$line" = "" || $(echo $line | cut -c1) = "#" ]] 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 # REMOTE-QUELLTEXTPFAD ERMITTELN line="" grep "$remote_host_string" $config_file | grep "%source_path" | while read line1 do if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] then line="$line1" fi done if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] then remote_source_path=`echo $line | cut -d" " -s -f2` fi if [[ "$remote_source_path" = "" ]] then if [[ "$global_source_path" != "" ]] then remote_source_path=$global_source_path else printf "\n +++ no source path found in configuration file" printf "\n for \"$remote_host_string\" " locat=config_file; exit fi fi # REMOTE-PFAD FUER MAKE-DEPOSITORY ERMITTELN line="" grep "$remote_host_string" $config_file | grep "%depository_path" | while read line1 do if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] then line="$line1" fi done if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] then remote_md=`echo $line | cut -d" " -s -f2` fi if [[ "$remote_md" = "" ]] then if [[ "$global_depository_path" != "" ]] then remote_md=$global_depository_path else printf "\n +++ no depository path found in configuration file" printf "\n for \"$remote_host_string\" " printf "\n please set \"\%depository_path\" in configuration file" locat=config_file; exit fi fi echo "### $remote_md" echo "### $base_directory" remote_md=$(eval echo $remote_md) # COMPILERNAMEN ERMITTELN line="" grep "$remote_host_string" $config_file | grep "%compiler_name" | while read line1 do if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] then line="$line1" fi done if [[ "$line" = "" || $(echo $line | cut -c1) = "#" ]] 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 # PRAEPROZESSOR-DIREKTIVEN SETZEN if [[ $(echo $remote_host | cut -c1-3) = ibm ]] then if [[ $remote_host = ibms ]] then cpp_options="$cpp_options -WF,-DMPI_REAL=MPI_DOUBLE_PRECISION" [[ $netcdf_support = true ]] && cpp_options="${cpp_options},-D__netcdf" else cpp_options="$cpp_options -WF,-DMPI_REAL=MPI_DOUBLE_PRECISION" [[ $netcdf_support = true ]] && cpp_options="${cpp_options},-D__netcdf,-D__netcdf_64bit" [[ $remote_host = ibmy ]] && cpp_options="${cpp_options},-D__ibmy_special" fi elif [[ $remote_host = lcmuk ]] then cpp_options="$cpp_options -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION" [[ $netcdf_support = true ]] && cpp_options="$cpp_options -D__netcdf -D__netcdf_64bit" elif [[ $remote_host = lctit ]] then cpp_options="$cpp_options -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION" [[ $netcdf_support = true ]] && cpp_options="$cpp_options -D__netcdf" elif [[ $remote_host = decalpha ]] then cpp_options="$cpp_options -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION" [[ $netcdf_support = true ]] && cpp_options="$cpp_options -D__netcdf" elif [[ $remote_host = nech || $remote_host = neck ]] then cpp_options="$cpp_options -DMPI_REAL=MPI_REAL8 -DMPI_2REAL=MPI_2REAL8 -DSCFFT=DZFFT -DCSFFT=ZDFFT" [[ $netcdf_support = true ]] && cpp_options="$cpp_options -D__netcdf -D__netcdf_64bit" fi if [[ $(echo $remote_host | cut -c1-3) = ibm ]] then for string in $remote_host_string do if [[ $(echo $string | cut -c1-3) = ibm ]] then cpp_options="${cpp_options},-D__ibm" if [[ $remote_host = ibmy ]] then cpp_options="${cpp_options},-D__ibmy_special" fi else cpp_options="${cpp_options},-D__$string" fi done cpp_options="$cpp_options " elif [[ $remote_host = nech || $remote_host = neck ]] then for string in $remote_host_string do if [[ $(echo $string | cut -c1-3) = nec ]] then cpp_options="${cpp_options} -D__nec" else cpp_options="${cpp_options} -D__$string" fi done cpp_options="$cpp_options " else for string in $remote_host_string do cpp_options="$cpp_options -D__$string " done fi # COMPILEROPTIONEN ERMITTELN line="" grep "$remote_host_string" $config_file | grep "%fopts" | while read line1 do if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] then line="$line1" fi done if [[ "$line" = "" || $(echo $line | cut -c1) = "#" ]] 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'` fi if [[ $netcdf_support = true ]] then case $remote_host in (decalpha) compiler_options="-I${netcdf_path}/include $compiler_options";; (ibmb|ibmh) compiler_options="-I ${netcdf_path}/include-64 $compiler_options";; (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}/f90 $compiler_options";; (nech|neck) compiler_options="-I ${netcdf_path}/include $compiler_options";; esac fi # LADER-OPTIONEN ERMITTELN line="" grep "$remote_host_string" $config_file | grep "%lopts" | while read line1 do if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]] then line="$line1" fi done if [[ "$line" = "" || $(echo $line | cut -c1) = "#" ]] 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'` 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}/libsrc -lnetcdf";; esac fi printf "\n\n#------------------------------------------------------------------------# \n" if [[ $remote_host = $local_host ]] then column1="remote_host:"; column2="$remote_host (= local host!)" else column1="remote_host:"; column2=$remote_host fi printf "| $column1$column2 | \n" printf "| | \n" column1="conditions:"; column2="$condition1 $condition2" printf "| $column1$column2 | \n" column1="make depository:"; column2=$remote_md printf "| $column1$column2 | \n" column1="username:"; column2=$remote_username printf "| $column1$column2 | \n" column1="addres:"; column2=$remote_addres printf "| $column1$column2 | \n" column1="compiler:"; column2=$compiler_name printf "| $column1$column2 | \n" column1="cpp options:"; column2=$cpp_options printf "| $column1$column2 | \n" line=$(echo "$cpp_options" | cut -c51-) while [[ "$line" != "" ]] do column1="" column2=$line printf "| $column1$column2 | \n" line=$(echo "$line" | cut -c51-) done column1="compiler options:"; column2=$compiler_options printf "| $column1$column2 | \n" line=$(echo "$compiler_options" | cut -c51-) while [[ "$line" != "" ]] do column1="" column2=$line printf "| $column1$column2 | \n" line=$(echo "$line" | cut -c51-) done column1="loader options:"; column2=$loader_options printf "| $column1$column2 | \n" line=$(echo "$loader_options" | cut -c51-) while [[ "$line" != "" ]] do column1="" column2=$line printf "| $column1$column2 | \n" line=$(echo "$line" | cut -c51-) done printf "#------------------------------------------------------------------------# \n" if [[ $silent = false ]] then answer=dummy printf "\n\n" while [[ "$answer" != y && "$answer" != Y && "$answer" != c && "$answer" != C && "$answer" != s && "$answer" != S && "$answer" != a && "$answer" != A ]] do printf " >>> continue (y(es)/c(ontinue)/a(bort)/s(skip)) ? " read answer done if [[ $answer = a || $answer = A ]] then locat=user_abort; exit fi if [[ $answer = c || $answer = C ]] then silent=false fi if [[ $answer = s || $answer = S ]] then continue fi fi if [[ $remote_mode = batch ]] then # BATCH-JOB PARAMETER SETZEN case $remote_host in (t3eb) queue=berte; memory=60; cputime=1000; xoption="-X 0";; (t3eh) queue=comp_t3e; memory=60; cputime=360;; (t3ej2) queue=normal; memory=60; cputime=1000; xoption="-X 0";; (t3ej5|ground.yonsei.ac.kr) printf "\n --- remote host \"$remote_host\" does not allow batch jobs"; continue;; esac # BATCH-JOB ZUSAMMENSTELLEN printf "\n *** creating batch-job for remote host" echo " " > mbuild_job # AUF CRAY-RECHNERN IN JUELICH WIRD KEIN BENUTZER-PROFILE AUSGEFUEHRT # DIES WIRD HIER GETAN, UM PFADE USW. ZU SETZEN if [[ $remote_host = t3ej2 ]] then echo "set +vx" >> mbuild_job echo ". .profile" >> mbuild_job echo "set -x" >> mbuild_job fi # AUF CRAY-RECHNERN GELADENE MODULE AUFLISTEN if [[ $host = t3eb || $host = t3eh || $host = t3ej2 ]] then echo "module list" >> mbuild_job fi # WECHSEL IN TEMPORAERES VERZEICHNIS echo "cd ${remote_md}" >> mbuild_job # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN echo "scp ${local_username}@${local_addres}:~/modell/code_3dp/palm_current_version/${mainprog}_sources.tar ${mainprog}_sources.tar" >> mbuild_job # echo "[[ \$? != 0 ]] && (echo "+++ scp failed"; exit)" >> mbuild_job # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN echo "[[ -f ${mainprog}_current_version.tar ]] && tar -xvf ${mainprog}_current_version.tar" >> mbuild_job # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN echo "tar -xvf ${mainprog}_sources.tar" >> mbuild_job # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN echo "make PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " >> mbuild_job echo "chmod u+w *" >> mbuild_job # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN echo "tar -cvf ${mainprog}_current_version.tar *.f90 *.o" >> mbuild_job # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN echo "make clean" >> mbuild_job echo "rm ${mainprog}_sources.tar" >> mbuild_job echo "rm *.f90 Makefile" >> mbuild_job # JOB MITTELS SUBJOB STARTEN printf "\n *** sending batch job to remote host" # subjob $xoption -h $remote_host -q $queue -m $memory -t $cputime -v mbuild_job # JOBFILE LOESCHEN # rm aljob else if [[ $remote_host != $local_host ]] then # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT echo " *** copying \"${mainprog}_sources.tar\" to \"${remote_addres}:${remote_md}/\" " if [[ $remote_host != lctit ]] then ssh ${remote_username}@${remote_addres} "[[ ! -d ${remote_md} ]] && (echo \" *** ${remote_md} will be created\"; mkdir -p ${remote_md})" else # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS # MIT SSH, DESHALB AUFRUF PER PIPE print "[[ ! -d ${remote_md} ]] && (echo \" *** ${remote_md} will be created\"; mkdir -p ${remote_md})" | ssh ${remote_username}@${remote_addres} 2>&1 fi if [[ $local_host = decalpha ]] then # DECALPHA BENUTZT BEI NICHTANGABE DES VOLLSTÄNDIGEN PFADES # IRGENDEIN ANDERES SCP (WAS NICHT FUNKTIONIERT). AUSSERDEM # KOENNEN DOLLAR-ZEICHEN NICHT BENUTZT WERDEN remote_md=`echo $remote_md | sed 's/\$HOME\///'` /bin/scp ${mainprog}_sources.tar ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar else scp ${mainprog}_sources.tar ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar fi # FALLS VORHANDEN, LETZTE VERSION AUF DEM REMOTE-RECHNER AUSPACKEN echo " *** untar previous update on remote host, if existing" if [[ $remote_host != lctit ]] then ssh ${remote_username}@${remote_addres} "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]] && tar -xf ${mainprog}_current_version.tar" else # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS # MIT SSH, DESHALB AUFRUF PER PIPE print "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]] && tar -xf ${mainprog}_current_version.tar" | ssh ${remote_username}@${remote_addres} 2>&1 fi # AKTUELLE QUELLTEXTVERSION AUF REMOTE-RECHNER AUSPACKEN echo " *** untar actual sources on remote host" if [[ $remote_host != lctit ]] then ssh ${remote_username}@${remote_addres} "cd ${remote_md}; tar -xf ${mainprog}_sources.tar" else # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS # MIT SSH, DESHALB AUFRUF PER PIPE print "cd ${remote_md}; tar -xf ${mainprog}_sources.tar" | ssh ${remote_username}@${remote_addres} 2>&1 fi # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF REMOTE RECHNER AUSFUEHREN # KOMMANDOUEBERGABE AN SSH PER PIPE, DA SO DIE SYSTEM- UND # BENUTZERPROFILE VOLLSTAENDIG AUSGEFUEHRT WERDEN (SONST FEHLEN MAKE # Z.B. DIE PFADE ZUM COMPILER) echo " *** execute \"make\" on remote host" if [[ $remote_host = nech ]] then make_call_string="sxmake PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " else make_call_string="make PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " fi if [[ $remote_host = t3eh ]] then print "xterm\nexit\n cd ${remote_md}; make PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " | ssh ${remote_username}@${remote_addres} 2>&1 | tee ${remote_host}_last_make_protokoll elif [[ $remote_host = t3ej2 || $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 elif [[ $remote_host = ibmb || $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 elif [[ $remote_host = lctit ]] then echo " " > ${remote_host}_last_make_protokoll while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]] do 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 done 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 fi if [[ $(grep -c MAKE_ERROR ${remote_host}_last_make_protokoll) != 0 ]] then printf "\a\n +++ error(s) occurred during compiling or linking on host \"$remote_host\" " if [[ $silent = false ]] then answer=dummy printf "\n" while [[ "$answer" != c && "$answer" != k ]] do printf " >>> continue / list errors / kill mbuild (c/l/k) ? " read answer if [[ "$answer" = l ]] then more ${remote_host}_last_make_protokoll fi done if [[ $answer = k ]] then locat=user_abort; exit fi fi fi # NEUE VERSION AUF REMOTE-RECHNER ZUSAMMENPACKEN printf "\n *** tar update on remote host ..." if [[ $remote_host != lctit ]] then ssh ${remote_username}@${remote_addres} "cd ${remote_md}; chmod u+w *; tar -cf ${mainprog}_current_version.tar *.f90 *.o *.mod" else # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS # MIT SSH, DESHALB AUFRUF PER PIPE print "cd ${remote_md}; chmod u+w *; tar -cf ${mainprog}_current_version.tar *.f90 *.o *.mod" | ssh ${remote_username}@${remote_addres} 2>&1 fi # AKTUELLES VERSIONSVERZEICHNIS AUF REMOTE-RECHNER BEREINIGEN # printf "\n *** \"make clean\" on remote host ..." # ssh ${remote_username}@${remote_addres} "cd ${remote_md}; make clean; rm ${mainprog}_sources.tar; rm *.f90 Makefile" # printf "\n" # NUR AUF EINEM HLRN-RECHNER UEBERSETZEN [[ $remote_host = ibmb || $remote_host = ibmh ]] && ibm_hb_done=true else # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF LOKALEM RECHNER AUSFUEHREN echo " *** execute \"make\" on local host" make PROG=$mainprog F90=$compiler_name COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$loader_options" 2>&1 | tee ${remote_host}_last_make_protokoll if [[ $? != 0 ]] then printf "\a\n +++ error(s) occurred during compiling or linking on host \"$remote_host\" " if [[ $silent = false ]] then answer=dummy printf "\n" while [[ "$answer" != c && "$answer" != k ]] do printf " >>> continue / list errors / kill mbuild (c/l/k) ? " read answer if [[ "$answer" = l ]] then more ${remote_host}_last_make_protokoll fi done if [[ $answer = k ]] then locat=user_abort; exit fi fi fi # NEUE VERSION AUF LOKALEM RECHNER ZUSAMMENPACKEN printf "\n *** tar update on local host ..." tar -cf ${mainprog}_current_version.tar *.$suf *.o *.mod # NUR EINMAL AUF LCMUK UEBERSETZEN [[ $remote_host = lcmuk ]] && lcmuk_done=true fi fi done if [[ $host_found = false ]] then if [[ $host = all ]] then printf "\n +++ no hosts found in configuration file" else printf "\n +++ host \"$host\" not found in configuration file" fi locat=config_file; exit fi # ABSCHLIESSENDE ARBEITEN rm -f hosts_found_in_config_file