Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

forrtl callbacks

Ernie_P_
Beginner
287 Views

 

forrtl: severe (59): list-directed I/O syntax error, unit -5, file Internal List-Directed Read

 

My question is, is there a way to optionally provide a callback to the forrtl library than will call a function that I provide?  Perhaps for each 'severity' level. For example, the severe error above,  I'd like it to call one of my functions and then carry on after my function returns.

Thanks in advance.

--ernie

 

 

0 Kudos
3 Replies
Steven_L_Intel1
Employee
287 Views

There is. See ESTABLISHQQ.

0 Kudos
Ernie_P_
Beginner
287 Views

Hi Steve,

Thanks for the insite into ESTABLISHQQ.

I tried the example program and I can't get it to compile.  I've pared it down to this simple example program to show the compile error.  Any insites as to what I'm doing wrong?  Thanks in advance.

<blockquote>

Vxp_hou712058% /cgv/Compilers/intel/compiler-14.0.1/bin/ifort -o example3 example3.f90                                                                                                                                                                            example3.f90(42): warning #6075: The data type of the actual argument does not match the definition.   [MY_CONTEXT]
     ret = ESTABLISHQQ(my_handler_3, my_context, old_handler_3, old_context)
-------------------------------------^
example3.f90(42): error #6633: The type of the actual argument differs from the type of the dummy argument.   [OLD_CONTEXT]
     ret = ESTABLISHQQ(my_handler_3, my_context, old_handler_3, old_context)
----------------------------------------------------------------^
compilation aborted for example3.f90 (code 1)
Vxp_hou712058%
 

 

Vxp_hou712058% more example3.f90

function my_handler_3 (error_code, continuable, message_string, context)
     use, intrinsic :: iso_c_binding
     implicit none

     ! Arguments
     !
     logical :: my_handler_3
     integer, intent(in) :: error_code             ! RTL error code from IOSTAT table
     logical, intent(in) :: continuable            ! True if condition is continuable
     character(*), intent(in) :: message_string    ! Formatted message string a la ERRMSG/IOMSG
     integer(INT_PTR_KIND()), intent(in) :: context    ! Address-sized integer passed in to call
                                                       ! ESTABLISHQQ, for whatever purpose
                                                       ! the programmer desires
     if (context == 1) then
         print *,"    Handler 3, continue"
     else if (context == 2) then
         print *, "    Handler 3, error is ", error_code, message_string
     end if

     my_handler_3 = .TRUE. ! Continue
     return

end function my_handler_3

program example
use ifestablish
implicit none

     procedure(establishqq_handler), pointer :: old_handler_3
     procedure(establishqq_handler)          :: my_handler_3

     logical                 :: ret
     integer(INT_PTR_KIND()) :: old_context
     integer(INT_PTR_KIND()) :: my_context

     my_context = 1

     ! Establish third handler
     !
     old_handler_3 => null()
     ret = ESTABLISHQQ(my_handler_3, my_context, old_handler_3, old_context)

     if (associated(old_handler_3)) then
         print *, "== Expect second handler as old handler"
         ret =  old_handler_3(100, .true., "call number one", 1 )
     else
         print *,"** Unexpectedly didn't get second handler as old handler **"
     end if
end

</blockquote>

0 Kudos
Steven_L_Intel1
Employee
287 Views

That's a bug in 14.0. I can reproduce it in that version but it works in 15.0 and 16.0. You didn't say you were using such an old version.

If you can't use a newer version, make a copy of ifestablish.f90 from the compiler's include folder and edit the interface so that the type of the "context" argument is "integer(int_ptr_kind())" rather than just integer. Compile this locally and reference it in your build.

0 Kudos
Reply