 
 
     } //end timestepping
+    err = nc_close(ncid);
     err = nc_close(ncid_out);
 
     return 0;

        err = nc_put_att_text( ncid_out, id0d[name], "long_name", long_name.size(),
            long_name.data());
    }
    //steps = 3;
    for( unsigned i=0; i<steps; i++)//timestepping
    {

    att["inputfile"] = input;
    att["geomfile"] = geom;
    for( auto pair : att)
        err = nc_put_att_text( ncid_out, NC_GLOBAL,
            pair.first.data(), pair.second.size(), pair.second.data());

    //-------------------Construct grids-------------------------------------//
