Index: /palm/trunk/SCRIPTS/inifor_script
===================================================================
--- /palm/trunk/SCRIPTS/inifor_script	(revision 3790)
+++ /palm/trunk/SCRIPTS/inifor_script	(revision 3791)
@@ -1,5 +1,5 @@
 #!/bin/bash
 
-# palmrun - script for running PALM jobs
+# inifor - The Mesoscale Interface for Initializing and Forcing PALM
 
 #--------------------------------------------------------------------------------#
@@ -29,5 +29,5 @@
 # 
 #--------------------------------------------------------------------------------#
-# inifor - script for running inifor
+# inifor - script for running the inifor executable
 #--------------------------------------------------------------------------------#
 
@@ -41,85 +41,15 @@
  set +o noclobber    # EXISTING FILES ARE ALLOWED TO BE OVERWRITTEN
 
- typeset -i  ibd=0 ibdt=0 iec=0 iic=0 iin=0 ioc=0 iout=0 nr_of_input_files=0
- typeset -i  nr_of_output_files=0
- typeset -x -i  memory=0   # HAS TO BE EXPORTED HERE, OTHERWISE AN UNKNOWN SIDE
-                           # SIDE EFFECT MAY CAUSE DATA LOSS WHEN GETOPTS IS READING THE
-                           # SCRIPT-OPTION ARGUMENTS
- typeset -i  cores cputime cpu_hours cpu_minutes cpu_seconds i ii iia iii iio
- typeset -i  icycle inode ival maxcycle mpi_tasks
- typeset -i  nodes remaining_cores run_number tasks_per_node threads_per_task
-
- activation_string_list=""
- AddFilenames=""
- combine_plot_fields=true
- compiler_name=""
- compiler_name_ser=""
- compiler_options=""
+ typeset -i  i iec=0
+
+ activation_string_list="inifor"
  configuration_identifier="default"
- cores=1
- cores_atmos=0
- cores_ocean=0
- coupled_dist=""
- cpp_options=""
- cpumax=0
- create_batch_job=false
- create_jobfile_only=false
- create_remote_batch_job=false
- dashes="  ----------------------------------------------------------------------------"
- defaultqueue=""
  delete_temporary_catalog=true
- do_compile=true
- do_trace=false
- executable=""
- execute_command=""
- execution_error=false
  fileconnection_file=trunk/SCRIPTS/.palm.iofiles
- global_revision=""
- hostfile=""
- hp=""
- keep_data_from_previous_run=false
- link_local_input=false
- link_local_output=false
- linker_options=""
- local_jobcatalog=""
  locat=normal
- makefile=""
- max_par_io_str=""
- prc=$0
- while [[ $(echo $prc | grep -c "/") != 0 ]]
- do
-    prc=`echo $prc | cut -f2- -d"/"`
- done
- module_calls=""
- palmrun_memory=""
- palmrun_script_name=$prc
- openmp=false
- previous_job=""
- project_account=""
- queue=none
- read_svf=""
- restart_run=false
- return_address=""
- remote_jobcatalog=""
- remote_username=""
- running_in_batch_mode=false
- running_in_test_mode=false
- run_coupled_model=false
- run_id=""
- run_id_number=""
  run_identifier=test
  silent=false
- source_list=""
- source_path=""
- tasks_per_node=0
- threads_per_task=1
- transfer_problems=false
- user_source_path=""
- use_existing_sources_folder=""
- use_openmp=false
- version="palmrun  1.0 Rev$Rev: 3725 $"
+ version="inifor  0.1 Rev$Rev$"
  working_directory=`pwd`
- write_binary=""
- write_svf=""
 
 
@@ -138,13 +68,13 @@
           done
           [[ $delete_temporary_catalog = true ]]  &&  (cd; rm -rf $tempdir)
-          printf "\n\n+++ palmrun crashed \n\n"
+          printf "\n\n+++ inifor crashed \n\n"
           exit 1
        elif [[ $locat != normal ]]
        then
           [[ $delete_temporary_catalog = true ]]  &&  (cd; rm -rf $tempdir)
-          printf "\n+++ palmrun killed by \"^C\" \n\n"
+          printf "\n+++ inifor killed by \"^C\" \n\n"
           exit 2
        else
-          printf "\n --> palmrun finished\n\n"
+          printf "\n --> inifor finished\n\n"
           exit 0
        fi' exit
@@ -157,41 +87,14 @@
 
 
-    # READ SHELLSCRIPT-OPTIONS AND REBUILD THE PALMRUN-COMMAND STRING (prc),
-    # WHICH WILL BE USED TO START RESTART-JOBS
- while  getopts  :a:A:bBc:CFG:i:jkm:M:O:q:r:R:s:t:T:u:U:vVw:W:xX:yY:zZ option
+    # READ SHELLSCRIPT-OPTIONS
+    # TODO: add additional inifor options
+ while  getopts  :a:Bc:r:v  option
  do
    case  $option  in
-       (a)   activation_string_list=$OPTARG; prc="$prc -a'$OPTARG'";;
-       (A)   project_account=$OPTARG; prc="$prc -A'$OPTARG'";;
-       (b)   create_batch_job=true; prc="$prc -b";;
-       (B)   delete_temporary_catalog=false; prc="$prc -B";;
-       (c)   configuration_identifier=$OPTARG; prc="$prc -c$OPTARG";;
-       (C)   restart_run=true; prc="$prc -C";;
-       (F)   create_jobfile_only=true;;
-       (G)   global_revision=$OPTARG; prc="$prc -G'$OPTARG'";;
-       (i)   run_id_number=$OPTARG;;
-       (j)   running_in_batch_mode=true;;
-       (k)   keep_data_from_previous_run=true; prc="$prc -k";;
-       (m)   palmrun_memory=$OPTARG; prc="$prc -m$OPTARG";;
-       (M)   makefile=$OPTARG; prc="$prc -M$OPTARG";;
-       (O)   use_openmp=true; threads_per_task=$OPTARG; prc="$prc -O$OPTARG";;
-       (q)   queue=$OPTARG; prc="$prc -q$OPTARG";;
-       (r)   run_identifier=$OPTARG; prc="$prc -r$OPTARG";;
-       (R)   return_address=$OPTARG;;
-       (s)   source_list=$OPTARG;;
-       (t)   palmrun_cpumax=$OPTARG; prc="$prc -t$OPTARG";;
-       (T)   palmrun_tasks_per_node=$OPTARG; prc="$prc -T$OPTARG";;
-       (u)   remote_username=$OPTARG; prc="$prc -u$OPTARG";;
-       (U)   return_username=$OPTARG; prc="$prc -U$OPTARG";;
-       (v)   silent=true; prc="$prc -v";;
-       (V)   use_existing_sources_folder="-V";;
-       (w)   max_par_io_str=$OPTARG; prc="$prc -w$OPTARG";;
-       (W)   previous_job=$OPTARG;;
-       (x)   do_trace=true;set -x; prc="$prc -x";;
-       (X)   palmrun_cores=$OPTARG; prc="$prc -X$OPTARG";;
-       (y)   ocean_file_appendix=true; prc="$prc -y";;
-       (Y)   run_coupled_model=true; coupled_dist=$OPTARG; prc="$prc -Y'$OPTARG'";;
-       (z)   running_in_test_mode=true;;
-       (Z)   combine_plot_fields=false; prc="$prc -Z";;
+       (a)   activation_string_list=$OPTARG;;
+       (B)   delete_temporary_catalog=false;;
+       (c)   configuration_identifier=$OPTARG;;
+       (r)   run_identifier=$OPTARG;;
+       (v)   silent=true;;
        (\?)  printf "\n  +++ unknown option $OPTARG \n"
              printf "\n  --> type \"$0 ?\" for available options \n"
@@ -207,4 +110,5 @@
 
     # PRINT SHORT DESCRIPTION OF PALMRUN OPTIONS
+    # TODO: add description of additional inifor options
  if [[ "$1" = "?" ]]
  then
@@ -212,35 +116,7 @@
     printf "\n      Option  Description                              Default-Value"
     printf "\n        -a    activation string list                   \"\" "
-    printf "\n        -A    project account number                   ---"
-    printf "\n        -b    batch-job on local machine               ---"
-    printf "\n        -B    do not delete temporary directory at end ---"
     printf "\n        -c    configuration identifier                 \"default\" "
-    printf "\n        -F    create batch job file only               ---"
-    printf "\n        -k    keep data from previous run"
-    printf "\n        -m    memory demand in MB (batch-jobs)         0 MB"
-    printf "\n        -M    Makefile name                            Makefile"
-    printf "\n        -O    threads per openMP task                  ---"
-    printf "\n        -q    queue                                    \"$queue\" "
     printf "\n        -r    run identifier                           test"
-    printf "\n        -s    filenames of routines to be compiled     \"\" "
-    printf "\n              must end with .f, .f90, .F, or .c !"
-    printf "\n              use \"..\" for more than one file and wildcards"
-    printf "\n              -s LM compiles all locally modified files"
-    printf "\n        -t    allowed cpu-time in seconds (batch)      0"
-    printf "\n        -T    tasks per node                           ---"
-    printf "\n        -u    username on remote machine               \"\" "
     printf "\n        -v    no prompt for confirmation               ---"
-    printf "\n        -V    check if SOURCES_FOR_RUN_... exists      ---"
-    printf "\n        -w    maximum parallel io streams              as given by -X"
-    printf "\n        -W    name of job to wait for                  ---"
-    printf "\n        -x    tracing of palmrun for debug purposes    ---"
-    printf "\n        -X    # of processors (on parallel machines)   1"
-    printf "\n        -y    add appendix \"_O\" to all local output"
-    printf "\n              files (ocean precursor runs followed by"
-    printf "\n              coupled atmosphere-ocean runs)           ---"
-    printf "\n        -Y    run coupled model, \"#1 #2\" with" 
-    printf "\n              #1 atmosphere and #2 ocean processors    \"#/2 #/2\" depending on -X"
-    printf "\n        -Z    skip combine_plot_fields at the end of      "
-    printf "\n              the simulation                           ---"
     printf "\n "
     printf "\n      Possible values of positional parameter <modus>:"
@@ -268,8 +144,10 @@
  if [[ ! -f $config_file ]]
  then
+
     printf "\n\n  +++ configuration file: "
     printf "\n           $config_file"
     printf "\n      does not exist"
-    locat=connect; exit  
+    locat=connect; exit
+
  fi
 
@@ -280,16 +158,11 @@
 
        # CHECK VERSION MISMATCH
