# load conda environment

eval "$(conda shell.bash hook)"

if ! { conda config --show-sources | grep '/gpfs/projects/bsc32/repository/apps/conda_envs/'; } >/dev/null 2>&1; then
        conda config --append envs_dirs /gpfs/projects/bsc32/repository/apps/conda_envs/
fi

if { conda env list | grep 'ghost-env_v1.6.0'; } >/dev/null 2>&1; then 
    echo "Activating environment in /gpfs/projects/bsc32/repository/apps/conda_envs/ghost-env_v1.6.0..."
    conda activate ghost-env_v1.6.0
else
    # create environment if it does not exist
    echo "Environment ghost-env_v1.6.0 does not exist."; 
    echo "Creating environment..."
    conda create -p /gpfs/projects/bsc32/repository/apps/conda_envs/ghost-env_v1.6.0 -y python=3.11.5 -c conda-forge --override-channels
    #conda create -n ghost-env -y python=3.9.16
    conda activate ghost-env_v1.6.0
    conda install -c conda-forge cartopy -y --override-channels
    pip install -r requirements.txt
fi