The following example shows how to stop the execution on the error.

program f77error
    implicit none
    include 'f90calceph.h'
    integer*8 peph
    integer res

    ! set the  error handler to stop on error
     call f90calceph_seterrorhandler(2, 0)

    ! open the ephemeris file
    res = f90calceph_open(peph, "example1.dat")
    ! ...
stop
end

The following example shows how to define a custom error handler function.

 !-----------------------------------------------------------------
 ! custom error handler
 !-----------------------------------------------------------------
         subroutine myhandler(msg)
            implicit none
            character(len=*) :: msg
            write (*,*) "The calceph calls the function myhandler"
            write (*,*) "The message contains ",len(msg)," characters"
            write(*,*) "The error message is :"
            write(*,*) "----------------------"
            write(*,*) msg
            write(*,*) "----------------------"
            write(*,*) "The error handler returns"
         end

 !-----------------------------------------------------------------
 ! main program
 !-----------------------------------------------------------------
 program f77error
    implicit none
    include 'f90calceph.h'
    integer res
    integer*8 peph
    external myhandler


     ! set the  error handler to use my own callback
     call f90calceph_seterrorhandler(3, myhandler)

    ! open the ephemeris file
    res = f90calceph_open(peph, "example1.dat")
    ! ...
stop
end