# Writing a 3D array from Petsc

I am trying to do something fairly simple somehow I have made it hard. Is there an example of how to send a 3D array to a binary file?

• Is your "3D array" actually a distributed Vec based on a DMDA? If so, you should use VecView like Geoff says. – Jed Brown Aug 25 '14 at 19:49

It depends on the object representation of your 3D array. If it's a PETSc Mat, you want to look at MatView; if it's a Vec, you want to look at VecView. The links are to PETSc documentation, and each of the links has a list of relevant examples. They may not be exactly what you're looking for, but they should be close; in general, you're looking for something like a "View" type command. If these suggestions don't help, I suggest e-mailing the PETSc user list.