Fixed segfault on Linux systems

err = foo() was causing segfaults on Linux systems because the variable
name err was shadowed by the err function (implicitly) brought in
through err.h.  The variable is now local instead of at global scope,
and has been renamed to ierr for improved resilience.