#!/usr/bin/env bash

module load conda/22.11.1-2
conda activate condaCerise
export LD_LIBRARY_PATH=/perm/cyce/conda/envs/condaCerise/lib

dir=/ec/res4/scratch/cyce/cerise/data/esarchive/recon/ecmwf/era5/1hourly/tasmin/
cd $dir
outdir=/ec/res4/scratch/cyce/cerise/data/esarchive/recon/ecmwf/era5/monthly_mean/tasmin_f24h/
mkdir -p $outdir
for f in *; do
  echo "$f"
  if [[ ! -f $outdir/$f ]]; then  
    cdo daymin "$f" $TMPDIR/$f
    cdo monmean $TMPDIR/$f $outdir/$f 
  fi
done

