#!/bin/ksh # mbuild - script for compiling the PALM code and its utility programs #--------------------------------------------------------------------------------# # This file is part of PALM. # # PALM is free software: you can redistribute it and/or modify it under the terms # of the GNU General Public License as published by the Free Software Foundation, # either version 3 of the License, or (at your option) any later version. # # PALM is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # PALM. If not, see . # # Copyright 1997-2012 Leibniz University Hannover #--------------------------------------------------------------------------------# # # Current revisions: # ------------------ # # # Former revisions: # ----------------- # $Id: mbuild 1256 2013-11-07 14:46:21Z heinze $ # # 1255 2013-11-07 14:43:35Z raasch # further adjustments for lccrayb remote access # # 1229 2013-09-20 06:55:19Z raasch # adjustments for lccrayb # # 1216 2013-08-26 09:31:42Z raasch # RCS renamed SOURCES # # 1210 2013-08-14 10:58:20Z raasch # fftw support added # # 1197 2013-07-04 06:19:45Z raasch # adjustments for CSC Helsinki (lccrayf) # # 1099 2013-02-10 01:47:43Z raasch # adjustments for Forwind cluster (lcflow) # # 1096 2013-02-03 01:52:12Z raasch # decalpha parts (yonsei) removed # # 2013-02-02 07:06:13Z raasch # adjustments for Kyushu-University computing center (lckyut) # old changelog messages removed # # 1083 2013-01-04 10:22:09Z maronga # bugfix in parameter file check (in case that no preprocessor flag, i.e. -cpp was # set in %cpp_options, the last directive in the variable was processed. # # 1081 2013-01-03 08:44:36Z maronga # loader options set for parameter file check_depository_path # # 1069 2012-11-28 16:18:43Z maronga # added copy of nc2vdf tools to remote host_found # # 1046 2012-11-09 14:38:45Z maronga # code put under GPL (PALM 3.9) # # 12/06/02 - Siggi - first version finished # 06/05/02 - Siggi - script development started # #--------------------------------------------------------------------------------# # mbuild - script for compiling the PALM code and its utility programs # # Procedure to compile code on local and remote hosts using the # make-mechanism. The source code must be provided on the local host. #--------------------------------------------------------------------------------# # VARIABLE DECLARATIONS + DEFAULT VALUES block_conditions=none block_conditions_found=false compile_utility_programs=false config_file=.mrun.config fimm=false host=all host_found=false locat=normal makefile="" module_calls="" util_compiled_localhost=false scirocco=false silent=false suf=f90 update=false working_directory=`pwd` typeset -i ih ihost=0 typeset -R30 calltime typeset -L20 column1 typeset -L50 column2 typeset -L70 column3 typeset -L40 version="MBUILD 2.1 Rev$Rev: 1256 $" # ERROR HANDLING # IN CASE OF EXIT: trap 'rm -rf $working_directory/tmp_mbuild if [[ $locat != normal ]] then printf "\n\n +++ mbuild killed \n\n" else printf "\n\n *** mbuild finished \n\n" fi' exit # IN CASE OF TERMINAL-BREAK: trap 'rm -rf $working_directory/tmp_mbuild printf "\n\n +++ mbuild killed by \"^C\" \n\n" exit ' 2 tmp_mbuild=${working_directory}/tmp_mbuild # READ SHELLSCRIPT-OPTIONS while getopts :c:h:K:m:s:uv option do case $option in (c) config_file=$OPTARG;; (h) host=$OPTARG;; (K) block_conditions=$OPTARG;; (m) makefile=$OPTARG;; (s) suf=$OPTARG;; (u) compile_utility_programs=true;; (v) silent=true;; (\?) printf "\n +++ unknown option $OPTARG \n"; locat=parameter; exit;; esac done # CHECK, IF CONFIGURATION-FILE EXISTS if [[ ! -f $config_file ]] then printf "\n +++ configuration file: " printf "\n $config_file" printf "\n does not exist" locat=configuration; exit fi # DETERMINE THE LOCAL HOST local_host_real_name=$(hostname) # local_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}') # DETERMINE HOST-IDENTIFIER (local_host) FROM THE CONFIG-FILE 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 [[ $local_host_real_name = $HOSTNAME ]] 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 \"" printf "\n to the configuration file." locat=local_host; exit fi [[ $local_host_real_name = scirocco ]] && scirocco=true [[ $local_host_real_name = fimm.bccs.uib.no ]] && fimm=true if [[ $local_host != ibms ]] then config_file=$PWD/$config_file else config_file=`pwd`/$config_file fi # determine the block conditions if [[ $block_conditions != none ]] then block_condition1=`echo $block_conditions | cut -d" " -f1` block_condition2=`echo $block_conditions | cut -d" " -f2` if [[ "$block_condition2" = "$block_condition1" ]] then block_condition2="" fi fi # DETERMINE USER NAME ON LOCAL HOST FROM THE CONFIG-FILE line="" grep " $local_host" $config_file | grep "%remote_username" > $tmp_mbuild while read line do if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] then local_username=`echo $line | cut -d" " -s -f2` fi done < $tmp_mbuild 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 # DETERMINE LOCAL SOURCE-CODE PATH. # FIRST CHECK, IF A GLOBAL SOURCE-CODE PATH HAS BEEN DECLARED FOR ALL HOSTS. # THEREFORE, FIRST SET ALL GLOBAL VARIABLES DECLARED IN THE CONFIG-FILE, # BECAUSE THEY MAY BE USED AS PART OF THE PATH NAME. line="" grep "%" $config_file > $tmp_mbuild while read line do if [[ "$line" != "" && "$(echo $line | cut -d" " -s -f3)" = "" && $(echo $line | cut -c1) != "#" ]] then var=`echo $line | cut -d" " -s -f1 | cut -c2-` value=`echo $line | cut -d" " -s -f2` eval export $var=\$value fi done < $tmp_mbuild # NOW CHECK, IF A GLOBAL SOURCE-CODE-PATH HAS BEEN DECLARED line="" grep "%source_path" $config_file > $tmp_mbuild 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 < $tmp_mbuild line="" grep " $local_host" $config_file | grep "%source_path" > $tmp_mbuild while read line do if [[ "$line" != "" && $(echo $line | cut -c1) != "#" ]] then local_source_path=`echo $line | cut -d" " -s -f2` fi done < $tmp_mbuild 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 # DETERMINE GLOBAL DEPOSITORY-PATH line="" grep "%depository_path" $config_file > $tmp_mbuild 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 < $tmp_mbuild if [[ $found = false ]] then printf "\n +++ no \%depository_path found in" printf "\n $config_file" locat=depository_path; exit fi # CHECK, IF A MAIN PROGRAM HAS BEEN DEFINED IN THE CONFIG-FILE 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 # CHECK IF MAKEFILE EXITS [[ "$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-OUTPUT (PART1: MESSAGES CONCERNING THE LOCAL HOST) 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" printf "#------------------------------------------------------------------------# \n" # printf "| | \n" if [[ $compile_utility_programs = false ]] then # IN ANY CASE, GIVE ALL FILES WRITE-PERMIT, IN ORDER TO AVOID PROBLEMS # WITH OVERWRITING FILES ON THE REMOTE HOST cd $local_source_path printf "\n\n *** tar of makefile and source files in $local_source_path" tar -cf ${mainprog}_sources.tar Makefile *.$suf printf "\n" else cd $local_source_path printf "\n\n *** tar of makefile and source files in $local_source_path" cat Makefile_check|while read line do line=$(echo $line|grep SOURCES) if [[ $line == *"SOURCES"* ]] then line=$(echo $line|sed 's/SOURCES = //g') break fi done tar -cf ${mainprog}_sources_check.tar Makefile_check $line printf "\n" fi # GET CONFIRMATION TO CONTINUE 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 > $tmp_mbuild while read line do # KOMMENTARZEILEN UEBERSPRINGEN [[ $(echo $line | cut -c1) = "#" ]] && continue (( ihost = ihost + 1 )) hostline[$ihost]="$line" done < $tmp_mbuild while (( ih < ihost )) do (( ih = ih + 1 )) # determine remote host and conditions for the respective block # continue, only if this host has been chosen via -h option and if # conditions have been chosen via -K option 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 if [[ $block_conditions != none ]] then if [[ "$condition1" != "$block_condition1" || "$condition2" != "$block_condition2" ]] then continue fi block_conditions_found=true fi fftw_inc="" fftw_lib="" modules="" netcdf_inc="" netcdf_lib="" make_options="" # IP-ADRESSE DES REMOTE-RECHNERS BESTIMMEN case $remote_host in (lccrayb) remote_addres=130.73.233.1;; (lcflow) remote_addres="flow.hpc.uni-oldenburg.de";; (lckordi) remote_adress=210.219.61.8;; (lcmuk) remote_addres=130.75.105.2;; (lcrte) remote_addres=133.5.185.60;; (lcsb) remote_addres=147.46.30.151;; (lcsgib) remote_addres=130.73.232.102;; (lcsgih) remote_addres=130.75.4.101;; (lck) remote_addres=165.132.26.61;; (lckiaps) remote_addres=118.128.66.223;; (lckyut) remote_addres=133.5.4.37;; (lctit) remote_addres=10.1.6.170;; (lcxe6) remote_addres=129.177.20.113;; (lcxt5m) remote_addres=193.166.211.144;; (ibmh) remote_addres=136.172.40.15;; (ibmkisti) remote_addres=150.183.146.24;; (ibmku) remote_addres=133.5.4.129;; (ibms) remote_addres=150.183.5.101;; (ibmy) remote_addres=165.132.26.58;; (nech) remote_addres=136.172.44.192;; (neck) remote_addres=133.5.178.11;; (ground.yonsei.ac.kr) remote_addres=134.75.155.33;; (*) if [[ $local_host != $remote_host ]] then printf "\n +++ remote host \"$remote_host\" unknown"; printf "\n please inform PALM group support!" locat=remote_host; exit fi;; esac # 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 [[ $found = false ]] then printf "\n +++ no remote username found in configuration file" printf "\n for \"$remote_host_string\" " locat=config_file; exit fi # REMOTE-QUELLTEXTPFAD ERMITTELN line="" remote_source_path="" grep "$remote_host_string" $config_file | grep "%source_path" > $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_source_path=`echo $line | cut -d" " -s -f2` fi done < $tmp_mbuild 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_ud=${remote_source_path}/../UTIL remote_ud=$(eval echo $remote_ud) # REMOTE-PFAD FUER MAKE-DEPOSITORY ERMITTELN remote_md="" line="" grep "$remote_host_string" $config_file | grep "%depository_path" > $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_md=`echo $line | cut -d" " -s -f2` fi done < $tmp_mbuild 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 remote_md=$(eval echo $remote_md) block="" [[ "$condition1" != "" ]] && block=_$condition1 [[ "$condition2" != "" ]] && block=${block}_$condition2 remote_md=${remote_md}$block # 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 [[ $found = false ]] then printf "\n +++ no compiler name found in configuration file" printf "\n for \"$remote_host_string\" " locat=config_file; exit fi # BEI BENUTZUNG EINES PARALLELEN COMPILERS MUSS AUCH EIN # SERIELLER COMPILERNAME ERMITTELT WERDEN if [[ $(echo $remote_host_string | grep -c parallel) = 1 ]] 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 [[ $found = false ]] then printf "\n +++ no serial compiler name found in configuration file" printf "\n for \"$remote_host_string\" " locat=config_file; exit fi else compiler_name_ser=$compiler_name fi # 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 [[ $found = false ]] then printf "\n +++ no preprocessor options found in configuration file" printf "\n for \"$remote_host_string\" " locat=config_file; exit 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 " elif [[ $(echo $remote_host | cut -c1-3) = ibm && $(echo $string | cut -c1-3) = ibm ]] then cpp_options="${cpp_options},-D__ibm" elif [[ $(echo $remote_host | cut -c1-3) = nec && $(echo $string | cut -c1-3) = nec ]] then cpp_options="${cpp_options} -D__nec" else if [[ $(echo $remote_host | cut -c1-3) = ibm ]] then cpp_options="${cpp_options},-D__$string" else cpp_options="$cpp_options -D__$string " fi fi done # get netCDF options 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 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 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 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 # get fftw options line="" grep "$remote_host_string" $config_file | grep "%fftw_inc" > $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 fftw_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` fi done < $tmp_mbuild line="" grep "$remote_host_string" $config_file | grep "%fftw_lib" > $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 fftw_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` fi done < $tmp_mbuild # get make options line="" found=false grep "$remote_host_string" $config_file | grep "%mopts" > $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 # remove colons from directive string make_options=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` fi done < $tmp_mbuild # 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 # add include paths for netCDF and fftw compiler_options="$compiler_options $netcdf_inc $fftw_inc" fi done < $tmp_mbuild if [[ $found = false ]] then printf "\n +++ no compiler options found in configuration file" printf "\n for \"$remote_host_string\" " locat=config_file; exit fi # get login init commands, "::" is replacing a space line="" grep "$remote_host_string" $config_file | grep "%login_init_cmd" > $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 init_cmds=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` init_cmds="${init_cmds};" fi done < $tmp_mbuild # get modules to be loaded line="" grep "$remote_host_string" $config_file | grep "%modules" > $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 modules=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'` fi done < $tmp_mbuild # 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 # add netCDF- and fftw-library loader_options="$loader_options $netcdf_lib $fftw_lib" fi done < $tmp_mbuild if [[ $found = false ]] then printf "\n +++ no loader options found in configuration file" printf "\n for \"$remote_host_string\" " locat=config_file; exit 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" line=$(echo "$remote_md" | cut -c51-) while [[ "$line" != "" ]] do column1="" column2=$line printf "| $column1$column2 | \n" line=$(echo "$line" | cut -c51-) done if [[ $compile_utility_programs = true ]] then column1="utility directory:"; column2=$remote_ud printf "| $column1$column2 | \n" fi 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" if [[ $compile_utility_programs = true ]] then column1="serial compiler:"; column2=$compiler_name_ser printf "| $column1$column2 | \n" fi if [[ "$make_options" != "" ]] then column1="make options:"; column2=$make_options printf "| $column1$column2 | \n" fi 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 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" 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=true fi if [[ $answer = s || $answer = S ]] then continue fi fi # make on remote host if [[ $remote_host != $local_host ]] then if [[ $compile_utility_programs = false ]] 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 scp ${local_source_path}/${mainprog}_sources.tar ${remote_username}@${remote_addres}:${remote_md}/${mainprog}_sources.tar # 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" # generate make call with make options if [[ $remote_host = nech ]] then make_call_string="sxmake $make_options PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " else make_call_string="make $make_options PROG=$mainprog F90=$compiler_name COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " fi # generate command to load modules, if modules are given if [[ "$modules" != "" ]] then if [[ $remote_host = lctit ]] then module_calls=". $modules" else module_calls="module load ${modules};" fi # bugfix for wrong netcdf module if [[ $remote_host = lcsgib || $remote_host = lcsgih ]] then if [[ $(echo $module_calls | grep -c netcdf/3.6.3-intel) != 0 ]] then module_calls="$module_calls export LD_LIBRARY_PATH=/sw/dataformats/netcdf/3.6.3-intel/lib:\$LD_LIBRARY_PATH;" fi fi else module_calls="" fi if [[ $remote_host = ibmkisti || $remote_host = ibms || $remote_host = ibmy ]] then ssh ${remote_username}@${remote_addres} "$init_cmds $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 "$init_cmds $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_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 print "$init_cmds $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 ]] 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 elif [[ $remote_host = lcxe6 ]] then ssh ${remote_username}@${remote_addres} "$init_cmds $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 else print "$init_cmds $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 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 ${mainprog} *.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 ${mainprog} *.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" # GLEICHE AKTIONEN FUER DIE UTILITY-PROGRAMME DURCHFUEHREN # AKTUELLE QUELLTEXTVERSION INS REMOTE-QUELLTEXTVERZEICHNIS KOPIEREN # FALLS DIESES NOCH NICHT EXISTIERT, WIRD ES ERZEUGT elif [[ $compile_utility_programs = true ]] then printf "\n\n" echo " *** copying scripts and utility programs to \"${remote_addres}:${remote_ud}/\" " cd ${local_source_path}/../SCRIPTS if [[ $remote_host != lctit ]] then ssh ${remote_username}@${remote_addres} "[[ ! -d ${remote_ud} ]] && (echo \" *** ${remote_ud} will be created\"; mkdir -p ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]] && (echo \" *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p ${remote_ud}/../SCRIPTS)" else # TIT ERLAUBT NUR DIE AUSFUEHRUNG GANZ BESTIMMTER KOMMANDOS # MIT SSH, DESHALB AUFRUF PER PIPE print "[[ ! -d ${remote_ud} ]] && (echo \" *** ${remote_ud} will be created\"; mkdir -p ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]] && (echo \" *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p ${remote_ud}/../SCRIPTS)" | ssh ${remote_username}@${remote_addres} 2>&1 fi # KOPIEREN DER SCRIPTE scp batch_scp mbuild mrun process_dvr_output .dvrserver.config subjob batch_nc2vdf nc2vdf nc2vdf.ncl nc2vdf.config ${remote_username}@${remote_addres}:${remote_ud}/../SCRIPTS > /dev/null cd - > /dev/null cd ${local_source_path}/../UTIL # KOPIEREN DER UTILITY-PROGRAMME scp Makefile *.f90 ${remote_username}@${remote_addres}:${remote_ud} > /dev/null # 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 $make_options BLOCK=$block F90=$compiler_name F90_SER=$compiler_name_ser COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " else make_call_string="make $make_options BLOCK=$block F90=$compiler_name F90_SER=$compiler_name_ser COPT=\"$cpp_options\" F90FLAGS=\"$compiler_options\" LDFLAGS=\"$loader_options\" " fi # generate command to load modules, if modules are given if [[ "$modules" != "" ]] then if [[ $remote_host = lctit ]] then module_calls=". $modules" else module_calls="module load ${modules};" fi # bugfix for wrong netcdf module if [[ $remote_host = lcsgib || $remote_host = lcsgih ]] then if [[ $(echo $module_calls | grep -c netcdf/3.6.3-intel) != 0 ]] then module_calls="$module_calls export LD_LIBRARY_PATH=/sw/dataformats/netcdf/3.6.3-intel/lib:\$LD_LIBRARY_PATH;" fi fi else module_calls="" fi if [[ $remote_host = ibms || $remote_host = ibmy ]] then ssh ${remote_username}@${remote_addres} "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" elif [[ $remote_host = ibmh ]] then print "$init_cmds $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 ]] then echo " " > ${remote_host}_last_make_protokoll while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]] do print "$init_cmds $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 elif [[ $remote_host = lcxe6 ]] then ssh ${remote_username}@${remote_addres} "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" 2>&1 | tee ${remote_host}_last_make_protokoll else print "$init_cmds $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 fi # ENDE UEBERSETZUNG DER UTILITY-PROGRAMME rm -rf ${remote_host}_last_make_protokoll # make on local host else # workaround for lcxe6 if [[ $remote_host = lcxe6 || $remote_host = lccrayb || $remote_host = lccrayf ]] then eval $init_cmds > /dev/null 2>&1 fi # first load modules, if given if [[ "$modules" != "" ]] then if [[ $remote_host = lctit ]] then . $modules elif [[ $remote_host = lcflow ]] then eval `$MODULESHOME/bin/modulecmd ksh load ${modules}` else module load ${modules} fi fi if [[ $compile_utility_programs = false ]] then # DEPOSITORY VERZEICHNIS ERZEUGEN, FALLS NOCH NICHT VORHANDEN eval remote_md=$remote_md if [[ ! -d $remote_md ]] then if mkdir $remote_md then printf "\n\n *** directory for make depository:" printf "\n $remote_md" printf "\n was created\n" else printf "\n +++ directory for make depository:" printf "\n $remote_md" printf "\n cannot be created" locat=local_depository_path; exit fi fi # QUELLTEXT-DATEIEN AUS REPOSITORY INS DEPOSITORY KOPIEREN echo " " echo " *** updating sources in $remote_md" cd $remote_md cp $local_source_path/${mainprog}_sources.tar . tar xf ${mainprog}_sources.tar # MAKE MIT ZUVOR ERMITTELTEN OPTIONEN AUF LOKALEM RECHNER AUSFUEHREN echo " " echo " *** execute \"make\" on local host" 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 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 # TAR NEW VERSION ON LOCAL HOST printf "\n *** tar update on local host ..." tar -cf ${mainprog}_current_version.tar *.$suf *.o *.mod # COMPILE THE UTILITY PROGRAMS elif [[ $compile_utility_programs = true ]] then printf "\n\n" echo " *** compiling the utility programs ..." cd ${local_source_path}/../UTIL # TOUCH FILES IN ORDER TO FORCE COMPILATION FOR EVERY BLOCK touch *.f90 make $make_options BLOCK=$block F90=$compiler_name F90_SER=$compiler_name_ser COPT="$cpp_options" F90FLAGS="$compiler_options" LDFLAGS="$loader_options" # CHECK IF QMAKE IS AVAILABLE AND COMPILE MRUNGUI if [[ $util_compiled_localhost == false ]] then printf "\n\n" echo " *** compiling the mrun GUI" if which qmake >/dev/null; then cd mrungui touch * qmake make make clean rm Makefile cd .. else echo " +++ no qmake found. The (optional) GUI will not be compiled." fi # COMPILE CHECK_NAMELIST_FILES (ONLY FOR ONE BRANCH on LOCALHOST NEEDED) printf "\n\n" echo " *** compiling check_namelist_files ..." # GET CHECK OPTIONS 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 UND ALLE -D ENTFERNEN line="$line " copts_check=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g' | sed 's/-D[^ ]* //g' | sed 's/ -D.*//g'` found=true fi done < $tmp_mbuild copts_check="$copts_check -D__check -D__parallel" check_depository_path=${local_source_path}/../UTIL cd $check_depository_path mkdir check_tmp cp ${local_source_path}/${mainprog}_sources_check.tar ./check_tmp cd check_tmp tar -xf ${mainprog}_sources_check.tar rm -rf ${mainprog}_sources_check.tar make -f Makefile_check $make_options F90=$compiler_name_ser COPT="$copts_check" F90FLAGS="$compiler_options" tar -cf check_namelist_files.tar Makefile_check check_namelist_files.x *.f90 *.o *.mod mv check_namelist_files.tar $check_depository_path mv check_namelist_files.x $PALM_BIN cd $check_depository_path rm -rf check_tmp util_compiled_localhost=true else cd $check_depository_path printf "\n\n" echo " *** skipped compilation of mrun GUI." printf "\n\n" echo " *** skipped compilation of check_namelist_files." fi 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 if [[ "$block_conditions" != none && $block_conditions_found = false ]] then printf "\n +++ block conditions \"$block_conditions\" not found for host \"$host\"" fi # FINAL WORK rm -f hosts_found_in_config_file rm -f ${local_source_path}/${mainprog}_sources_check.tar