#!/bin/bash
#CK:27/10/2021
#Some functions using nco/cdo


###CDO
#Extract selected months in a year file
set -x
for i in `seq 1 12` ; do 
ii=$i
 if [ $i -lt 10 ] ; then 
  ii=0$i
 fi

cdo -selmon,$i MAR.2017.nc MARmonth.2017.$ii.nc #selmon,1 select mon number one, ...

done

exit

####NCO

#Concat monthly files into one file

ncrcat MARmonth.2017.*.nc MAR.2017.nc2

#Extract temperature variable (TT in the files)
ncks -v TT MAR.2017.nc MAR.2017.TT.nc

#### NCO
#Compute Mean monthly temperature
cdo -monave MAR.2017.TT.nc monthave.TT.2017.nc

#Extract SF + compute annual sum
cdo -selvar,SF -yearsum MAR.2017.nc SF.2017.nc

#And a lot of more operations on https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf
