Spain sweated under its first official heatwave of the year with temperatures expected to reach 40 degrees Celcius (104 Fahrenheit) in a large swathe of the country on Thursday.