# The script links the bathymetries from the Earth Science department repository to the bathymetries folder.
set -xuve

# WARNING! dirty workaround
[ -d /gpfs/projects/bsc32/models/ ] && REPOSITORY_PATH=/gpfs/projects/bsc32/models/
[ -d /project/spesiccf/shared/models ] && REPOSITORY_PATH=/project/spesiccf/shared/models


NEMO_REPOSITORY_PATH=$REPOSITORY_PATH/nemo/v3.6/inidata/nemo/

if [[ ! -d bathymetries ]];then
    mkdir -p bathymetries
fi

# Linking NEMO resolutions
for res in ORCA2 ORCA1 ORCA025 ORCA12 ; do
 [ -f ${NEMO_REPOSITORY_PATH}/${res}L[0-9][0-9]/bathy_meter.nc ] && ln -sf ${NEMO_REPOSITORY_PATH}/${res}L[0-9][0-9]/bathy_meter.nc bathymetries/nemo_bathy_meter_$res.nc || echo "${NEMO_REPOSITORY_PATH}/${res}L[0-9][0-9]/bathy_meter.nc not found"
done


# Linking ECE resolutions
ECE_REPOSITORY_PATH=$REPOSITORY_PATH/ecearth/v3.2.2/inidata/nemo/initial/
for res in ORCA1 ORCA025; do
 [ -f ${ECE_REPOSITORY_PATH}/${res}L[0-9][0-9]/bathy_meter.nc ] && ln -sf ${ECE_REPOSITORY_PATH}/${res}L[0-9][0-9]/bathy_meter.nc bathymetries/ece_bathy_meter_$res.nc || echo "${ECE_REPOSITORY_PATH}/${res}L[0-9][0-9]/bathy_meter.nc not found"
done

set +xuve
