cdo mergetime
Added by Amali, AMALI over 1 year ago
I am trying to merge multiple nc files using cdo mergetime
#!/bin/bash
# Get list of files in directory
files=$(ls /xxxxx/Input/trial/tas_Amon_UKESM1-0-LL_1pctCO2*.nc)
# Loop over realizations
for r in $(echo "$files" | sed -E 's/.*_r([0-9]+)i.*/\1/' | sort -u); do
# Get list of files for current realization
r_files=$(echo "$files" | grep "_r${r}i")
# Get smallest and largest timestamps
times=$(cdo showtimestamp $r_files | cut -d ' ' -f 1 | sort | uniq)
smallest=$(echo $times | cut -d ' ' -f 1)
largest=$(echo $times | cut -d ' ' -f $(echo $times | wc -w))
# Merge files for current realization
cdo mergetime $r_files /xxxxx/Input/trial/tas_Amon_UKESM1-0-LL_1pctCO2_r${r}i1p1f2_gn_${smallest}-${largest}.nc
done
But I still get the error "cdo command not found" when I run the script.
Any idea what could be wrong?
Replies (5)
RE: cdo mergetime - Added by Estanislao Gavilan over 1 year ago
Hi Amali,
try to change "mergetime" to "-mergetime"
Regards,
Estanislao
RE: cdo mergetime - Added by Karin Meier-Fleischer over 1 year ago
Hi Amali,
what do you get when you run the following command in a terminal?
which cdo
RE: cdo mergetime - Added by Amali, AMALI over 1 year ago
@Karin, I get
/usr/bin/which: no cdo in (/sw/spack-levante/texlive-live2021-l5o6sw/bin/x86_64-linux:/sw/spack-levante/texlive-live2021-l5o6sw/bin:/sw/spack-levante/git-lfs-2.11.0-oihcwo/bin:/sw/spack-levante/git-2.31.1-25ve7r/bin:/sw/spack-levante/jupyterhub/jupyterhub/bin:/sw/spack-workplace/spack/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
Which is surprising because I am running on levante.
RE: cdo mergetime - Added by Karin Meier-Fleischer over 1 year ago
Did you load one of the cdo modules?
- cdo/2.0.4-gcc-11.2.0
- cdo/2.0.5-gcc-11.2.0
- cdo/2.0.6-gcc-11.2.0
RE: cdo mergetime - Added by Amali, AMALI over 1 year ago
module load cdo/2.0.4-gcc-11.2.0 worked for me.
Thank you very much.