1 | #!/bin/bash |
---|
2 | set -vx |
---|
3 | |
---|
4 | # Script that prepares the PCMDI-AMIP-1-1-6 files to be read by ce0l in LMDZ. |
---|
5 | # These new files are stored in IGCM/ATM/LIMIT/AMIP.v20191121/original |
---|
6 | # and can be used to produce limit.nc files on model grid. |
---|
7 | # Done by J. Ghattas, 2020/03/03 |
---|
8 | |
---|
9 | dirold=original/360x180.orig |
---|
10 | dirnew=original/360x180.new |
---|
11 | |
---|
12 | # 0) Copy original files from ciclad Input4MIPS and save in $dirold |
---|
13 | #/bdd/input4MIPs/CMIP6/CMIP/PCMDI/PCMDI-AMIP-1-1-6/ocean/mon/tosbcs/gn/v20191121/tosbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-6_gn_187001-201812.nc |
---|
14 | #/bdd/input4MIPs/CMIP6/CMIP/PCMDI/PCMDI-AMIP-1-1-6/seaIce/mon/siconcbcs/gn/v20191121/siconcbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-6_gn_187001-201812.nc |
---|
15 | |
---|
16 | # 1) Split files to yearly files |
---|
17 | cd $dirold |
---|
18 | cdo splityear tosbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-6_gn_187001-201812.nc amipbc_sst_360x180_ |
---|
19 | cdo splityear siconcbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-6_gn_187001-201812.nc amipbc_sic_360x180_ |
---|
20 | |
---|
21 | |
---|
22 | # 2) Produce climatologie files |
---|
23 | ncea amipbc_sst_360x180_1979.nc amipbc_sst_360x180_198* amipbc_sst_360x180_199* amipbc_sst_360x180_200[012345678]* amipbc_sst_360x180_1979_2008_clim.nc |
---|
24 | ncea amipbc_sic_360x180_1979.nc amipbc_sic_360x180_198* amipbc_sic_360x180_199* amipbc_sic_360x180_200[012345678]* amipbc_sic_360x180_1979_2008_clim.nc |
---|
25 | |
---|
26 | # 3) Rename variable name for sea-ice concentration into sicbcs |
---|
27 | # and 4) The time axis is set fixed instead of unlimited |
---|
28 | mkdir -p $dirnew |
---|
29 | |
---|
30 | Date_Begin=1870 |
---|
31 | Date_End=2018 |
---|
32 | year=${Date_Begin} |
---|
33 | while [ ${year} -le ${Date_End} ] ; do |
---|
34 | echo year = $year |
---|
35 | filesic=amipbc_sic_360x180_${year}.nc |
---|
36 | filesst=amipbc_sst_360x180_${year}.nc |
---|
37 | |
---|
38 | echo "Rename variable sicbcs in file $dirold/$filesic " |
---|
39 | ncrename -v siconcbcs,sicbcs $dirold/${filesic} $dirnew/tmpsic.nc |
---|
40 | echo "Copy sst file to new folder $dirold/$filesst " |
---|
41 | cp $dirold/${filesst} $dirnew/tmpsst.nc |
---|
42 | |
---|
43 | # The time axis is set fixed instead of unlimited and the files are transformend into netcdf-4 format. |
---|
44 | # This is done so that the files can be read by XIOS. |
---|
45 | echo "Change time axis" |
---|
46 | ncks -4 --no_rec_dmn time $dirnew/tmpsic.nc -o $dirnew/${filesic} |
---|
47 | ncks -4 --no_rec_dmn time $dirnew/tmpsst.nc -o $dirnew/${filesst} |
---|
48 | |
---|
49 | let year=${year}+1 |
---|
50 | echo "" |
---|
51 | rm -f $dirnew/tmpsic.nc $dirnew/tmpsst.nc |
---|
52 | done |
---|
53 | |
---|
54 | # Do 3) and 4) also for the climatologie files |
---|
55 | filesic=amipbc_sic_360x180_1979_2008_clim.nc |
---|
56 | filesst=amipbc_sst_360x180_1979_2008_clim.nc |
---|
57 | |
---|
58 | echo "Rename variable sicbcs in file $dirold/$filesic " |
---|
59 | ncrename -v siconcbcs,sicbcs $dirold/${filesic} $dirnew/tmpsic.nc |
---|
60 | |
---|
61 | echo "Copy sst file to new folder $dirold/$filesst " |
---|
62 | cp $dirold/${filesst} $dirnew/tmpsst.nc |
---|
63 | |
---|
64 | echo "Change time axis" |
---|
65 | ncks -4 --no_rec_dmn time $dirnew/tmpsic.nc -o $dirnew/${filesic} |
---|
66 | ncks -4 --no_rec_dmn time $dirnew/tmpsst.nc -o $dirnew/${filesst} |
---|
67 | |
---|
68 | rm -f $dirnew/tmpsic.nc $dirnew/tmpsst.nc |
---|
69 | |
---|
70 | |
---|