#Load function files
source("read_netcdf.r")
source("mon_mean_areaavg.r")

var_name <- 'tas'
lat_name <- 'latitude'
path <- '/esarchive/recon/ecmwf/erainterim/daily_mean/tas/'
file <- 'tas_201801.nc'

var <- read_netcdf(var_name, path, file)
lat <- read_netcdf(lat_name, path, file)

latmin <- 120
latmax <- 122 
lonmin <- 200
lonmax <- 201

monmean <- mon_mean_areaavg(var, lat, latmin, latmax, lonmin, lonmax)

message('Monthly mean over the region [',lonmin,':',lonmax,',',latmin,':',latmax,']: ',monmean)

