#!/bin/bash


workdir=$(pwd)
ccadat="${workdir}/ccadat/"
echo  $ccadat

cat > myccadat << EOF

CCAdat   = "${ccadat}"
currentDir   = "${workdir}"

EOF


cat myccadat paramsAllSkill.ncl templateShapeFileNames.ncl templateObjectiveFcst.ncl > finalObjectiveFcst.ncl
LoadManager="LINUX"

if [[ $LoadManager == "SLURM" ]]; then

echo "working for $LoadManager"
module purge
module load contrib pyncl
ncl finalObjectiveFcst.ncl

elif [[ $LoadManager == "QSUB" ]]; then
  echo "$LoadManager"


elif [[ $LoadManager == "LINUX" ]]; then
  echo "$LoadManager"

#CONDA_BASE="/cpc/data/software/miniconda"
#source "$CONDA_BASE/bin/activate"
#conda activate rccaenv

# 1. Point explicitly to the micromamba binary in your home folder
export MAMBA_EXE="${HOME}/.local/bin/micromamba"
export MAMBA_ROOT_PREFIX="${HOME}/micromamba"

# 2. Generate the shell hook using the explicit binary path
eval "$($MAMBA_EXE shell hook --shell bash)"

# 3. Now activate will work flawlessly
micromamba activate cpc_rcca_env

ncl finalObjectiveFcst.ncl

fi

