check for pending I/O operations and invalid modes and return proper error codes before executing MPI_File_sync makes the e_sync_1 test from the ibm testsuite pass. Signed-off-by: Edgar Gabriel <egabriel@central.uh.edu>