/*needs to have all worldclim variablesplaced in root folder (prec5, prec6, etc) /*and all tiles.out files /*resulting structure: /*result----|----prec5 (grd01, grd02) /* |----prec6 (grd01, grd02) /* |----precN (grd01, grd02) &s count := [filelist *.out outfile -file] &if %count% <= 0 &then &return Error generating output file. &s unit := [open outfile ok -read] &s count2 := [filelist * variablelst -GRID] &if %count2% <= 0 &then &return Error generating output file. &s unit2 := [open variablelst ok -read] cw result &type do variable count &do j := 1 &to %count2% &do &s infile2 := [read %unit2% ok] &if [exists %infile2% -GRID] &then &do CW result\%infile2% GRID &do i := 1 &to %count% &do &type Begin processing of tile %i% out of %count% for variable %infile2% &s infile := [read %unit% ok] &type %infile% &if [exists %infile% -FILE] &then &do &s sb := [substr %infile% 1 2] &type creating grd%sb% &s output = grd%sb% &type Selecting from grid based on %infile% %output% = selectpolygon (%infile2%, %infile%, inside) &describe %output% &sv mean = %grd$mean% &if %mean% = 0 &then &do &type ----------------WARNING %output% VAT is EMPTY ------------ copy %output% result\%infile2%\%output% kill %output% &end &else &do &type %output% is OK - copying... copy %output% result\%infile2%\%output% kill %output% &end &type Done &end &end &end &s ok := [close %unit%] &s unit := [open outfile ok -read] kill %infile2% Q &end &end &end &s ok := [close %unit%] &s ok := [delete outfile -file] &s ok := [close %unit2%] &s ok := [delete variablelst -file] &return