module error_handling_grillix_m !! Contains functionality for error handling in GRILLIX, !! based on PARALLAX error handling. use error_handling_m, only: error_handler_t, ERRORS_ARE_FATAL, error_info_t ! from PARALLAX use status_codes_grillix_m implicit none public :: handle_error public :: handle_error_netcdf type(error_handler_t), private :: grillix_error_handler = & error_handler_t(handler_name="GRILLIX", & error_mode=ERRORS_ARE_FATAL, & netcdf_error_code=GRILLIX_ERR_NETCDF) contains subroutine handle_error(message, status_code, line_number, file_name, & additional_info) !! Logs an error to stderr and stops the program. If status_code is !! GRILLIX_SUCCESS, this subroutine will do nothing. !! !! If status_code has an undefined value, the subroutine will be !! executed but the undefined status_code will be printed. !! This usage should be avoided, instead valid status codes given in !! status_codes_grillix_m should be used. character(len=*), intent(in) :: message !! Error or warning message integer, intent(in) :: status_code !! Error or warning code integer, intent(in) :: line_number !! Line number where error or warning occured, i.e. __LINE__ character(len=*), intent(in) :: file_name !! File name where error or warning occured, i.e. __FILE__ type(error_info_t), optional, intent(in) :: additional_info !! Additional information call grillix_error_handler%handle_error(message, status_code, & line_number, file_name, & additional_info) end subroutine subroutine handle_error_netcdf(istatus, line_number, file_name) !! Wrapper of handle error for calls of NetCDF functions. !! Checks for NetCDF errors and prints a standardized error message. integer, intent(in) :: istatus !! Status integer returned by the NetCDF function integer, intent(in) :: line_number !! Line number where error or warning occured, i.e. __LINE__ character(len=*), intent(in) :: file_name !! File name where error or warning occured, i.e. __FILE__ call grillix_error_handler%handle_error_netcdf(istatus, line_number, & file_name) end subroutine end module