
library(ncdf4)

read_netcdf <- function(var_name, path, file) {
nc_data <- nc_open(paste0(path,file))

lon <- ncvar_get(nc_data, "longitude")
lat <- ncvar_get(nc_data, "latitude")
t <- ncvar_get(nc_data, "time")
var <- ncvar_get(nc_data, var_name)

message("dimension of variable:")
print(dim(var))

nc_close(nc_data)

return(var)
}
