cd /ROOT/
for m in rf;do 
  for i in F;do
	  for y2 in `seq 1987 1987`;do
  	  for y1 in `seq 850 20 1850`;do
  	    for conf in 0;do
      		cp /ROOT/params.txt /ROOT/params_005_${m}_${i}_${y1}_${conf}.txt
      		cp /ROOT/run.sh /ROOT/run_005_${m}_${i}_${y1}_${conf}.sh
      
      		sed 's/name_reconstruction=/name_reconstruction=AMV1900_nest_005_'$m'_'$i'_'$y1'_'$conf'_hadisst/g' params_005_${m}_${i}_${y1}_${conf}.txt > tmp
      		sed 's/path_mode=/path_mode=\/home\/smichel\/p2\/AMV_instru_005.csv/g' tmp > tmp2
      		sed 's/y_start=/y_start='$y1'/g' tmp2 > tmp3
      		sed 's/y_stop=/y_stop='$y2'/g' tmp3 > tmp4
      		sed 's/method=/method='$m'/g' tmp4 > tmp5
      		sed 's/conf=/conf=0.'$conf'/g' tmp5 > tmp6
      		sed 's/reg_px=/reg_px=T'$ce'/g' tmp6 > tmp7
      		sed 's/path_database=\/home\/smichel\/p2\/files\/all_proxies3.csv/path_database=\/home\/smichel\/p2\/mat_PPE_005.csv/g' tmp7 > tmp8

      		mv tmp8 params_005_${m}_${i}_${y1}_${conf}.txt
      		rm tmp*
      
      		sed 's/params.txt/params_005_'$m'_'$i'_'$y1'_'$conf'.txt/g' run_005_${m}_${i}_${y1}_${conf}.sh > tmp
      		sed 's/_amv.r/_amv_005.r/g' tmp > tmp2
		mv tmp2 run_005_${m}_${i}_${y1}_${conf}.sh
		rm tmp

                chmod +x run_005_${m}_${i}_${y1}_${conf}.sh
       	        
		cp go_run.sh go_run_005_${m}_${i}_${y1}_${conf}.sh
		sed 's/run/run_005_'${m}'_'${i}'_'${y1}'_'${conf}'/g' go_run_005_${m}_${i}_${y1}_${conf}.sh > tmp
		sed 's/_amv.r/_amv_005.r/g' tmp > tmp2

		mv tmp2 go_run_005_${m}_${i}_${y1}_${conf}.sh
		rm tmp

		chmod +x go_run_005_${m}_${i}_${y1}_${conf}.sh
		sbatch ./go_run_005_${m}_${i}_${y1}_${conf}.sh
  	    done
  	  done
      done
  done
done
