#!/bin/bash set -vx # Script that prepares the PCMDI-AMIP-1-1-6 files to be read by ce0l in LMDZ. # These new files are stored in IGCM/ATM/LIMIT/AMIP.v20191121/original # and can be used to produce limit.nc files on model grid. # Done by J. Ghattas, 2020/03/03 dirold=original/360x180.orig dirnew=original/360x180.new # 0) Copy original files from ciclad Input4MIPS and save in $dirold #/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 #/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 # 1) Split files to yearly files cd $dirold cdo splityear tosbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-6_gn_187001-201812.nc amipbc_sst_360x180_ cdo splityear siconcbcs_input4MIPs_SSTsAndSeaIce_CMIP_PCMDI-AMIP-1-1-6_gn_187001-201812.nc amipbc_sic_360x180_ # 2) Produce climatologie files 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 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 # 3) Rename variable name for sea-ice concentration into sicbcs # and 4) The time axis is set fixed instead of unlimited mkdir -p $dirnew Date_Begin=1870 Date_End=2018 year=${Date_Begin} while [ ${year} -le ${Date_End} ] ; do echo year = $year filesic=amipbc_sic_360x180_${year}.nc filesst=amipbc_sst_360x180_${year}.nc echo "Rename variable sicbcs in file $dirold/$filesic " ncrename -v siconcbcs,sicbcs $dirold/${filesic} $dirnew/tmpsic.nc echo "Copy sst file to new folder $dirold/$filesst " cp $dirold/${filesst} $dirnew/tmpsst.nc # The time axis is set fixed instead of unlimited and the files are transformend into netcdf-4 format. # This is done so that the files can be read by XIOS. echo "Change time axis" ncks -4 --no_rec_dmn time $dirnew/tmpsic.nc -o $dirnew/${filesic} ncks -4 --no_rec_dmn time $dirnew/tmpsst.nc -o $dirnew/${filesst} let year=${year}+1 echo "" rm -f $dirnew/tmpsic.nc $dirnew/tmpsst.nc done # Do 3) and 4) also for the climatologie files filesic=amipbc_sic_360x180_1979_2008_clim.nc filesst=amipbc_sst_360x180_1979_2008_clim.nc echo "Rename variable sicbcs in file $dirold/$filesic " ncrename -v siconcbcs,sicbcs $dirold/${filesic} $dirnew/tmpsic.nc echo "Copy sst file to new folder $dirold/$filesst " cp $dirold/${filesst} $dirnew/tmpsst.nc echo "Change time axis" ncks -4 --no_rec_dmn time $dirnew/tmpsic.nc -o $dirnew/${filesic} ncks -4 --no_rec_dmn time $dirnew/tmpsst.nc -o $dirnew/${filesst} rm -f $dirnew/tmpsic.nc $dirnew/tmpsst.nc