             if( record_name[0] == 'j')
                 record_name[1] = 'v';
             //1. Read toroidal average
-            err = nc_get_vara_double( ncid, id2d.at(record_name+"_ta2d"),
+            int dataID =0;
+            err = nc_inq_varid(ncid, (record.name+"_ta2d").data(), &dataID);
+            err = nc_get_vara_double( ncid, dataID,
                 start2d, count2d, transferH2d.data());
             //2. Compute fsa and output fsa
             dg::blas2::symv( grid2gridX2d, transferH2d, transferH2dX); //interpolate onto X-point grid

    for( auto tp : map1d)
    {
        int vid;
        err = nc_def_var( ncid, std::get<0>(tp).data(), NC_DOUBLE, 1,
            &dim_ids1d[1], &vid);
        err = nc_put_att_text( ncid, vid, "long_name",
            std::get<2>(tp).size(), std::get<2>(tp).data());
        err = nc_enddef( ncid);
        err = nc_put_var_double( ncid, vid, std::get<1>(tp).data());
        err = nc_redef(ncid);
    }
    err = nc_close(ncid_out);

    /////////////////////////////////////////////////////////////////////////
    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);
    err = nc_close( ncid); //close 3d file

    err = nc_open( argv[1], NC_NOWRITE, &ncid); //open 3d file
    //read in Ne,Ni,Ue,Ui,Phi,Apar
    for( auto& record : feltor::diagnostics2d_list)
    {
        std::string record_name = record.name;

    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_out, tvarID, "long_name", long_name.size(),
            long_name.data());
    long_name = "Flux surface label";
    err = nc_put_att_text( ncid_out, dim_ids1d[1], "long_name",
        long_name.size(), long_name.data());

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