source: trunk/TOOLS/NUDGING_FILE/Job_moistc_histr1.sh @ 6024

Last change on this file since 6024 was 6024, checked in by josefine.ghattas, 5 years ago

Add script to create soil moisture nudging file to be used for LS3MIP (CMIP6).

  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision HeadURL
File size: 3.8 KB
Line 
1#MSUB -r moistcr1
2#MSUB -o moistc.out_%I
3#MSUB -e moistc.out_%I
4#MSUB -n 1
5#MSUB -T 36000
6#MSUB -q xlarge
7#MSUB -c 8
8#MSUB -Q normal
9#MSUB -A gen0239
10#MSUB -m store,work,scratch
11##MSUB -A ls3cmip6
12set +vx
13
14# Script to create nudging file for soil moisture.
15# This creates a climatology of the soil moisture over 1980-2014 with daily frequency.
16#
17# 1. Daily output for the years 1980-2014 from the simulation CM61-LR-hist-03.1910 are used.
18# 2. The variable moistc is first splitted into moistc_1, moistc_2, moistc_3 to remove the axes on soiltiles.
19# 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.
22#
23# $HeadURL$
24# $Date$
25# $Revision$
26#######################################################################################################################
27date
28JobName=CM61-LR-hist-03.1910
29mkdir run_moistc_${JobName}
30cd run_moistc_${JobName}
31
32echo Start
33# 1. historical r1: CM61-LR-hist-03.1910
34simulpath=/ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM6/PROD/historical/CM61-LR-hist-03.1910/SRF/Output/DA
35allpack=" 19800101_19891231 19900101_19991231 20000101_20091231 20100101_20141231 "
36
37# 2. Extract moistc
38echo Extract variable moistc from pack files
39# float moistc(time_counter, soiltyp, solay, lat, lon)
40
41for pack in ${allpack} ; do
42  echo Treat file ${simulpath}/${JobName}_${pack}_DA_sechiba_out_2.nc
43  ncks -v moistc ${simulpath}/${JobName}_${pack}_DA_sechiba_out_2.nc moistc_${pack}_DA_sechiba_out_2.nc
44done
45
46echo Separate into variables per soiltile
47for pack in ${allpack} ; do
48  ncks -d soiltyp,0,0 moistc_${pack}_DA_sechiba_out_2.nc moistc1_${pack}_DA_sechiba_out_2.nc
49  ncks -d soiltyp,1,1 moistc_${pack}_DA_sechiba_out_2.nc moistc2_${pack}_DA_sechiba_out_2.nc
50  ncks -d soiltyp,2,2 moistc_${pack}_DA_sechiba_out_2.nc moistc3_${pack}_DA_sechiba_out_2.nc
51
52  ncrename -v moistc,moistc_1 moistc1_${pack}_DA_sechiba_out_2.nc
53  ncrename -v moistc,moistc_2 moistc2_${pack}_DA_sechiba_out_2.nc
54  ncrename -v moistc,moistc_3 moistc3_${pack}_DA_sechiba_out_2.nc
55done
56
57echo Remove dimension soiltyp (which is now 1) by averaging over the dimension. Put all variables in the same file.
58for pack in ${allpack} ; do
59  for soiltyp in 1 2 3 ; do
60    ncwa -A -a soiltyp  moistc${soiltyp}_${pack}_DA_sechiba_out_2.nc moistc_allsoil_${pack}_DA_sechiba_out_2.nc
61  done
62  ncatted -a long_name,moistc_1,m,c,"Soil Moisture profile for soil tile 1" moistc_allsoil_${pack}_DA_sechiba_out_2.nc
63  ncatted -a long_name,moistc_2,m,c,"Soil Moisture profile for soil tile 2" moistc_allsoil_${pack}_DA_sechiba_out_2.nc
64  ncatted -a long_name,moistc_3,m,c,"Soil Moisture profile for soil tile 3" moistc_allsoil_${pack}_DA_sechiba_out_2.nc
65done
66
67echo Separate per year
68for pack in ${allpack} ; do
69  cdo splityear moistc_allsoil_${pack}_DA_sechiba_out_2.nc moistc_
70done
71
72# 3. Remove one time step in leap years
73echo Remove last time step 31 of december from leap years
74allleap=" 1980 1984 1988 1992 1996 2000 2004 2008 2012 "
75for year in $allleap ; do
76  mv moistc_${year}.nc moistc_${year}.leap.nc
77  ncks -d time_counter,0,364 moistc_${year}.leap.nc moistc_${year}.365.nc
78  cp moistc_${year}.365.nc moistc_${year}.nc
79done
80
81# 4. Calculate the median
82echo Calculate median
83cdo enspctl,50 moistc_????.nc moistc_clim_1980_2014.nc
84
85# 5. Duplicate last day to make a file with 366days
86echo Duplicate last day to make a file with 366days
87# Extract last day
88cdo seltimestep,365 moistc_clim_1980_2014.nc moistc_clim_365.nc
89# Switch time axis one day ahead
90ncatted -O -a units,time_counter,m,c,"seconds since 1850-01-02 00:00:00"  moistc_clim_365.nc
91# Merge with clim file
92ncrcat moistc_clim_1980_2014.nc moistc_clim_365.nc moistc_clim_1980_2014_366d.nc
93
94echo End
95
Note: See TracBrowser for help on using the repository browser.