The previous answers, although correct, aren't valid for most large scale computer clusters.
Computer clusters not always follow the standard conventions for machines, usually for good reasons, and there is no point in discussing it with the sysadmins.
Your current directory is referring to the central file system, which is accessed through the network. This is not only slow, but also puts loads on the system for the rest of the users, so you shouldn't use it unless you aren't writing much and you can recover from it if the job crashes.
The computing nodes have their own hard drive, that is the fastest file system available, and what you should be using. The cluster documentation should tell you what it is, typically
/tmp/[jobid], or some non standard enviroment variable (
$SNIC_TMP in one of the ones I use).
So, what I recommend is making it user-configurable. The defaults can be the first one you have write access to:
But expect a low success rate with this approach, and make sure to emit a big fat warning.
Edit: I'll add another reason for force it to be user-set. One of my clusters has
$TMPDIR set to
/scratch, that is user-writable and on the local hard drive. But, the documentation says that anything you write outside of
/scratch/[jobid] may be deleted at any point, even in the middle of the run. So, if you follow the standards, and trust
$TMPDIR, you will encounter random crashes, very hard to debug. So, you may accept
$TMPDIR, but not trust it.
Some other clusters do have this variable properly configured, so you may add an option to explicitly trust
$TMPDIR, otherwise, emit a big, fat warning.