Skip to content

Commit 38481ad

Browse files
committed
Fix mmap when qp set_file has not been called
1 parent d77f48b commit 38481ad

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/utils/mmap.f90

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module mmap_module
22

33
use iso_c_binding
44

5+
character*(256) :: mmap_prefix = '/tmp/'
6+
57
type mmap_type
68
type(c_ptr) :: ptr ! Pointer to the data
79
character*(128) :: filename ! Name of the file
@@ -155,7 +157,15 @@ subroutine mmap_create(filename, shape, bytes, read_only, single_node, map)
155157
map%filename = filename
156158
else
157159
call getenv('EZFIO_FILE', map%filename)
158-
map%filename = trim(map%filename) // '/work/tmpfile'
160+
if (trim(map%filename) /= '') then
161+
map%filename = trim(map%filename) // '/work/'
162+
else
163+
call getenv('TMPDIR', map%filename)
164+
if (trim(map%filename) == '') then
165+
map%filename = '/tmp/'
166+
endif
167+
endif
168+
map%filename = trim(map%filename) // '/tmpfile'
159169
endif
160170

161171
map%length = int(bytes,8)

0 commit comments

Comments
 (0)