Changeset 6072 for trunk/TOOLS
- Timestamp:
- 2019-06-27T16:33:04+02:00 (5 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/TOOLS/NUDGING_FILE/Job_moistc_runningmedian.sh
r6029 r6072 1 #MSUB -r moistc r12 #MSUB -o moistc .out_%I3 #MSUB -e moistc .out_%I1 #MSUB -r moistc_rmssp126 2 #MSUB -o moistc_rmssp126.out_%I 3 #MSUB -e moistc_rmssp126.out_%I 4 4 #MSUB -n 1 5 5 #MSUB -T 36000 … … 10 10 #MSUB -m store,work,scratch 11 11 ##MSUB -A ls3cmip6 12 set +vx 12 set -vx 13 #!/bin/bash 13 14 14 # Script to create nudging file for soil moisture. 15 # This creates a climatology of the soil moisture over 1980-2014 with daily frequency. 15 # Script to create nudging files for soil moisture climatology derived from 30 year running mean 16 # This creates running mean climatology of the soil moisture with daily frequency, starting with 17 # the historical siumlation and then using one scenario. 16 18 # 17 # 1. Daily output for the years 1980-2014 from the simulation CM61-LR-hist-03.1910 are used. 19 # 1. Daily output for the years 1980-2014 from the simulation CM61-LR-hist-03.1910 and for the years 20 # 2015-210O from sceanario simulation CM61-LR-scen-ssp126 or CM61-LR-scen-585 are used 18 21 # 2. The variable moistc is first splitted into moistc_1, moistc_2, moistc_3 to remove the axes on soiltiles. 19 22 # 3. For years with 366 days, the 31 of decembre is removed to enable making the median over all years. 20 # 4. The median is calculated over the whole period 1980-2014 to obtain one year climatologie file with daily frequency. 21 # 5. The last day is duplicated to have 366 days in the file. 23 # 4. For each year in the intervall 1994-2085, the median is calculated using 30years in total with the current year in the middle. 24 # For the first 15 years 1980-1995: the median for the first 30years will be used => running median for year 1994 25 # For the last 15 years 2085-2100: the median for the last 30years will be used => running meadian for year 2085 26 # 5. For each year, the last day is duplicated to have 366 days in each file. 22 27 # 23 28 # $HeadURL$ … … 27 32 date 28 33 JobName=CM61-LR-hist-03.1910 29 mkdir run_moistc_${JobName} 30 cd run_moistc_${JobName} 34 ssp=ssp126 35 #ssp=ssp585 36 JobNameScen=CM61-LR-scen-${ssp} 37 mkdir run_moistc_rm_${JobName}_${JobNameScen} 38 cd run_moistc_rm_${JobName}_${JobNameScen} 31 39 32 40 echo Start 33 41 # 1. historical r1: CM61-LR-hist-03.1910 34 simulpath=/ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM6/PROD/historical/CM61-LR-hist-03.1910/SRF/Output/DA 35 allpack=" 19800101_19891231 19900101_19991231 20000101_20091231 20100101_20141231 " 42 simulpathHist=/ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM6/PROD/historical/CM61-LR-hist-03.1910/SRF/Output/DA 43 simulpathScen=/ccc/store/cont003/gencmip6/oboucher/IGCM_OUT/IPSLCM6/PROD/${ssp}/${JobNameScen}/SRF/Output/DA 44 45 allpackHist=" 19800101_19891231 19900101_19991231 20000101_20091231 20100101_20141231 " 46 allpackScen=" 20150101_20241231 20250101_20341231 20350101_20441231 20450101_20541231 20550101_20641231 20650101_20741231 20750101_20841231 20850101_20941231 20950101_21001231 " 36 47 37 48 # 2. Extract moistc 38 echo Extract variable moistc from pack files 49 # First from historical simulation and then also from scenario simulation 50 echo Extract variable moistc from packed files 39 51 # float moistc(time_counter, soiltyp, solay, lat, lon) 40 52 41 for pack in ${allpack } ; do42 echo Treat file ${simulpath }/${JobName}_${pack}_DA_sechiba_out_2.nc43 ncks -v moistc ${simulpath }/${JobName}_${pack}_DA_sechiba_out_2.nc moistc_${pack}_DA_sechiba_out_2.nc53 for pack in ${allpackHist} ; do 54 echo Treat file ${simulpathHist}/${JobName}_${pack}_DA_sechiba_out_2.nc 55 ncks -v moistc ${simulpathHist}/${JobName}_${pack}_DA_sechiba_out_2.nc moistc_${pack}_DA_sechiba_out_2.nc 44 56 done 45 57 46 echo Separate into variables per soiltile 47 for pack in ${allpack} ; do 58 for pack in ${allpackScen} ; do 59 echo Treat file ${simulpathScen}/${JobNameScen}_${pack}_DA_sechiba_out_2.nc 60 ncks -v moistc ${simulpathScen}/${JobNameScen}_${pack}_DA_sechiba_out_2.nc moistc_${pack}_DA_sechiba_out_2.nc 61 done 62 63 64 echo Separate into variables per soiltile, for historical and scenario 65 for pack in ${allpackHist} ${allpackScen} ; do 48 66 ncks -d soiltyp,0,0 moistc_${pack}_DA_sechiba_out_2.nc moistc1_${pack}_DA_sechiba_out_2.nc 49 67 ncks -d soiltyp,1,1 moistc_${pack}_DA_sechiba_out_2.nc moistc2_${pack}_DA_sechiba_out_2.nc … … 55 73 done 56 74 57 echo Remove dimension soiltyp (which is now 1) by averaging over the dimension. Put all variables in the same file. 58 for pack in ${allpack} ; do 75 76 echo "Remove dimension soiltyp (which is now 1) by averaging over the dimension. Put all variables in the same file." 77 78 for pack in ${allpackHist} ${allpackScen} ; do 59 79 for soiltyp in 1 2 3 ; do 60 80 ncwa -A -a soiltyp moistc${soiltyp}_${pack}_DA_sechiba_out_2.nc moistc_allsoil_${pack}_DA_sechiba_out_2.nc … … 66 86 67 87 echo Separate per year 68 for pack in ${allpack } ; do88 for pack in ${allpackHist} ${allpackScen} ; do 69 89 cdo splityear moistc_allsoil_${pack}_DA_sechiba_out_2.nc moistc_ 70 90 done 71 91 72 92 # 3. Remove one time step in leap years 73 echo Remove last time step 31 of decemberfrom leap years93 echo Remove last time step (31 of december) from leap years 74 94 allleap=" 1980 1984 1988 1992 1996 2000 2004 2008 2012 " 75 for year in $allleap ; do 95 allleapScen=" 2016 2020 2024 2028 2032 2036 2040 2044 2048 2052 2056 2060 2064 2068 2072 2076 2080 2084 2088 2092 2096 " 96 for year in $allleap ${allleapScen} ; do 76 97 mv moistc_${year}.nc moistc_${year}.leap.nc 77 98 ncks -d time_counter,0,364 moistc_${year}.leap.nc moistc_${year}.365.nc … … 79 100 done 80 101 81 # 4. Calculate the median102 # 4. Calculate running median over 30 years 82 103 echo Calculate median 83 cdo enspctl,50 moistc_????.nc moistc_clim_1980_2014.nc84 104 85 # 5. Duplicate last day to make a file with 366days 86 echo Duplicate last day to make a file with 366days 87 # Extract last day 88 cdo seltimestep,365 moistc_clim_1980_2014.nc moistc_clim_365.nc 89 # Switch time axis one day ahead 90 ncatted -O -a units,time_counter,m,c,"seconds since 1850-01-02 00:00:00" moistc_clim_365.nc 91 # Merge with clim file 92 ncrcat moistc_clim_1980_2014.nc moistc_clim_365.nc moistc_clim_1980_2014_366d.nc 105 # For the first 15 years 1980-1995: take median for the first 30years => running median for year 1994 106 # For the last 15 years 2085-2100: take median for the last 30years => running meadian for year 2085 107 # For the years in between, take the median using 14 years before, the current year and 15 years after 108 109 # Calculate here the running median for the years 1994-2085 110 year=1994 111 lastyear=2085 112 while [ ${year} -le ${lastyear} ] ; do 113 echo year=${year} 114 # Determine the list of files for 14 years before, the current year and 15 years after current year 115 y1=$(( ${year} - 15 )) 116 y2=$(( ${year} + 15 )) 117 filelist="" 118 while [ ${y1} -le ${y2} ] ; do 119 filelist="$filelist moistc_${y1}.nc " 120 let y1=${y1}+1 121 done 122 echo for year=$year filelist= $filelist 123 124 echo "Calculate median for year=$year using files: $filelist " 125 cdo enspctl,50 $filelist moistc_30yrm_${year}.nc 126 127 128 # 5. Duplicate last day to make a file with 366days 129 echo Duplicate last day to make a file with 366days 130 # Extract last day 131 cdo seltimestep,365 moistc_30yrm_${year}.nc moistc_clim_365.nc 132 # Switch time axis one day ahead 133 ncatted -O -a units,time_counter,m,c,"seconds since 1850-01-02 00:00:00" moistc_clim_365.nc 134 # Merge with clim file 135 ncrcat moistc_30yrm_${year}.nc moistc_clim_365.nc moistc_30yrm_${year}.nc 136 137 let year=${year}+1 138 done 139 93 140 94 141 echo End
Note: See TracChangeset
for help on using the changeset viewer.