Ignore:
Timestamp:
Nov 15, 2017 8:24:11 AM (6 years ago)
Author:
raasch
Message:

use of wildcards in file connection statements enabled, bugfix in logarithmic interpolation of v-component for particles (usws was used by mistake)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/palmrun

    r2605 r2610  
    2727# -----------------
    2828# $Id$
     29# use of wildcards in file connection statements enabled
     30#
     31# 2605 2017-11-09 15:31:46Z raasch
    2932# in case of remote jobs, input files with "job" or "jobopt" (new) attribute
    3033# will not be sent with the job file any more, but copied into the
    31 # SOURCES_FOR_RUN... folder on the remote host, before he job is submitted
     34# SOURCES_FOR_RUN... folder on the remote host, before the job is submitted
    3235#
    3336# 2600 2017-11-01 14:11:20Z raasch
     
    8588 set +o noclobber    # EXISTING FILES ARE ALLOWED TO BE OVERWRITTEN
    8689
    87  typeset -i  ibd=0 ibdt=0 iec=0 iic=0 iin=0 ioc=0 iout=0
     90 typeset -i  ibd=0 ibdt=0 iec=0 iic=0 iin=0 ioc=0 iout=0 nr_of_input_files=0
     91 typeset -i  nr_of_output_files=0
    8892 typeset -x -i  memory=0   # HAS TO BE EXPORTED HERE, OTHERWISE AN UNKNOWN SIDE
    8993                           # SIDE EFFECT MAY CAUSE DATA LOSS WHEN GETOPTS IS READING THE
     
    556560          # LOCALLY REQUIRED ON THAT MACHINE (I.E. s2b = loc), THE FILE CONNECTION
    557561          # IS NOT CHECKED AND STORED.
    558        IFSALT="$IFS"; IFS="$IFS:"
     562       IFSALT="$IFS"; IFS="$IFS:"      # ADD ":" AS FIELD SEPARATOR
    559563       if [[ "$s2a" = in  &&  ! ( $create_remote_batch_job = true  &&  ( "$s2b" = loc  ||  "$s2b" = locopt ) ) ]]
    560564       then
     
    570574          then
    571575             (( iin = iin + 1 ))
    572              localin[$iin]=$s1; transin[$iin]=$s2b; actionin[$iin]=$s2c;
    573              typein[$iin]=$s3; pathin[$iin]=$s4; endin[$iin]=$s5;
    574              extin[$iin]=$s6
     576             localin_pre[$iin]=$s1; transin_pre[$iin]=$s2b; actionin_pre[$iin]=$s2c;
     577             pathin_pre[$iin]=$s4; endin_pre[$iin]=$s5; extin_pre[$iin]=$s6
    575578
    576579                # FILES WITH JOB-ATTRIBUTE ARE STORED IN THE SOURCES_FOR_RUN
     
    578581             if [[ $running_on_remote = true  && ( "$s2b" = job  ||  "$s2b" = jobopt ) ]]
    579582             then
    580                 pathin[$iin]=${fast_io_catalog}/${sources_for_run_catalog}
     583                pathin_pre[$iin]=${fast_io_catalog}/${sources_for_run_catalog}
    581584             fi
    582585
     586                # CHECK FOR MULTIPLE FILES, SET A RESPECTIVE FLAG AND REMOVE
     587                # THE WILDCARD FROM THE ENDING
     588             if [[ "${s5: -1}" = "*" ]]
     589             then
     590                if [[ "$s2c" = "di" ]]
     591                then
     592                   printf "\n    +++ wildcards (*) not allowed with \"di\" file attribute."
     593                   printf "\n        see file \"$fileconnection_file\", line"
     594                   printf "\n$line"
     595                   locat=iofiles_file; exit
     596                fi
     597                multin[$iin]=true
     598                string=${endin_pre[$iin]}
     599                endin_pre[$iin]="${string%?}"
     600             else
     601                multin[$iin]=false
     602             fi
    583603          fi
    584604       elif [[ "$s2a" = out  &&  ! ( $create_remote_batch_job = true  &&  "$s2b" = loc ) ]]
     
    595615          then
    596616             (( iout = iout + 1 ))
    597              localout[$iout]=$s1; actionout[$iout]=$s2c; typeout[$iout]=$s3;
    598              pathout[$iout]=$s4; endout[$iout]=$s5; extout[$iout]=$s6
     617             localout_pre[$iout]=$s1; actionout_pre[$iout]=$s2c; typeout_pre[$iout]=$s3;
     618             pathout_pre[$iout]=$s4; endout_pre[$iout]=$s5; extout_pre[$iout]=$s6
     619
     620                # CHECK FOR MULTIPLE FILES, SET A RESPECTIVE FLAG AND REMOVE
     621                # THE WILDCARD FROM THE LOCAL FILENAME
     622             if [[ "${s1: -1}" = "*" ]]
     623             then
     624                if [[ "$s2c" = "di" ]]
     625                then
     626                   printf "\n    +++ wildcards (*) not allowed with \"di\" file attribute."
     627                   printf "\n        see file \"$fileconnection_file\", line"
     628                   printf "\n$line"
     629                   locat=iofiles_file; exit
     630                fi
     631                multout[$iout]=true
     632                string=${localout_pre[$iout]}
     633                localout_pre[$iout]="${string%?}"
     634             else
     635                multout[$iout]=false
     636             fi
    599637          fi
    600638       elif [[ "$s2a" != in  &&  "$s2a" != out ]]
     
    9671005    # CHECK, IF INPUT-FILES EXIST, AND DETERMINE HIGHEST CYCLE NUMBER (IF CYCLES EXIST)
    9681006 (( i = 0 ))
     1007 (( nr_of_input_files = 0 ))
    9691008 while (( i < iin ))
    9701009 do
    9711010    (( i = i + 1 ))
    972     (( maxcycle = 0 ))
    9731011
    9741012       # GENERATE PATH AND FULL FILE NAME (then-BRANCH: FIXED FULL NAME IS GIVEN, I.E. THE
    9751013       # FILE IDENTIFIER IS NOT PART OF THE FILENAME))
    976     if [[ "${actionin[$i]}" = di ]]
    977     then
    978        remotepathin[$i]=${pathin[$i]}/${endin[$i]}  # EVALUATE REMOTE-PATH ON THE REMOTE
    979                                                     # HOST ONLY
    980        eval filename=${pathin[$i]}/${endin[$i]}
     1014    if [[ "${actionin_pre[$i]}" = di ]]
     1015    then
     1016       eval filename=${pathin_pre[$i]}/${endin_pre[$i]}
    9811017    else
    982        remotepathin[$i]=${pathin[$i]}/${fname}${endin[$i]}  # EVALUATE REMOTE-PATH ON THE REMOTE
    983                                                              # HOST ONLY
    984        eval filename=${pathin[$i]}/${fname}${endin[$i]}
    985     fi
    986     eval pathname=${pathin[$i]}
     1018       eval filename=${pathin_pre[$i]}/${fname}${endin_pre[$i]}
     1019    fi
     1020
    9871021
    9881022       # CHECK IF FILE EXISTS
     
    9911025
    9921026          # FILES WITH ATTRIBUTE locopt ARE OPTIONAL. NO ABORT, IF THEY DO NOT EXIST.
    993        if [[ "${transin[$i]}" != "locopt"  &&  "${transin[$i]}" != "jobopt" ]]
     1027       if [[ "${transin_pre[$i]}" != "locopt"  &&  "${transin_pre[$i]}" != "jobopt" ]]
    9941028       then
    9951029          printf "\n\n  +++ INPUT-file: "
    996           if [[ "${extin[$i]}" = ""  ||  "${extin[$i]}" = " " ]]
     1030          if [[ "${extin_pre[$i]}" = ""  ||  "${extin_pre[$i]}" = " " ]]
    9971031          then
    9981032             printf "\n           $filename"
    9991033          else
    1000              printf "\n           $filename.${extin[$i]}"
     1034             printf "\n           $filename.${extin_pre[$i]}"
    10011035          fi
    10021036          printf "\n      does not exist\n"
    10031037          locat=input; exit
    10041038       else
    1005           transin[$i]="unavailable"
     1039          (( nr_of_input_files = nr_of_input_files + 1 ))
     1040          localin[$nr_of_input_files]="${localin_pre[$i]}"
     1041          transin[$nr_of_input_files]="unavailable"
     1042          actionin[$nr_of_input_files]="${actionin_pre[$i]}"
     1043          pathin[$nr_of_input_files]="${pathin_pre[$i]}"
     1044          endin[$nr_of_input_files]="${endin_pre[$i]}"
     1045          extin[$nr_of_input_files]="${extin_pre[$i]}"
    10061046       fi
    10071047
    10081048    else
    10091049
    1010           # DETERMINE THE FILE'S CYCLE NUMBER
    1011        ls -1 -d $filename    >   filelist  2>/dev/null
    1012        ls -1 -d $filename.*  >>  filelist  2>/dev/null
    1013        while  read line
     1050          # FIRST CHECK FOR MULTIPLE NAMES WITH THE SAME BASENAME ($fname) AND
     1051          # CREATE A LIST FOR THE DETECTED BASENAME ENDINGS
     1052       if [[ "${multin[$i]}" = true ]]
     1053       then
     1054             # DETERMINE THE EXISTING EXTENSIONS FROM THE LIST OF FILES
     1055          ls -1 -d ${filename}    >   filelist  2>/dev/null
     1056          ls -1 -d ${filename}.*  >>  filelist  2>/dev/null
     1057          ls -1 -d ${filename}_*  >>  filelist  2>/dev/null
     1058
     1059          endings=""
     1060          while  read line
     1061          do
     1062                 # filename without path (i.e. after the last "/")
     1063              basefilename=$(basename ${line})
     1064
     1065                 # check if there is an extension and remove it
     1066              ext=${basefilename##*.}
     1067              if [[ "$ext" = "${extin_pre[$i]}" ]]
     1068              then
     1069                 basefilename=${basefilename%.*}
     1070              fi
     1071
     1072                 # check for an existing cycle number and remove it
     1073              cycle=${basefilename##*.}
     1074              if [[ $cycle =~ ^-?[0-9]+$ ]]
     1075              then
     1076                 basefilename=${basefilename%.*}
     1077              fi
     1078
     1079                 # remove the fname from the beginning
     1080              length_fname=${#fname}
     1081              ending=${basefilename:${length_fname}}
     1082
     1083                 # remove the ending given in the .iofiles from the beginning
     1084              endingstring="${endin_pre[$i]}"
     1085              length_ending=${#endingstring}
     1086              ending=${ending:${length_ending}}
     1087
     1088              if [[ "$ending" = "" ]]
     1089              then
     1090                    # standard ending as given in the .iofiles
     1091                 if [[ $(echo $endings | grep -c DEFAULT) = 0 ]]
     1092                 then
     1093                    endings="$endings DEFAULT"
     1094                 fi
     1095              else
     1096                    # ending must start with "_", otherwise its a different file
     1097                 if [[ "${ending:0:1}" = "_" ]]
     1098                 then
     1099                    if [[ $(echo $endings | grep -c "$ending") = 0 ]]
     1100                    then
     1101                       endings="$endings $ending"
     1102                    fi
     1103                 fi
     1104              fi
     1105 
     1106          done <filelist
     1107
     1108          rm filelist
     1109
     1110       else
     1111
     1112             # SINGLE NAME
     1113          endings=DEFAULT
     1114
     1115       fi
     1116
     1117          # FOR EACH BASENAME ENDING CREATE AN ENTRY IN THE FINAL INPUT FILE LIST
     1118       for  ending  in  $endings
    10141119       do
    1015               # filename without path (i.e. after the last "/")
    1016            basefilename=$(basename ${line})
    1017 
    1018               # check if there is an extension
    1019            extension=${basefilename##*.}
    1020            if [[ "$extension" = "${extin[$i]}" ]]
    1021            then
    1022               basefilename=${basefilename%.*}
    1023            fi
    1024 
    1025               # check for an existing cycle number
    1026            cycle=${basefilename##*.}
    1027            if [[ $cycle =~ ^-?[0-9]+$ ]]
    1028            then
    1029               (( icycle = $cycle ))
    1030            else
    1031               (( icycle = 0 ))
    1032            fi
    1033 
    1034            if (( icycle > maxcycle ))
    1035            then
    1036               (( maxcycle = icycle ))
    1037 
    1038                  # FOR COMPATIBILITY REASONS WITH OLDER VERSIONS
    1039                  # CHECK IF CYCLE NUMBER CONTAINS LEADING ZEROS
    1040               if [[ $(echo $cycle | cut -c1) = 0 ]]
     1120
     1121             # DEFAULT MEANS THAT THE ENDING GIVEN IN .iofiles SHALL BE USED
     1122          if [[ $ending = DEFAULT ]]
     1123          then
     1124             ending=""
     1125          fi
     1126
     1127             # NEW ENTRY (ENDING IS ALSO ADDED TO LOCAL FILENAME READ BY PALM!)
     1128          (( nr_of_input_files = nr_of_input_files + 1 ))
     1129          localin[$nr_of_input_files]="${localin_pre[$i]}"$ending
     1130          transin[$nr_of_input_files]="${transin_pre[$i]}"
     1131          actionin[$nr_of_input_files]="${actionin_pre[$i]}"
     1132          pathin[$nr_of_input_files]="${pathin_pre[$i]}"
     1133          endin[$nr_of_input_files]="${endin_pre[$i]}"$ending
     1134          extin[$nr_of_input_files]="${extin_pre[$i]}"
     1135
     1136
     1137             # GENERATE PATH AND FULL FILE NAME (then-BRANCH: FIXED FULL NAME IS GIVEN, I.E. THE
     1138             # FILE IDENTIFIER IS NOT PART OF THE FILENAME))
     1139          if [[ "${actionin[$nr_of_input_files]}" = di ]]
     1140          then
     1141             eval filename=${pathin[$nr_of_input_files]}/${endin[$nr_of_input_files]}
     1142          else
     1143             eval filename=${pathin[$nr_of_input_files]}/${fname}${endin[$nr_of_input_files]}
     1144          fi
     1145
     1146             # DETERMINE THE FILE'S CYCLE NUMBER
     1147          (( maxcycle = 0 ))
     1148          ls -1 -d $filename    >   filelist  2>/dev/null
     1149          ls -1 -d $filename.*  >>  filelist  2>/dev/null
     1150          while  read line
     1151          do
     1152                 # filename without path (i.e. after the last "/")
     1153              basefilename=$(basename ${line})
     1154   
     1155                 # check if there is an extension
     1156              extension=${basefilename##*.}
     1157              if [[ "$extension" = "${extin[$nr_of_input_files]}" ]]
    10411158              then
    1042                  leading_zero=true
     1159                 basefilename=${basefilename%.*}
     1160              fi
     1161   
     1162                 # check for an existing cycle number
     1163              cycle=${basefilename##*.}
     1164              if [[ $cycle =~ ^-?[0-9]+$ ]]
     1165              then
     1166                 (( icycle = $cycle ))
    10431167              else
    1044                  leading_zero=false
     1168                 (( icycle = 0 ))
    10451169              fi
    1046            fi
    1047 
    1048        done <filelist
    1049        rm filelist
    1050 
    1051           # MAKE CYCLE NUMBER THREE DIGITS WIDE
    1052        if [[ $leading_zero = true ]]
    1053        then
    1054           cyclestring=`printf "%03d" $maxcycle`
    1055        else
    1056           cyclestring=$maxcycle
    1057        fi
    1058 
    1059           # APPEND CYCLE NUMBER TO FILENAME
    1060        if (( maxcycle > 0 ))
    1061        then
    1062           if [[ "${extin[$i]}" != " "  &&   "${extin[$i]}" != "" ]]
    1063           then
    1064              filename=${filename}.$cyclestring.${extin[$i]}
     1170   
     1171              if (( icycle > maxcycle ))
     1172              then
     1173                 (( maxcycle = icycle ))
     1174   
     1175                    # FOR COMPATIBILITY REASONS WITH OLDER VERSIONS
     1176                    # CHECK IF CYCLE NUMBER CONTAINS LEADING ZEROS
     1177                 if [[ $(echo $cycle | cut -c1) = 0 ]]
     1178                 then
     1179                    leading_zero=true
     1180                 else
     1181                    leading_zero=false
     1182                 fi
     1183              fi
     1184   
     1185          done <filelist
     1186          rm filelist
     1187   
     1188             # MAKE CYCLE NUMBER THREE DIGITS WIDE
     1189          if [[ $leading_zero = true ]]
     1190          then
     1191             cyclestring=`printf "%03d" $maxcycle`
    10651192          else
    1066              filename=${filename}.$cyclestring
    1067           fi
    1068        else
    1069           if [[ "${extin[$i]}" != " "  &&   "${extin[$i]}" != "" ]]
    1070           then
    1071              filename=${filename}.${extin[$i]}
    1072           fi
    1073        fi
    1074        
    1075           # STORE FILENAME WITHOUT PATH BUT WITH CYCLE NUMBER,
    1076           # IS LATER USED FOR TRANSFERRING FILES WIHIN THE JOB (SEE END OF FILE)
    1077        absnamein[$i]=$filename
    1078        if (( maxcycle > 0 ))
    1079        then
    1080           if [[ "${actionin[$i]}" = di ]]
    1081           then
    1082              frelin[$i]=${endin[$i]}.$cyclestring
     1193             cyclestring=$maxcycle
     1194          fi
     1195   
     1196             # APPEND CYCLE NUMBER TO FILENAME
     1197          if (( maxcycle > 0 ))
     1198          then
     1199             if [[ "${extin[$nr_of_input_files]}" != " "  &&   "${extin[$nr_of_input_files]}" != "" ]]
     1200             then
     1201                filename=${filename}.$cyclestring.${extin[$nr_of_input_files]}
     1202             else
     1203                filename=${filename}.$cyclestring
     1204             fi
    10831205          else
    1084              frelin[$i]=${fname}${endin[$i]}.$cyclestring
    1085           fi
    1086        else
    1087           if [[ "${actionin[$i]}" = di ]]
    1088           then
    1089              frelin[$i]=${endin[$i]}
     1206             if [[ "${extin[$nr_of_input_files]}" != " "  &&   "${extin[$nr_of_input_files]}" != "" ]]
     1207             then
     1208                filename=${filename}.${extin[$nr_of_input_files]}
     1209             fi
     1210          fi
     1211         
     1212             # STORE FILENAME WITHOUT PATH BUT WITH CYCLE NUMBER,
     1213             # IS LATER USED FOR TRANSFERRING FILES WIHIN THE JOB (SEE END OF FILE)
     1214          absnamein[$nr_of_input_files]=$filename
     1215          if (( maxcycle > 0 ))
     1216          then
     1217             if [[ "${actionin[$nr_of_input_files]}" = di ]]
     1218             then
     1219                frelin[$nr_of_input_files]=${endin[$nr_of_input_files]}.$cyclestring
     1220             else
     1221                frelin[$nr_of_input_files]=${fname}${endin[$nr_of_input_files]}.$cyclestring
     1222             fi
    10901223          else
    1091              frelin[$i]=${fname}${endin[$i]}
    1092           fi
    1093        fi
    1094 
    1095     fi
     1224             if [[ "${actionin[$nr_of_input_files]}" = di ]]
     1225             then
     1226                frelin[$nr_of_input_files]=${endin[$nr_of_input_files]}
     1227             else
     1228                frelin[$nr_of_input_files]=${fname}${endin[$nr_of_input_files]}
     1229             fi
     1230          fi
     1231
     1232       done
     1233
     1234    fi
     1235
    10961236 done
    10971237
    1098    
     1238
    10991239    # GENERATE FULL FILENAMES OF OUTPUT-FILES (WITHOUT $ OR ~),
    11001240    # CHECK, IF OUTPUT-FILES EXIST, AND DETERMINE HIGHEST CYCLE NUMBER (IF CYCLES EXIST),
    11011241    # OR, IN CASE THAT FILE DOES NOT EXIST, CHECK, IF IT CAN BE CREATED 
    1102     # THESE ACTIONS ARE NOT CARRIED OUT, IF FILES SHALL BE TRASFERRED FROM THE REMOTE TO
     1242    # THESE ACTIONS ARE NOT CARRIED OUT, IF FILES SHALL BE TRANSFERRED FROM THE REMOTE TO
    11031243    # THE LOCAL HOST (BECAUSE THEIR IS NO DIRECT ACCESS TO THE LOCAL DIRECTORIES FROM THE
    11041244    # REMOTE HOST)
     
    11071247 do
    11081248    (( i = i + 1 ))
    1109     if [[ ! ( $running_on_remote = true  &&  ( "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ) ) ]]
    1110     then
    1111        if [[ "${actionout[$i]}" = tr ]]
    1112        then
    1113           actionout[$i]=""
    1114        elif [[ "${actionout[$i]}" = trpe ]]
    1115        then
    1116           actionout[$i]=pe
    1117        elif [[ "${actionout[$i]}" = tra ]]
    1118        then
    1119           actionout[$i]=a
     1249    if [[ ! ( $running_on_remote = true  &&  ( "${actionout_pre[$i]}" = tr || "${actionout_pre[$i]}" = tra || "${actionout_pre[$i]}" = trpe ) ) ]]
     1250    then
     1251       if [[ "${actionout_pre[$i]}" = tr ]]
     1252       then
     1253          actionout_pre[$i]=""
     1254       elif [[ "${actionout_pre[$i]}" = trpe ]]
     1255       then
     1256          actionout_pre[$i]=pe
     1257       elif [[ "${actionout_pre[$i]}" = tra ]]
     1258       then
     1259          actionout_pre[$i]=a
    11201260       fi
    11211261       (( maxcycle = 0 ))
    1122        eval filename=${pathout[$i]}/${fname}${endout[$i]}
    1123        eval catalogname=${pathout[$i]}
     1262       eval filename=${pathout_pre[$i]}/${fname}${endout_pre[$i]}
     1263       eval catalogname=${pathout_pre[$i]}
    11241264       if ! ls $filename* 1>/dev/null 2>&1
    11251265       then
     
    11561296             fi
    11571297          fi 2>/dev/null
    1158        else
    1159 
    1160              # DETERMINE THE CYCLE NUMBER
    1161           ls -1 -d $filename    >   filelist  2>/dev/null
    1162           ls -1 -d $filename.*  >>  filelist  2>/dev/null
    1163           while  read line
    1164           do
    1165 
    1166                 # filename without path (i.e. after the last "/")
    1167              basefilename=$(basename ${line})
    1168 
    1169                 # check if there is an extension
    1170              extension=${basefilename##*.}
    1171              if [[ "$extension" = "${extout[$i]}" ]]
    1172              then
    1173                 basefilename=${basefilename%.*}
    1174              fi
    1175 
    1176                 # check for an existing cycle number
    1177              cycle=${basefilename##*.}
    1178              if [[ $cycle =~ ^-?[0-9]+$ ]]
    1179              then
    1180                 (( icycle = $cycle + 1 ))
    1181              else
    1182                 (( icycle = 1 ))
    1183              fi
    1184 
    1185              if (( icycle > maxcycle ))
    1186              then
    1187                 (( maxcycle = icycle ))
    1188              fi
    1189 
    1190           done <filelist
    1191           rm filelist
    1192        fi
    1193 
    1194           # APPEND CYCLE NUMBER TO FILENAME AND CHECK, IF FILE CAN BE CREATED
    1195           # IN CASE OF FILE-APPEND, FILE MUST BE APPENDED TO THE ONE WITH HIGHEST CYCLE NUMBER
    1196        if [[ "${actionout[$i]}" != a ]]
    1197        then
    1198           cyclestring=`printf "%03d" $maxcycle`
    1199           if (( maxcycle > 0 ))
    1200           then
    1201              filename_tmp=${filename}.$cyclestring
    1202              if  cat /dev/null > $filename_tmp
    1203              then
    1204                 rm  $filename_tmp
    1205              else
    1206                 printf "\n  +++ OUTPUT-file:"
    1207                 printf "\n           $filename_tmp"
    1208                 printf "\n      cannot be created"
    1209                 locat=output  ; exit
    1210              fi
    1211           fi
    1212        else
    1213           (( maxcycle = maxcycle - 1 ))
    1214        fi
    1215        
    1216        (( cycnum[$i] = maxcycle ))
    1217        pathout[$i]=$filename
     1298
     1299       fi
    12181300
    12191301    fi
     
    14991581 then
    15001582    (( i = 0 ))
    1501     while (( i < iin ))
     1583    while (( i < nr_of_input_files ))
    15021584    do
    15031585       (( i = i + 1 ))
     
    16781760 then
    16791761    (( i = 0 ))
    1680     while (( i < iin ))
     1762    while (( i < nr_of_input_files ))
    16811763    do
    16821764       (( i = i + 1 ))
     
    17211803       # LOOP OVER ALL ACTIVATED FILES (LISTED IN THE CONFIGURATION FILE)
    17221804    (( i = 0 ))
    1723     while (( i < iin ))
     1805    while (( i < nr_of_input_files ))
    17241806    do
    17251807       (( i = i + 1 ))
     
    19872069
    19882070
    1989        # PROVIDE DATA FOR
     2071       # PROVIDE DATA FOR ATMOSPHERE OCEAN COUPLING
    19902072    if [[ $run_coupled_model = false ]]
    19912073    then
     
    20662148
    20672149
     2150       # IN A FIRST PASS, ADD ADDITIONAL OUTPUT FILE CONNECTIONS IN CASE OF
     2151       # WILDCARDS
     2152    (( i = 0 ))
     2153    (( nr_of_output_files = 0 ))
     2154
     2155    while (( i < iout ))
     2156    do
     2157
     2158       (( i = i + 1 ))
     2159
     2160          # FIRST CHECK FOR MULTIPLE NAMES WITH THE SAME LOCAL NAME AND
     2161          # CREATE A LIST FOR THE DETECTED ENDINGS
     2162       if [[ "${multout[$i]}" = true ]]
     2163       then
     2164             # DETERMINE THE EXISTING EXTENSIONS FROM THE LIST OF FILES
     2165          ls -1 -d ${localout_pre[$i]}    >   filelist  2>/dev/null
     2166          ls -1 -d ${localout_pre[$i]}_*  >>  filelist  2>/dev/null
     2167
     2168          endings="DEFAULT"
     2169          while  read line
     2170          do
     2171                 # remove the local name from the beginning
     2172              localnamestring="${localout_pre[$i]}"
     2173              length_localname=${#localnamestring}
     2174              ending=${line:${length_localname}}
     2175
     2176              if [[ "$ending" != "" ]]
     2177              then
     2178                 endings="$endings $ending"
     2179              fi
     2180 
     2181          done <filelist
     2182
     2183          rm filelist
     2184
     2185       else
     2186
     2187             # SINGLE NAME
     2188          endings=DEFAULT
     2189
     2190       fi
     2191
     2192          # FOR EACH BASENAME ENDING CREATE AN ENTRY IN THE FINAL OUTPUT FILE LIST
     2193       for  ending  in  $endings
     2194       do
     2195
     2196             # DEFAULT MEANS THAT THE ENDING GIVEN IN .iofiles SHALL BE USED
     2197          if [[ $ending = DEFAULT ]]
     2198          then
     2199             ending=""
     2200          fi
     2201
     2202             # NEW ENTRY (ENDING IS ALSO ADDED TO LOCAL FILENAME READ BY PALM!)
     2203          (( nr_of_output_files = nr_of_output_files + 1 ))
     2204          localout[$nr_of_output_files]="${localout_pre[$i]}"$ending
     2205          transout[$nr_of_output_files]="${transout_pre[$i]}"
     2206          actionout[$nr_of_output_files]="${actionout_pre[$i]}"
     2207          pathout[$nr_of_output_files]="${pathout_pre[$i]}"
     2208          endout[$nr_of_output_files]="${endout_pre[$i]}"$ending
     2209          extout[$nr_of_output_files]="${extout_pre[$i]}"
     2210
     2211       done
     2212
     2213    done
     2214
     2215
     2216
     2217
    20682218       # COPY LOCAL OUTPUT-FILES TO THEIR PERMANENT DESTINATIONS
    20692219    (( i = 0 ))
    2070     while (( i < iout ))
     2220    while (( i < nr_of_output_files ))
    20712221    do
    20722222       (( i = i + 1 ))
     
    20932243       fi
    20942244
    2095           # ADD CYCLE NUMBER TO FILENAME
    20962245       if [[ ! ( $running_on_remote = true  &&  ( "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ) ) ]]
    20972246       then
    20982247
    2099               # IN APPEND MODE, FILES KEEP THEIR CURRENT CYCLE NUMBER
     2248          eval filename=${pathout[$i]}/${fname}${endout[$i]}
     2249
     2250             # DETERMINE THE CYCLE NUMBER
     2251          ls -1 -d $filename    >   filelist  2>/dev/null
     2252          ls -1 -d $filename.*  >>  filelist  2>/dev/null
     2253          while  read line
     2254          do
     2255   
     2256                # filename without path (i.e. after the last "/")
     2257             basefilename=$(basename ${line})
     2258   
     2259                # check if there is an extension
     2260             extension=${basefilename##*.}
     2261             if [[ "$extension" = "${extout[$i]}" ]]
     2262             then
     2263                basefilename=${basefilename%.*}
     2264             fi
     2265   
     2266                # check for an existing cycle number
     2267             cycle=${basefilename##*.}
     2268             if [[ $cycle =~ ^-?[0-9]+$ ]]
     2269             then
     2270                (( icycle = $cycle + 1 ))
     2271             else
     2272                (( icycle = 1 ))
     2273             fi
     2274   
     2275             if (( icycle > maxcycle ))
     2276             then
     2277                (( maxcycle = icycle ))
     2278             fi
     2279   
     2280          done <filelist
     2281          rm filelist
     2282
     2283   
     2284             # SET THE CYCLE NUMBER
     2285             # IN CASE OF FILE-APPEND, IT MUST BE THE HIGHEST EXISTING CYCLE NUMBER
     2286          if [[ "${actionout[$i]}" = a ]]
     2287          then
     2288             (( maxcycle = maxcycle - 1 ))
     2289          fi
     2290         
     2291          (( cycnum[$i] = maxcycle ))
     2292          pathout[$i]=$filename
     2293
     2294
     2295             # ADD CYCLE NUMBER TO FILENAME
     2296             # IN APPEND MODE, FILES KEEP THEIR CURRENT CYCLE NUMBER
    21002297          if [[ "${actionout[$i]}" != "a" ]]
    21012298          then
     
    23932590          # MAY BE VERY HUGE)
    23942591       (( i = 0 ))
    2395        while (( i < iin ))
     2592       while (( i < nr_of_input_files ))
    23962593       do
    23972594          (( i = i + 1 ))
Note: See TracChangeset for help on using the changeset viewer.