#!/usr/bin/env bash
set -euo pipefail

echo "Checking folders where T2MAX exists but no xsmtg/axsmtg/AXWLIQ exists..."
echo

find . -type f -name "*T2MAX_daily.nc" | sort | while read -r t2file; do
    dir=$(dirname "$t2file")

    # Check whether this folder has any acceptable soil file
    if ! find "$dir" -maxdepth 1 -type f \( \
        -name "*xsmtg_daily.nc" -o \
        -name "*axsmtg_daily.nc" -o \
        -name "*AXWLIQ_daily.nc" \
    \) | grep -q .; then
        echo "$dir"
    fi
done | sort -u
