TREX-CoE / trexio

TREX I/O library
https://trex-coe.github.io/trexio/
BSD 3-Clause "New" or "Revised" License
49 stars 14 forks source link

Representation of text backend #170

Closed scemama closed 2 weeks ago

scemama commented 2 weeks ago

Some function prototypes are missing in the text backend:

src/trexio_text.c:1190:1: error: no previous prototype for ‘trexio_text_free_read_metadata’ [-Werror=missing-prototypes]
 1190 | trexio_text_free_read_metadata (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, metadata_t* metadata)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1236:1: error: no previous prototype for ‘trexio_text_free_read_nucleus’ [-Werror=missing-prototypes]
 1236 | trexio_text_free_read_nucleus (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, nucleus_t* nucleus)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1281:1: error: no previous prototype for ‘trexio_text_free_read_cell’ [-Werror=missing-prototypes]
 1281 | trexio_text_free_read_cell (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, cell_t* cell)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1322:1: error: no previous prototype for ‘trexio_text_free_read_pbc’ [-Werror=missing-prototypes]
 1322 | trexio_text_free_read_pbc (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, pbc_t* pbc)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1361:1: error: no previous prototype for ‘trexio_text_free_read_electron’ [-Werror=missing-prototypes]
 1361 | trexio_text_free_read_electron (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, electron_t* electron)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1409:1: error: no previous prototype for ‘trexio_text_free_read_state’ [-Werror=missing-prototypes]
 1409 | trexio_text_free_read_state (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, state_t* state)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1471:1: error: no previous prototype for ‘trexio_text_free_read_basis’ [-Werror=missing-prototypes]
 1471 | trexio_text_free_read_basis (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, basis_t* basis)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1517:1: error: no previous prototype for ‘trexio_text_free_read_ecp’ [-Werror=missing-prototypes]
 1517 | trexio_text_free_read_ecp (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, ecp_t* ecp)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1563:1: error: no previous prototype for ‘trexio_text_free_read_grid’ [-Werror=missing-prototypes]
 1563 | trexio_text_free_read_grid (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, grid_t* grid)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1604:1: error: no previous prototype for ‘trexio_text_free_read_ao’ [-Werror=missing-prototypes]
 1604 | trexio_text_free_read_ao (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, ao_t* ao)
      | ^~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1653:1: error: no previous prototype for ‘trexio_text_free_read_ao_1e_int’ [-Werror=missing-prototypes]
 1653 | trexio_text_free_read_ao_1e_int (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, ao_1e_int_t* ao_1e_int)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1692:1: error: no previous prototype for ‘trexio_text_free_read_ao_2e_int’ [-Werror=missing-prototypes]
 1692 | trexio_text_free_read_ao_2e_int (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, ao_2e_int_t* ao_2e_int)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1746:1: error: no previous prototype for ‘trexio_text_free_read_mo’ [-Werror=missing-prototypes]
 1746 | trexio_text_free_read_mo (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, mo_t* mo)
      | ^~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1795:1: error: no previous prototype for ‘trexio_text_free_read_mo_1e_int’ [-Werror=missing-prototypes]
 1795 | trexio_text_free_read_mo_1e_int (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, mo_1e_int_t* mo_1e_int)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1834:1: error: no previous prototype for ‘trexio_text_free_read_mo_2e_int’ [-Werror=missing-prototypes]
 1834 | trexio_text_free_read_mo_2e_int (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, mo_2e_int_t* mo_2e_int)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1873:1: error: no previous prototype for ‘trexio_text_free_read_determinant’ [-Werror=missing-prototypes]
 1873 | trexio_text_free_read_determinant (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, determinant_t* determinant)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1912:1: error: no previous prototype for ‘trexio_text_free_read_csf’ [-Werror=missing-prototypes]
 1912 | trexio_text_free_read_csf (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, csf_t* csf)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1951:1: error: no previous prototype for ‘trexio_text_free_read_amplitude’ [-Werror=missing-prototypes]
 1951 | trexio_text_free_read_amplitude (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, amplitude_t* amplitude)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:1994:1: error: no previous prototype for ‘trexio_text_free_read_rdm’ [-Werror=missing-prototypes]
 1994 | trexio_text_free_read_rdm (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, rdm_t* rdm)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:2040:1: error: no previous prototype for ‘trexio_text_free_read_jastrow’ [-Werror=missing-prototypes]
 2040 | trexio_text_free_read_jastrow (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, jastrow_t* jastrow)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trexio_text.c:2082:1: error: no previous prototype for ‘trexio_text_free_read_qmc’ [-Werror=missing-prototypes]
 2082 | trexio_text_free_read_qmc (char* buffer, FILE* txt_file, trexio_text_t* trexio_file, qmc_t* qmc
q-posev commented 2 weeks ago

@scemama this error has never occured before. There must be something wrong with your current branch. I don't even understand where these functions names come from.

scemama commented 2 weeks ago

I added a load of compiler warnings (in the debug_flags branch), and these warnings appear with these compiler flags. Without flags, everything is as usual. These appear with -Werror=missing-prototypes

This is because the generator doesn't create the prototypes for these functions in the trexio_text.h file. I couldn't find where I should make the modification in the generator...

q-posev commented 2 weeks ago

Hm, it should not because these function are sort of "private" for text back end so I have indeed excluded them from trexio_text.h. I do not see it as an error as the code is there, compiles and works.

q-posev commented 2 weeks ago

It would make sense to run this error check on front-end trexio.c but I don't see the point in applying it to the back end files, sorry

scemama commented 2 weeks ago

Hm, it should not because these function are sort of "private" for text back end so I have indeed excluded them from trexio_text.h. I do not see it as an error as the code is there, compiles and works.

There is no error here. I turned the warnings into errors to make the code super-safe.

It is true that if there is no prototype and the function is defined before being used, it is fine. But if for some reason the order of concatenating files is swapped, or the order in which the functions are tangled changes, the code might break because of this.

Some prototypes of *_free* functions are already defined in free_group_text.h, but not all of them. I found where the prototypes were missing, and the warnings disappeared. I made the change in the debug_flags branch.


I really want to get to the point where activating all possible warnings on trexio keeps the compiler silent. In that case, we can turn all warnings into errors on the github actions, and also activate the sanitizers, and the PRs will be really well checked. My Fortran bug would have been detected better than being lucky to have a segmentation fault. I was lucky to have a segfault, because only O2 was giving it!

The good thing with activating all those warnings is that it also fails because of unused parameters in functions. It has shown me many "safe" functions that are not really safe because they just call the non-safe version... I have fixed a few by making the relevant checks, but there is still a lot more to do. ;-)