Nadal survives scare in Doha