GBTOlib: library for evaluation of molecular integrals in mixed Gaussian / B-spline basis 111
Loading...
Searching...
No Matches
file_mapping_gbl Module Reference

Virtual memory file mapping. More...

Data Types

type  file_mapping
 An auxiliary derived type which holds the pointer to the mapped data file window and performs the mapping and unmapping on call to init or final. More...
interface  map_file_window
interface  unmap_file_window

Functions/Subroutines

subroutine init_file_mapping (this, filename, offset, length, read_write, unique_name, create_new)
 Initialize file virtual memory mapping.
subroutine finalize_file_mapping (this)
 Finalize file virtual memory mapping.
subroutine destruct_file_mapping (this)
 Destructor of the type "file_mapping".

Variables

logical, parameter map = .false.
 Map integrals to virtual memory instead of fully reading them to the physical memory.

Detailed Description

Virtual memory file mapping.

Author
J Benda
Date
2020 - 2021

Direct mapping of disk files into virtual memory. This allows direct access to data in files without actually reading them to memory. The system performs all necessary I/O on the fly, to obtain the required values at the requested position. For simplicity, this module is accompanied with a C source code, which calls the necessary system API.

Function/Subroutine Documentation

◆ destruct_file_mapping()

subroutine file_mapping_gbl::destruct_file_mapping ( type(file_mapping), intent(inout) this)

Destructor of the type "file_mapping".

Author
J Benda
Date
2021

Called when an instance of "file_mapping" is being destructed.

◆ finalize_file_mapping()

subroutine file_mapping_gbl::finalize_file_mapping ( class(file_mapping), intent(inout) this)

Finalize file virtual memory mapping.

Author
J Benda
Date
2020

Cancel the file mapping. This simply calls the POSIX munmap function.

◆ init_file_mapping()

subroutine file_mapping_gbl::init_file_mapping ( class(file_mapping), intent(inout) this,
character(len=*), intent(in) filename,
integer(int64), intent(in) offset,
integer(int64), intent(in) length,
logical, intent(in), optional read_write,
logical, intent(in), optional unique_name,
logical, intent(in), optional create_new )

Initialize file virtual memory mapping.

Author
J Benda
Date
2020 - 2025

Set up a data file mapping window. The file name, byte offset and byte length of the window within the file needs to be given. Internally, this opens the file using the POSIX function open (or OpenFileMapping in Windows), requests the mapping starting from the virtual memory page boundary just below the requested offset as needed by mmap, and constructs the pointer to the actually wanted window, which starts at the specified offset.

If create_new is given and set to .true., then the file is created first before mapping from it. If read_write is given and set to .true., the mapped view will be writable. If unique_name is given and set to .true., the provided file name is interpreted only as a prefix for a file path, which will be suffixed to generate a unique file path. (This makes sense only together with create_new.) In this last case the file will be considered temporary and removed once the file mapping ends.

Parameters
[in]thisA file mapping object.
[in]filenameName of file to open (or prefix if unique_name is given).
[in]offsetPosition in file where to start mapped segment.
[in]lengthLength of the mapped segment.
[in]read_writeWhether to enable writing.
[in]unique_nameWhether to suffix filename with characters in order to make a unique file name.

Variable Documentation

◆ map

logical, parameter file_mapping_gbl::map = .false.

Map integrals to virtual memory instead of fully reading them to the physical memory.