Index: palm/trunk/SCRIPTS/palmrun
===================================================================
--- palm/trunk/SCRIPTS/palmrun	(revision 3151)
+++ palm/trunk/SCRIPTS/palmrun	(revision 3236)
@@ -27,4 +27,13 @@
 # -----------------
 # $Id$
+# warning issued in case of file connection file version mismatch,
+# host_configuration renamed configuration_identifier,
+# "host identifier" in header output renamed "config. identifier",
+# jobname renamed run_identifier,
+# run_id renamed run_id_number
+# job_id renamed run_id
+# option -r renamed -i
+# 
+# 3151 2018-07-19 08:45:38Z raasch
 # removed additional listing of files to be compiled, print PALM code revision
 # in header
@@ -170,4 +179,5 @@
  compiler_name_ser=""
  compiler_options=""
+ configuration_identifier="default"
  cores=1
  cores_atmos=0
@@ -188,7 +198,5 @@
  execution_error=false
  fileconnection_file=trunk/SCRIPTS/.palm.iofiles
- jobname=test
  global_revision=""
- host_configuration="default"
  hostfile=""
  hp=""
@@ -221,4 +229,6 @@
  run_coupled_model=false
  run_id=""
+ run_id_number=""
+ run_identifier=test
  silent=false
  source_list=""
@@ -267,5 +277,5 @@
     # READ SHELLSCRIPT-OPTIONS AND REBUILD THE PALMRUN-COMMAND STRING (prc),
     # WHICH WILL BE USED TO START RESTART-JOBS
- while  getopts  :a:A:bBCd:FG:h:jkm:M:O:q:r:R:s:t:T:u:U:vVw:W:xX:yY:Z option
+ while  getopts  :a:A:bBCd:FG:h:i:jkm:M:O:q:R:s:t:T:u:U:vVw:W:xX:yY:Z option
  do
    case  $option  in
@@ -275,8 +285,9 @@
        (B)   delete_temporary_catalog=false; prc="$prc -B";;
        (C)   restart_run=true; prc="$prc -C";;
-       (d)   jobname=$OPTARG; prc="$prc -d$OPTARG";;
+       (d)   run_identifier=$OPTARG; prc="$prc -d$OPTARG";;
        (F)   create_jobfile_only=true;;
        (G)   global_revision=$OPTARG; prc="$prc -G'$OPTARG'";;
-       (h)   host_configuration=$OPTARG; prc="$prc -h$OPTARG";;
+       (h)   configuration_identifier=$OPTARG; prc="$prc -h$OPTARG";;
+       (i)   run_id_number=$OPTARG;;
        (j)   running_in_batch_mode=true;;
        (k)   keep_data_from_previous_run=true; prc="$prc -k";;
@@ -285,5 +296,4 @@
        (O)   use_openmp=true; threads_per_task=$OPTARG; prc="$prc -O$OPTARG";;
        (q)   queue=$OPTARG; prc="$prc -q$OPTARG";;
-       (r)   run_id=$OPTARG;;
        (R)   return_address=$OPTARG;;
        (s)   source_list=$OPTARG;;
@@ -367,11 +377,12 @@
 
 
-    # FOR COMPATIBILITY REASONS SET OLD ENVIRONMENT VARIABLE
- export fname=$jobname
+    # FOR COMPATIBILITY REASONS SET OLD ENVIRONMENT VARIABLES
+ export fname=$run_identifier
+ export jobname=$run_identifier
 
 
     # BUILD THE CONFIGURATION-FILE NAME AND THE SOURCES_FOR_RUN-FOLDER NAME
- config_file=.palm.config.$host_configuration
- sources_for_run_catalog=SOURCES_FOR_RUN_${host_configuration}_$jobname
+ config_file=.palm.config.$configuration_identifier
+ sources_for_run_catalog=SOURCES_FOR_RUN_${configuration_identifier}_$run_identifier
 
 
@@ -389,5 +400,19 @@
  if [[ -f .palm.iofiles ]]
  then
+
+       # CHECK VERSION MISMATCH
+    if [[ $running_in_batch_mode != true ]]
+    then
+       if [[ $(head -n1 $fileconnection_file) != $(head -n1 .palm.iofiles) ]]
+       then
+          printf "\n\n  +++ WARNING: A file connection file has been found in your"
+          printf "\n               working directory, but its revision does not match"
+          printf "\n               the revision of the default (trunk) version."
+          printf "\n               You may need to update your connection file!"
+       fi
+    fi
+
     fileconnection_file=.palm.iofiles
