ECC-1235: Fortran examples: Show how to convert an error code into a string

This commit is contained in:
Shahram Najm 2021-04-23 13:22:45 +01:00
parent 2f26c45e69
commit ec67e1293a
1 changed files with 70 additions and 64 deletions

View File

@ -36,6 +36,7 @@ contains
integer :: count1 = 0 integer :: count1 = 0
integer(kind=4), dimension(intsize) :: buffer integer(kind=4), dimension(intsize) :: buffer
integer(kind=kindOfSize_t) :: len1 ! For large messages integer(kind=kindOfSize_t) :: len1 ! For large messages
character(len=128) :: error_message
ifile = 5 ifile = 5
call codes_open_file(ifile, input_grib_file, 'r') call codes_open_file(ifile, input_grib_file, 'r')
@ -54,6 +55,8 @@ contains
end do end do
if (iret /= CODES_END_OF_FILE) then if (iret /= CODES_END_OF_FILE) then
call codes_get_error_string(iret, error_message)
write (*, *) 'error message: ', error_message
call codes_check(iret, 'read_from_file', '') call codes_check(iret, 'read_from_file', '')
end if end if
call codes_close_file(ifile) call codes_close_file(ifile)
@ -70,6 +73,7 @@ contains
integer :: count1 = 0 integer :: count1 = 0
integer(kind=4), dimension(intsize) :: buffer integer(kind=4), dimension(intsize) :: buffer
integer :: len1 integer :: len1
character(len=128) :: error_message
ifile = 5 ifile = 5
call codes_open_file(ifile, input_grib_file, 'r') call codes_open_file(ifile, input_grib_file, 'r')
@ -88,6 +92,8 @@ contains
end do end do
if (iret /= CODES_END_OF_FILE) then if (iret /= CODES_END_OF_FILE) then
call codes_get_error_string(iret, error_message)
write (*, *) 'error message: ', error_message
call codes_check(iret, 'read_from_file', '') call codes_check(iret, 'read_from_file', '')
end if end if
call codes_close_file(ifile) call codes_close_file(ifile)