At a guess:
before the "endDef",
varid2 = netcdf.defVar(ncid, 'lat', NC_DOUBLE, dimid(2));
varid3 = netcdf.defVar(ncid, 'long', NC_DOUBLE, dimid(3));
Then after the putVar you have now, but before the close.
netcdf.putVar(ncid,varid2,lat);
netcdf.putVar(ncid,varid3,lon);
Best Answer