  library(easyNCDF)

  #Read a NetCDF file in esarchive with easyNCDF::NcToArray. Play a bit with all the function parameters.

  path <- '/esarchive/exp/ecearth/i00k/monthly_mean/prc_f3h/prc_Amon_EC-EARTH_decadal_S19771101_r5i1p1_198611-198702.nc'

  fnc <- NcOpen(path)
  fnc_dims <- NcReadDims(fnc)
  var_names <- NcReadVarNames(fnc)
  fnc_arr <- NcToArray(fnc, vars_to_read = var_names)
  a <- NcToArray(fnc, dim_indices = list(var = c(1, 2, 3)))
  b <- NcToArray(fnc, dim_indices = list(var = list(c(1, 2), c('prc'))), vars_to_read = var_names)
  b2 <- NcToArray(fnc, dim_indices = list(var = list(c(1, 2), c('prc'))), unlist = TRUE)
  c <- NcToArray(fnc, vars_to_read = var_names[2])
  c2 <- NcToArray(fnc, vars_to_read = var_names[2], drop_var_dim = TRUE)
  d <- NcToArray(fnc, dim_indices = list(var = c('time', 'lat')), 
                 vars_to_read = var_names[2], expect_all_indices = TRUE)


  NcClose(fnc)

  #Create a multidimensional array with unnamed dimensions and save it into a NetCDF file 
  #using easyNCDF::ArrayToNc (none of the dimensions should be called 'time' or 'var').
  #Check the structure of the file with ncdump -h.
  arr1 <- array(1:100, dim = c(10,2,5))
  ArrayToNc(arr1, 'arr1.nc')

  #Assign names to the dimensions of your array and save it again. Check it with ncdump.
  arr1a <- array(1:100, dim = c(height = 10, lat = 2, lon = 5))
  ArrayToNc(arr1a, 'arr1a.nc')

  #Create another sample array with no coinciding dimensions and save both into a NetCDF 
  #with a single ArrayToNc call. Check it with ncdump.
  arr2 <- array(1:12, dim = c(depth = 4, dim_a = 3))
  ArrayToNc(list(arr1a, arr2), 'arr2.nc')

  #Add a dimension 'var' of length > 1 to one of your arrays, and save it to a NetCDF file. 
  #Check it with ncdump.
  arr2a <- array(1 : (100 * 12 * 2), dim = c(dim(arr1a), dim(arr2), var = 2))
  ArrayToNc(arr2a, 'arr2a.nc')

  #Create a third array, which has one or more dimensions with matching dimension names 
  #in the first array. Save the new array together with the first one into a NetCDF file. 
  #Check it with ncdump.
  arr3 <- array(1:10, dim = c(height = 10))
  ArrayToNc(list(arr1a, arr3), 'arr3.nc')

  #Add a 'time' dimension to the first position of the second array and save it into a 
  #NetCDF file. Put the 'time' dimension in the last position of the array and save it 
  #into a NetCDF file. One of them should crash.
  arr2b <- array(1 : (30 * 100 * 12 * 2), dim = c(time = 30, dim(arr2a)))
  ArrayToNc(arr2b, 'arr2b.nc')

  arr2c <- array(1 : (100 * 12 * 2 * 30), dim = c(dim(arr2a), time = 30))
  ArrayToNc(arr2c, 'arr2c.nc')

  #Try to save one of your arrays in a NetCDF file where the variable created has the 
  #attributes 'hello = 2' and 'bye = "three"'. Check the examples in ?ArrayToNc to 
  #discover how that is done.
  metadata <- list(
                var1 = list(hello = 2, bye = 'three'),
                var2 = list(bye = 'three')
              )
  arr2d <- arr2c
  attr(arr2d, 'variables') <- metadata
  ArrayToNc(arr2d, 'arr2d.nc')

  #Try to save one of your arrays in a NetCDF file with a global attribute 'global = "i am global"'.
  metadata <- list(
                var1 = list(hello = 2, bye = 'three'),
                var2 = list(bye = 'three')
               )
  metadata2 <- list(
                global = 'i am global'
               )  
  arr2e <- arr2c
  attr(arr2e, 'variables') <- metadata
  attr(arr2e, 'global_attrs') <- metadata2

  ArrayToNc(arr2e, 'arr2e.nc')



#create unlimited dim manually
  a <- array(1:400, dim = c(lat = 5, lon = 10, unlimited = 4, var = 2))
  metadata <- list(tos = list(addOffset = 100, scaleFact = 10, 
                              dim = list(list(name = 'unlimited', unlim = TRUE))), 
                   tas = list(addOffset = 100, scaleFact = 10, 
                              dim = list(list(name ='unlimited', unlim = TRUE)))
                  )
  attr(a, 'variables') <- metadata
  ArrayToNc(a, 'tmp.nc')

#make it limited
  metadata <- list(tos = list(addOffset = 100, scaleFact = 10,
                              dim = list(list(name = 'unlimited', unlim = FALSE))),
                   tas = list(addOffset = 100, scaleFact = 10, 
                              dim = list(list(name = 'unlimited', unlim = FALSE)))
                  )
  attr(a, 'variables') <- metadata
  ArrayToNc(a, 'tmp.nc')