+
  fi
 
@@ -1124,5 +1149,5 @@
        eval filename=${pathin_pre[$i]}/${endin_pre[$i]}
     else
-       eval filename=${pathin_pre[$i]}/${jobname}${endin_pre[$i]}
+       eval filename=${pathin_pre[$i]}/${run_identifier}${endin_pre[$i]}
     fi
 
@@ -1156,6 +1181,7 @@
     else
 
-          # FIRST CHECK FOR MULTIPLE NAMES WITH THE SAME BASENAME ($jobname) AND
-          # CREATE A LIST FOR THE DETECTED BASENAME ENDINGS
+          # FIRST CHECK FOR MULTIPLE NAMES WITH THE SAME BASENAME
+          # ($run_identifier) AND CREATE A LIST FOR THE DETECTED BASENAME
+          # ENDINGS
        if [[ "${multin[$i]}" = true ]]
        then
@@ -1185,7 +1211,7 @@
               fi
 
-                 # remove the jobname from the beginning
-              length_jobname=${#jobname}
-              ending=${basefilename:${length_jobname}}
+                 # remove the run_identifier from the beginning
+              length_run_identifier=${#run_identifier}
+              ending=${basefilename:${length_run_identifier}}
 
                  # remove the ending given in the .iofiles from the beginning
@@ -1249,5 +1275,5 @@
              eval filename=${pathin[$nr_of_input_files]}/${endin[$nr_of_input_files]}
           else
-             eval filename=${pathin[$nr_of_input_files]}/${jobname}${endin[$nr_of_input_files]}
+             eval filename=${pathin[$nr_of_input_files]}/${run_identifier}${endin[$nr_of_input_files]}
           fi
 
@@ -1329,5 +1355,5 @@
                 frelin[$nr_of_input_files]=${endin[$nr_of_input_files]}.$cyclestring
              else
-                frelin[$nr_of_input_files]=${jobname}${endin[$nr_of_input_files]}.$cyclestring
+                frelin[$nr_of_input_files]=${run_identifier}${endin[$nr_of_input_files]}.$cyclestring
              fi
           else
@@ -1336,5 +1362,5 @@
                 frelin[$nr_of_input_files]=${endin[$nr_of_input_files]}
              else
-                frelin[$nr_of_input_files]=${jobname}${endin[$nr_of_input_files]}
+                frelin[$nr_of_input_files]=${run_identifier}${endin[$nr_of_input_files]}
              fi
           fi
@@ -1370,5 +1396,5 @@
        fi
        (( maxcycle = 0 ))
-       eval filename=${pathout_pre[$i]}/${jobname}${endout_pre[$i]}
+       eval filename=${pathout_pre[$i]}/${run_identifier}${endout_pre[$i]}
        eval catalogname=${pathout_pre[$i]}
        if ! ls $filename* 1>/dev/null 2>&1
@@ -1416,8 +1442,8 @@
  if [[ $running_in_batch_mode = false ]]
  then
-    run_id=$RANDOM
-    job_id=${jobname}.$run_id
-
-    tempdir=$fast_io_catalog/$job_id
+    run_id_number=$RANDOM
+    run_id=${run_identifier}.$run_id_number
+
+    tempdir=$fast_io_catalog/$run_id
  fi
 
@@ -1511,11 +1537,11 @@
  if [[ $create_remote_batch_job = true ]]
  then
-    column1="execution on:"; column2="$host_configuration (username: $remote_username)"
+    column1="execution on:"; column2="$configuration_identifier (username: $remote_username)"
  else
     if [[ $running_on_remote = true ]]
     then
-       column1="host identifier:"; column2="$host_configuration (execute on IP: $remote_ip)"
+       column1="config. identifier:"; column2="$configuration_identifier (execute on IP: $remote_ip)"
     else
-       column1="host identifier:"; column2="$host_configuration (execute on IP: $local_ip)"
+       column1="config. identifier:"; column2="$configuration_identifier (execute on IP: $local_ip)"
     fi
  fi
@@ -1662,5 +1688,5 @@
  fi
  printf "|                                                                        | \n"
- column1="run identifier:"; column2=$jobname
+ column1="run identifier:"; column2=$run_identifier
  printf "| %-25s%-45s | \n" "$column1" "$column2"
  column1="activation string list:"; column2=$(echo $activation_string_list)
@@ -1780,8 +1806,8 @@
 
        line=`grep %base_directory $config_file`
-       make_depository=`echo $line | cut -d" " -s -f2`/MAKE_DEPOSITORY_${host_configuration}
-       echo  "[[ ! -d ${make_depository} ]]  &&  echo depository not found" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1  | tee ${host_configuration}_last_make_protokoll
-
-       if [[ $(grep -c "depository not found" ${host_configuration}_last_make_protokoll) != 0 ]]
+       make_depository=`echo $line | cut -d" " -s -f2`/MAKE_DEPOSITORY_${configuration_identifier}
+       echo  "[[ ! -d ${make_depository} ]]  &&  echo depository not found" | ssh  -q  $ssh_key  ${remote_username}@${remote_ip} 2>&1  | tee ${configuration_identifier}_last_make_protokoll
+
+       if [[ $(grep -c "depository not found" ${configuration_identifier}_last_make_protokoll) != 0 ]]
        then
           printf "\n\n  +++ make depository \"${make_depository}\""
@@ -1789,10 +1815,10 @@
           ask_for_make_depository=true
        fi
-       rm ${host_configuration}_last_make_protokoll
+       rm ${configuration_identifier}_last_make_protokoll
 
     else
 
           # CHECK FOR MAKE_DEPOSITORY ON THE LOCAL HOST
-       make_depository=${base_directory}/MAKE_DEPOSITORY_${host_configuration}
+       make_depository=${base_directory}/MAKE_DEPOSITORY_${configuration_identifier}
        if [[ ! -d ${make_depository} ]]
        then
@@ -1826,7 +1852,7 @@
        if [[ $do_trace = true ]]
        then
-          palmbuild  -h $host_configuration
+          palmbuild  -h $configuration_identifier
        else
-          palmbuild  -v  -h $host_configuration
+          palmbuild  -v  -h $configuration_identifier
        fi
 
@@ -1845,5 +1871,5 @@
 
        # NOW CREATE THE SOURCES_FOR_RUN FOLDER
-    palmbuild  -v  $use_existing_sources_folder  -h $host_configuration  -d $jobname
+    palmbuild  -v  $use_existing_sources_folder  -h $configuration_identifier  -d $run_identifier
 
     if [[ $? != 0 ]]
@@ -2110,5 +2136,5 @@
        # (FILE ENVPAR WILL BE READ BY PALM)
     cat  >  ENVPAR  <<  EOF
- &envpar  run_identifier = '$jobname', host = '$host_configuration',
+ &envpar  run_identifier = '$run_identifier', host = '$configuration_identifier',
           write_svf = .${write_svf}., write_binary = .${write_binary}., 
           read_svf = .${read_svf}., tasks_per_node = $tasks_per_node,
@@ -2361,5 +2387,5 @@
        then
 
-          eval filename=${pathout[$i]}/${jobname}${endout[$i]}
+          eval filename=${pathout[$i]}/${run_identifier}${endout[$i]}
 
              # DETERMINE THE CYCLE NUMBER
@@ -2503,12 +2529,12 @@
                 transfer_failed=false
                 printf "\n  >>> OUTPUT: ${localout[$i]}$catalog_string  $append_string by SCP to"
-                printf "\n              ${pathout[$i]}/${host_configuration}_${jobname}${endout[$i]}$catalog_string\n"
+                printf "\n              ${pathout[$i]}/${configuration_identifier}_${run_identifier}${endout[$i]}$catalog_string\n"
 
                    # TRANSFER VIA SCP
                 if [[ "$remote_loginnode" != "" ]]
                 then
-                   echo "cd $tempdir; ${fast_io_catalog}/${sources_for_run_catalog}/batch_scp $PORTOPT $catalog_option $append_option -b -m $usecycle_option -u $local_username $return_address  ${localout[$i]} \"${pathout[$i]}\" ${host_configuration}_${jobname}${endout[$i]}  ${extout[$i]}"  |  ssh -q $remote_username@$remote_loginnode
+                   echo "cd $tempdir; ${fast_io_catalog}/${sources_for_run_catalog}/batch_scp $PORTOPT $catalog_option $append_option -b -m $usecycle_option -u $local_username $return_address  ${localout[$i]} \"${pathout[$i]}\" ${configuration_identifier}_${run_identifier}${endout[$i]}  ${extout[$i]}"  |  ssh -q $remote_username@$remote_loginnode
                 else
-                   batch_scp $PORTOPT $catalog_option $append_option -b -m $usecycle_option -u $local_username $return_address  ${localout[$i]} "${pathout[$i]}" ${host_configuration}_${jobname}${endout[$i]}  ${extout[$i]}
+                   batch_scp $PORTOPT $catalog_option $append_option -b -m $usecycle_option -u $local_username $return_address  ${localout[$i]} "${pathout[$i]}" ${configuration_identifier}_${run_identifier}${endout[$i]}  ${extout[$i]}
                 fi
                 [[ $? != 0 ]]  &&  transfer_failed=true
@@ -2519,5 +2545,5 @@
                 then
                    printf "  +++ transfer failed. Trying to save a copy on this host under:\n"
-                   printf "      ${pathout[$i]}/${host_configuration}_${jobname}${endout[$i]}_$run_id\n"
+                   printf "      ${pathout[$i]}/${configuration_identifier}_${run_identifier}${endout[$i]}_$run_id_number\n"
 
                       # FIRST CHECK, IF DIRECTORY EXISTS, AND CREATE IT, IF NECESSARY
@@ -2529,5 +2555,5 @@
                       mkdir -p  $local_catalog
                    fi
-                   eval  cp  ${localout[$i]}  ${pathout[$i]}/${host_configuration}_${jobname}${endout[$i]}_$run_id
+                   eval  cp  ${localout[$i]}  ${pathout[$i]}/${configuration_identifier}_${run_identifier}${endout[$i]}_$run_id_number
                    transfer_problems=true
                 fi
@@ -2755,5 +2781,5 @@
 
        # BUILD THE PALMRUN-COMMAND TO BE CALLED IN THE BATCH-JOB
-    palmrun_com="$palmrun_script_name -d $jobname -h $host_configuration -m $memory -t $cpumax -q $queue -r $run_id -U $local_username"
+    palmrun_com="$palmrun_script_name -d $run_identifier -h $configuration_identifier -m $memory -t $cpumax -q $queue -i $run_id_number -U $local_username"
     [[ "$activation_string_list" != "" ]]  &&  palmrun_com=${palmrun_com}" -a \"$activation_string_list\""
     [[ "$global_revision" != "" ]]  &&  palmrun_com=${palmrun_com}" -G \"$global_revision\""
@@ -2788,17 +2814,17 @@
        # DETERMINE THE FULL PATHS FOR THE JOB PROTOCOL FILES ON THE LOCAL AND
        # REMOTE HOST
-    job_protocol_file_local=${local_jobcatalog}/${host_configuration}_${job_id}
+    job_protocol_file_local=${local_jobcatalog}/${configuration_identifier}_${run_id}
     job_protocol_file=$job_protocol_file_local
     if [[ $create_remote_batch_job = true ]]
     then
-       job_protocol_file_remote=${remote_jobcatalog}/${host_configuration}_${job_id}
+       job_protocol_file_remote=${remote_jobcatalog}/${configuration_identifier}_${run_id}
        job_protocol_file=$job_protocol_file_remote
        job_transfer_protocol_file=${remote_jobcatalog}/last_job_transfer_protocol
-       scpjob_file=${remote_jobcatalog}/scpjob.$run_id
+       scpjob_file=${remote_jobcatalog}/scpjob.$run_id_number
     fi
 
 
        # BUILD THE JOB-SCRIPTS ON FILE jobfile
-    jobfile=jobfile.$run_id
+    jobfile=jobfile.$run_id_number
 
 
@@ -2819,9 +2845,9 @@
     if [[ $create_remote_batch_job = true ]]
     then
-       echo "set +vx"                              >>  $jobfile
-       echo "trap '"                               >>  $jobfile
-       echo "set +vx"                              >>  $jobfile
-       echo "cd ${remote_jobcatalog}"              >>  $jobfile
-       echo "cat >  scpjob.$run_id << %%END%%"     >>  $jobfile
+       echo "set +vx"                                   >>  $jobfile
+       echo "trap '"                                    >>  $jobfile
+       echo "set +vx"                                   >>  $jobfile
+       echo "cd ${remote_jobcatalog}"                   >>  $jobfile
+       echo "cat >  scpjob.$run_id_number << %%END%%"   >>  $jobfile
 
           # ADD THE BATCH DIRECTIVES
@@ -2837,5 +2863,5 @@
 
        echo "set -x"                               >>  $jobfile
-       echo "${fast_io_catalog}/${sources_for_run_catalog}/batch_scp  $PORTOPT  -d  -w 10  -u $local_username $local_ip  $job_protocol_file_remote  \"$local_jobcatalog\"  ${host_configuration}_${jobname}"  >>  $jobfile
+       echo "${fast_io_catalog}/${sources_for_run_catalog}/batch_scp  $PORTOPT  -d  -w 10  -u $local_username $local_ip  $job_protocol_file_remote  \"$local_jobcatalog\"  ${configuration_identifier}_${run_identifier}"  >>  $jobfile
        echo "%%END%%"                              >>  $jobfile
        echo "echo \" *** submitting job for transfering the job protocol file to $local_ip\" "  >>  $jobfile
@@ -2916,14 +2942,14 @@
           if [[ $do_trace = true ]]
           then
-             echo "     scp $ssh_key $PORTOPT $jobfile ${remote_username}@${remote_ip}:${remote_jobcatalog}/${host_configuration}_${job_id}"
-          fi
-          scp $ssh_key $PORTOPT $jobfile ${remote_username}@${remote_ip}:${remote_jobcatalog}/${host_configuration}_${job_id}  >  /dev/null
+             echo "     scp $ssh_key $PORTOPT $jobfile ${remote_username}@${remote_ip}:${remote_jobcatalog}/${configuration_identifier}_${run_id}"
+          fi
+          scp $ssh_key $PORTOPT $jobfile ${remote_username}@${remote_ip}:${remote_jobcatalog}/${configuration_identifier}_${run_id}  >  /dev/null
 
           printf " *** submit the job (output of submit command, e.g. the job-id, may follow)"
           if [[ $do_trace = true ]]
           then
-             echo "     cd $remote_jobcatalog; $submit_command ${host_configuration}_${job_id}; rm ${host_configuration}_${job_id}  |  ssh  -q  $ssh_key $SSH_PORTOPT  ${remote_username}@${remote_ip}  2>&1"
-          fi
-          echo "cd $remote_jobcatalog; $submit_command ${host_configuration}_${job_id}; rm ${host_configuration}_${job_id}"  |  ssh  -q  $ssh_key $SSH_PORTOPT  ${remote_username}@${remote_ip}  2>&1
+             echo "     cd $remote_jobcatalog; $submit_command ${configuration_identifier}_${run_id}; rm ${configuration_identifier}_${run_id}  |  ssh  -q  $ssh_key $SSH_PORTOPT  ${remote_username}@${remote_ip}  2>&1"
+          fi
+          echo "cd $remote_jobcatalog; $submit_command ${configuration_identifier}_${run_id}; rm ${configuration_identifier}_${run_id}"  |  ssh  -q  $ssh_key $SSH_PORTOPT  ${remote_username}@${remote_ip}  2>&1
 
        elif [[ $create_batch_job = true ]]
@@ -2931,5 +2957,5 @@
 
           eval  local_jobcatalog=$local_jobcatalog
-          cp  $jobfile  ${local_jobcatalog}/${host_configuration}_${job_id}
+          cp  $jobfile  ${local_jobcatalog}/${configuration_identifier}_${run_id}
           cd $local_jobcatalog
           echo " "
@@ -2937,8 +2963,8 @@
           if [[ $do_trace = true ]]
           then
-             echo "$submit_command ${host_configuration}_${job_id}"
-          fi
-          $submit_command ${host_configuration}_${job_id}
-          rm ${host_configuration}_${job_id}
+             echo "$submit_command ${configuration_identifier}_${run_id}"
+          fi
+          $submit_command ${configuration_identifier}_${run_id}
+          rm ${configuration_identifier}_${run_id}
           cd -  > /dev/null
 
