[petsc-users] Multiple output using one viewer

Alexander Grayver agrayver at gfz-potsdam.de
Thu Jan 5 09:22:50 CST 2012


Hello,

To output many vectors I use following trick:

         call 
PetscViewerBinaryOpen(comm,'out',FILE_MODE_WRITE,viewer,ierr); CHKERRQ(ierr)

         call PetscViewerFileSetName(viewer,'A1.dat',ierr)
         call MatView(A1,viewer,ierr); CHKERRQ(ierr)

         call PetscViewerFileSetName(viewer,'A2.dat',ierr)
         call MatView(A2,viewer,ierr); CHKERRQ(ierr)

         call PetscViewerFileSetName(viewer,'A3.dat',ierr)
         call MatView(A3,viewer,ierr); CHKERRQ(ierr)

         call PetscViewerFileSetName(viewer,'A4.dat',ierr)
         call MatView(A4,viewer,ierr); CHKERRQ(ierr)

         call PetscViewerFileSetName(viewer,'V1.dat',ierr)
         call VecView(V1,viewer,ierr); CHKERRQ(ierr)

         call PetscViewerFileSetName(viewer,'V2.dat',ierr)
         call VecView(V2,viewer,ierr); CHKERRQ(ierr)

         call PetscViewerDestroy(viewer,ierr); CHKERRQ(ierr)

In real application there are hundreds of calls like that. This is 
necessary for analyzing data somewhere in matlab.
Eventually I get error:

[0]PETSC ERROR: --------------------- Error Message 
------------------------------------
[0]PETSC ERROR: Unable to open file!
[0]PETSC ERROR: Cannot open .info file V2.info for writing!
[0]PETSC ERROR: 
------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Development HG revision: 
199bab0ea052fc92ce8e4abb56afc442629a19c8  HG Date: Tue Dec 13 22:22:13 
2011 -0800
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR: 
------------------------------------------------------------------------
[0]PETSC ERROR: /home/test on a openmpi-i named node228 by agrayver Thu 
Jan  5 15:24:10 2012
[0]PETSC ERROR: Libraries linked from 
/home/lib/petsc-dev/openmpi-intel-complex-release-f-ds/lib
[0]PETSC ERROR: Configure run at Wed Dec 14 10:54:32 2011
[0]PETSC ERROR: Configure options 
--with-petsc-arch=openmpi-intel-complex-release-f-ds 
--with-fortran-interfaces=1 --download-superlu --download-superlu_dist 
--download-mumps --download-pastix --download-parmetis --download-metis 
--download-ptscotch 
--with-scalapack-lib=/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_scalapack_lp64.a 
--with-scalapack-include=/opt/intel/Compiler/11.1/072/mkl/include 
--with-blacs-lib=/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_blacs_openmpi_lp64.a 
--with-blacs-include=/opt/intel/Compiler/11.1/072/mkl/include 
--with-mpi-dir=/opt/mpi/intel/openmpi-1.4.2 --with-scalar-type=complex 
--with-blas-lapack-dir=/opt/intel/Compiler/11.1/072/mkl/lib/em64t 
--with-precision=double --with-debugging=0 --with-fortran-kernels=1 
--with-x=0
[0]PETSC ERROR: 
------------------------------------------------------------------------
[0]PETSC ERROR: PetscViewerFileSetName_Binary() line 1056 in 
/home/lib/petsc-dev/src/sys/viewer/impls/binary/binv.c
[0]PETSC ERROR: PetscViewerFileSetName() line 595 in 
/home/lib/petsc-dev/src/sys/viewer/impls/ascii/filev.c

Sorry!  You were supposed to get help about:
     mpi-abort
But I couldn't open the help file:
     /opt/mpi/intel/openmpi-1.4.2/share/openmpi/help-mpi-api.txt: Too 
many open files.  Sorry!

When I switch off verbose mode or reduce number of output files 3-4 
times it works.
My question is whether all file handles are closed correctly when I 
change file name?

Regards,
Alexander


More information about the petsc-users mailing list