mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-08-25 06:31:43 +02:00
Reformat
This commit is contained in:
parent
aa47ae4c2e
commit
7d640b06dd
@ -3,6 +3,18 @@
|
||||
#+SETUPFILE: ../../docs/theme.setup
|
||||
# -*- mode: org -*-
|
||||
|
||||
The "file" produced by the text back end is a directory with one
|
||||
file per group.
|
||||
|
||||
When the file is open, it is locked by the current process. No other
|
||||
process can read/write the same file. This guarantees that the
|
||||
representation in memory is consistent with the file and avoid
|
||||
re-reading the file before writing.
|
||||
To lock the file, we lock the =.lock= file which is present in the
|
||||
directory.
|
||||
|
||||
The file is written when closed, or when the flush function is called.
|
||||
|
||||
* Constant file prefixes (not used by the generator) :noexport:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
@ -61,21 +73,7 @@
|
||||
|
||||
#+end_src
|
||||
|
||||
* TEXT back end
|
||||
|
||||
The "file" produced by the text back end is a directory with one
|
||||
file per group.
|
||||
|
||||
When the file is open, it is locked by the current process. No other
|
||||
process can read/write the same file. This guarantees that the
|
||||
representation in memory is consistent with the file and avoid
|
||||
re-reading the file before writing.
|
||||
To lock the file, we lock the =.lock= file which is present in the
|
||||
directory.
|
||||
|
||||
The file is written when closed, or when the flush function is called.
|
||||
|
||||
** Template for group-related structures in text back end
|
||||
* Template for group-related structures in text back end
|
||||
|
||||
#+begin_src c :tangle struct_text_group_dset.h
|
||||
typedef struct $group$_s {
|
||||
@ -91,7 +89,7 @@ typedef struct $group$_s {
|
||||
} $group$_t;
|
||||
#+end_src
|
||||
|
||||
** Template for general structure in text back end
|
||||
* Template for general structure in text back end
|
||||
|
||||
#+begin_src c :tangle struct_text_group.h
|
||||
typedef struct trexio_text_s {
|
||||
@ -101,7 +99,7 @@ typedef struct trexio_text_s {
|
||||
} trexio_text_t;
|
||||
#+end_src
|
||||
|
||||
** Initialize function (constant part)
|
||||
* Initialize function (constant part)
|
||||
|
||||
#+begin_src c :tangle basic_text.h :exports none
|
||||
trexio_exit_code trexio_text_init(trexio_t* const file);
|
||||
@ -246,7 +244,7 @@ trexio_text_unlock (trexio_t* const file)
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Deinitialize function (templated part)
|
||||
* Deinitialize function (templated part)
|
||||
|
||||
#+begin_src c :tangle basic_text_group.c
|
||||
trexio_exit_code
|
||||
@ -265,7 +263,7 @@ trexio_text_deinit (trexio_t* const file)
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Template for text read a group
|
||||
* Template for text read a group
|
||||
|
||||
#+begin_src c :tangle read_group_text.h :exports none
|
||||
$group$_t* trexio_text_read_$group$(trexio_text_t* const file);
|
||||
@ -567,7 +565,7 @@ trexio_text_read_$group$ (trexio_text_t* const file)
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Template for text flush a group
|
||||
* Template for text flush a group
|
||||
|
||||
#+begin_src c :tangle flush_group_text.h :exports none
|
||||
trexio_exit_code trexio_text_flush_$group$(trexio_text_t* const file);
|
||||
@ -632,7 +630,7 @@ trexio_text_flush_$group$ (trexio_text_t* const file)
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Template for text free memory
|
||||
* Template for text free memory
|
||||
|
||||
Memory is allocated when reading. The following function frees memory.
|
||||
|
||||
@ -678,7 +676,7 @@ trexio_text_free_$group$ (trexio_text_t* const file)
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Template for has/read/write a numerical attribute
|
||||
* Template for has/read/write a numerical attribute
|
||||
|
||||
#+begin_src c :tangle hrw_attr_num_text.h :exports none
|
||||
trexio_exit_code trexio_text_has_$group_num$ (trexio_t* const file);
|
||||
@ -742,7 +740,7 @@ trexio_text_has_$group_num$ (trexio_t* const file)
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Template for has/read/write a dataset of numerical data
|
||||
* Template for has/read/write a dataset of numerical data
|
||||
|
||||
The ~group_dset~ array is assumed allocated with the appropriate size.
|
||||
|
||||
@ -837,7 +835,7 @@ trexio_text_has_$group_dset$ (trexio_t* const file)
|
||||
|
||||
}
|
||||
#+end_src
|
||||
** Template for has/read/write a dataset of strings
|
||||
* Template for has/read/write a dataset of strings
|
||||
|
||||
The ~group_dset~ array is assumed allocated with the appropriate size.
|
||||
|
||||
@ -937,7 +935,7 @@ trexio_text_has_$group_dset$ (trexio_t* const file)
|
||||
|
||||
}
|
||||
#+end_src
|
||||
** Template for has/read/write a string attribute
|
||||
* Template for has/read/write a string attribute
|
||||
|
||||
#+begin_src c :tangle hrw_attr_str_text.h :exports none
|
||||
trexio_exit_code trexio_text_has_$group_str$ (trexio_t* const file);
|
||||
@ -1012,7 +1010,7 @@ trexio_text_has_$group_str$ (trexio_t* const file)
|
||||
|
||||
}
|
||||
#+end_src
|
||||
** Template for has/read/write the dataset of sparse data
|
||||
* Template for has/read/write the dataset of sparse data
|
||||
|
||||
Each sparse array is stored in a separate =.txt= file due to the fact that sparse I/O has to be decoupled
|
||||
from conventional write/read/flush behaviour of the TEXT back end. Chunks are used to read/write sparse data
|
||||
@ -1284,7 +1282,7 @@ trexio_exit_code trexio_text_has_$group_dset$(trexio_t* const file)
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Template for text delete a group (UNSAFE mode)
|
||||
* Template for text delete a group (UNSAFE mode)
|
||||
|
||||
#+begin_src c :tangle delete_group_text.h :exports none
|
||||
trexio_exit_code trexio_text_delete_$group$ (trexio_t* const file);
|
||||
@ -1313,7 +1311,7 @@ trexio_text_delete_$group$ (trexio_t* const file)
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** Source code for the determinant part
|
||||
* Source code for the determinant part
|
||||
|
||||
Each array is stored in a separate =.txt= file due to the fact that determinant I/O has to be decoupled
|
||||
from conventional write/read/flush behaviour of the TEXT back end. Chunks are used to read/write the data
|
||||
@ -1328,13 +1326,12 @@ trexio_exit_code trexio_text_write_determinant_list(trexio_t* const file, const
|
||||
#+end_src
|
||||
|
||||
#+begin_src c :tangle read_determinant_text.c
|
||||
trexio_exit_code trexio_text_read_determinant_list(
|
||||
trexio_t* const file,
|
||||
const int64_t offset_file,
|
||||
const uint32_t rank,
|
||||
const uint64_t* dims,
|
||||
int64_t* const eof_read_size,
|
||||
int64_t* const list)
|
||||
trexio_exit_code trexio_text_read_determinant_list(trexio_t* const file,
|
||||
const int64_t offset_file,
|
||||
const uint32_t rank,
|
||||
const uint64_t* dims,
|
||||
int64_t* const eof_read_size,
|
||||
int64_t* const list)
|
||||
{
|
||||
if (file == NULL) return TREXIO_INVALID_ARG_1;
|
||||
if (eof_read_size == NULL) return TREXIO_INVALID_ARG_5;
|
||||
@ -1359,7 +1356,7 @@ trexio_exit_code trexio_text_read_determinant_list(
|
||||
then this number is doubled because we have the same number for down-spin electrons,
|
||||
and then one newline char.
|
||||
,*/
|
||||
uint64_t line_length = 6UL*10UL + 6UL; // + 6UL + 1UL; // dims[1]*11UL + 1UL;
|
||||
uint64_t line_length = dims[1]*11UL; /* 10 digits per int64_t bitfield + 1 space = 11 spots + (?) 1 newline char
|
||||
|
||||
/* Offset in the file according to the provided value of offset_file and optimal line_length */
|
||||
fseek(f, (long) offset_file * line_length, SEEK_SET);
|
||||
@ -1413,10 +1410,10 @@ trexio_exit_code trexio_text_read_determinant_list(
|
||||
|
||||
#+begin_src c :tangle write_determinant_text.c
|
||||
trexio_exit_code trexio_text_write_determinant_list(trexio_t* const file,
|
||||
const int64_t offset_file,
|
||||
const uint32_t rank,
|
||||
const uint64_t* dims,
|
||||
const int64_t* list)
|
||||
const int64_t offset_file,
|
||||
const uint32_t rank,
|
||||
const uint64_t* dims,
|
||||
const int64_t* list)
|
||||
{
|
||||
if (file == NULL) return TREXIO_INVALID_ARG_1;
|
||||
|
||||
@ -1430,7 +1427,7 @@ trexio_exit_code trexio_text_write_determinant_list(trexio_t* const file,
|
||||
strncat (file_full_path, determinant_list_file_name,
|
||||
TREXIO_MAX_FILENAME_LENGTH-strlen(determinant_list_file_name));
|
||||
|
||||
/* Open the file in "a" (append) mode to guarantee that no truncation happens upon consecutive reads */
|
||||
/* Open the file in "a" (append) mode to guarantee that no truncation happens upon consecutive writes */
|
||||
FILE* f = fopen(file_full_path, "a");
|
||||
if(f == NULL) return TREXIO_FILE_ERROR;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user