I/O in pure Fortran procedures
问题 I'm trying to incorporate error checking within a pure procedure I am writing. I would like something like: pure real function func1(output_unit,a) implicit none integer :: a, output_unit if (a < 0) then write(output_unit,*) 'Error in function func1: argument must be a nonnegative integer. It is ', a else func1 = a/3 endif return end function func1 However, pure functions are not allowed to have IO statements to external files, so I tried passing a unit number to the function, e.g. output