1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-10-02 14:31:05 +02:00

add error message for an attempt to overwrite dimensioning variables

This commit is contained in:
q-posev 2021-05-06 17:44:31 +02:00
parent 51a1e2bca3
commit 57655a8344
3 changed files with 22 additions and 20 deletions

View File

@ -115,7 +115,7 @@ typedef int32_t trexio_exit_code;
#+NAME: table-exit-codes
| Macro | Code | Description |
|----------------------------+------+----------------------|
|-----------------------------+------+--------------------------------|
| ~TREXIO_FAILURE~ | -1 | 'Unknown failure' |
| ~TREXIO_SUCCESS~ | 0 | 'Success' |
| ~TREXIO_INVALID_ARG_1~ | 1 | 'Invalid argument 1' |
@ -130,6 +130,7 @@ typedef int32_t trexio_exit_code;
| ~TREXIO_ALLOCATION_FAILED~ | 10 | 'Allocation failed' |
| ~TREXIO_HAS_NOT~ | 11 | 'Element absent' |
| ~TREXIO_INVALID_NUM~ | 12 | 'Invalid exit code' |
| ~TREXIO_NUM_ALREADY_EXISTS~ | 13 | 'This variable already exists' |
# We need to force Emacs not to indent the Python code:
# -*- org-src-preserve-indentation: t
@ -175,6 +176,7 @@ return '\n'.join(result)
#define TREXIO_ALLOCATION_FAILED ((trexio_exit_code) 10)
#define TREXIO_HAS_NOT ((trexio_exit_code) 11)
#define TREXIO_INVALID_NUM ((trexio_exit_code) 12)
#define TREXIO_NUM_ALREADY_EXISTS ((trexio_exit_code) 13)
#+end_src
#+begin_src f90 :tangle prefix_fortran.f90 :exports none
@ -192,6 +194,7 @@ return '\n'.join(result)
integer(trexio_exit_code), parameter :: TREXIO_ALLOCATION_FAILED = 10
integer(trexio_exit_code), parameter :: TREXIO_HAS_NOT = 11
integer(trexio_exit_code), parameter :: TREXIO_INVALID_NUM = 12
integer(trexio_exit_code), parameter :: TREXIO_NUM_ALREADY_EXISTS = 13
#+end_src
:end:

View File

@ -235,9 +235,8 @@ trexio_hdf5_write_$group_num$ (trexio_t* const file, const uint64_t num)
if (infile_num != num) {
if (infile_num != 0) {
printf("%lu -> %lu %s \n", num, infile_num,
"This variable already exists. Overwriting it is not supported");
return TREXIO_FAILURE;
return TREXIO_NUM_ALREADY_EXISTS;
} else {

View File

@ -77,7 +77,7 @@ int test_h5write() {
// should not work: try to overwrite the nucleus_num
rc = trexio_write_nucleus_num(file,25);
assert (rc != TREXIO_SUCCESS);
assert (rc == TREXIO_NUM_ALREADY_EXISTS);
// close current session
rc = trexio_close(file);