-       # RESTART RUNS DON'T REQUIRE A CHECK, BECAUSE THEY USE A COPY OF THAT
-       # FILE WHICH HAS ALREADY BEEN CHECKED WITHIN THE INITAL PALMRUN CALL
-    if [[ $running_in_batch_mode != true  &&  $restart_run != 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"
-          printf "\n               \"${working_directory}/.palm.iofiles\" !"
-       fi
+    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"
+       printf "\n               \"${working_directory}/.palm.iofiles\" !"
     fi
 
@@ -310,4 +183,6 @@
 
     # CHECK, IF THE ACTIVATION_STRING_LIST HAS BEEN GIVEN
+    # TODO: I suggest to use/extend the .palm.iofiles file to set the inifor I/O files,
+    #       activation string could be "inifor"
  if [[ "$activation_string_list" = "" ]]
  then
@@ -318,31 +193,10 @@
 
 
-    # SET VARIABLE TO ACTIVATE PALM BINARY OUTPUT FOR RESTARTS
- if [[ $(echo $activation_string_list | grep -c "restart") != 0 ]]
- then
-    write_binary=true
- else
-    write_binary=false
- fi
-
-    # SET VARIABLE TO ACTIVATE WRITING OF SVF DATA
- if [[ $(echo $activation_string_list | grep -c "svfout") != 0 ]]
- then
-    write_svf=true
- else
-    write_svf=false
- fi
-
-    # SET VARIABLE TO ACTIVATE READING OF SVF DATA 
- if [[ $(echo $activation_string_list | grep -c "svfin") != 0 ]]
- then
-    read_svf=true
- else
-    read_svf=false
- fi
-
-
     # READ AND EVALUATE THE CONFIGURATION-FILE
+    # TODO: we can think about if it is really required tio read and interpret the whole file
+    #       since many settings are not relevant for inifor. Instead, we could read only lines
+    #       inifor-specific variables are set (like it is done in palmbuild)
  [[ $silent = false ]]  &&  printf "\n\n    Reading the configuration file... "
+
 
     # READ VARIABLE SETTINGS FROM CONFIG FILE LINE BY LINE
@@ -444,80 +298,25 @@
 
     # CHECK SETTING OF REQUIRED PARAMETERS
- if [[ "$fast_io_catalog" = "" ]]
- then
-    printf "\n  +++ no fast_io_catalog found in $config_file"
-    printf "\n      Please add line \"fast_io_catalog ...\" to that file."
+    # TODO: we probably need to include such a line in the configuration file
+ if [[ "$execute_command_inifor" = "" ]]
+ then
+    printf "\n  +++ no execute command found for inifor in $config_file"
+    printf "\n      Please add line \"execute_command_inifor ...\" to that file."
     locat=config_file; exit
  fi
- if [[ "$compiler_name" = "" ]]
- then
-    printf "\n  +++ no compiler name found in $config_file"
-    printf "\n      Please add line \"compiler_name ...\" to that file."
-    locat=config_file; exit
- fi
- if [[ "$compiler_name_ser" = "" ]]
- then
-    printf "\n  +++ no compiler name for non-paralle compilation found in $config_file"
-    printf "\n      Please add line \"compiler_name_ser ...\" to that file."
-    locat=config_file; exit
- fi
- if [[ "$compiler_options" = "" ]]
- then
-    printf "\n  +++ no compiler options found in $config_file"
-    printf "\n      Please add line \"compiler_options ...\" to that file."
-    locat=config_file; exit
- fi
- if [[ "$execute_command" = "" ]]
- then
-    printf "\n  +++ no execute command found in $config_file"
-    printf "\n      Please add line \"execute_command ...\" to that file."
-    locat=config_file; exit
- fi
-
- if [[ "$hostfile" != "" ]]
- then
-    if [[ $hostfile != auto  &&  ! -f $hostfile ]]
-    then
-       printf "\n  +++ no hostfile \"$hostfile\" found"
-       printf "\n      Please check line \"hostfile ...\" in $config_file"
-       locat=config_file; exit    
-    fi
- fi
 
 
     # DETERMINE THE CALL STATUS
- if [[ "$return_address" != "" ]]
- then
- 
-       # I AM RUNNING ON A REMOTE HOST, WHICH ALSO MEANS THAT I AM RUNNING IN
-       # BATCH MODE AND ...
-    running_on_remote=true
- 
+ if [[ "$remote_ip" != "" ]]
+ then
+    run_on_remote=true
  else
-
-       # I HAVE BEEN CALLED INTERACTIVELY ON THIS HOST
-     if [[ "$remote_ip" != "" ]]
-     then
-
-           # I HAVE TO CREATE A BATCH JOB TO RUN PALM ON THE REMOTE HOST
-        create_remote_batch_job=true
-
-           # CHECK THAT THE REMOTE JOBCATALOG HAS BEEN SET
-        if [[ "$remote_jobcatalog" = "" ]]
-        then
-           printf "\n  +++ no remote jobcatalog found in $config_file"
-           printf "\n      Please add line \"remote_jobcatalog ...\" to that file."
-           locat=config_file; exit
-        fi
- 
-
-     fi
-     running_on_remote=false
- fi
-
+    run_on_remote=false
+ fi
 
 
     # READ AND EVALUATE THE I/O-FILE LIST
  [[ $silent = false ]]  &&  printf "\n    Reading the I/O files... "
+
 
     # READ THE FILE CONNECTION FILE LINE BY LINE
@@ -673,243 +472,32 @@
 
 
-    # VALUES OF PALMRUN-OPTIONS OVERWRITE THOSE FROM THE CONFIGURATION-FILE
- [[ "$palmrun_memory" != "" ]]  &&  memory=$palmrun_memory
- [[ "$palmrun_cpumax" != "" ]]  &&  cpumax=$palmrun_cpumax
- [[ "$palmrun_cores"  != "" ]]  &&  cores=$palmrun_cores
- [[ "$max_par_io_str" != "" ]]  &&  maximum_parallel_io_streams=$max_par_io_str
- [[ "$palmrun_tasks_per_node" != "" ]]  &&  tasks_per_node=$palmrun_tasks_per_node
-
-
-
-      # EVALUATE MODEL COUPLING FEATURES (OPTION -Y)
- if [[ $run_coupled_model = true ]] 
- then
-
-    cores_atmos=`echo $coupled_dist | cut -d" " -s -f1`
-    cores_ocean=`echo $coupled_dist | cut -d" " -s -f2`
-
-    if (( $cores_ocean + $cores_atmos != $cores ))
-    then
-
-       printf "\n  +++ number of processors does not fit to specification by \"-Y\"."
-       printf "\n      PEs (total)     : $cores"
-       printf "\n      PEs (atmosphere): $cores_atmos"
-       printf "\n      PEs (ocean)     : $cores_ocean"
-       locat=coupling; exit
-
-    fi
-
- fi
-
-
-    # IF I AM IN BATCH MODE, CHECK IF EXECUTABLE AND OTHER REQUIRED FILES
-    # HAVE BEEN GENERATED BY PALMBUILD AND STORED IN THE SOURCES_FOR_RUN_...
-    # FOLDER
- if [[ $running_in_batch_mode = true ]]
+    # VALUES OF INIFOR-OPTIONS OVERWRITE THOSE FROM THE CONFIGURATION-FILE
+    # next line is just an example
+    # TODO: default values for inifor script options could be set in the configuration file
+    #       (if it makes sense)
+ [[ "$inifor_cores"  != "" ]]  &&  cores=$inifor_cores
+
+
+
+    # CHECK IF INIFOR EXECUTABLE EXISTS
+ if [[ $run_on_remote = false ]]
  then
  
-    if [[ ! -d ${fast_io_catalog}/${sources_for_run_catalog} ]]
-    then
-       printf "\n  +++ directory ${fast_io_catalog}/${sources_for_run_catalog} is missing"
-       printf "\n      Please check the output of the palmrun-call"
-       printf "\n      that you did on your local host."
-       locat=SOURCES_FOR_RUN; exit
+    if [[ ! -f ${base_directory}/MAKE_DEPOSITORY_${configuration_identifier}/inifor ]]
+    then
+       printf "\n  +++ no inifor executable found in folder"
+       printf "\n      \"${base_directory}/MAKE_DEPOSITORY_${configuration_identifier}\" "
+       printf "\n      You may run \"palmbuild -c ${configuration_identifier}\" to create"
+       printf "\n      the utility routines."
+       locat=connect; exit
     fi
 
  else
 
-       # CREATE THE SOURCES_FOR_RUN_... FOLDER, BUT NOT IF I AM PART OF AN
-       # AUTOMATIC RESTART RUN
-       # AUTOMATIC RESTART RUNS JUST ACCESS THE DIRECTORY CREATED BY THE INITIAL RUN
-    if [[ $restart_run = false ]]
-    then
-
-          # COLLECT FILES TO BE COMPILED IN THE SOURCES_FOR_RUN_... FOLDER ON
-          # THE LOCAL HOST
-       if [[ ! -d $source_path ]]
-       then
-          printf "\n\n  +++ source path \"$source_path\" on local host"
-          printf "\n      \"$(hostname)\" does not exist"
-          locat=source_path; exit
-       fi
-
-       rm -rf   ${base_directory}/${sources_for_run_catalog}
-       mkdir -p ${base_directory}/${sources_for_run_catalog}
-
-       if [[ "$source_list" = LM ]]
-       then
-
-             # DETERMINE MODIFIED FILES OF THE SVN WORKING COPY
-          source_list=""
-          cd  $source_path
-
-
-             # CHECK, IF TRUNK-DIRECTORY IS UNDER SVN CONTROL
-          if [[ ! -d ../.svn ]]
-          then
-             printf "\n\n  +++ source directory"
-             printf "\n         \"$source_path\" "
-             printf "\n         is not under control of \"subversion\"."
-             printf "\n         Please do not use palmrun-option \"-s LM\"\n"
-          fi
-
-
-             # LIST ALL MODIFIED SOURCE CODE FILES
-          Filenames=""
-          svn status  >  tmp_svnstatus
-          while  read line
-          do
-             firstc=`echo $line | cut -c1`
-             if [[ $firstc = M  ||  $firstc = "?" ]]
-             then
-                Name=`echo "$line" | cut -c8-`
-                extension=`echo $Name | cut -d. -f2`
-                if [[ "$extension" = f90 || "$extension" = F90 || "$extension" = f || "$extension" = F || "$extension" = c ]]
-                then
-                   Filenames="$Filenames "$Name
-                fi
-             fi
-          done < tmp_svnstatus
-          rm -rf  tmp_svnstatus
-
-
-             # COPY FILES TO SOURCES_FOR_RUN_...
-          for  filename  in  $Filenames
-          do
-             cp  $filename  ${base_directory}/${sources_for_run_catalog}
-             source_list=$source_list"$filename "
-          done
-
-          cd -  > /dev/null
-
-
-          # COPY FILES GIVEN BY OPTION -s TO DIRECTORY SOURCES_FOR_RUN_...
-       elif [[ "$source_list" != "" ]]
-       then
-
-          cd  $source_path
-
-          for  filename  in  $source_list
-          do
-
-                # SOURCE CODE FILE IS NOT ALLOWED TO INCLUDE PATH
-             if [[ $(echo $filename | grep -c "/") != 0 ]]
-             then
-                printf "\n  +++ source code file:  $filename"
-                printf "\n      must not contain (\"/\") "
-                locat=source; exit
-             fi
-
-             if [[ ! -f $filename ]]
-             then
-                printf "\n  +++ source code file:  $filename"
-                printf "\n      does not exist"
-                locat=source; exit
-             else
-                cp  $filename  ${base_directory}/${sources_for_run_catalog}
-             fi
-
-          done
-
-          cd -  > /dev/null
-
-       fi
-
-          # CHECK, IF MAKEFILE EXISTS AND COPY IT TO THE SOURCES_FOR_RUN... DIRECTORY
-       [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
-       if [[ ! -f $makefile ]]
-       then
-          printf "\n  +++ file \"$makefile\" does not exist"
-          locat=make; exit
-       else
-          cp  $makefile  ${base_directory}/${sources_for_run_catalog}/Makefile 
-       fi
-
-
-          # COPY FILES FROM OPTIONAL SOURCE PATH GIVEN IN THE CONFIGURATION FILE
-       if [[ "$user_source_path" != "" ]]
-       then
-
-             # DOES THE DIRECTORY EXIST?
-          if [[ ! -d $user_source_path ]]
-          then
-
-             printf "\n\n  *** INFORMATIVE: additional source code directory"
-             printf "\n      \"$user_source_path\" "
-             printf "\n      does not exist or is not a directory."
-             printf "\n      No source code will be used from this directory!\n"
-             user_source_path=""
-             if [[ $silent == false ]]
-             then
-                sleep 2
-             fi
-
-          else
-
-             cd $user_source_path
-
-             Names=$(ls -1 *.f90 2>&1)
-             [[ $(echo $Names | grep -c '*.f90') = 0 ]]  &&  AddFilenames="$Names"
-             Names=$(ls -1 *.F90 2>&1)
-             [[ $(echo $Names | grep -c '*.F90') = 0 ]]  &&  AddFilenames="$AddFilenames $Names"
-             Names=$(ls -1 *.F 2>&1)
-             [[ $(echo $Names | grep -c '*.F') = 0   ]]  &&  AddFilenames="$AddFilenames $Names"
-             Names=$(ls -1 *.f 2>&1)
-             [[ $(echo $Names | grep -c '*.f') = 0   ]]  &&  AddFilenames="$AddFilenames $Names"
-             Names=$(ls -1 *.c 2>&1)
-             [[ $(echo $Names | grep -c '*.c') = 0   ]]  &&  AddFilenames="$AddFilenames $Names"
-
-             cd -  > /dev/null
-             cd  ${base_directory}/${sources_for_run_catalog}
-
-                # COPY MAKEFILE IF EXISTING
-             if [[ -f $user_source_path/Makefile ]]
-             then
-                printf "\n\n  *** user Makefile from directory"
-                printf "\n      \"$user_source_path\" is used \n"
-                if [[ $silent == false ]]
-                then
-                   sleep 1
-                fi
-                cp  $user_source_path/Makefile  .
-             fi
-
-             for  filename  in  $AddFilenames
-             do
-                if [[ -f $filename ]]
-                then
-                   printf "\n  +++ source code file \"$filename\" found in additional"
-                   printf "\n      source code directory \"$user_source_path\" "
-                   printf "\n      but was also given with option \"-s\" which means that it should be taken"
-                   printf "\n      from directory \"$source_path\"."
-                   locat=source; exit
-                fi
-
-                cp  $user_source_path/$filename  .
-                source_list="$source_list $filename"
-
-                   # CHECK IF FILE IS CONTAINED IN MAKEFILE
-                if [[ $(grep -c $filename Makefile) = 0 ]]
-                then
-                   printf "\n\n  +++ user file \"$filename\" "
-                   printf "\n      is not listed in Makefile \n"
-                   locat=source; exit
-                fi
-             done
-             cd -  > /dev/null
-          fi
-       fi
-
-          # COPY CONFIGURATION FILES
-       cp  $config_file  ${base_directory}/${sources_for_run_catalog}
-       cp  $fileconnection_file  ${base_directory}/${sources_for_run_catalog}
-
-          # COPY SHELLSCRIPTS
-       cp  ${source_path}/../SCRIPTS/palmrun    ${base_directory}/${sources_for_run_catalog}
-       cp  ${source_path}/../SCRIPTS/batch_scp  ${base_directory}/${sources_for_run_catalog}
-
-    fi
-
- fi
+    printf "\n  +++ remote call of inifor not realized yet"
+    locat=inifor_remote; exit
+
+ fi
+
 
 
@@ -923,56 +511,4 @@
 
 
-    # IN CASE OF PARALLEL EXECUTION, CHECK SOME SPECIFICATIONS CONCERNING PROCESSOR NUMBERS
- if [[ -n $cores ]]
- then
-
-       # CHECK, IF THE NUMBER OF CORES PER NODE HAS BEEN GIVEN UND IF IT IS AN
-       # INTEGRAL DIVISOR OF THE TOTAL NUMBER OF CORES GIVEN BY OPTION -X
-    if [[ $tasks_per_node = 0 ]]
-    then
-       if [[ $create_batch_job = true  ||  $create_remote_batch_job = true ]]
-       then
-          printf "\n"
-          printf "\n  +++ option \"-T\" (tasks per node) is missing"
-          printf "\n      set -T option or define tasks_per_node in the config file"
-          locat=tasks_per_node; (( iec = 0 )); exit
-       else
-             # DEFAULT FOR INTERACTIVE RUN
-          tasks_per_node=$cores
-       fi
-    fi
-
-    if (( cores < tasks_per_node ))
-    then
-       printf "\n"
-       printf "\n  +++ tasks per node (-T) cannot exceed total number of cores (-X)"
-       printf "\n      given values: -T $tasks_per_node  -X $cores"
-       locat=tasks_per_node; (( iec = 0 )); exit 
-    fi
-
-    (( nodes = cores / ( tasks_per_node * threads_per_task ) ))
-    (( mpi_tasks = cores / threads_per_task ))
-    [[ $mpi_tasks = 0 ]]  &&  (( mpi_tasks = 1 ))
-    (( ii = cores / tasks_per_node ))
-    (( remaining_cores =  cores - ii * tasks_per_node ))
-    if (( remaining_cores > 0 ))
-    then
-       printf "\n"
-       printf "\n  +++ WARNING: tasks per node (option \"-T\") is not an integral"
-       printf "\n      divisor of the total number of cores (option \"-X\")"
-       printf "\n      values of this palmrun-call: \"-T $tasks_per_node\" \"-X $cores\""
-       printf "\n      One of the nodes is filled with $remaining_cores instead of $tasks_per_node tasks"
-       (( nodes = nodes + 1 ))
-    fi
-
- fi
-
-
-    # SET DEFAULT VALUE FOR THE MAXIMUM NUMBER OF PARALLEL IO STREAMS
- if [[ "$maximum_parallel_io_streams" = "" ]]
- then
-    maximum_parallel_io_streams=$cores
- fi
-
 
     # SET PORT NUMBER OPTION FOR CALLS OF SSH/SCP AND batch_scp SCRIPT
@@ -989,23 +525,4 @@
  then
     ssh_key="-i $HOME/.ssh/$ssh_key"
- fi
-
-
-    # SET QUEUE, IF NOT GIVEN
- if [[ $create_batch_job = true  ||  $create_remote_batch_job = true ]]
- then
-
-    if [[ $queue = none  &&  "$defaultqueue" = "" ]]
-    then
-       printf "\n"
-       printf "\n  +++ no default queue given in configuration file and no queue"
-       printf "\n      given with option -q"
-       locat=queue; exit
-    fi
-    if [[ $queue = none ]]
-    then
-       queue=$defaultqueue
-    fi
-
  fi
 
@@ -1315,96 +832,13 @@
 
 
-    # DETERMINE THE NAME OF PALMRUN'S TEMPORARY WORKING DIRECTORY
- if [[ $running_in_batch_mode = false ]]
- then
-    run_id_number=$RANDOM
-    run_id=${run_identifier}.$run_id_number
-
-    tempdir=$fast_io_catalog/$run_id
-
-       # FOR COMPATIBILITY REASONS WITH OLDER VERSIONS SET JOB_ID
-    export job_id=$run_id
-
- fi
-
-
-    # CHECK SETTINGS REQUIRED FOR BATCH JOBS
- if [[ $create_batch_job = true  ||  $create_remote_batch_job = true ]]
- then
-
-       # CHECK, IF JOB DIRECTIVES HAVE BEEN GIVEN IN CONFIGURATION FILE
-    if [[ $ibd = 0 ]]
-    then
-       printf "\n"
-       printf "\n  +++ no batch directives found in configuration file"
-       locat=config_file_batch_directives; (( iec = 0 )); exit 
-    fi
-
-       # CHECK IF CPUTIME IS GIVEN FOR JOB
-    done=false
-    cputime=$cpumax
-    while [[ $done = false ]]
-    do
-       if (( cputime == 0 ))
-       then
-          printf "\n  +++ cpu-time is undefined"
-          printf "\n  >>> Please type CPU-time in seconds as INTEGER:"
-          printf "\n  >>> "
-          read  cputime   1>/dev/null  2>&1
-       else
-          done=true
-       fi
-    done
-    cpumax=$cputime
-
-       # CHECK THE MEMORY DEMAND
-    done=false
-    while [[ $done = false ]]
-    do
-       if (( memory == 0 ))
-       then
-          printf "\n  +++ memory demand is undefined"
-          printf "\n  >>> Please type memory in  MByte per process  as INTEGER:"
-          printf "\n  >>> "
-          read  memory  1>/dev/null  2>&1
-       else
-          done=true
-       fi
-    done
-
-       # IN CASE OF REMOTE-JOBS CHECK, IF A USERNAME FOR THE REMOTE HOST IS GIVEN
-    if [[ $create_remote_batch_job = true  &&  -z $remote_username ]]
-    then
-       while [[ -z $remote_username ]]
-       do
-          printf "\n  +++ username on remote host with IP \"$remote_ip\" is undefined"
-          printf "\n  >>> Please type username:"
-          printf "\n  >>> "
-          read  remote_username
-       done
-    fi
-
- else
-
-    if [[ $running_in_batch_mode = false ]]
-    then
-       cputime=10000000  # NO LIMT FOR INTERACTIVE RUNS
-       cpumax=$cputime
-    else
-       cputime=$cpumax
-    fi
-
- fi
-
-
-    # CALCULATE HOURS/MINUTES/SECONDS, E.G. FOR BATCH-DIRECTIVES
- (( cpu_hours  = cputime / 3600 ))
- (( resttime = cputime - cpu_hours * 3600 ))
- (( cpu_minutes  = resttime / 60 ))
- (( cpu_seconds = resttime - cpu_minutes * 60 ))
- timestring=${cpu_hours}:${cpu_minutes}:${cpu_seconds}
-
-
-    # OUTPUT OF THE PALMRUN-HEADER
+    # DETERMINE THE NAME OF INIFOR'S TEMPORARY WORKING DIRECTORY
+ run_id_number=$RANDOM
+ run_id=${run_identifier}.$run_id_number
+ tempdir=$fast_io_catalog/$run_id
+
+
+
+
+    # OUTPUT OF THE INIFOR-HEADER
  calltime=$(date)
  printf "\n"
@@ -1415,128 +849,12 @@
  column1="called on:"; column2=$(hostname)
  printf "| %-25s%-45s | \n" "$column1" "$column2"
- if [[ $create_remote_batch_job = true ]]
- then
-    column1="execution on:"; column2="$configuration_identifier (username: $remote_username)"
+ if [[ $run_on_remote = true ]]
+ then
+    column1="config. identifier:"; column2="$configuration_identifier (execute on IP: $remote_ip)"
  else
-    if [[ $running_on_remote = true ]]
-    then
-       column1="config. identifier:"; column2="$configuration_identifier (execute on IP: $remote_ip)"
-    else
-       column1="config. identifier:"; column2="$configuration_identifier (execute on IP: $local_ip)"
-    fi
+    column1="config. identifier:"; column2="$configuration_identifier (execute on IP: $local_ip)"
  fi
  printf "| %-25s%-45s | \n" "$column1" "$column2"
 
- column1="running in:"
- if [[ $running_in_batch_mode = true ]]
- then
-    column2="batch job mode"
- else
-    if [[ $create_batch_job = true  ||  $create_remote_batch_job = true ]]
-    then
-       column2="job creation mode"
-    else
-       column2="interactive run mode"
-    fi
- fi
- printf "| %-25s%-45s | \n" "$column1" "$column2"
-
- if  [[ $running_in_batch_mode = true  ||  $create_batch_job = true  ||  $create_remote_batch_job = true ]]
- then
-    if [[ "$project_account" != "" ]]
-    then
-       column1="project account number:"
-       column2="$project_account"
-       printf "| %-25s%-45s | \n" "$column1" "$column2"
-    fi
- fi
-
- if [[ -n $cores ]]
- then
-    if [[ $run_coupled_model = false ]]
-    then
-       column1="number of cores:"; column2=$cores
-    else
-       column1="number of cores:"; column2="$cores  (atmosphere: $cores_atmos, ocean: $cores_ocean)"
-    fi
-    printf "| %-25s%-45s | \n" "$column1" "$column2"
- fi
- if [[ -n $tasks_per_node ]]
- then
-    column1="tasks per node:"; column2="$tasks_per_node (number of nodes: $nodes)"
-    printf "| %-25s%-45s | \n" "$column1" "$column2"
-    if (( remaining_cores > 0 ))
-    then
-       column1=" "; column2="one of the nodes only filled with $remaining_cores tasks"
-       printf "| %-25s%-45s | \n" "$column1" "$column2"
-    fi
- fi
- if [[ $maximum_parallel_io_streams != $cores ]]
- then
-    column1="max par io streams:"; column2="$maximum_parallel_io_streams"
-    printf "| %-25s%-45s | \n" "$column1" "$column2"
- fi
- if [[ $use_openmp = true ]]
- then
-    column1="threads per task:"; column2="$threads_per_task"
-    printf "| %-25s%-45s | \n" "$column1" "$column2"
- fi
- if [[ $create_batch_job = true  ||  $create_remote_batch_job = true  ||  $running_in_batch_mode = true ]]
- then
-    column1="memory demand / PE":; column2="$memory MB"
-    printf "| %-25s%-45s | \n" "$column1" "$column2"
-    column1="job cpu time (h:m:s):"; column2="$timestring"
-    printf "| %-25s%-45s | \n" "$column1" "$column2"
- fi
- printf "|                                                                        | \n"
- if [[ "$source_list" != "" ]]
- then
-    if [[ "$make_options" != "" ]]
-    then
-       column1="make options:"; column2=$(echo "$make_options" | cut -c-45)
-       printf "| %-25s%-45s | \n" "$column1" "$column2"
-       line=$(echo "$make_options" | cut -c46-)
-       while [[ "$line" != "" ]]
-       do
-          column1=""
-          column2=$(echo "$line" | cut -c-45)
-          printf "| %-25s%-45s | \n" "$column1" "$column2"
-          line=$(echo "$line" | cut -c46-)
-       done
-    fi
- fi
-
- column1="cpp directives:"; column2=$(echo "$cpp_options" | cut -c-45)
- printf "| %-25s%-45s | \n" "$column1" "$column2"
- line=$(echo "$cpp_options" | cut -c46-)
- while [[ "$line" != "" ]]
- do
-    column1=""
-    column2=$(echo "$line" | cut -c-45)
-    printf "| %-25s%-45s | \n" "$column1" "$column2"
-    line=$(echo "$line" | cut -c46-)
- done
-
- column1="compiler options:"; column2=$(echo "$compiler_options" | cut -c-45)
- printf "| %-25s%-45s | \n" "$column1" "$column2"
- line=$(echo "$compiler_options" | cut -c46-)
- while [[ "$line" != "" ]]
- do
-    column1=""
-    column2=$(echo "$line" | cut -c-45)
-    printf "| %-25s%-45s | \n" "$column1" "$column2"
-    line=$(echo "$line" | cut -c46-)
- done
-
- column1="linker options:"; column2=$(echo "$linker_options" | cut -c-45)
- printf "| %-25s%-45s | \n" "$column1" "$column2"
- line=$(echo "$linker_options" | cut -c46-)
- while [[ "$line" != "" ]]
- do
-    column1=""
-    column2=$(echo "$line" | cut -c-45)
-    printf "| %-25s%-45s | \n" "$column1" "$column2"
-    line=$(echo "$line" | cut -c46-)
- done
 
  if [[ "$login_init_cmd" != "" ]]
@@ -1573,72 +891,11 @@
  printf "| %-25s%-45s | \n" "$column1" "$column2"
 
- if [[ "$ocean_file_appendix" = true ]]
- then
-    printf "| %-35s%-35s | \n" "suffix \"_O\" is added to local files" " "
- fi
-
- if [[ "$source_list" != "" ]]
- then
-    printf "|                                                                        | \n"
-    printf "| Files to be compiled:                                                  | \n"
-    line=$source_list
-    while [[ "$line" != "" ]]
-    do
-       linestart=$(echo $line | cut -c-70)
-       printf "| %-70s | \n" "$linestart"
-       line=$(echo "$line" | cut -c71-)
-    done
- fi
  printf "#------------------------------------------------------------------------#"
 
 
 
-    # OUTPUT OF FILE CONNECTIONS IN CASE OF TRACEBACK
- if [[ $do_trace = true ]]
- then
-    (( i = 0 ))
-    while (( i < nr_of_input_files ))
-    do
-       (( i = i + 1 ))
-       if (( i == 1 ))
-       then
-          printf "\n\n >>> INPUT-file assignments:\n"
-       fi
-       printf "\n     ${localin[$i]} :  ${absnamein[$i]}"
-    done
-    (( i = 0 ))
-    while (( i < iout ))
-    do
-       (( i = i + 1 ))
-       if (( i == 1 ))
-       then
-          printf "\n\n >>> OUTPUT-file assignments:\n"
-       fi
-       printf "\n     ${localout[$i]} :  ${pathout[$i]}"
-    done
-    (( i = 0 ))
-    while (( i < iic ))
-    do
-       (( i = i + 1 ))
-       if (( i == 1 ))
-       then
-          printf "\n\n >>> INPUT-commands:\n"
-       fi
-       printf "\n     ${in_command[$i]}" 
-    done
-    (( i = 0 ))
-    while (( i < ioc ))
-    do
-       (( i = i + 1 ))
-       if (( i == 1 ))
-       then
-          printf "\n\n >>> OUTPUT-commands:\n"
-       fi
-       printf "\n     ${out_command[$i]}" 
-    done
- fi
 
     # QUERY FOR CONTINUE
- if [[ $silent = false  &&  $running_in_batch_mode = false ]]
+ if [[ $silent = false ]]
  then
     antwort=dummy
@@ -1658,370 +915,226 @@
        locat=user_abort; (( iec = 0 )); exit
     fi
-    if [[ $create_batch_job = true  ||  $create_remote_batch_job = true ]]
-    then
-       printf "\n ***  batch-job will be created and submitted"
+    if [[ $run_on_remote ]]
+    then
+       printf "\n ***  inifor will now run on remote"
     else
-       printf "\n ***  PALMRUN will now continue to execute on this machine"
+       printf "\n ***  inifor will now continue to execute on this machine"
     fi
  fi
 
  
-
-    # PROVIDE FILES TO EXECUTE PALM AND CREATE THE EXECUTABLE
- if [[ $restart_run = false  &&  $running_in_batch_mode = false ]]
- then
-
-    if [[ $create_batch_job = true  ||  $create_remote_batch_job  = true ]]
-    then
-       printf "\n\n  *** creating executable and other sources for the remote host\n"
+    # NOW PERFORM THOSE ACTIONS REQUIRED TO EXECUTE INIFOR ON THIS MACHINE (COPYING I/O FILES)
+    # CHANGE TO THE TEMPORARY WORKING DIRECTORY
+
+ mkdir -p  $tempdir
+ chmod  go+rx  $tempdir
+ cd  $tempdir
+
+ printf "\n  *** changed to temporary directory: $tempdir"
+
+
+
+    # PROVIDE THE INPUT FILES
+    # LOOP OVER ALL ACTIVATED FILES (LISTED IN THE CONFIGURATION FILE)
+ optional_files_missing=false
+ (( i = 0 ))
+ while (( i < nr_of_input_files ))
+ do
+    (( i = i + 1 ))
+    if (( i == 1 ))
+    then
+       printf "\n\n  *** providing INPUT-files:\n$dashes"
+    fi
+
+
+       # SKIP OPTIONAL FILES, IF THEY DO NOT EXIST
+    if [[ "${actionin[$i]}" = unavailable ]]
+    then
+       optional_files_missing=true
+       continue
+    fi
+
+       # CHECK FOR SINGLE FILE (SERIAL RUN) OR DIRECTORY (ONE FILE PER CORE FOR PARELLEL EXECUTION)
+    files_for_cores=false; filetype=file
+    if [[ "${actionin[$i]}" = pe  &&  -n $cores ]]
+    then
+       files_for_cores=true; filetype=files
+       actionin[$i]=""
+    elif [[ "${actionin[$i]}" = pe  &&  ! -n $cores ]]
+    then
+       actionin[$i]=""
+    elif [[ "${actionin[$i]}" = lnpe  &&  -n $cores ]]
+    then
+       files_for_cores=true; filetype=files
+       actionin[$i]="ln"
+    elif [[ "${actionin[$i]}" = lnpe  &&  ! -n $cores ]]
+    then
+       actionin[$i]="ln"
+    fi
+
+    if [[ $files_for_cores = true ]]
+    then
+       printf "\n  >>> INPUT: ${absnamein[$i]}/....  to  ${localin[$i]}"
     else
-       printf "\n\n  *** creating executable and other sources for the local host\n"
-    fi
-
-       # FIRST CHECK, IF A MAKE DEPOSITORY EXISTS, AND IF NOT, ASK THE USER IF
-       # IT SHALL BE CREATED
-    ask_for_make_depository=false
-    if [[ $create_remote_batch_job = true ]]
-    then
-
-       line=`grep %base_directory $config_file`
-       make_depository=`echo $line | cut -d" " -s -f2`/MAKE_DEPOSITORY_${configuration_identifier}
-       ssh  -q  $ssh_key  ${remote_username}@${remote_ip} "[[ ! -d ${make_depository} ]]  &&  echo depository not found" 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}\""
-          printf "\n      on remote host not found!"
-          ask_for_make_depository=true
-       fi
-       rm ${configuration_identifier}_last_make_protokoll
-
-    else
-
-          # CHECK FOR MAKE_DEPOSITORY ON THE LOCAL HOST
-       make_depository=${base_directory}/MAKE_DEPOSITORY_${configuration_identifier}
-       if [[ ! -d ${make_depository} ]]
-       then
-          printf "\n\n  +++ make depository \"${make_depository}\""
-          printf "\n      on local host not found!"
-          ask_for_make_depository=true
-       fi
-
-    fi
-
-    if [[ $ask_for_make_depository = true ]]
-    then
-
-       antwort=dummy
-       printf "\n\n"
-       printf "  >>> Create a new one (y/n) ?  "
-       while  read antwort
-       do
-          if [[ "$antwort" != y  &&  "$antwort" != Y  &&  "$antwort" != n  &&  "$antwort" != N ]]
-          then
-             printf "  >>> Create a new one (y/n) ?  "
-          else
-             break
-          fi
-       done
-       if [[ $antwort = n  ||  $antwort = N ]]
-       then
-          locat=user_abort; (( iec = 0 )); exit
-       fi
-
-       if [[ $do_trace = true ]]
-       then
-          palmbuild  -c $configuration_identifier
+       printf "\n  >>> INPUT: ${absnamein[$i]}  to  ${localin[$i]}"
+    fi
+
+       # INPUT-FILES TO BE LINKED
+    if [[ "${actionin[$i]}" = ln ]]
+    then
+
+       printf "\n      $filetype will be linked"
+       if [[ $files_for_cores = false ]]
+       then
+          if [[ -f "${absnamein[$i]}" ]]
+          then
+             ln  ${absnamein[$i]}  ${localin[$i]}
+             got_tmp[$i]=true
+          fi
        else
-          palmbuild  -v  -c $configuration_identifier
-       fi
-
-       if [[ ${PIPESTATUS[0]} != 0 ]]
-       then
-   
-              # ABORT IN CASE OF COMPILATION PROBLEMS
-          printf "\n  +++ error while compiling for the MAKE_DEPOSITORY"
-          locat=make_depository
-          exit
+          if [[ -d "${absnamein[$i]}" ]]
+          then
+             mkdir -p ${localin[$i]}
+             cd ${absnamein[$i]}
+             for file in $(ls *)
+             do
+                ln $file $tempdir/${localin[$i]}
+             done >|/dev/null 2>&1
+             cd $tempdir
+          fi
+
+             # IF "ln -f" HAS FAILED DO A NORMAL COPY "cp -r"
+          if [[ ! -f "${localin[$i]}/_000000" ]]
+          then
+             printf "\n  --- WARNING: ln failed, using cp instead (might be time consuming...)"
+             cp -r  ${absnamein[$i]}/*  ${localin[$i]}
+          fi
+
+          got_tmp[$i]=true
+       fi
+    fi
+
+       # FILE IS STORED IN THE RESPECTIVE DIRECTORY GIVEN IN THE CONFIGURATION FILE
+    if [[ "${actionin[$i]}" = ""  ||  "${actionin[$i]}" = "di"  ||  "${actionin[$i]}" = "tr"  ||  "${actionin[$i]}" = "npe" ]]
+    then
+
+       if [[ "${actionin[$i]}" = "npe"  &&  -n $cores ]]
+       then
+
+             # FILE COPIES ARE PROVIDED FOR ALL CORES
+             # EACH FILE GETS A UNIQUE FILENAME WITH A FOUR DIGIT NUMBER
+          printf "\n      file will be provided for $cores processors"
+          mkdir -p ${localin[$i]}
+          ival=$cores
+          (( ii = 0 ))
+          while (( ii <= ival-1 ))
+          do
+             if (( ii < 10 ))
+             then
+                cp  ${absnamein[$i]}  ${localin[$i]}/_000$ii
+             elif (( ii < 100 ))
+             then
+                cp  ${absnamein[$i]}  ${localin[$i]}/_00$ii
+             elif (( ii < 1000 ))
+             then
+                cp  ${absnamein[$i]}  ${localin[$i]}/_0$ii
+             else
+                cp  ${absnamein[$i]}  ${localin[$i]}/_$ii
+             fi
+             (( ii = ii + 1 ))
+          done
+
        else
-          echo "  *** now continue with creating executable and other sources"
-       fi
-
-    fi
-
-       # NOW CREATE THE SOURCES_FOR_RUN FOLDER
-    palmbuild  -v  $use_existing_sources_folder  -c $configuration_identifier  -r $run_identifier
-
-    if [[ ${PIPESTATUS[0]} != 0 ]]
-    then
-
-           # ABORT IN CASE OF COMPILATION PROBLEMS
-       printf "\n  +++ error while creating executable and/or other sources"
-       locat=execution
-       rm -rf  ${base_directory}/${sources_for_run_catalog}
-       exit
-
-    else
-
-       printf "  *** executable and other sources created\n"
-       rm -rf  ${base_directory}/${sources_for_run_catalog}
-
-    fi
-
- fi
-
-
-    # WHEN CREATING A REMOTE BATCH JOB, THOSE INPUT FILES WITH TRANSFER-ATTRIBUT
-    # WILL BE COPIED TO THE REMOTE HOST
- if [[ $create_remote_batch_job = true ]]
- then
-    (( i = 0 ))
-    while (( i < nr_of_input_files ))
-    do
-       (( i = i + 1 ))
-       if [[ "${actionin[$i]}" = tr ]]
-       then
-          eval inputfile=${pathin[$i]}/${frelin[$i]}
-          scp  -q $ssh_key  $PORTOPT  $inputfile  ${remote_username}@${remote_ip}:${fast_io_catalog}/${sources_for_run_catalog}/${frelin[$i]}
-       fi
-    done
-    if (( i > 0 ))
-    then
-       printf "\n\n  *** input files have been copied to the remote host\n"
-    fi
- fi
- 
-
-    # NOW PERFORM THOSE ACTIONS REQUIRED TO EXECUTE THE PROGRAM (PALM) ON THIS MACHINE
-    # (COMPILING/LINKING, EXECUTING, COPYING I/O FILES)
- if [[ $create_batch_job = false  &&  $create_remote_batch_job = false ]]
- then
-
-       # CHANGE TO THE TEMPORARY WORKING DIRECTORY
-    if [[ $running_in_batch_mode = false ]]
-    then
-          # CREATE THE DIRECTORY AND COPY FILES FROM SOURCES_FOR_RUN_... TO THAT
-          # FOLDER
-       mkdir -p  $tempdir
-       chmod  go+rx  $tempdir
-       cd  $tempdir
-       cp  ${fast_io_catalog}/${sources_for_run_catalog}/{*,.[!.]*}  $tempdir
-       printf "\n  *** changed to temporary directory: $tempdir"
-
-    else
-
-          # IN BATCH MODE PALMRUN IS CALLED FROM TEMPDIR
-       printf "\n  *** running in temporary directory: $tempdir"
-
-    fi
-
-
-       # PROVIDE THE INPUT FILES
-       # LOOP OVER ALL ACTIVATED FILES (LISTED IN THE CONFIGURATION FILE)
-    optional_files_missing=false
-    (( i = 0 ))
-    while (( i < nr_of_input_files ))
-    do
-       (( i = i + 1 ))
-       if (( i == 1 ))
-       then
-          printf "\n\n  *** providing INPUT-files:\n$dashes"
-       fi
-
-
-          # SKIP OPTIONAL FILES, IF THEY DO NOT EXIST
-       if [[ "${actionin[$i]}" = unavailable ]]
-       then
-          optional_files_missing=true
-          continue
-       fi
-
-          # CHECK FOR SINGLE FILE (SERIAL RUN) OR DIRECTORY (ONE FILE PER CORE FOR PARELLEL EXECUTION)
-       files_for_cores=false; filetype=file
-       if [[ "${actionin[$i]}" = pe  &&  -n $cores ]]
-       then
-          files_for_cores=true; filetype=files
-          actionin[$i]=""
-       elif [[ "${actionin[$i]}" = pe  &&  ! -n $cores ]]
-       then
-          actionin[$i]=""
-       elif [[ "${actionin[$i]}" = lnpe  &&  -n $cores ]]
-       then
-          files_for_cores=true; filetype=files
-          actionin[$i]="ln"
-       elif [[ "${actionin[$i]}" = lnpe  &&  ! -n $cores ]]
-       then
-          actionin[$i]="ln"
-       fi
-
-       if [[ $files_for_cores = true ]]
-       then
-          printf "\n  >>> INPUT: ${absnamein[$i]}/....  to  ${localin[$i]}"
-       else
-          printf "\n  >>> INPUT: ${absnamein[$i]}  to  ${localin[$i]}"
-       fi
-
-          # INPUT-FILES TO BE LINKED
-       if [[ "${actionin[$i]}" = ln ]]
-       then
-
-          printf "\n      $filetype will be linked"
-          if [[ $files_for_cores = false ]]
-          then
-             if [[ -f "${absnamein[$i]}" ]]
-             then
-                ln  ${absnamein[$i]}  ${localin[$i]}
-                got_tmp[$i]=true
-             fi
-          else
-             if [[ -d "${absnamein[$i]}" ]]
-             then
-                mkdir -p ${localin[$i]}
+
+          if [[ $files_for_cores = true ]]
+          then
+
+                # PROVIDE FILES FOR EACH CORE
+                # FIRST CREATE THE LOCAL DIRECTORY, THEN COPY FILES
+                # FROM THE PERMANENT DIRECTORY BY LINKING THEM TO THE LOCAL ONE
+             printf "\n      providing $cores files for the respective cores"
+             mkdir -p ${localin[$i]}
+            	if [[ $link_local_input = true ]]
+             then
+                printf "      files will be linked\n"
                 cd ${absnamein[$i]}
                 for file in $(ls *)
                 do
-                   ln $file $tempdir/${localin[$i]}
-                done >|/dev/null 2>&1
+                   ln -f $file  ${localin[$i]}
+                done
                 cd $tempdir
              fi
 
-                # IF "ln -f" HAS FAILED DO A NORMAL COPY "cp -r"
+                # IF "ln -f" FAILED OR IF "$link_local_input = false" DO A NORMAL "cp -r"
              if [[ ! -f "${localin[$i]}/_000000" ]]
              then
-                printf "\n  --- WARNING: ln failed, using cp instead (might be time consuming...)"
+                if [[ $link_local_input = true ]]
+               	then
+                 		printf "\n  --- WARNING: ln failed, using cp instead (might be time consuming...)"
+                fi
                 cp -r  ${absnamein[$i]}/*  ${localin[$i]}
              fi
 
-             got_tmp[$i]=true
-          fi
-       fi
-
-          # FILE IS STORED IN THE RESPECTIVE DIRECTORY GIVEN IN THE CONFIGURATION FILE
-       if [[ "${actionin[$i]}" = ""  ||  "${actionin[$i]}" = "di"  ||  "${actionin[$i]}" = "tr"  ||  "${actionin[$i]}" = "npe" ]]
-       then
-
-          if [[ "${actionin[$i]}" = "npe"  &&  -n $cores ]]
-          then
-
-                # FILE COPIES ARE PROVIDED FOR ALL CORES
-                # EACH FILE GETS A UNIQUE FILENAME WITH A FOUR DIGIT NUMBER
-             printf "\n      file will be provided for $cores processors"
-             mkdir -p ${localin[$i]}
-             ival=$cores
-             (( ii = 0 ))
-             while (( ii <= ival-1 ))
-             do
-                if (( ii < 10 ))
+          else
+
+                # PROVIDE FILE FOR RUNS ON A SINGLE CORE
+           		if [[ $link_local_input = true ]]
+            	then
+                printf "      file will be linked\n"
+                ln -f  ${absnamein[$i]}  ${localin[$i]}
+            	fi
+               	# If "ln -f" fails or if "$link_local_input = false" do a normal "cp"
+            	if [[ ! -f "${localin[$i]}" ]]
+             then
+                if [[ $link_local_input = true ]]
                 then
-                   cp  ${absnamein[$i]}  ${localin[$i]}/_000$ii
-                elif (( ii < 100 ))
+                   printf "\n  --- WARNING: ln failed, using cp instead (might be time consuming...)"
+                fi
+                if [[ $running_on_remote = true  &&  "${actionin[$i]}" = tr ]]
                 then
-                   cp  ${absnamein[$i]}  ${localin[$i]}/_00$ii
-                elif (( ii < 1000 ))
-                then
-                   cp  ${absnamein[$i]}  ${localin[$i]}/_0$ii
+                   mv  ${absnamein[$i]}  ${localin[$i]}
                 else
-                   cp  ${absnamein[$i]}  ${localin[$i]}/_$ii
+		                 cp  ${absnamein[$i]}  ${localin[$i]}
                 fi
-                (( ii = ii + 1 ))
-             done
-
-          else
-
-             if [[ $files_for_cores = true ]]
-             then
-
-                   # PROVIDE FILES FOR EACH CORE
-                   # FIRST CREATE THE LOCAL DIRECTORY, THEN COPY FILES
-                   # FROM THE PERMANENT DIRECTORY BY LINKING THEM TO THE LOCAL ONE
-                printf "\n      providing $cores files for the respective cores"
-                mkdir -p ${localin[$i]}
-	              	if [[ $link_local_input = true ]]
-		              then
-		                 printf "      files will be linked\n"
-		                 cd ${absnamein[$i]}
-		                 for file in $(ls *)
-		                 do
-		                    ln -f $file  ${localin[$i]}
-		                 done
-		                 cd $tempdir
-		              fi
-
-                   # IF "ln -f" FAILED OR IF "$link_local_input = false" DO A NORMAL "cp -r"
-		              if [[ ! -f "${localin[$i]}/_000000" ]]
-		              then
-		                 if [[ $link_local_input = true ]]
-		                	then
-	                   		printf "\n  --- WARNING: ln failed, using cp instead (might be time consuming...)"
-		                 fi
-		                 cp -r  ${absnamein[$i]}/*  ${localin[$i]}
-		              fi
-
-             else
-
-                   # PROVIDE FILE FOR RUNS ON A SINGLE CORE
-              		if [[ $link_local_input = true ]]
-	              	then
-		                 printf "      file will be linked\n"
-		                 ln -f  ${absnamein[$i]}  ${localin[$i]}
-	              	fi
-	                 	# If "ln -f" fails or if "$link_local_input = false" do a normal "cp"
-	              	if [[ ! -f "${localin[$i]}" ]]
-                then
-		                 if [[ $link_local_input = true ]]
-	                  then
-                      printf "\n  --- WARNING: ln failed, using cp instead (might be time consuming...)"
-		                 fi
-                   if [[ $running_on_remote = true  &&  "${actionin[$i]}" = tr ]]
-                   then
-                      mv  ${absnamein[$i]}  ${localin[$i]}
-                   else
-   		                 cp  ${absnamein[$i]}  ${localin[$i]}
-                   fi
-                fi
-             fi
-          fi
-       fi
-
-    done
-    if (( i != 0 ))
-    then
-       if [[ $optional_files_missing = true ]]
-       then
-          printf "\n  *** INFORMATIVE: some optional INPUT-files are not present"
-       fi
-       printf "\n$dashes\n  *** all INPUT-files provided \n"
-    fi
-
-
-       # EXECUTE INPUT-COMMANDS GIVEN IN THE CONFIGURATION FILE
-    (( i = 0 ))
-    while (( i < iic ))
-    do
-       (( i = i + 1 ))
-       if (( i == 1 ))
-       then
-          printf "\n\n  *** execution of INPUT-commands:\n$dashes"
-       fi
-       printf "\n  >>> ${in_command[$i]}"
-       eval  ${in_command[$i]}
-       if (( i == iic ))
-       then
-          printf "\n$dashes\n"
-       fi
-    done
-
-
-    # CHECK IF THE PROGRESS BAR NEEDS TO BE DISABLED
-    if [[ $running_in_batch_mode = true  ||  $running_in_test_mode = true ]]
-    then
-       progress_bar_disabled=true
-    else
-       progress_bar_disabled=false
-    fi
+             fi
+          fi
+       fi
+    fi
+
+ done
+ if (( i != 0 ))
+ then
+    if [[ $optional_files_missing = true ]]
+    then
+       printf "\n  *** INFORMATIVE: some optional INPUT-files are not present"
+    fi
+    printf "\n$dashes\n  *** all INPUT-files provided \n"
+ fi
+
+
+    # EXECUTE INPUT-COMMANDS GIVEN IN THE CONFIGURATION FILE
+ (( i = 0 ))
+ while (( i < iic ))
+ do
+    (( i = i + 1 ))
+    if (( i == 1 ))
+    then
+       printf "\n\n  *** execution of INPUT-commands:\n$dashes"
+    fi
+    printf "\n  >>> ${in_command[$i]}"
+    eval  ${in_command[$i]}
+    if (( i == iic ))
+    then
+       printf "\n$dashes\n"
+    fi
+ done
 
 
        # CREATE THE NAMELIST-FILE WITH VALUES OF ENVIRONMENT-VARIABLES REQUIRED BY PALM
        # (FILE ENVPAR WILL BE READ BY PALM)
+       # TODO: this has to be adjusted for inifor, i.e. the values of the script options
+       #       have to be converted to NAMELIST variables which are then read by inifor.
+       #       Required PALM parameters could also be extracted from local file PARIN
+       #       and added here 
     cat  >  ENVPAR  <<  EOF
  &envpar  run_identifier = '$run_identifier', host = '$configuration_identifier',
@@ -2035,871 +1148,471 @@
 EOF
 
-
-       # STARTING THE EXECUTABLE
-    printf "\n\n  *** execution starts in directory\n      \"`pwd`\"\n$dashes\n"
-    PATH=$PATH:$tempdir
-
-
-       # REPLACE PARAMETERS IN THE EXECUTION COMMAND WITH REAL VALUES
-    line=`echo  "${execute_command}" | sed 's/{{/$/g' | sed 's/}}//g'`
-    line2=`echo  "${execute_command}" | sed 's/{{mpi_tasks}}/1/g' | sed 's/{{tasks_per_node}}/1/g' | sed 's/palm/combine_plot_fields.x/g'`
-    eval line=\"$line\"
-    execute_command="$line"
-
-
-       # EXECUTION COMMAND FOR COMBINE_PLOT_FIELDS
-    if [[ "$execute_command_for_combine" = "" ]]
-    then
-       eval line2=\"$line2\"
-       execute_command_for_combine="$line2"
-    fi
-    
-
-
-       # PROVIDE A HOSTFILE, IF REQUIRED
-    if [[ "$hostfile" != "" ]]
-    then
-
-       if [[ $hostfile = auto ]]
-       then
-             # CREATE A NEW HOSTFILE
-          (( ii = 1 ))
-          while (( ii <= cores / threads_per_task ))
-          do
-             echo  $(hostname)  >>  hostfile
-             (( ii = ii + 1 ))
-          done
-          if (( cores / threads_per_task == 0 ))
-          then
-             echo  $(hostname)  >>  hostfile
-          fi
-       
+    # TODO: this is just an example for a possible access of the PALM parameters
+ grep -Eo '(\s*\&(initialization_parameters|inipar|runtime_parameters|d3par)\s*)|(([nd][xyz]|end_time|longitude|latitude|dz_stretch_level|dz_stretch_factor|dz_max)\s*\=\s*[0-9]*\.*\,*)|((dz_stretch_level_start|dz_stretch_level_end)\s*\=(\s*[0-9]*\.*\,*)*)|\/' PARIN
+
+    # COPY EXECUTABLE TO THIS TEMPORARY FOLDER
+ cp  ${base_directory}/MAKE_DEPOSITORY_${configuration_identifier}/inifor  .
+
+    # STARTING THE EXECUTABLE
+ printf "\n\n  *** inifor starts in directory\n      \"`pwd`\"\n$dashes\n"
+ PATH=$PATH:$tempdir
+
+
+    # REPLACE PARAMETERS IN THE EXECUTION COMMAND WITH REAL VALUES
+ line=`echo  "${execute_command_inifor}" | sed 's/{{/$/g' | sed 's/}}//g'`
+ eval line=\"$line\"
+ execute_command="$line"
+
+
+
+    # SET THE NUMBER OF OPENMP-THREADS
+ if [[ $use_openmp = true ]]
+ then
+    export OMP_NUM_THREADS=$threads_per_task
+    printf "\n  *** number of OpenMP threads per MPI-task: $OMP_NUM_THREADS"
+ else
+    export OMP_NUM_THREADS=1
+ fi
+
+
+ printf "\n  *** execute command:"
+ printf "\n      \"$execute_command\" \n\n"
+
+
+ $execute_command    &> >(tee STDOUT)
+ exit_code=${PIPESTATUS[0]}
+
+ if [[ ${exit_code} != 0 ]]
+ then
+
+        # ABORT IN CASE OF RUNTIME ERRORS
+    printf "\n  +++ runtime error occured"
+    locat=execution
+    exit
+
+ else
+
+    printf "\n$dashes\n  *** execution finished \n"
+
+ fi
+
+
+    # EXECUTE OUTPUT-COMMANDS GIVEN IN THE CONFIGURATION FILE
+ (( i = 0 ))
+ while (( i < ioc ))
+ do
+    (( i = i + 1 ))
+    if (( i == 1 ))
+    then
+       printf "\n\n  *** execution of OUTPUT-commands:\n$dashes"
+    fi
+
+       # REPLACE PARAMETERS IN THE OUTPUT COMMAND WITH REAL VALUES
+    out_command[$i]=`echo  "${out_command[$i]}" | sed 's/{{/$/g' | sed 's/}}//g'`
+
+    printf "\n  >>> ${out_command[$i]}"
+    eval  ${out_command[$i]}
+    if (( i == ioc ))
+    then
+       printf "\n$dashes\n"
+    fi
+ done
+
+
+    # IN A FIRST PASS, ADD ADDITIONAL OUTPUT FILE CONNECTIONS IN CASE OF
+    # WILDCARDS
+ (( i = 0 ))
+ (( nr_of_output_files = 0 ))
+
+ while (( i < iout ))
+ do
+
+    (( i = i + 1 ))
+
+       # FIRST CHECK FOR MULTIPLE NAMES WITH THE SAME LOCAL NAME AND
+       # CREATE A LIST FOR THE DETECTED ENDINGS
+    if [[ "${multout[$i]}" = true ]]
+    then
+          # DETERMINE THE EXISTING EXTENSIONS FROM THE LIST OF FILES
+       ls -1 -d ${localout_pre[$i]}    >   filelist  2>/dev/null
+       ls -1 -d ${localout_pre[$i]}_*  >>  filelist  2>/dev/null
+
+       endings="DEFAULT"
+       while  read line
+       do
+              # remove the local name from the beginning
+           localnamestring="${localout_pre[$i]}"
+           length_localname=${#localnamestring}
+           ending=${line:${length_localname}}
+
+           if [[ "$ending" != "" ]]
+           then
+              endings="$endings $ending"
+           fi
+ 
+       done <filelist
+
+       rm filelist
+
+    else
+
+          # SINGLE NAME
+       endings=DEFAULT
+
+    fi
+
+       # FOR EACH BASENAME ENDING CREATE AN ENTRY IN THE FINAL OUTPUT FILE LIST
+    for  ending  in  $endings
+    do
+
+          # DEFAULT MEANS THAT THE ENDING GIVEN IN .iofiles SHALL BE USED
+       if [[ $ending = DEFAULT ]]
+       then
+          ending=""
+       fi
+
+          # NEW ENTRY (ENDING IS ALSO ADDED TO LOCAL FILENAME READ BY PALM!)
+       (( nr_of_output_files = nr_of_output_files + 1 ))
+       localout[$nr_of_output_files]="${localout_pre[$i]}"$ending
+       transout[$nr_of_output_files]="${transout_pre[$i]}"
+       actionout[$nr_of_output_files]="${actionout_pre[$i]}"
+       pathout[$nr_of_output_files]="${pathout_pre[$i]}"
+       endout[$nr_of_output_files]="${endout_pre[$i]}"$ending
+       extout[$nr_of_output_files]="${extout_pre[$i]}"
+       warnout[$nr_of_output_files]="${warnout_pre[$i]}"
+
+    done
+
+ done
+
+
+    # COPY LOCAL OUTPUT-FILES TO THEIR PERMANENT DESTINATIONS
+ (( i = 0 ))
+ while (( i < nr_of_output_files ))
+ do
+    (( i = i + 1 ))
+    if (( i == 1 ))
+    then
+       printf "\n\n  *** saving OUTPUT-files:"
+
+          # GET RUN NUMBER ASSIGNED BY PALM
+       if [[ -f RUN_NUMBER ]]
+       then
+           read  run_number  <  RUN_NUMBER
+           printf "\n  *** PALM generated run_number = "$run_number" will be used as unified cycle number for all output files"
+           usecycle_option="-U $run_number"
        else
-          cp  $hostfile  hostfile
-       fi
-       eval line=\"`head -n $ii  hostfile`\"
-       printf "\n  *** running on: $line"
-    fi
-
-
-
-       # SET THE NUMBER OF OPENMP-THREADS
-    if [[ $use_openmp = true ]]
-    then
-       export OMP_NUM_THREADS=$threads_per_task
-       printf "\n  *** number of OpenMP threads per MPI-task: $OMP_NUM_THREADS"
+           run_number=0
+           usecycle_option=""
+       fi
+       if [[ $running_on_remote = true  &&  "$remote_loginnode" != "" ]]
+       then
+          printf "\n  *** in case of SCP transfers to local host"
+          printf "\n      they will be done via remote login-node \"$remote_loginnode\" "
+       fi
+       printf "\n$dashes"
+    fi
+
+    if [[ ! ( $running_on_remote = true  &&  ( "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ) ) ]]
+    then
+
+       eval filename=${pathout[$i]}/${run_identifier}${endout[$i]}
+
+          # DETERMINE THE CYCLE NUMBER
+       ls -1 -d $filename    >   filelist  2>/dev/null
+       ls -1 -d $filename.*  >>  filelist  2>/dev/null
+       while  read line
+       do
+   
+             # filename without path (i.e. after the last "/")
+          basefilename=$(basename ${line})
+   
+             # check if there is an extension
+          extension=${basefilename##*.}
+          if [[ "$extension" = "${extout[$i]}" ]]
+          then
+             basefilename=${basefilename%.*}
+          fi
+   
+             # check for an existing cycle number
+          cycle=${basefilename##*.}
+          if [[ $cycle =~ ^-?[0-9]+$ ]]
+          then
+                # NUMBERS WITH LEADING ZEROS ARE INTERPRETED AS OCTAL NUMBERS
+                # 10# EXPLICITLY SPECIFIES THE NUMBER BASE AS 10
+             (( icycle = $((10#$cycle)) + 1 ))
+          else
+             (( icycle = 1 ))
+          fi
+   
+          if (( icycle > maxcycle ))
+          then
+             (( maxcycle = icycle ))
+          fi
+   
+       done <filelist
+       rm filelist
+
+   
+          # SET THE CYCLE NUMBER
+          # IN CASE OF FILE-APPEND, IT MUST BE THE HIGHEST EXISTING CYCLE NUMBER
+       if [[ "${actionout[$i]}" = a ]]
+       then
+          (( maxcycle = maxcycle - 1 ))
+       fi
+          
+       (( cycnum[$i] = maxcycle ))
+       pathout[$i]=$filename
+
+
+          # ADD CYCLE NUMBER TO FILENAME
+          # IN APPEND MODE, FILES KEEP THEIR CURRENT CYCLE NUMBER
+       if [[ "${actionout[$i]}" != "a" ]]
+       then
+             # SET RUN NUMBER AS CYCLE NUMBER, IF THERE IS NOT A CONFLICT
+             # WITH AN EXISTING CYCLE NUMBER
+          if (( run_number >= cycnum[$i] ))
+          then
+             (( cycnum[$i] = run_number ))
+          else
+             if (( run_number > 0 ))
+             then
+                printf "\n  --- INFORMATIVE: The following file cannot get a unified cycle number"
+             fi
+          fi
+       fi
+       if (( cycnum[$i] > 0 ))
+       then
+          cyclestring=`printf "%03d" ${cycnum[$i]}`
+          pathout[$i]=${pathout[$i]}.$cyclestring
+       fi
+    fi           
+
+       # CHECK FOR SINGLE FILE (SERIAL RUN) OR DIRECTORY (ONE FILE PER CORE FOR PARELLEL EXECUTION)
+    files_for_cores=false; filetype=file
+    link_local_output=false
+    if [[ "${actionout[$i]}" = pe  &&  -n $cores ]]
+    then
+       files_for_cores=true; filetype=directory
+       actionout[$i]=""
+    elif [[ "${actionout[$i]}" = pe  &&  ! -n $cores ]]
+    then
+       actionout[$i]=""
+    elif [[ "${actionout[$i]}" = lnpe  &&  -n $cores ]]
+    then
+       files_for_cores=true; filetype=directory
+       link_local_output=true
+       actionout[$i]=""
+    elif [[ "${actionout[$i]}" = lnpe  &&  ! -n $cores ]]
+    then
+       link_local_output
+       actionout[$i]=""
+    elif [[ "${actionout[$i]}" = trpe  &&  -n $cores ]]
+    then
+       files_for_cores=true; filetype=directory
+       actionout[$i]="tr"
+    elif [[ "${actionout[$i]}" = trpe  &&  ! -n $cores ]]
+    then
+       actionout[$i]="tr"
+    fi
+
+    if [[ ! -f ${localout[$i]}  &&  $files_for_cores = false ]]
+    then
+       if [[ ${warnout[$i]} = true ]]
+       then
+          printf "\n  +++ temporary OUTPUT-file  ${localout[$i]}  does not exist\n"
+       fi
+    elif [[ ! -d ${localout[$i]}  &&  $files_for_cores = true ]]
+    then
+       if [[ ${warnout[$i]} = true ]]
+       then
+          printf "\n  +++ temporary OUTPUT-file  ${localout[$i]}/....  does not exist\n"
+       fi
     else
-       export OMP_NUM_THREADS=1
-    fi
-
-
-       # PROVIDE DATA FOR ATMOSPHERE OCEAN COUPLING
-    if [[ $run_coupled_model = false ]]
-    then
-       if [[ "$ocean_file_appendix" = true ]]
-       then
-          echo "precursor_ocean"  >  coupling_steering
-       else
-          echo "precursor_atmos"  >  coupling_steering
-      fi
+
+
+          # COPY VIA SCP TO LOCAL HOST (ALWAYS IN BINARY MODE USING batch_scp option -m)
+          # IF TARGET DIRECTORY DOES NOT EXISTS, TRY TO CREATE IT
+       if [[ "${actionout[$i]}" = tr  ||  "${actionout[$i]}" = tra ]]
+       then
+          if [[ $running_on_remote = true ]]
+          then
+
+                # SET OPTIONS FOR TRANSFER
+             if [[ "${actionout[$i]}" = tr ]]
+             then
+                if [[ $files_for_cores = false ]]
+                then
+                   catalog_option=""
+                   catalog_string=""
+                else
+                   catalog_option="-c"
+                   catalog_string="/"
+                fi
+                append_option=""
+                append_string=""
+             else
+                append_option="-A"
+                append_string="append"
+             fi
+
+             transfer_failed=false
+             printf "\n  >>> OUTPUT: ${localout[$i]}$catalog_string  $append_string by SCP to"
+             printf "\n              ${pathout[$i]}/${configuration_identifier}_${run_identifier}${endout[$i]}$catalog_string\n"
+
+                # TRANSFER VIA SCP
+             if [[ "$remote_loginnode" != "" ]]
+             then
+                ssh -q $remote_username@$remote_loginnode  "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]}"
+             else
+                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
+             [[ ${PIPESTATUS[0]} != 0 ]]  &&  transfer_failed=true
+
+
+                # IF TRANSFER FAILED, CREATE BACKUP COPY ON THIS MACHINE
+             if [[ $transfer_failed = true ]]
+             then
+                printf "  +++ transfer failed. Trying to save a copy on this host under:\n"
+                printf "      ${pathout[$i]}/${configuration_identifier}_${run_identifier}${endout[$i]}_$run_id_number\n"
+
+                   # FIRST CHECK, IF DIRECTORY EXISTS, AND CREATE IT, IF NECESSARY
+                eval  local_catalog=${pathout[$i]}
+                if [[ ! -d $local_catalog ]]
+                then
+                   printf "  *** local directory does not exist. Trying to create:\n"
+                   printf "      $local_catalog \n"
+                   mkdir -p  $local_catalog
+                fi
+                eval  cp  ${localout[$i]}  ${pathout[$i]}/${configuration_identifier}_${run_identifier}${endout[$i]}_$run_id_number
+                transfer_problems=true
+             fi
+
+          else
+
+                # UNSET actionout. DUE TO THIS SETTING, FILE WILL LATER JUST
+                # BE COPIED OR APPENDED ON THIS MACHINE
+             if [[ "${actionout[$i]}" = tr ]]
+             then
+                actionout[$i]=""
+             else
+                actionout[$i]="a"
+             fi
+          fi
+       fi
+
+
+          # APPEND ON THIS MACHINE
+       if [[ "${actionout[$i]}" = "a" ]]
+       then
+          if [[ "${extout[$i]}" != " "  &&  "${extout[$i]}" != "" ]]
+          then
+             printf "\n  >>> OUTPUT: ${localout[$i]}  append to"
+             printf "\n              ${pathout[$i]}.${extout[$i]}\n"
+             cat  ${localout[$i]}  >>  ${pathout[$i]}.${extout[$i]}
+          else
+             printf "\n  >>> OUTPUT: ${localout[$i]}  append to"
+             printf "\n              ${pathout[$i]}\n"
+             cat  ${localout[$i]}  >>  ${pathout[$i]}
+          fi
+       fi
+
+          # COPY ON THIS MACHINE
+          # COPY HAS TO BE USED, BECAUSE MOVE DOES NOT WORK IF FILE-ORIGIN AND TARGET ARE
+          # ON DIFFERENT FILE-SYSTEMS
+       if [[ "${actionout[$i]}" = ""  &&  $files_for_cores = false ]]
+       then
+
+             # COPY IN CASE OF RUNS ON SINGLE CORES
+          if [[ "${extout[$i]}" != " "  &&  "${extout[$i]}" != "" ]]
+          then
+             printf "\n  >>> OUTPUT: ${localout[$i]}  to"
+             printf "\n              ${pathout[$i]}.${extout[$i]}\n"
+             if [[ $link_local_output = true ]]
+             then
+                printf "      file will be linked\n"
+                ln -f  ${localout[$i]}  ${pathout[$i]}.${extout[$i]}
+             fi
+                # If "ln -f" fails of if "$link_local_output = false" do a normal "cp"
+             if [[ ! -f "${pathout[$i]}.${extout[$i]}" ]]
+             then
+                if [[ $link_local_output = true ]]
+                then
+                   printf "  --- WARNING: ln failed, using cp instead (might be time consuming...)\n"
+                fi
+                cp  ${localout[$i]}  ${pathout[$i]}.${extout[$i]}
+             else
+                printf "+++ no copy because file ${pathout[$i]}.${extout[$i]} exists\n"
+             fi
+          else
+             printf "\n  >>> OUTPUT: ${localout[$i]}  to"
+             printf "\n              ${pathout[$i]}\n"
+             if [[ $link_local_output = true ]]
+             then
+                printf "      file will be linked\n"
+                ln -f  ${localout[$i]}  ${pathout[$i]}
+             fi
+                # If "ln -f" fails of if "$link_local_output = false" do a normal "cp"
+            	if [[ ! -f "${pathout[$i]}" ]]
+             then
+                if [[ $link_local_output = true ]]
+                then
+                   printf "  --- WARNING: ln failed, using cp instead (might be time consuming...)\n"
+                fi
+                cp  ${localout[$i]}  ${pathout[$i]}
+             else
+                printf "+++ no copy because file ${pathout[$i]} exists\n"
+             fi
+          fi
+
+       elif [[ "${actionout[$i]}" = ""  &&  $files_for_cores = true ]]
+       then
+
+             # FILES FROM THE DIFFERENT CORES ARE MOVED WITH ln-COMMAND TO THE PERMANENT DIRECTORY
+             # AS A FIRST STEP, THE PERMANENT DIRECTORY IS CREATED
+          printf "\n  >>> OUTPUT: ${localout[$i]}/_....  to"
+          printf "\n              ${pathout[$i]}\n"
+          if [[ $link_local_output = true ]]
+          then
+             printf "      files will be linked\n"
+             mkdir -p ${pathout[$i]}
+             cd ${localout[$i]}
+             for file in $(ls *)
+             do
+                ln -f $file  ${pathout[$i]}
+             done >|/dev/null 2>&1
+             cd $tempdir
+          fi
+
+             # IF "ln -f" HAS FAILED OR IF "$link_local_output = false" DO A NORMAL COPY "cp -r"
+          if [[ ! -f "${pathout[$i]}/_000000" ]]
+          then
+             if [[ $link_local_output = true ]]
+             then
+                printf "  --- WARNING: ln failed, using cp instead (might be time consuming...)\n"
+             fi
+             [[ ! -d "${pathout[$i]}" ]]  &&  mkdir  ${pathout[$i]}
+             cp -r  ${localout[$i]}/*  ${pathout[$i]}
+    	     fi
+
+       fi
+    fi
+ done
+
+ if (( i != 0 ))
+ then
+    if [[ $transfer_problems = true ]]
+    then
+       printf "\n$dashes\n  *** OUTPUT-files saved"
+       printf "\n  +++ WARNING: some data transfers failed! \n"
     else
-       (( iia = $cores_atmos / $threads_per_task ))
-       (( iio = $cores_ocean / $threads_per_task ))
-       printf "\n      coupled run ($iia atmosphere, $iio ocean)"
-       printf "\n\n"
-       echo "coupled_run $iia $iio"  >  coupling_steering
-    fi
-
-    printf "\n  *** execute command:"
-    printf "\n      \"$execute_command\" \n\n"
-
-
-    if [[ $progress_bar_disabled = true ]]
-    then
-       $execute_command  <  coupling_steering  &> >(grep -v --line-buffered -e '^STOP 1$' -e '^1$' &> >(tee STDOUT) )
-       exit_code=${PIPESTATUS[0]}
-    else
-       $execute_command  <  coupling_steering  &> >(tee STDOUT)
-       exit_code=${PIPESTATUS[0]}
-    fi
-
-    if [[ ${exit_code} != 0 ]]
-    then
-
-           # ABORT IN CASE OF RUNTIME ERRORS
-       printf "\n  +++ runtime error occured"
-       locat=execution
-       exit
-
-    else
-
-       printf "\n$dashes\n  *** execution finished \n"
-
-    fi
-
-
-       # CALL OF combine_plot_fields IN ORDER TO MERGE SINGLE FILES WRITTEN
-       # BY EACH CORE INTO ONE FILE
-   if [[ ! -f combine_plot_fields.x ]]
-   then
-
-      printf "\n\n\n  +++ WARNING: no combine_plot_fields found"
-      printf "\n      2d- and/or 3d-data may be incomplete!"
-      printf "\n      Your previous palmbuild may have failed. Please check.\n"
-
-   elif [[ "$combine_plot_fields" == true ]]
-   then
-
-      printf "\n\n\n *** post-processing: now executing \"$execute_command_for_combine\" ..."
-      $execute_command_for_combine
-
-   else
-
-         # TEMPORARY SOLUTION TO SKIP combine_plot_fields. THIS IS REQUIRED IN CASE OF HUGE AMOUNT OF
-         # DATA OUTPUT
-      printf "\n\n\n *** post-processing: skipping combine_plot_fields (-Z option set) ..."
-   fi
-
-
-
-       # EXECUTE OUTPUT-COMMANDS GIVEN IN THE CONFIGURATION FILE
-    (( i = 0 ))
-    while (( i < ioc ))
-    do
-       (( i = i + 1 ))
-       if (( i == 1 ))
-       then
-          printf "\n\n  *** execution of OUTPUT-commands:\n$dashes"
-       fi
-
-          # REPLACE PARAMETERS IN THE OUTPUT COMMAND WITH REAL VALUES
-       out_command[$i]=`echo  "${out_command[$i]}" | sed 's/{{/$/g' | sed 's/}}//g'`
-
-       printf "\n  >>> ${out_command[$i]}"
-       eval  ${out_command[$i]}
-       if (( i == ioc ))
-       then
-          printf "\n$dashes\n"
-       fi
-    done
-
-
-       # IN A FIRST PASS, ADD ADDITIONAL OUTPUT FILE CONNECTIONS IN CASE OF
-       # WILDCARDS
-    (( i = 0 ))
-    (( nr_of_output_files = 0 ))
-
-    while (( i < iout ))
-    do
-
-       (( i = i + 1 ))
-
-          # FIRST CHECK FOR MULTIPLE NAMES WITH THE SAME LOCAL NAME AND
-          # CREATE A LIST FOR THE DETECTED ENDINGS
-       if [[ "${multout[$i]}" = true ]]
-       then
-             # DETERMINE THE EXISTING EXTENSIONS FROM THE LIST OF FILES
-          ls -1 -d ${localout_pre[$i]}    >   filelist  2>/dev/null
-          ls -1 -d ${localout_pre[$i]}_*  >>  filelist  2>/dev/null
-
-          endings="DEFAULT"
-          while  read line
-          do
-                 # remove the local name from the beginning
-              localnamestring="${localout_pre[$i]}"
-              length_localname=${#localnamestring}
-              ending=${line:${length_localname}}
-
-              if [[ "$ending" != "" ]]
-              then
-                 endings="$endings $ending"
-              fi
- 
-          done <filelist
-
-          rm filelist
-
-       else
-
-             # SINGLE NAME
-          endings=DEFAULT
-
-       fi
-
-          # FOR EACH BASENAME ENDING CREATE AN ENTRY IN THE FINAL OUTPUT FILE LIST
-       for  ending  in  $endings
-       do
-
-             # DEFAULT MEANS THAT THE ENDING GIVEN IN .iofiles SHALL BE USED
-          if [[ $ending = DEFAULT ]]
-          then
-             ending=""
-          fi
-
-             # NEW ENTRY (ENDING IS ALSO ADDED TO LOCAL FILENAME READ BY PALM!)
-          (( nr_of_output_files = nr_of_output_files + 1 ))
-          localout[$nr_of_output_files]="${localout_pre[$i]}"$ending
-          transout[$nr_of_output_files]="${transout_pre[$i]}"
-          actionout[$nr_of_output_files]="${actionout_pre[$i]}"
-          pathout[$nr_of_output_files]="${pathout_pre[$i]}"
-          endout[$nr_of_output_files]="${endout_pre[$i]}"$ending
-          extout[$nr_of_output_files]="${extout_pre[$i]}"
-          warnout[$nr_of_output_files]="${warnout_pre[$i]}"
-
-       done
-
-    done
-
-
-
-
-       # COPY LOCAL OUTPUT-FILES TO THEIR PERMANENT DESTINATIONS
-    (( i = 0 ))
-    while (( i < nr_of_output_files ))
-    do
-       (( i = i + 1 ))
-       if (( i == 1 ))
-       then
-          printf "\n\n  *** saving OUTPUT-files:"
-
-             # GET RUN NUMBER ASSIGNED BY PALM
-          if [[ -f RUN_NUMBER ]]
-          then
-              read  run_number  <  RUN_NUMBER
-              printf "\n  *** PALM generated run_number = "$run_number" will be used as unified cycle number for all output files"
-              usecycle_option="-U $run_number"
-          else
-              run_number=0
-              usecycle_option=""
-          fi
-          if [[ $running_on_remote = true  &&  "$remote_loginnode" != "" ]]
-          then
-             printf "\n  *** in case of SCP transfers to local host"
-             printf "\n      they will be done via remote login-node \"$remote_loginnode\" "
-          fi
-          printf "\n$dashes"
-       fi
-
-       if [[ ! ( $running_on_remote = true  &&  ( "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ) ) ]]
-       then
-
-          eval filename=${pathout[$i]}/${run_identifier}${endout[$i]}
-
-             # DETERMINE THE CYCLE NUMBER
-          ls -1 -d $filename    >   filelist  2>/dev/null
-          ls -1 -d $filename.*  >>  filelist  2>/dev/null
-          while  read line
-          do
-   
-                # filename without path (i.e. after the last "/")
-             basefilename=$(basename ${line})
-   
-                # check if there is an extension
-             extension=${basefilename##*.}
-             if [[ "$extension" = "${extout[$i]}" ]]
-             then
-                basefilename=${basefilename%.*}
-             fi
-   
-                # check for an existing cycle number
-             cycle=${basefilename##*.}
-             if [[ $cycle =~ ^-?[0-9]+$ ]]
-             then
-                   # NUMBERS WITH LEADING ZEROS ARE INTERPRETED AS OCTAL NUMBERS
-                   # 10# EXPLICITLY SPECIFIES THE NUMBER BASE AS 10
-                (( icycle = $((10#$cycle)) + 1 ))
-             else
-                (( icycle = 1 ))
-             fi
-   
-             if (( icycle > maxcycle ))
-             then
-                (( maxcycle = icycle ))
-             fi
-   
-          done <filelist
-          rm filelist
-
-   
-             # SET THE CYCLE NUMBER
-             # IN CASE OF FILE-APPEND, IT MUST BE THE HIGHEST EXISTING CYCLE NUMBER
-          if [[ "${actionout[$i]}" = a ]]
-          then
-             (( maxcycle = maxcycle - 1 ))
-          fi
-          
-          (( cycnum[$i] = maxcycle ))
-          pathout[$i]=$filename
-
-
-             # ADD CYCLE NUMBER TO FILENAME
-             # IN APPEND MODE, FILES KEEP THEIR CURRENT CYCLE NUMBER
-          if [[ "${actionout[$i]}" != "a" ]]
-          then
-                # SET RUN NUMBER AS CYCLE NUMBER, IF THERE IS NOT A CONFLICT
-                # WITH AN EXISTING CYCLE NUMBER
-             if (( run_number >= cycnum[$i] ))
-             then
-                (( cycnum[$i] = run_number ))
-             else
-                if (( run_number > 0 ))
-                then
-                   printf "\n  --- INFORMATIVE: The following file cannot get a unified cycle number"
-                fi
-             fi
-          fi
-          if (( cycnum[$i] > 0 ))
-          then
-             cyclestring=`printf "%03d" ${cycnum[$i]}`
-             pathout[$i]=${pathout[$i]}.$cyclestring
-          fi
-       fi           
-
-          # CHECK FOR SINGLE FILE (SERIAL RUN) OR DIRECTORY (ONE FILE PER CORE FOR PARELLEL EXECUTION)
-       files_for_cores=false; filetype=file
-       link_local_output=false
-       if [[ "${actionout[$i]}" = pe  &&  -n $cores ]]
-       then
-          files_for_cores=true; filetype=directory
-          actionout[$i]=""
-       elif [[ "${actionout[$i]}" = pe  &&  ! -n $cores ]]
-       then
-          actionout[$i]=""
-       elif [[ "${actionout[$i]}" = lnpe  &&  -n $cores ]]
-       then
-          files_for_cores=true; filetype=directory
-          link_local_output=true
-          actionout[$i]=""
-       elif [[ "${actionout[$i]}" = lnpe  &&  ! -n $cores ]]
-       then
-          link_local_output
-          actionout[$i]=""
-       elif [[ "${actionout[$i]}" = trpe  &&  -n $cores ]]
-       then
-          files_for_cores=true; filetype=directory
-          actionout[$i]="tr"
-       elif [[ "${actionout[$i]}" = trpe  &&  ! -n $cores ]]
-       then
-          actionout[$i]="tr"
-       fi
-
-       if [[ ! -f ${localout[$i]}  &&  $files_for_cores = false ]]
-       then
-          if [[ ${warnout[$i]} = true ]]
-          then
-             printf "\n  +++ temporary OUTPUT-file  ${localout[$i]}  does not exist\n"
-          fi
-       elif [[ ! -d ${localout[$i]}  &&  $files_for_cores = true ]]
-       then
-          if [[ ${warnout[$i]} = true ]]
-          then
-             printf "\n  +++ temporary OUTPUT-file  ${localout[$i]}/....  does not exist\n"
-          fi
-       else
-
-
-             # COPY VIA SCP TO LOCAL HOST (ALWAYS IN BINARY MODE USING batch_scp option -m)
-             # IF TARGET DIRECTORY DOES NOT EXISTS, TRY TO CREATE IT
-          if [[ "${actionout[$i]}" = tr  ||  "${actionout[$i]}" = tra ]]
-          then
-             if [[ $running_on_remote = true ]]
-             then
-
-                   # SET OPTIONS FOR TRANSFER
-                if [[ "${actionout[$i]}" = tr ]]
-                then
-                   if [[ $files_for_cores = false ]]
-                   then
-                      catalog_option=""
-                      catalog_string=""
-                   else
-                      catalog_option="-c"
-                      catalog_string="/"
-                   fi
-                   append_option=""
-                   append_string=""
-                else
-                   append_option="-A"
-                   append_string="append"
-                fi
-
-                transfer_failed=false
-                printf "\n  >>> OUTPUT: ${localout[$i]}$catalog_string  $append_string by SCP to"
-                printf "\n              ${pathout[$i]}/${configuration_identifier}_${run_identifier}${endout[$i]}$catalog_string\n"
-
-                   # TRANSFER VIA SCP
-                if [[ "$remote_loginnode" != "" ]]
-                then
-                   ssh -q $remote_username@$remote_loginnode  "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]}"
-                else
-                   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
-                [[ ${PIPESTATUS[0]} != 0 ]]  &&  transfer_failed=true
-
-
-                   # IF TRANSFER FAILED, CREATE BACKUP COPY ON THIS MACHINE
-                if [[ $transfer_failed = true ]]
-                then
-                   printf "  +++ transfer failed. Trying to save a copy on this host under:\n"
-                   printf "      ${pathout[$i]}/${configuration_identifier}_${run_identifier}${endout[$i]}_$run_id_number\n"
-
-                      # FIRST CHECK, IF DIRECTORY EXISTS, AND CREATE IT, IF NECESSARY
-                   eval  local_catalog=${pathout[$i]}
-                   if [[ ! -d $local_catalog ]]
-                   then
-                      printf "  *** local directory does not exist. Trying to create:\n"
-                      printf "      $local_catalog \n"
-                      mkdir -p  $local_catalog
-                   fi
-                   eval  cp  ${localout[$i]}  ${pathout[$i]}/${configuration_identifier}_${run_identifier}${endout[$i]}_$run_id_number
-                   transfer_problems=true
-                fi
-
-             else
-
-                   # UNSET actionout. DUE TO THIS SETTING, FILE WILL LATER JUST
-                   # BE COPIED OR APPENDED ON THIS MACHINE
-                if [[ "${actionout[$i]}" = tr ]]
-                then
-                   actionout[$i]=""
-                else
-                   actionout[$i]="a"
-                fi
-             fi
-          fi
-
-
-             # APPEND ON THIS MACHINE
-          if [[ "${actionout[$i]}" = "a" ]]
-          then
-             if [[ "${extout[$i]}" != " "  &&  "${extout[$i]}" != "" ]]
-             then
-                printf "\n  >>> OUTPUT: ${localout[$i]}  append to"
-                printf "\n              ${pathout[$i]}.${extout[$i]}\n"
-                cat  ${localout[$i]}  >>  ${pathout[$i]}.${extout[$i]}
-             else
-                printf "\n  >>> OUTPUT: ${localout[$i]}  append to"
-                printf "\n              ${pathout[$i]}\n"
-                cat  ${localout[$i]}  >>  ${pathout[$i]}
-             fi
-          fi
-
-             # COPY ON THIS MACHINE
-             # COPY HAS TO BE USED, BECAUSE MOVE DOES NOT WORK IF FILE-ORIGIN AND TARGET ARE
-             # ON DIFFERENT FILE-SYSTEMS
-          if [[ "${actionout[$i]}" = ""  &&  $files_for_cores = false ]]
-          then
-
-                # COPY IN CASE OF RUNS ON SINGLE CORES
-             if [[ "${extout[$i]}" != " "  &&  "${extout[$i]}" != "" ]]
-             then
-                printf "\n  >>> OUTPUT: ${localout[$i]}  to"
-                printf "\n              ${pathout[$i]}.${extout[$i]}\n"
-		              if [[ $link_local_output = true ]]
-		              then
-		                 printf "      file will be linked\n"
-		                 ln -f  ${localout[$i]}  ${pathout[$i]}.${extout[$i]}
-		              fi
-		                 # If "ln -f" fails of if "$link_local_output = false" do a normal "cp"
-		              if [[ ! -f "${pathout[$i]}.${extout[$i]}" ]]
-                then
-		                 if [[ $link_local_output = true ]]
-	                  then
-                      printf "  --- WARNING: ln failed, using cp instead (might be time consuming...)\n"
-		                 fi
-		                 cp  ${localout[$i]}  ${pathout[$i]}.${extout[$i]}
-		              else
-                   printf "+++ no copy because file ${pathout[$i]}.${extout[$i]} exists\n"
-                fi
-             else
-                printf "\n  >>> OUTPUT: ${localout[$i]}  to"
-                printf "\n              ${pathout[$i]}\n"
-		              if [[ $link_local_output = true ]]
-		              then
-		                 printf "      file will be linked\n"
-		                 ln -f  ${localout[$i]}  ${pathout[$i]}
-		              fi
-		                 # If "ln -f" fails of if "$link_local_output = false" do a normal "cp"
-	              	if [[ ! -f "${pathout[$i]}" ]]
-                then
-		                 if [[ $link_local_output = true ]]
-	                  then
-                      printf "  --- WARNING: ln failed, using cp instead (might be time consuming...)\n"
-		                 fi
-		                 cp  ${localout[$i]}  ${pathout[$i]}
-		              else
-		                 printf "+++ no copy because file ${pathout[$i]} exists\n"
-                fi
-             fi
-
-          elif [[ "${actionout[$i]}" = ""  &&  $files_for_cores = true ]]
-          then
-
-                # FILES FROM THE DIFFERENT CORES ARE MOVED WITH ln-COMMAND TO THE PERMANENT DIRECTORY
-                # AS A FIRST STEP, THE PERMANENT DIRECTORY IS CREATED
-             printf "\n  >>> OUTPUT: ${localout[$i]}/_....  to"
-             printf "\n              ${pathout[$i]}\n"
-	            if [[ $link_local_output = true ]]
-	            then
-		              printf "      files will be linked\n"
-		              mkdir -p ${pathout[$i]}
-		              cd ${localout[$i]}
-		              for file in $(ls *)
-		              do
-		                 ln -f $file  ${pathout[$i]}
-		              done >|/dev/null 2>&1
-		              cd $tempdir
-	            fi
-
-                # IF "ln -f" HAS FAILED OR IF "$link_local_output = false" DO A NORMAL COPY "cp -r"
-	            if [[ ! -f "${pathout[$i]}/_000000" ]]
-             then
-		              if [[ $link_local_output = true ]]
-		              then
-                   printf "  --- WARNING: ln failed, using cp instead (might be time consuming...)\n"
-		              fi
-		              [[ ! -d "${pathout[$i]}" ]]  &&  mkdir  ${pathout[$i]}
-		              cp -r  ${localout[$i]}/*  ${pathout[$i]}
-       	     fi
-
-          fi
-       fi
-    done
-
-    if (( i != 0 ))
-    then
-       if [[ $transfer_problems = true ]]
-       then
-          printf "\n$dashes\n  *** OUTPUT-files saved"
-          printf "\n  +++ WARNING: some data transfers failed! \n"
-       else
-          printf "\n$dashes\n  *** all OUTPUT-files saved \n"
-       fi
-    fi
-
-
-       # IF REQUIRED, START A RESTART-JOB
-       # FILE CONTINUE_RUN MUST HAVE BEEN CREATED BY THE EXECUTABLE (PALM)
-    if [[ -f CONTINUE_RUN ]]
-    then
-
-          # ADD RESTART-OPTIONS TO THE PALMRUN-CALL (IF THEY ARE NOT USED ALREADY):
-          # -C TELLS PALMRUN THAT IT IS A RESTART-RUN
-          # -v SILENT MODE WITHOUT INTERACTIVE QUERIES
-          # -b START A BATCH JOB
-       [[ $(echo $prc | grep -c "\-C") = 0 ]]  &&  prc="$prc -C"
-       [[ $(echo $prc | grep -c "\-v") = 0 ]]  &&  prc="$prc -v"
-       [[ $(echo $prc | grep -c "\-b") = 0 ]]  &&  prc="$prc -b"
-
-          # REPLACE SVFOUT IN THE ACTIVATION STRINGS (GIVEN WITH OPTION -a)
-          # SO THAT RESTARTS USE SVF DATA CREATED BY THE INITIAL RUN
-       if [[ $(echo $prc | grep -c "svfout") != 0 ]]
-       then
-          prc=`echo $prc | sed 's/svfout/svfin/g'`
-       fi
-
-          # REPLACE THE HASH IN THE ACTIVATION STRINGS (GIVEN WITH OPTION -a)
-          # SO THAT RESTARTS ACCESS DIFFERENT FILES THAN THE INITIAL RUN
-       if [[ $(echo $prc | grep -c "#") != 0 ]]
-       then
-          prc=`echo $prc | sed 's/#/r/g'`
-       fi
-
-
-          # START THE RESTART-JOB
-       printf "\n\n  *** initiating restart-run on \"$local_ip\" using command:\n"
-       echo "      $prc"
-       printf "\n$dashes\n"
-       if [[ $running_on_remote = true ]]
-       then
-
-          echo "*** ssh will be used to initiate restart-runs!"
-          echo "    return_address=\"$return_address\" "
-          echo "    return_username=\"$local_username\" "
-
-          if [[ "$remote_loginnode" != "" ]]
-          then
-             ssh -q $remote_username@$remote_loginnode  "ssh -q $SSH_PORTOPT  $local_username@$return_address \" PATH=\\\$PATH:$LOCAL_PALMRUN_PATH; cd $LOCAL_PWD; $prc\" " |  tee palmrun_restart.log
-          else
-             ssh -q $SSH_PORTOPT  $local_username@$return_address  " PATH=\\\$PATH:$LOCAL_PALMRUN_PATH; cd $LOCAL_PWD; $prc" |  tee palmrun_restart.log
-          fi
-
-             # WAIT TO ALLOW THE RESTART-JOB TO BE QUEUED, BEFORE THE CURRENT JOB IS FINISHED
-          sleep 30
-
-       else
-
-             # START THE RESTART JOB ON THE LOCAL HOST
-          eval  $prc  |  tee palmrun_restart.log              # THE ' MUST BE EVALUATED
-
-       fi
-
-          # CHECK, IF RESTART JOB HAS BEEN STARTED
-       if [[ $( grep -c "+++ palmrun crashed"  palmrun_restart.log ) != 0 ]]
-       then
-          printf "\n$dashes\n  +++ creating restart run failed \n"
-          locat=create_restart
-          rm  palmrun_restart.log
-          exit
-       elif [[ $( grep -c "*** palmrun finished"  palmrun_restart.log ) != 1 ]]
-       then
-          printf "\n$dashes\n  +++ creating restart run failed, probably due to network problems\n"
-          locat=create_restart
-          rm  palmrun_restart.log
-          exit       
-       else
-          printf "\n$dashes\n  *** restart run initiated \n"
-          rm  palmrun_restart.log
-       fi
-
-
-          # DELETE INPUT-(RESTART)FILES, WHICH HAVE BEEN FETCHED FROM THE TEMPORARY DATA
-          # DIRECTORY, BACAUSE THEY ARE NOT REQUIRED BY THE RESTART-JOB.
-          # THIS IS DONE IN ORDER TO AVOID EXCEEDING DISC QUOTAS OR DISC SPACE (RESTART-FILES
-          # MAY BE VERY HUGE)
-       (( i = 0 ))
-       while (( i < nr_of_input_files ))
-       do
-          (( i = i + 1 ))
-          if [[ "${got_tmp[$i]}" = true   &&  $keep_data_from_previous_run = false ]]
-          then
-             rm -r  ${absnamein[$i]}
-          fi
-       done
-
-    fi
-
-
-       # ALL ACTIONS FINISHED, TEMPORARY WORKING-DIRECTORY CAN BE DELETED
-    cd  $HOME
-    [[ $delete_temporary_catalog = true ]]  &&  rm -rf $tempdir
-
-
- else
-
-
-       # PREPARING ACTIONS,
-       # IF A BATCH-JOB IS TO BE GENERATED AND TO BE STARTED ON A LOCAL OR REMOTE-MACHINE
-
-       # BUILD THE PALMRUN-COMMAND TO BE CALLED IN THE BATCH-JOB
-    palmrun_com="$palmrun_script_name -r $run_identifier -c $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\""
-    [[ $keep_data_from_previous_run = true ]]  &&  palmrun_com=${palmrun_com}" -k"
-    [[ $do_trace = true ]]        &&  palmrun_com=${palmrun_com}" -x"
-    [[ "$cores" != "" ]]       &&  palmrun_com=${palmrun_com}" -X $cores"
-    [[ $use_openmp = true ]]  &&  palmrun_com=${palmrun_com}" -O $threads_per_task"
-    [[ $tasks_per_node != 0 ]]  &&  palmrun_com=${palmrun_com}" -T $tasks_per_node"
-    [[ $delete_temporary_catalog = false ]]  &&  palmrun_com=${palmrun_com}" -B"
-    [[ "$ocean_file_appendix" = true ]]  &&  palmrun_com=${palmrun_com}" -y"
-    [[ $run_coupled_model = true ]]  &&  palmrun_com=${palmrun_com}" -Y \"$coupled_dist\""
-    [[ "$combine_plot_fields" = false ]]  &&  palmrun_com=${palmrun_com}" -Z"
-    [[ "$max_par_io_str" != "" ]]  &&  palmrun_com=${palmrun_com}" -w $max_par_io_str"
-    [[ "$project_account" != "" ]]  &&  palmrun_com=${palmrun_com}" -A $project_account"
-    if [[ $create_remote_batch_job = true ]]
-    then
-       palmrun_com=${palmrun_com}" -j -u $remote_username -R $local_ip"
-       if [[ $do_trace = true ]]
-       then
-          printf "\n *** PALMRUN-command on remote host:\n     $palmrun_com \n"
-       fi
-    elif [[ $create_batch_job = true ]]
-    then
-       palmrun_com=${palmrun_com}" -j"
-       if [[ $do_trace = true ]]
-       then
-          printf "\n *** PALMRUN-command on local host:\n     $palmrun_com \n"
-       fi
-    fi
-
-
-       # DETERMINE THE FULL PATHS FOR THE JOB PROTOCOL FILES ON THE LOCAL AND
-       # REMOTE HOST
-    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}/${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_number
-    fi
-
-
-       # BUILD THE JOB-SCRIPTS ON FILE jobfile
-    jobfile=jobfile.$run_id_number
-
-
-       # FIRST CREATE THE BATCH DIRECTIVES
-    (( i = 0 ))
-    while (( i < ibd ))
-    do
-       (( i = i + 1 ))
-       line=`echo  "${batch_directive[$i]}" | sed 's/{{/$/g' | sed 's/}}//g'`
-       eval line=\"$line\"
-       echo  "$line"                               >>  $jobfile
-    done
-    echo " "                                       >>  $jobfile
-
-
-       # FOR BATCH JOBS ON REMOTE HOSTS, ADD THE JOBFILE TO SEND BACK THE JOB
-       # PROTOCOL
-    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_number << %%END%%"   >>  $jobfile
-
-          # ADD THE BATCH DIRECTIVES
-       (( i = 0 ))
-       while (( i < ibdt ))
-       do
-          (( i = i + 1 ))
-          line=`echo  "${batch_directive_transfer[$i]}" | sed 's/{{/$/g' | sed 's/}}//g'`
-          eval line=\"$line\"
-          echo  "$line"                            >>  $jobfile
-       done
-       echo " "                                    >>  $jobfile
-
-       echo "set -x"                               >>  $jobfile
-       if [[ "$remote_loginnode" != "" ]]
-       then
-          echo "ssh -q $remote_username@$remote_loginnode  \"cd ${remote_jobcatalog}; ${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
-       else
-          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
-       fi
-       echo "%%END%%"                              >>  $jobfile
-       echo "echo \" *** submitting job for transfering the job protocol file to $local_ip\" "  >>  $jobfile
-       echo "$submit_command  $scpjob_file"     >>  $jobfile
-       echo "rm $scpjob_file"                      >>  $jobfile
-       echo "rm -rf $job_transfer_protocol_file"   >>  $jobfile
-       echo "set -x"                               >>  $jobfile
-       echo "     ' exit"                          >>  $jobfile
-    fi
-
-
-       # ACTIVATE ERROR-TRACEBACK
-    if [[ $do_trace = true ]]
-    then
-       echo  "set -x"                                    >>  $jobfile
-    else
-       echo  "set +vx"                                   >>  $jobfile
-    fi
-
-
-       # INITIALIZE THE ENVIRONMENT AND LOAD MODULES
-    if [[ "$login_init_cmd" != "" ]]
-    then
-       echo  "$login_init_cmd"        >>  $jobfile
-    fi
-    if [[ "$module_commands" != "" ]]
-    then
-       echo  "$module_commands"     >>  $jobfile
-    fi
-
-
-       # CREATE TEMPORARY DIRECTORY AND SWITCH TO IT
-    if [[ $create_remote_batch_job = true ]]
-    then
-       echo  "mkdir  $tempdir"           >>  $jobfile
-       echo  "chmod  go+rx  $tempdir"    >>  $jobfile
-    else
-          # DIRECTORY FOR LOCAL BATCH JOBS IS CREATED NOW, DUE TO A
-          # REQUIREMENT OF THE GRID ENGINE BATCH SYSTEM (WORKING DIR IS GIVEN IN
-          # BATCH DIRECTIVE -wd AND MUST ALREADY EXIST WHEN THE JOB IS SUBMITTED)
-       mkdir  $tempdir
-       chmod  go+rx  $tempdir
-    fi
-    echo  "cd  $tempdir"                 >>  $jobfile
-    echo  "export tempdir=$tempdir"      >>  $jobfile
-    echo  "cp  ${fast_io_catalog}/${sources_for_run_catalog}/{*,.[!.]*}  ."  >>  $jobfile
-    echo  "export PATH=.:\$PATH"         >>  $jobfile
-    echo  "export execute_palmrun=true"  >>  $jobfile
-
-
-       # PROVIDE NAME OF THE CURRENT WORKING-DIRECTORY ON THE LOCAL MACHINE (FROM WHERE THE JOB IS
-       # STARTED) BY SETTING AN ENVIRONMENT-VARIABLE. THIS INFORMATION IS USED IN THE JOB BY PALMRUN
-       # IN CASE THAT RESTART-RUNS HAVE TO BE GENERATED
-    echo  "LOCAL_PWD=$working_directory"                >>  $jobfile
-    echo  "export LOCAL_PWD"                            >>  $jobfile
-
-
-       # PROVIDE THE PATH OF THE LOCAL PALMRUN-SCRIPT FOR THE SAME REASON 
-    echo  "LOCAL_PALMRUN_PATH=${source_path}/../SCRIPTS"   >>  $jobfile
-    echo  "export LOCAL_PALMRUN_PATH"                      >>  $jobfile
-
-
-       # CALL PALMRUN WITHIN THE JOB
-       # AS FINAL ACTION, REMOVE THE TEMPORARY DIRECTORY CREATED AT THE BEGINNING OF THE JOB
-    echo  "set -x"                                              >>  $jobfile
-    echo  "[[ \$execute_palmrun = true ]]  &&  $palmrun_com"    >>  $jobfile
-
-
-       # TRANSFER JOBFILE TO THE TARGET HOST
-    if [[ $create_jobfile_only = false ]]
-    then
-
-          # CREATE LOCAL JOB FOLDER
-       eval  local_jobcatalog=$local_jobcatalog
-       if [[ ! -d $local_jobcatalog ]]
-       then
-          echo " "
-          echo " *** local jobcatalog \"$local_jobcatalog\" does not exist and will be created now"
-          mkdir  $local_jobcatalog
-       fi
- 
-       if [[ $create_remote_batch_job = true ]]
-       then
-
-          echo " "
-          echo " *** transfer of job to remote host via scp"
-
-             # CREATE REMOTE JOB FOLDER, IF IT DOES NOT EXIST
-          ssh  -q  $ssh_key $SSH_PORTOPT  ${remote_username}@${remote_ip}  "[[ ! -d $remote_jobcatalog ]]  &&  mkdir $remote_jobcatalog"  2>&1
-
-             # COPY THE JOB FILE 
-          if [[ $do_trace = true ]]
-          then
-             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
-
-             # SUBMIT THE JOB
-          printf " *** submit the job (output of submit command, \n"
-          printf "     e.g. the job-id given by the batch-system, may follow) \n"
-          if [[ $do_trace = true ]]
-          then
-             echo "     ssh  -q  $ssh_key $SSH_PORTOPT  ${remote_username}@${remote_ip} \"cd $remote_jobcatalog; $submit_command ${configuration_identifier}_${run_id}; rm ${configuration_identifier}_${run_id}\" "
-          fi
-          ssh  -q  $ssh_key $SSH_PORTOPT  ${remote_username}@${remote_ip} "cd $remote_jobcatalog; $submit_command ${configuration_identifier}_${run_id}; rm ${configuration_identifier}_${run_id}"
-
-       elif [[ $create_batch_job = true ]]
-       then
-
-          eval  local_jobcatalog=$local_jobcatalog
-          cp  $jobfile  ${local_jobcatalog}/${configuration_identifier}_${run_id}
-          cd $local_jobcatalog
-          echo " "
-          echo " *** submit the job"
-          if [[ $do_trace = true ]]
-          then
-             echo "$submit_command ${configuration_identifier}_${run_id}"
-          fi
-          $submit_command ${configuration_identifier}_${run_id}
-          rm ${configuration_identifier}_${run_id}
-          cd -  > /dev/null
-
-       fi
-
-       rm -rf  $jobfile
-
-    else
-
-       printf "\n *** jobfile created under name \"$jobfile\" "
-       printf "\n     no batch-job has been sent!"
-
-    fi
-
- fi  # END OF REMOTE-PART
+       printf "\n$dashes\n  *** all OUTPUT-files saved \n"
+    fi
+ fi
+
+
+
+
+    # ALL ACTIONS FINISHED, TEMPORARY WORKING-DIRECTORY CAN BE DELETED
+ cd  -
+ [[ $delete_temporary_catalog = true ]]  &&  rm -rf $tempdir
