source: TOOLS/AMIP/prepare_amip_original.sh @ 5011

Last change on this file since 5011 was 5011, checked in by jgipsl, 4 years ago

Corrected errors

File size: 2.8 KB
Line 
1#!/bin/bash
2set -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
9dirold=original/360x180.orig
10dirnew=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
17cd $dirold
18cdo splityear tosbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-6_gn_187001-201812.nc      amipbc_sst_360x180_
19cdo splityear siconcbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-6_gn_187001-201812.nc   amipbc_sic_360x180_
20
21
22# 2) Produce climatologie files
23ncea 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
24ncea 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
28mkdir -p $dirnew
29
30Date_Begin=1870
31Date_End=2018
32year=${Date_Begin}
33while [ ${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
52done
53
54# Do 3) and 4) also for the climatologie files
55filesic=amipbc_sic_360x180_1979_2008_clim.nc
56filesst=amipbc_sst_360x180_1979_2008_clim.nc
57
58echo "Rename variable sicbcs in file $dirold/$filesic "
59ncrename -v siconcbcs,sicbcs $dirold/${filesic} $dirnew/tmpsic.nc
60
61echo "Copy sst file to new folder $dirold/$filesst "
62cp $dirold/${filesst} $dirnew/tmpsst.nc
63
64echo "Change time axis"
65ncks -4 --no_rec_dmn time $dirnew/tmpsic.nc -o $dirnew/${filesic}
66ncks -4 --no_rec_dmn time $dirnew/tmpsst.nc -o $dirnew/${filesst}
67 
68rm -f $dirnew/tmpsic.nc $dirnew/tmpsst.nc
69
70
Note: See TracBrowser for help on using the repository browser.