         err = nc_put_att_text( ncid_out, id0d[name], "long_name", long_name.size(),
             long_name.data());
     }
+    /////////////////////////////////////////////////////////////////////////
+    int timeID;
+    double time=0.;
+
+    size_t steps;
+    err = nc_open( argv[1], NC_NOWRITE, &ncid); //open 3d file
+    err = nc_inq_unlimdim( ncid, &timeID); //Attention: Finds first unlimited dim, which hopefully is time and not energy_time
+    err = nc_inq_dimlen( ncid, timeID, &steps);
     //steps = 3;
     for( unsigned i=0; i<steps; i++)//timestepping
     {

    err = file::define_dimension( ncid_out, "psi", &dim_ids1d[1], g1d_out);
    //Write long description
    std::string long_name = "Time at which 2d fields are written";
    err = nc_put_att_text( ncid, tvarID, "long_name", long_name.size(),
            long_name.data());
    long_name = "Flux surface label";
    err = nc_put_att_text( ncid, dim_ids1d[1], "long_name",
        long_name.size(), long_name.data());

    std::map<std::string, int> id0d, id1d, id2d;

                start2d, count2d, transferH2d.data() );

            //4. Read 2d variable and compute fluctuations
            err = nc_inq_varid(ncid, (record.name+"_2d").data(), &dataID);
            err = nc_get_vara_double( ncid, dataID,
                start2d, count2d, transferH2d.data());
            err = nc_get_vara_double( ncid, dataID, start2d, count2d,
                t2d_mp.data());
            if( record_name[0] == 'j')
                dg::blas1::pointwiseDot( t2d_mp, dvdpsip2d, t2d_mp );
