# write\_to\_disk does not work.

**URL:** <https://itensor.discourse.group/t/write-to-disk-does-not-work/278>\
**Category:** ITensor Julia Questions\
**Tags:** dmrg\
**Created:** [July 23, 2022, 4:31am UTC](https://itensor.discourse.group/t/write-to-disk-does-not-work/278 "2022-07-23T04:31:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhouzsh](https://avatars.discourse-cdn.com/v4/letter/z/a88e4f/32.png) [@zhouzsh](https://itensor.discourse.group/u/zhouzsh)\
**Post date:** [July 23, 2022, 4:31am UTC](https://itensor.discourse.group/t/write-to-disk-does-not-work/278/1 "2022-07-23T04:31:10Z")

</div>

Hello,

In dmrg calculations, When the bond dimension is large, we can write some operators in the disk to reduce the memory cost. From the sample code, we should add the kwargs write\_when\_maxdim\_exceeds when call dmrg engine, and the following is my julia code

```julia
       energy, psi = dmrg(H, psi0, sweeps; write_when_maxdim_exceeds=25)

```

But I find it does not work, as I can not find the related files in the work directory. What should I do to fixed this problem？

my ITensor is v0.3.18

Thanks a lot.

Zongsheng Zhou.

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [July 23, 2022, 8:45pm UTC](https://itensor.discourse.group/t/write-to-disk-does-not-work/278/2 "2022-07-23T20:45:21Z")

</div>

Hi Zongsheng,  
Thanks for the question. The write to disk feature here is working, but is just putting the files into a folder on your computer in a location you may not expect. The locations are determined by calling the `tempname()` function in Julia, which on my Mac have values like `"/var/folders/lp/ps_h2f0x3slbjl73k01qf1v800014g/T/jl_owCTeT"`. Depending on your machine the locations may be different.

The writing to disk in ITensor is handled by the [SerializedElementArrays](https://github.com/ITensor/SerializedElementArrays.jl) library which calls `tempname()` internally to determine the folder location.

A good feature we might add is to have the `dmrg` function print the folder name when write to disk is turned on, and when the `outputlevel` option is `>=2`.

Overall, though, you shouldn’t need to know the folder name in a typical scenario since ITensor will manage the location for you, and Julia will or should delete this folder after it finishes running (I checked and on my machine Julia does delete the files automatically after the Julia session ends).

---

<div class="post-metadata">

**Author:** ![zhouzsh](https://avatars.discourse-cdn.com/v4/letter/z/a88e4f/32.png) [@zhouzsh](https://itensor.discourse.group/u/zhouzsh)\
**Post date:** [July 24, 2022, 2:25am UTC](https://itensor.discourse.group/t/write-to-disk-does-not-work/278/3 "2022-07-24T02:25:56Z")

</div>

Hi miles,

Thanks a lot for your answer，it dispels my doubts .

Best regards.
