0

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 stopthe 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?

psoo
  • 91
  • 1
  • 3

1 Answers1

0

call exit. PetscFinalize(ierr) is not designed for the stop of a program.

ztdep
  • 343
  • 1
  • 4
  • 17