TREX-CoE/trexio

verbose error reporting

Closed this issue · 2 comments

I implemented the recent version of trexio (2.2.0) and found that the trexio_assert subroutine could be better. I made a local copy of that subroutine which might be useful for verbose error reporting.

Call with:

call trexio_error(rc, TREXIO_SUCCESS, 'trexio_read_mo_num failed', __FILE__, __LINE__)

Subroutine::

      subroutine trexio_error(trexio_rc, check_rc, message, filename, line)
            !> This subroutine handles the error in reading/writing with trexio data
            !> @author Ravindra Shinde (r.l.shinde@utwente.nl)
            !> @date 01 June 2022
            !> \param[in] trexio_rc : the return code from the trexio library
            !> \param[in] check_rc  : the return code to compare against trexio_rc
            !> \param[in] message   : the error message for printing
            !> \param[in] filename  : the name of the file where the error occurred
            !> \param[in] line      : the line number where the error occurred


            use contrl_file,    	only: ounit, errunit
            use mpi,            	only: mpi_abort, MPI_COMM_WORLD
            implicit none

            integer, intent(in), value :: trexio_rc
            integer, intent(in), value :: check_rc
            integer, intent(in), value :: line
            character(len=*), intent(in), optional  :: message
            character(len=*), intent(in), optional  :: filename
            integer :: ierr

            if (trexio_rc /= check_rc) then
                  write(ounit,'(a)') "Error reading/writing data from trexio file :: ", trim(message)
                  write(errunit,'(a)') "Error reading/writing data from trexio file :: ", trim(message)
                  write(errunit,'(3a,i6)') "Debug source file :: ", trim(filename), " at line " , line
                  call mpi_abort(MPI_COMM_WORLD,-100,ierr)
            endif

      end subroutine trexio_error

Thanks!

Thanks @neelravi , but I do not see a particular improvement in this function. What was precisely the missing functionality?

Since the function is used within the MPI context, perhaps is should be moved into a new MPI-aware variant, e.g. trexio_assert_mpi.