Changeset 4109
- Timestamp:
- 11/06/18 17:14:39 (5 years ago)
- Location:
- TOOLS/CMIP6_FORCING/OZONE
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/CMIP6_FORCING/OZONE/clims_CMIP6.bash
r3870 r4109 4 4 #=== Indices of chosen datasets among available collection (see DATANAMES after) 5 5 DOPROCESS=('n' 'y') #--- PROCESSED DATA TYPES (SSTandSeaIce, ozone) 6 IXPROCESS=("0" " 5 6 7")#--- PROCESSED DATASETS INDICES6 IXPROCESS=("0" "1 2 3 4") #--- PROCESSED DATASETS INDICES 7 7 recomp='n' #--- RECOMPUTE FILES THAT ARE ALREADY PRESENT (y/n) 8 8 … … 31 31 esac 32 32 if [ "$DATAIN" = "" ]; then echo "Raw data folder for $machine has to be specified."; exit; fi 33 #DATAOU=/data/dcugnet$DATAOU # No write acces to $DATAOU => temporary storage space.33 DATAOU=/data/dcugnet$DATAOU # No write acces to $DATAOU => temporary storage space. 34 34 35 35 #--- DATA TO TREAT (INTERANNUAL AND CLIMATOLOGIES): "SSTsAndSeaIce" "ozone": … … 42 42 input4MIPs/CMIP6/CMIP/PCMDI/PCMDI-AMIP-1-1-4/ocean/mon/\${var}/gn/v20180427/$f" \ 43 43 "input4MIPs/CMIP6/CMIP/UReading/UReading-CCMI-1-0/atmos/mon/\${var}/gn/v20160711/$f \ 44 input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-ssp126-1-0/atmos/mon/\${var}/gn/v20181101/$f \ 45 input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-ssp245-1-0/atmos/mon/\${var}/gn/v20181101/$f \ 46 input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-ssp370-1-0/atmos/mon/\${var}/gn/v20181101/$f \ 47 input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-ssp585-1-0/atmos/mon/\${var}/gn/v20181101/$f \ 44 48 input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-stratO3-1-0/atmos/mon/\${var}/gn/v20170814/$f \ 45 49 input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-nat-1-0/atmos/mon/\${var}/gn/v20180503/$f \ … … 48 52 input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-sol-1-1/atmos/mon/\${var}/gn/v20180525/$f \ 49 53 input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-nat-1-1/atmos/mon/\${var}/gn/v20180525/$f \ 50 input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-volc-1-1/atmos/mon/\${var}/gn/v20180525/$f") 54 input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-volc-1-1/atmos/mon/\${var}/gn/v20180525/$f \ 55 input4MIPs/CMIP6/DAMIP/CCCma/CCMI-ssp245-nat-1-0/atmos/mon/\${var}/gn/v20180820/$f") 51 56 CLIMS_IN=("/ / / / /" \ 52 "input4MIPs/CMIP6/CMIP/UReading/UReading-CCMI-1-0/atmos/monC/\${var}/gn/v20160830/$f / / / / ")57 "input4MIPs/CMIP6/CMIP/UReading/UReading-CCMI-1-0/atmos/monC/\${var}/gn/v20160830/$f / / / / /") 53 58 VARNAM_IN=('tosbcs siconcbcs' 'vmro3') 54 59 DIRSTRUCT='datasets/exercise/project/origin/dataset/domain/frequency/var/grid/version/' … … 79 84 date=(${DATADATES[$i]}); fin=($fin); if [ ${DOPROCESS[$i]} != 'y' ]; then continue; fi 80 85 echo ">> Chosen $dt:" 81 for ka in ${IXPROCESS[$i]}; do echo " * ${fin[$ka]%/*} (${date[$ka]%-*})"; done 86 for ka in ${IXPROCESS[$i]}; do d=${date[$ka]}; dy=${d%%-*}; d=${d#*-} 87 echo " * ${fin[$ka]%/*} (${dy}-${d%%-*})" 88 done 82 89 done 83 90 … … 87 94 if [ ${DOPROCESS[$i]} != 'y' ]; then continue; fi 88 95 dt=${DATATYPES[$i]} #=== SSTAndSeaIce, ozone... 89 fin=(${FILES_IN[$i]}); vin=(${VARNAM_IN[$i]}) #=== INPUT FILE/VAR NAMES (each version)96 fin=(${FILES_IN[$i]}); vin=(${VARNAM_IN[$i]}) #=== INPUT FILE/VAR NAMES (each version) 90 97 fou=${FILES_OU[$i]} ; vou=(${VARNAM_OU[$i]}) #=== OUTPUT FILE/VAR NAMES (single pair) 91 98 date=(${DATADATES[$i]}) #=== ${Yb}-${Ye}-${dY} … … 96 103 #================================================================================ 97 104 parse_dir ${fin[$is]} $DIRSTRUCT $ex #--- Parse input directory 98 dso=$dataset #--- For naming purpose 99 case $dt in #--- NAMING EXCEPTIONS 100 ozone) dso=${dso#*hist-}; dso=hist-${dso%%-*} 101 if [ "$dataset" = "UReading-CCMI-1-0" ]; then dso="historical"; fi ;; 102 SSTAndSeaIce) if [ "$dataset" = "PCMDI-AMIP-1-1-0" ]; then dso='AMIP'; fi ;; 103 esac 105 dso=$(remove_version $dataset); dso=${dso#*-} #--- For naming purpose 106 if [ $dso = "CCMI" ]; then dso="historical"; fi #--- NAMING EXCEPTION: UReading-CCMI-1-0 104 107 #============================================================================== 105 108 for iv in $(eval echo {0..$((${#vin[@]}-1))}); do #--- Loop on variables 106 109 #============================================================================== 107 da=${date[$is]}; Y b=${da%%-*}; Ye=${da#*-}; dY=${Ye##*-}; Ye=${Ye%-*}110 da=${date[$is]}; Yi=${da%%-*}; Yf=${da#*-}; dYt=${Yf#*-}; Yf=${Yf%%-*} 108 111 v_in=${vin[$iv]}; v_ou=${vou[$iv]} #--- Variables names 109 112 f_in=$(var=$v_in; Yb=\${Yb}; Ye=\${Ye}; datatype=$dt; eval echo $DATAIN/${fin[$is]}) 110 axis=$(get_grid $(Yb=$Y b; Ye=????; eval echo $f_in) $v_in)113 axis=$(get_grid $(Yb=$Yi; Ye=????; eval echo $f_in) $v_in) 111 114 res=${axis#*=}; axis=${axis%=*} 112 115 Zonal='n'; if [ $axis = 'XYZT' ]; then Zonal='y'; fi #--- Zonal mean ? For 3D files … … 115 118 res3D=${res%x*}; res2D=${res3D#*x}_zonal; f_ou=${f_ou%/*}/\${res}/${f_ou##*/} 116 119 fi 117 echo ">> BUILDING 12 MONTHS ${v_in} FILES FOR THE $Yb-$Ye PERIOD USING $dataset DATASET ($version)..." 120 echo ">> BUILDING 12 MONTHS ${v_in} FILES FOR THE $Yi-$Yf PERIOD USING $dataset DATASET ($version)..." 121 Ye=$((Yi-1)) 118 122 #============================================================================ 119 for Y in $(eval echo {$Y b..$Ye}); do #--- Loop on years123 for Y in $(eval echo {$Yi..$Yf}); do #--- Loop on years 120 124 #============================================================================ 121 125 fO=$(Y=$Y; res=${res3D}; eval echo ${f_ou}) #--- Original resolution 126 if [ $Y -eq $((Ye+1)) ]; then Yb=$Y; dY=${dYt%%-*}; Ye=$((Yb+dY-1)); dYt=${dYt#*-}; fi 122 127 if [[ ! -f $fO || $recomp = 'y' ]]; then 123 128 extract $v_in,$v_ou $f_in,$fO $Yb,$Ye,$dY $Y 0 #--- Field extraction … … 128 133 if [[ ! -f $fZ || $recomp = 'y' ]]; then zonal_mean $fO $fZ; fi 129 134 fi 130 progress_bar $((Y-Y b+1)) $((Ye-Yb+1)) 50 #--- Check progress135 progress_bar $((Y-Yi+1)) $((Yf-Yi+1)) 50 #--- Check progress 131 136 #============================================================================ 132 137 done … … 135 140 #============================================================================ 136 141 Yb=${per%%-*}; Ye=${per##*-}; Yc=${Yb}_${Ye}_clim; c='n'; cli0=${cli[$is]} 142 143 #=== Skip periods outside available years interval 144 if [[ $Yb -lt ${da%%-*} || ${Yb} -gt ${da#*-} || $Yb -lt ${da%%-*} || ${Yb} -gt ${da#*-} ]]; then 145 continue 146 fi 137 147 138 148 #=== Is there a single file climatology available ? -
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.