In my Fortran program, I call an external function only at the root processor. I have a few checks to ensure that the function worked. If it doesn't work, then I stop
the program and call PetscFinalize
. For example:
if(rank==0) then
call_status = external_function(x)
! function failed
if (call_status/=1) then
write(6,*) "external_function failed"
call PetscFinalize(ierr)
stop
end if
end if
However, I noticed that during runtime, if there is an error with external_function
, the program hangs and is not finalized properly.
My question is: what is the appropriate way to terminate the program at the root processor?