mkdir -p ../archives/reanalysis
echo
echo ----DOWNLOADING REANALYSIS PRODUCT SAMPLES----
echo
for f in *reanalysis*.py;do
    if [[ $f != *"uerra"*"experimental"* ]];then
        echo
        echo RUNNING $f
        echo > ../archives/LOG_down_"${f%.py}.txt"
        echo "Running $f" >> ../archives/LOG_down_"${f%.py}.txt"
        echo >> ../archives/LOG_down_"${f%.py}.txt"
        nohup python $f &>> ../archives/LOG_down_"${f%.py}.txt" &
        echo
    else
        echo > ../archives/LOG_down_"${f%.py}.txt"
        echo "******************************************************************************************">> ../archives/LOG_down_"${f%.py}.txt"
        echo >> ../archives/LOG_down_"${f%.py}.txt"
        echo "Script $f" >> ../archives/LOG_down_"${f%.py}.txt"
        echo >> ../archives/LOG_down_"${f%.py}.txt"
        echo "This kind of experimental option was defined as the ECMWF as not valid because it crashes" >> ../archives/LOG_down_"${f%.py}.txt"
        echo "when trying to convert from GRIB to NETCDF format due to its LCC projection" >> ../archives/LOG_down_"${f%.py}.txt"
        echo >> ../archives/LOG_down_"${f%.py}.txt"
        cat $f >> ../archives/LOG_down_"${f%.py}.txt"
        echo >> ../archives/LOG_down_"${f%.py}.txt"
        echo "Anyway, we will try to download it just to check the issue" >> ../archives/LOG_down_"${f%.py}.txt"
        echo >> ../archives/LOG_down_"${f%.py}.txt"
        nohup python $f &>> ../archives/LOG_down_"${f%.py}.txt" &
        echo >> ../archives/LOG_down_"${f%.py}.txt"
        echo "******************************************************************************************">> ../archives/LOG_down_"${f%.py}.txt"
        echo >> ../archives/LOG_down_"${f%.py}.txt"
    fi
done
