Eliminate/move DIJITSO temporary files

I have set DIJITSO_CACHE_DIR to a ramdisk to avoid clogging the /tmp directory and wasting read/write cycles on the storage drive. However, Fenics continues to write many directories and files to /tmp. The directories are of the format /tmp/tmplcvws9sv. The files contain assembly language and are of the format /tmp/cc81OMd8.o, /tmp/ccHsfhM5.c, /tmp/ccjd2VW6.le, /tmp/ccNOV0O6.res, and /tmp/ccYkvkx7.s.

I have traced the directory generation to dijitso/build.py:120 and fixed it by changing:

return tempfile.mkdtemp(dir=cache_params[“temp_dir_root”])

to:

return tempfile.mkdtemp(dir=cache_params[“cache_dir”])

However, I can’t find the source of the cc* files. Is there a better way to get Fenics to stop writing these nuisance files?

These files are being written by the C++ compiler, not FEniCS itself. You can change the directory by setting the environment variable TMPDIR in your shell, e.g.,

export TMPDIR=/path/to/ramdisk/

If this variable is not set, the compiler defaults to using /tmp.

1 Like

Thank-you. I was able to move all the cc* file creation to the ramdisk by setting TMPDIR. This also makes my modification to dijitso/build.py unnecessary. temp_dir_root is None, which makes tempfile.mkdtemp also default to TMPDIR.