# Check of CMIP6 simulations =======================================================
#
# This script has to be run after 2 years of simulation and the results should be
# reported to Arnaud and Anne.
#
# May 2020
#
# Note: The variables SIMULATION CARD_FILES anbd LOGDIR has to be changed for each
#       simulation.


case $1 in

  piClim-control-v2)
    SIMULATION=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-control/LOI61-LR-AER-piclim-Control-v2/CMIP6
    CARD_FILES=/ccc/cont003/home/gencmip6/checagar/aerchemmip_IPSLCM6.1.11_LR_amd/modipsl/config/IPSLCM6/LOI61-LR-AER-piclim-Control-v2
    LOGDIR=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-control/LOI61-LR-AER-piclim-Control-v2/
    ;;

  piClim-control)
    SIMULATION=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-control/LOI61-LR-AER-piClim-control-vF/CMIP6
    CARD_FILES=/ccc/cont003/home/gencmip6/checagar/aerchemmip_IPSLCM6.1.11_LR_amd/modipsl/config/IPSLCM6/LOI61-LR-AER-piClim-control-vF
    LOGDIR=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-control/LOI61-LR-AER-piClim-control-vF/
    ;;

  piClim-aer)
    SIMULATION=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-aer/LOI61-LR-AER-piclim-AER-v2/CMIP6
    CARD_FILES=/ccc/cont003/home/gencmip6/checagar/aerchemmip_IPSLCM6.1.11_LR_amd/modipsl/config/IPSLCM6/LOI61-LR-AER-piclim-AER-v2
    LOGDIR=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-aer/LOI61-LR-AER-piclim-AER-v2/
    ;;

  piClim-2xdust)
    SIMULATION=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-2xdust/LOI61-LR-AER-piclim-2xDUST-v2/CMIP6
    CARD_FILES=/ccc/cont003/home/gencmip6/checagar/aerchemmip_IPSLCM6.1.11_LR_amd/modipsl/config/IPSLCM6/LOI61-LR-AER-piclim-2xDUST-v2
    LOGDIR=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-2xdust/LOI61-LR-AER-piclim-2xDUST-v2/
    ;;

  piClim-2xss)
    SIMULATION=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-2xss/LOI61-LR-AER-piclim-2xSS-v2/CMIP6
    CARD_FILES=/ccc/cont003/home/gencmip6/checagar/aerchemmip_IPSLCM6.1.11_LR_amd/modipsl/config/IPSLCM6/LOI61-LR-AER-piclim-2xSS-v2
    LOGDIR=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-2xss/LOI61-LR-AER-piclim-2xSS-v2/
    ;;

  piClim-BC)
    SIMULATION=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-BC/LOI61-LR-AER-piClim-BC-vF/CMIP6
    CARD_FILES=/ccc/cont003/home/gencmip6/checagar/aerchemmip_IPSLCM6.1.11_LR_amd/modipsl/config/IPSLCM6/LOI61-LR-AER-piClim-BC-vF
    LOGDIR=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-BC/LOI61-LR-AER-piClim-BC-vF/
    ;;

  piClim-OC)
    SIMULATION=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-OC/LOI61-LR-AER-piClim-OC-vF/CMIP6
    CARD_FILES=/ccc/cont003/home/gencmip6/checagar/aerchemmip_IPSLCM6.1.11_LR_amd/modipsl/config/IPSLCM6/LOI61-LR-AER-piClim-OC-vF
    LOGDIR=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-OC/LOI61-LR-AER-piClim-OC-vF/
    ;;

  piClim-NH3)
    SIMULATION=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-NH3/LOI61-LR-AER-piClim-NH3-vF/CMIP6
    CARD_FILES=/ccc/cont003/home/gencmip6/checagar/aerchemmip_IPSLCM6.1.11_LR_amd/modipsl/config/IPSLCM6/LOI61-LR-AER-piClim-NH3-vF
    LOGDIR=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-NH3/LOI61-LR-AER-piClim-NH3-vF/
    ;;

  piClim-SO2)
    SIMULATION=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-SO2/LOI61-LR-AER-piClim-SO2-vF/CMIP6
    CARD_FILES=/ccc/cont003/home/gencmip6/checagar/aerchemmip_IPSLCM6.1.11_LR_amd/modipsl/config/IPSLCM6/LOI61-LR-AER-piClim-SO2-vF
    LOGDIR=/ccc/work/cont003/gencmip6/checagar/IGCM_OUT/IPSLCM6/PROD/piClim-SO2/LOI61-LR-AER-piClim-SO2-vF/
    ;;



esac

setfacl -Rm u:levavasg:rwX $SIMULATION
setfacl -Rdm u:levavasg:rwX $SIMULATION

module load datadir/gencmip6
export PATH=$GENCMIP6_ALL_CCCWORKDIR/miniconda/bin:$PATH
source activate cmip6


XIOFileChecker $SIMULATION --card $CARD_FILES -l $LOGDIR

nctxck $SIMULATION --card $CARD_FILES --set-inc Esubhr:subhrPt=15m --exclude-file ".*_Odec_.*" --exclude-file ".*-clim\.nc" --ignore-errors 002 -l $LOGDIR

nctcck $SIMULATION --card $CARD_FILES -l $LOGDIR

