Changeset 4109 for TOOLS/CMIP6_FORCING/OZONE/tools.bash
- Timestamp:
- 11/06/18 17:14:39 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/CMIP6_FORCING/OZONE/tools.bash
r3870 r4109 76 76 Yb=$Ymin; Ye=$Ymax 77 77 else 78 Yb=$((dY*(Y/dY))); Ye=$((Yb+dY-1)); Ye=$(($Ye>$Ymax?$Ymax:$Ye)) 78 Yb=$((Ymin+dY*((Y-Ymin)/dY))); Ye=$((Yb+dY-1)) 79 Ye=$(($Ye>$Ymax?$Ymax:$Ye)) 79 80 fi 80 81 nbm=$((12*(Ye-Yb+1)-1)) #--- MONTHS NUMBER OF CURRENT FILE 81 82 it=$((12*(Y-Yb))) #--- JANUARY INDEX IN CURRENT FILE 82 83 fin=`var=$v_in; Yb=$Yb; Ye=$Ye; eval echo $f_in` #--- CURRENT FILE NAME 83 fou=`var=$v_ou; Y=$Y; eval echo $f_ou` #--- OUTPUT FILE NAME84 fou=`var=$v_ou; Y=$Y; eval echo $f_ou` #--- OUTPUT FILE NAME 84 85 ib=$(($it<=nmrg?0:$((it-nmrg)))) #--- INDEX OF FIRST USED MONTH 85 86 ie=$(($((it+11+mrg))>=$nbm?$nbm:$((it+11+nmrg)))) #--- INDEX OF LAST USED MONTHF … … 246 247 #================================================================================== 247 248 function get_date { 248 # Assumes the following filename structure: *_${Yb}*-${Ye}*.* (Yb/e: 4 digits) 249 # $1: varname 250 # $2: datatype 251 # $3: dirin 252 # $4: dirin structure patch 253 # $5...$N: files_in 249 # Call get_date1 one time each input file. 250 # $1: varname $2: datatype $3: dirin $4: <dir_in> patch $5...$N: <files_in> 254 251 # [$N+1...]: <dset>:<var>=<val> to overwrite value of variables evaluated from parsing. 255 252 local v_in dtyp d_in dstr f_in Yb Ye St a f first date dates files_in="" … … 264 261 function get_date_1 { 265 262 # Assumes the following filename structure: *_${Yb}*-${Ye}*.* (Yb/e: 4 digits) 266 # $1: varname 267 # $2: datatype 268 # $3: base directory for files 269 # $4: dirin structure patch 270 # $5: file_in 263 # Returns ${FirstYear}-${LastYear}-${IntervalsLengths} 264 # $1: varname $2: datatype $3: dirin $4: <dir_in> patch $5: <file_in> 271 265 # [$6...]: <dset>:<var>=<val> to overwrite value of variables evaluated from parsing. 272 266 local v_in dtyp d_in d_str f_in Yb Ye St a f first … … 274 268 parse_dir $f_in $dstr $*; Yb=1000000; Ye=0; first='t' 275 269 for f in $(var=$v_in; Yb=????; Ye=????; datatype=$dtyp; eval ls $d_in/$f_in); do 276 a=${f##*_}; if [ ${a::4} -le $Yb ]; then Yb=${a::4}; fi277 a=${a##*-}; if [ ${a::4} -ge $Ye ]; then Ye=${a::4}; fi278 if [ $first = 't' ]; then St=$((Ye-Yb+1)); first='f'; fi270 a=${f##*_}; ymn=${a::4}; if [ $ymn -le $Yb ]; then Yb=$ymn; fi 271 a=${a##*-}; ymx=${a::4}; if [ $ymx -ge $Ye ]; then Ye=$ymx; fi 272 if [ $first != 't' ]; then St=${St}-; fi; first='f'; St=${St}$((ymx-ymn+1)) 279 273 done 280 274 echo $Yb-$Ye-$St … … 311 305 } 312 306 #================================================================================== 307 function is_int { 308 # $1: string to be checked 309 set +vx 310 if [[ $1 =~ ^[0-9]+$ ]]; then return 0; else return 1; fi 311 set -vx 312 } 313 #================================================================================== 314 function remove_version { 315 # $1: variable name 316 local out=$1 317 while `is_int ${out##*-}`; do out=${out%-*}; done; echo $out; return 1 318 } 313 319
Note: See TracChangeset
for help on using the changeset viewer.