Ignore:
Timestamp:
Sep 29, 2017 8:30:37 AM (7 years ago)
Author:
raasch
Message:

new options -V and -W plus other small changes in PALM scripts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/palmbuild

    r2500 r2506  
    2727# -----------------
    2828# $Id$
     29# option -V added to check for an existing SOURCES_FOR_RUN_... folder
     30# host configuration added to SOURCES_FOR_RUN_... folder name
     31# SOURCES_FOR_RUN_... folder is deleted in case of compilation errors
     32# host_identifier renamed host_configuration
     33#
     34# 2500 2017-09-25 11:10:03Z raasch
    2935# bugfix for r2492
    3036#
     
    5258 column1=""
    5359 column2=""
    54  host_identifier=default
     60 host_configuration=default
    5561 locat=normal
    5662 makefile=""
     
    6268 ssh_key=""
    6369 suf=f90
     70 use_existing_sources_folder=false
    6471 version="palmbuild  1.0  Rev$Rev: 2316 $"
    6572 working_directory=`pwd`
     
    6976    # ERROR HANDLING
    7077    # IN CASE OF EXIT:
    71  trap 'if [[ $locat != normal ]]
     78 trap 'rm -rf  ${source_path}/${host_configuration}_last_make_protocol
     79       if [[ $locat != normal ]]
    7280       then
    7381          printf "\n\n +++ palmbuild killed \n\n"
     
    7785          exit 0
    7886       fi
    79        rm  ${source_path}/${host_identifier}_last_make_protocol
    8087      ' exit
    8188
     
    8390    # IN CASE OF TERMINAL-BREAK:
    8491 trap 'printf "\n\n +++ palmbuild killed by \"^C\" \n\n"
    85        rm  ${source_path}/${host_identifier}_last_make_protocol
     92       rm  ${source_path}/${host_configuration}_last_make_protocol
    8693       exit
    8794      ' 2
     
    9097
    9198    # READ SHELLSCRIPT-OPTIONS
    92  while  getopts  :d:h:m:s:S:uv  option
     99 while  getopts  :d:h:m:s:S:uvV  option
    93100 do
    94101   case  $option  in
    95102       (d)   fname=$OPTARG;;
    96        (h)   host_identifier=$OPTARG;;
     103       (h)   host_configuration=$OPTARG;;
    97104       (m)   makefile=$OPTARG;;
    98105       (s)   suf=$OPTARG;;
    99106       (S)   source_list="$OPTARG";;
    100107       (v)   silent=true;;
     108       (V)   use_existing_sources_folder=true;;
    101109       (\?)  printf "\n  +++ unknown option $OPTARG \n";
    102110             locat=parameter; exit;;
     
    105113
    106114
    107     # BUILD THE CONFIGURATION-FILE NAME
    108  config_file=.palm.config.$host_identifier
     115    # BUILD THE CONFIGURATION-FILE NAME AND THE SOURCES_FOR_RUN-FOLDER NAME
     116 config_file=.palm.config.$host_configuration
     117 sources_for_run_catalog=SOURCES_FOR_RUN_${host_configuration}_$fname
    109118
    110119
     
    277286
    278287    line=`grep %base_directory $config_file`
    279     make_depository=`echo $line | cut -d" " -s -f2`/MAKE_DEPOSITORY_${host_identifier}
     288    make_depository=`echo $line | cut -d" " -s -f2`/MAKE_DEPOSITORY_${host_configuration}
    280289
    281290 else
    282291
    283     make_depository=${base_directory}/MAKE_DEPOSITORY_${host_identifier}
     292    make_depository=${base_directory}/MAKE_DEPOSITORY_${host_configuration}
    284293
    285294 fi
     
    342351
    343352    # GET CONFIRMATION TO CONTINUE
    344  printf "\n  *** update will be made for host \"$host_identifier\" "
     353 printf "\n  *** update will be made for host configuration \"$host_configuration\" "
    345354
    346355
     
    367376    if [[ "$remote_ip" != "" ]]
    368377    then
    369        column2="$host_identifier"
     378       column2="$host_configuration"
    370379       printf "| %-20s%-50s | \n" "host identifier:" "$column2"
    371380       printf "|                                                                        | \n"
     
    373382       printf "| %-20s%-50s | \n" "remote depository:" "$column2"
    374383    else
    375        column2="$host_identifier"
     384       column2="$host_configuration"
    376385       printf "| %-20s%-50s | \n" "host identifier:" "$column2"
    377386       printf "|                                                                        | \n"
     
    518527          echo "  *** creating utilities on remote host"
    519528          make_call_string="make  -f Makefile_utilities  $make_options  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$linker_options\" "
    520           echo "$login_init_cmd $module_commands cd ${make_depository}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${host_identifier}_last_make_protocol
    521 
    522           if [[ $(grep -c MAKE_ERROR ${host_identifier}_last_make_protocol) != 0 ]]
     529          echo "$login_init_cmd $module_commands cd ${make_depository}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${host_configuration}_last_make_protocol
     530
     531          if [[ $(grep -c MAKE_ERROR ${host_configuration}_last_make_protocol) != 0 ]]
    523532          then
    524533             printf "\a\n  +++ error(s) occurred during compiling or linking of utilities"
    525              printf "\n      for host \"$host_identifier\" "
     534             printf "\n      for host configuration \"$host_configuration\" "
    526535             if [[ $silent = false ]]
    527536             then
     
    534543                   if [[ "$answer" = l ]]
    535544                   then
    536                       more ${host_identifier}_last_make_protocol
     545                      more ${host_configuration}_last_make_protocol
    537546                   fi
    538547                done
     
    555564          echo "  *** compile PALM sources on remote host"
    556565          make_call_string="make  $make_options  PROG=$program_name  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$compiler_options\"  LDFLAGS=\"$linker_options\" "
    557           echo "$login_init_cmd $module_commands cd ${make_depository}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${host_identifier}_last_make_protocol
    558 
    559           if [[ $(grep -c MAKE_ERROR ${host_identifier}_last_make_protocol) != 0 ]]
    560           then
    561              printf "\a\n  +++ error(s) occurred during compiling or linking for host \"$host_identifier\" "
     566          echo "$login_init_cmd $module_commands cd ${make_depository}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${host_configuration}_last_make_protocol
     567
     568          if [[ $(grep -c MAKE_ERROR ${host_configuration}_last_make_protocol) != 0 ]]
     569          then
     570             printf "\a\n  +++ error(s) occurred during compiling or linking for host configuration \"$host_configuration\" "
    562571             if [[ $silent = false ]]
    563572             then
     
    570579                   if [[ "$answer" = l ]]
    571580                   then
    572                       more ${host_identifier}_last_make_protocol
     581                      more ${host_configuration}_last_make_protocol
    573582                   fi
    574583                done
     
    596605             # FIRST CHECK, IF COMPILED SOURCES FOR THIS RUN IDENTIFIER EXISTS
    597606             # AND ASK, IF THEY SHALL BE USED
    598           echo  "[[ -d $fast_io_catalog/SOURCES_FOR_RUN_$fname ]]  &&  echo sources for run found" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1  >  ${host_identifier}_last_make_protocol
    599           if [[ $(grep -c "sources for run found" ${host_identifier}_last_make_protocol) != 0 ]]
     607          echo  "[[ -d ${fast_io_catalog}/${sources_for_run_catalog} ]]  &&  echo sources for run found" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1  >  ${host_configuration}_last_make_protocol
     608          if [[ $(grep -c "sources for run found" ${host_configuration}_last_make_protocol) != 0  &&  $use_existing_sources_folder = true ]]
    600609          then
    601610             printf "\a\n  *** compiled sources for run \"$fname\" found on remote host in folder"
    602              printf "\n      $fast_io_catalog/SOURCES_FOR_RUN_$fname" 
    603              answer=dummy
    604              printf "\n\n"
    605              while [[ "$answer" != y  &&  "$answer" != n ]]
    606              do
    607                 printf "  >>> shall they be used (y/n) ? "
    608                 read  answer
    609              done
    610              if [[ $answer = y ]]
    611              then
    612                 exit
    613              fi
     611             printf "\n      ${fast_io_catalog}/${sources_for_run_catalog}"
     612             printf "\n      will be used!"
     613             exit
    614614          fi
    615615
    616616             # COPY MAKE DEPOSITORY ON REMOTE MACHINE TO SOURCES_FOR_RUN_...
    617           printf "\n  *** copy MAKE_DEPOSITORY_${host_identifier} on remote host to SOURCES_FOR_RUN_$fname \n"
    618           echo  "rm -rf $fast_io_catalog/SOURCES_FOR_RUN_$fname; mkdir -p $fast_io_catalog/SOURCES_FOR_RUN_$fname; cp ${make_depository}/${program_name}_current_version.tar  $fast_io_catalog/SOURCES_FOR_RUN_$fname; cd $fast_io_catalog/SOURCES_FOR_RUN_$fname; tar xf ${program_name}_current_version.tar"  |  ssh  -q  $ssh_key  ${remote_username}@${remote_ip}  2>&1
     617          printf "\n  *** copy MAKE_DEPOSITORY_${host_configuration} on remote host to $sources_for_run_catalog \n"
     618          echo  "rm -rf ${fast_io_catalog}/${sources_for_run_catalog}; mkdir -p ${fast_io_catalog}/${sources_for_run_catalog}; cp ${make_depository}/${program_name}_current_version.tar  ${fast_io_catalog}/${sources_for_run_catalog}; cd ${fast_io_catalog}/${sources_for_run_catalog}; tar xf ${program_name}_current_version.tar"  |  ssh  -q  $ssh_key  ${remote_username}@${remote_ip}  2>&1
    619619
    620620
    621621             # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_... ON THE REMOTE MACHINE
    622           printf "\n  *** copy $base_directory/SOURCES_FOR_RUN_$fname"
    623           printf "\n      to SOURCES_FOR_RUN_$fname on remote host \n"
    624           scp  -q  $ssh_key  $base_directory/SOURCES_FOR_RUN_$fname/{*,.[!.]*}  ${remote_username}@${remote_ip}:${fast_io_catalog}/SOURCES_FOR_RUN_$fname
     622          printf "\n  *** copy ${base_directory}/${sources_for_run_catalog}"
     623          printf "\n      to $sources_for_run_catalog on remote host \n"
     624          scp  -q  $ssh_key  ${base_directory}/${sources_for_run_catalog}/{*,.[!.]*}  ${remote_username}@${remote_ip}:${fast_io_catalog}/${sources_for_run_catalog}
    625625
    626626
    627627             # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY
    628           if [[ $(ls -1 $base_directory/SOURCES_FOR_RUN_$fname/ | grep -c .$suf) != 0 ]]
     628          if [[ $(ls -1 ${base_directory}/${sources_for_run_catalog}/ | grep -c .$suf) != 0 ]]
    629629          then
    630630
     
    633633             [[ "$module_commands" != "" ]]  &&  module_commands=${module_commands}";"
    634634             echo "  *** execute \"make\" on remote host"
    635              echo "$login_init_cmd $module_commands cd ${fast_io_catalog}/SOURCES_FOR_RUN_$fname; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${host_identifier}_last_make_protocol
    636 
    637              if [[ $(grep -c MAKE_ERROR ${host_identifier}_last_make_protocol) != 0 ]]
     635             echo "$login_init_cmd $module_commands cd ${fast_io_catalog}/${sources_for_run_catalog}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1 | tee ${host_configuration}_last_make_protocol
     636
     637             if [[ $(grep -c MAKE_ERROR ${host_configuration}_last_make_protocol) != 0 ]]
    638638             then
    639                 printf "\a\n  +++ error(s) occurred during compiling or linking for host \"$host_identifier\" "
     639                printf "\a\n  +++ error(s) occurred during compiling or linking for host configuration \"$host_configuration\" "
    640640                if [[ $silent = false ]]
    641641                then
     
    648648                      if [[ "$answer" = l ]]
    649649                      then
    650                          more ${host_identifier}_last_make_protocol
     650                         more ${host_configuration}_last_make_protocol
    651651                      fi
    652652                   done
    653653                   if [[ $answer = k ]]
    654654                   then
     655                      echo "rm -rf ${fast_io_catalog}/${sources_for_run_catalog}" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1
    655656                      locat=user_abort; exit
    656657                   fi
    657658                else
    658659                      # ABORT ANYWAY
     660                   echo "rm -rf ${fast_io_catalog}/${sources_for_run_catalog}" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1
    659661                   locat=user_abort; exit
    660662                fi
     
    669671       fi
    670672
    671        rm -rf  ${host_identifier}_last_make_protocol
     673       rm -rf  ${source_path}/${host_configuration}_last_make_protocol
    672674
    673675
     
    729731          echo "  *** compile PALM sources on local host"
    730732
    731           make  $make_options  PROG=$program_name  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$linker_options"  2>&1 | tee ${host_identifier}_last_make_protocol
     733          make  $make_options  PROG=$program_name  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$linker_options"  2>&1 | tee ${host_configuration}_last_make_protocol
    732734
    733735          if [[ $? != 0 ]]
    734736          then
    735              printf "\a\n  +++ error(s) occurred during compiling or linking for host \"$host_identifier\" "
     737             printf "\a\n  +++ error(s) occurred during compiling or linking for host configuration \"$host_configuration\" "
    736738             if [[ $silent = false ]]
    737739             then
     
    744746                   if [[ "$answer" = l ]]
    745747                   then
    746                       more ${host_identifier}_last_make_protocol
     748                      more ${host_configuration}_last_make_protocol
    747749                   fi
    748750                done
     
    770772             # FIRST CHECK, IF COMPILED SOURCES FOR THIS RUN IDENTIFIER EXISTS
    771773             # AND ASK, IF THEY SHALL BE USED
    772           if [[ -d $fast_io_catalog/SOURCES_FOR_RUN_$fname ]]
     774          if [[ -d ${fast_io_catalog}/${sources_for_run_catalog}  &&  $use_existing_sources_folder = true ]]
    773775          then
    774776             printf "\a\n  *** compiled sources for run \"$fname\" found on local host in folder"
    775              printf "\n      $fast_io_catalog/SOURCES_FOR_RUN_$fname" 
    776              answer=dummy
    777              printf "\n\n"
    778              while [[ "$answer" != y  &&  "$answer" != n ]]
    779              do
    780                 printf "  >>> shall they be used (y/n) ? "
    781                 read  answer
    782              done
    783              if [[ $answer = y ]]
    784              then
    785                 exit
    786              fi
     777             printf "\n      ${fast_io_catalog}/${sources_for_run_catalog}"
     778             printf "\n      will be used!"
     779             exit
    787780          fi
    788781
     
    792785             printf "\n  +++ directory for local make depository:"
    793786             printf "\n           $make_depository"
    794              printf "\n      not found. Please run \"palmbuild -h $host_identifier\" "
     787             printf "\n      not found. Please run \"palmbuild -h $host_configuration\" "
    795788             locat=make_depository; exit
    796789          fi
     
    798791
    799792             # COPY MAKE DEPOSITORY ON LOCAL MACHINE TO SOURCES_FOR_RUN_...
    800           printf "\n  *** copy MAKE_DEPOSITORY_${host_identifier} on local host to "
    801           printf "\n      $fast_io_catalog/SOURCES_FOR_RUN_$fname \n"
    802           rm -rf $fast_io_catalog/SOURCES_FOR_RUN_$fname
    803           mkdir -p $fast_io_catalog/SOURCES_FOR_RUN_$fname
    804           cp ${make_depository}/${program_name}_current_version.tar  $fast_io_catalog/SOURCES_FOR_RUN_$fname
    805           cd $fast_io_catalog/SOURCES_FOR_RUN_$fname
     793          printf "\n  *** copy MAKE_DEPOSITORY_${host_configuration} on local host to "
     794          printf "\n      ${fast_io_catalog}/${sources_for_run_catalog} \n"
     795          rm -rf ${fast_io_catalog}/${sources_for_run_catalog}
     796          mkdir -p ${fast_io_catalog}/${sources_for_run_catalog}
     797          cp ${make_depository}/${program_name}_current_version.tar  ${fast_io_catalog}/${sources_for_run_catalog}
     798          cd $fast_io_catalog/${sources_for_run_catalog}
    806799          tar xf ${program_name}_current_version.tar
    807800
     
    809802             # COPY CONTENTS OF SOURCES_FOR_RUN_... TO SOURCES_FOR_RUN_...
    810803             # IN THE FAST_IO_CATALOG ON THE LOCAL MACHINE
    811           printf "\n  *** copy $base_directory/SOURCES_FOR_RUN_$fname to"
    812           printf "\n      $fast_io_catalog/SOURCES_FOR_RUN_$fname on local host \n"
    813           cp  $base_directory/SOURCES_FOR_RUN_$fname/{*,.[!.]*}  ${fast_io_catalog}/SOURCES_FOR_RUN_$fname
     804          printf "\n  *** copy ${base_directory}/${sources_for_run_catalog} to"
     805          printf "\n      ${fast_io_catalog}/${sources_for_run_catalog} on local host \n"
     806          cp  ${base_directory}/${sources_for_run_catalog}/{*,.[!.]*}  ${fast_io_catalog}/${sources_for_run_catalog}
    814807
    815808
    816809             # CREATE EXECUTABLE FROM THE NEW/MODIFIED SOURCE FILES, IF THERE ARE ANY
    817           if [[ $(ls -1 $base_directory/SOURCES_FOR_RUN_$fname/ | grep -c .$suf) != 0 ]]
     810          if [[ $(ls -1 ${base_directory}/${sources_for_run_catalog}/ | grep -c .$suf) != 0 ]]
    818811          then
    819812
     
    827820             then
    828821
    829                 printf "\a\n  +++ error(s) occurred during compiling or linking for host \"$host_identifier\" "
     822                printf "\a\n  +++ error(s) occurred during compiling or linking for host configuration \"$host_configuration\" "
    830823                if [[ $silent = false ]]
    831824                then
     
    834827                   while [[ "$answer" != c  &&  "$answer" != k ]]
    835828                   do
    836                       printf "  >>> continue / list errors / kill palmbuild (c/k) ? "
     829                      printf "  >>> continue / kill palmbuild (c/k) ? "
    837830                      read  answer
    838831                   done
    839832                   if [[ $answer = k ]]
    840833                   then
     834                      rm -rf ${fast_io_catalog}/${sources_for_run_catalog}
    841835                      locat=user_abort; exit
    842836                   fi
    843837                else
    844838                      # ABORT ANYWAY
     839                   rm -rf ${fast_io_catalog}/${sources_for_run_catalog}
    845840                   locat=user_abort; exit
    846841                fi
Note: See TracChangeset for help on using the changeset viewer.