Remove globals from write_netcdf