R script for LPJ model