Warning in <TFile::Write>: file ... not opened in write mode

Hi all,

on Scientific Linux SL release 5.4 (Boron), the attached macro a.C runs fine in

ROOT 5.27/06b (branches/v5-27-06-patches@36515, Nov 05 2010, 15:46:56 on linuxx8664gcc)

but fails to write output into the output file in

ROOT 5.32/00 (branches/v5-32-00-patches@42372, Jun 14 2012, 16:18:00 on linuxx8664gcc).

I run the macro in the same directory (after switching ROOT version with …/setroot.csh), so I think it is not an issue with (file) permissions, as has been the case with other posts regarding this topic. My output (a.C.txt) is attached.

The behavior is identical with compiled code (works with 5.27/06, but not with 5.32/00).

Code similar to what is in a.C used to work for a very long time. Did I miss an important change? Any hints/help would be much appreciated.


PS: At least on MacOS X, the problem persists with the newer root version

ROOT 5.34/01 (tags/v5-34-01@45048, Jul 20 2012, 15:31:33 on macosx64)

and no output is written into the output rootfile with the same error message. (Initially I thought my problem was Mac OS specific, because I was comparing against 5.27/06 on Linux.)
a.C.txt (1.72 KB)
a.C (465 Bytes)


Due to the monolithic nature of CINT, we currently must, at process tear down, close the TFile objects before CINT is tear down. When closing a TFile we require all the dictionary information to be available, while the CINT tear down can not (properly) separate the deletion of the dictionary from the deletion of the global variable.

So in your case, the TFile is closed before your destructor is called ; also, the automatic closing (intentionally) does not write the file’s content.

This problem will be resolved in the context of ROOT 6 (and the replacement of CINT by Cling).

Note that your technique will work in all cases but the case of global variables.