Evidently not returning a value from a function that should causes some weird behaviors with (ierr != 0) not working properly