On Sat, 2015-03-07 at 15:51 -0600, Barry Smith wrote:
> Did you follow the directions in the manual page for PetscDrawSetSave()?
> "Requires that PETSc be configured with the option --with-afterimage to save
> the images and ffmpeg must be in your path to make the movie"
Yes. For some reason configure does not find libAfterImage in Debian's
default location, but it works if I provide both with-afterimage-lib and
with-afterimage-include. Debian Jessie provides packages
libafterimage-dev and libafterimage0, both marked as version 2.2.12-3.
gtheler@blinky:~/libs/petsc-3.5.3$ ./configure
--with-afterimage-lib=/usr/lib/x86_64-linux-gnu/libAfterImage.so
--with-afterimage-include=/usr/include/libAfterImage
===============================================================================
Configuring PETSc to compile on your
system
===============================================================================
TESTING: alternateConfigureLibrary from
PETSc.packages.petsc4py(config/PETSc/packages/petsc4py.py:74)
Compilers:
C Compiler: mpicc -fPIC -Wall -Wwrite-strings
-Wno-strict-aliasing -Wno-unknown-pragmas -g3 -O0
C++ Compiler: mpicxx -Wall -Wwrite-strings -Wno-strict-aliasing
-Wno-unknown-pragmas -g -O0 -fPIC
Fortran Compiler: mpif90 -fPIC -Wall -Wno-unused-variable
-ffree-line-length-0 -Wno-unused-dummy-argument -g -O0
Linkers:
Shared linker: mpicc -shared -fPIC -Wall -Wwrite-strings
-Wno-strict-aliasing -Wno-unknown-pragmas -g3 -O0
Dynamic linker: mpicc -shared -fPIC -Wall -Wwrite-strings
-Wno-strict-aliasing -Wno-unknown-pragmas -g3 -O0
make:
MPI:
Includes: -I/usr/include/mpich
BLAS/LAPACK: -llapack -lblas
cmake:
X:
Library: -lX11
pthread:
Library: -lpthread
ssl:
Library: -lssl -lcrypto
afterimage:
Includes: -I/usr/include/libAfterImage
Library: -Wl,-rpath,/usr/lib/x86_64-linux-gnu
-L/usr/lib/x86_64-linux-gnu -lAfterImage
valgrind:
Arch:
PETSc:
PETSC_ARCH: arch-linux2-c-debug
PETSC_DIR: /home/gtheler/libs/petsc-3.5.3
Clanguage: C
shared libraries: enabled
Scalar type: real
Precision: double
Memory alignment: 16
xxx=========================================================================xxx
Configure stage complete. Now build PETSc libraries with (gnumake
build):
make PETSC_DIR=/home/gtheler/libs/petsc-3.5.3
PETSC_ARCH=arch-linux2-c-debug all
xxx=========================================================================xxx
gtheler@blinky:~/libs/petsc-3.5.3$
Now, consider the attached source file (based on
mat/examples/tutorials/ex16.c). It does compile and gets linked to
libAfterImage:
gtheler@blinky:~/codigos/mat2img$ make
mpicc -c -o mat2img.o mat2img.c -Wall
-I/home/gtheler/libs/petsc-3.5.3/include
-I/home/gtheler/libs/petsc-3.5.3/arch-linux2-c-debug/include
-I/usr/include/libAfterImage -I/usr/include/mpich
mpicc -o mat2img mat2img.o
-Wl,-rpath,/home/gtheler/libs/petsc-3.5.3/arch-linux2-c-debug/lib
-L/home/gtheler/libs/petsc-3.5.3/arch-linux2-c-debug/lib -lpetsc
-llapack -lblas -Wl,-rpath,/usr/lib/x86_64-linux-gnu
-L/usr/lib/x86_64-linux-gnu -lAfterImage -lX11 -lpthread -lssl -lcrypto
-lm -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/4.9
-L/usr/lib/gcc/x86_64-linux-gnu/4.9 -Wl,-rpath,/lib/x86_64-linux-gnu
-L/lib/x86_64-linux-gnu -lmpichf90 -lgfortran -lm -lgfortran -lm
-lquadmath -lm -lmpichcxx -lstdc++ -Wl,-rpath,/usr/lib/x86_64-linux-gnu
-L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/4.9
-L/usr/lib/gcc/x86_64-linux-gnu/4.9 -Wl,-rpath,/usr/lib/x86_64-linux-gnu
-L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/lib/x86_64-linux-gnu
-L/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu
-L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lopa -lmpl -lrt -lcr -lpthread
-lgcc_s -ldl
gtheler@blinky:~/codigos/mat2img$ ldd mat2img | grep After
libAfterImage.so.0
=> /usr/lib/x86_64-linux-gnu/libAfterImage.so.0 (0x00007f95bc4b7000)
libAfterBase.so.0 => /usr/lib/x86_64-linux-gnu/libAfterBase.so.0
(0x00007f95b7ad4000)
gtheler@blinky:~/codigos/mat2img$
However, an empty directory called "test" is created when running the
code:
gtheler@blinky:~/codigos/mat2img$ ./mat2img -info
[0] PetscInitialize(): PETSc successfully started: number of processors
= 1
[0] PetscGetHostName(): Rejecting domainname, likely is NIS
blinky.(none)
[0] PetscInitialize(): Running on machine: blinky
[0] PetscCommDuplicate(): Duplicating a communicator 1140850688
-2080374784 max tags = 536870911
[0] PetscGetFileStat(): System call stat() succeeded on file matrix.bin
[0] PetscTestOwnership(): System call access() succeeded on file
matrix.bin
[0] PetscFileRetrieve(): Found file matrix.bin
[0] PetscGetFileStat(): System call stat() failed on file
matrix.bin.info
[0] PetscFileRetrieve(): Did not find file matrix.bin.info
[0] PetscCommDuplicate(): Using internal PETSc communicator 1140850688
-2080374784
[0] MatAssemblyEnd_SeqAIJ(): Matrix size: 20 X 20; storage space: 0
unneeded,58 used
[0] MatAssemblyEnd_SeqAIJ(): Number of mallocs during MatSetValues() is
0
[0] MatAssemblyEnd_SeqAIJ(): Maximum nonzeros in any row is 3
[0] MatCheckCompressedRow(): Found the ratio (num_zerorows
0)/(num_localrows 20) < 0.6. Do not use CompressedRow routines.
[0] Mat_CheckInode(): Found 20 nodes out of 20 rows. Not using Inode
routines
[0] PetscCommDuplicate(): Using internal PETSc communicator 1140850688
-2080374784
[0] PetscDrawSetUpColormap_Shared(): Successfully allocated colors
[0] PetscGetHostName(): Rejecting domainname, likely is NIS
blinky.(none)
[0] PetscPOpen(): Running command :rm -fr matrix matrix.m4v
[0] PetscGetHostName(): Rejecting domainname, likely is NIS
blinky.(none)
[0] PetscPOpen(): Running command :mkdir matrix
[0] PetscFinalize(): PetscFinalize() called
gtheler@blinky:~/codigos/mat2img$
I cannot find out what I am missing.
> So you have to install afterimage on your machine and then ./configure PETSc
> so it knows about it. If you have done all that and PETSc is being linked
> with the afterimage libraries then run your code with -info and send all the
> output; it may indicate why the images are not being saved.
>
> Barry
>
>
> > On Mar 7, 2015, at 3:38 PM, Theler German Guillermo <[email protected]>
> > wrote:
> >
> > Hi
> >
> > Last week I asked how to dump a matrix structure into an image and Barry
> > kindly pointed me out the PetscDrawSetSave function. But I cannot figure
> > out how to use it. So far, I can show my matrix structure into an X window
> > with something like
> >
> > PetscViewerDrawOpen(PETSC_COMM_WORLD, PETSC_NULL, "R", 100, 100, size,
> > size, &viewer);
> > MatView(milonga.R, viewer);
> >
> > I tried with this snippet of code but had no luck:
> >
> > PetscViewerDrawOpen(PETSC_COMM_WORLD, PETSC_NULL, "R", 100, 100, size,
> > size, &viewer);
> > MatView(milonga.R, viewer);
> > PetscViewerDrawGetDraw(viewer, 0, &draw);
> > PetscDrawFlush(draw);
> > PetscDrawSetSave(draw, "test.gif", PETSC_FALSE);
> > PetscDrawSetSaveFinalImage(draw, "test2.gif");
> >
> > The result is that test.gif and test2.gif are created but they are empty
> > directories.
> > What am I missing?
> >
> > --
> > jeremy
> >
> > ________________________________
> > Imprima este mensaje sólo si es absolutamente necesario.
> > Para imprimir, en lo posible utilice el papel de ambos lados.
> > El Grupo Sancor Seguros se compromete con el cuidado del medioambiente.
> >
> >
> >
> > ************AVISO DE CONFIDENCIALIDAD************
> >
> > El Grupo Sancor Seguros comunica que:
> >
> > Este mensaje y todos los archivos adjuntos a el son para uso exclusivo del
> > destinatario y pueden contener información confidencial o propietaria, cuya
> > divulgación es sancionada por ley. Si usted recibió este mensaje
> > erróneamente, por favor notifíquenos respondiendo al remitente, borre el
> > mensaje original y destruya las copias (impresas o grabadas en cualquier
> > medio magnético) que pueda haber realizado del mismo. Todas las opiniones
> > contenidas en este mail son propias del autor del mensaje. La publicación,
> > uso, copia o impresión total o parcial de este mensaje o documentos
> > adjuntos queda prohibida.
> >
> > Disposición DNDP 10-2008. El titular de los datos personales tiene la
> > facultad de ejercer el derecho de acceso a los mismos en forma gratuita a
> > intervalos no inferiores a seis meses, salvo que acredite un interés
> > legítimo al efecto conforme lo establecido en el artículo 14, inciso 3 de
> > la Ley 25.326. La DIRECCIÓN NACIONAL DE PROTECCIÓN DE DATOS PERSONALES,
> > Organo de Control de la Ley 25.326, tiene la atribución de atender las
> > denuncias y reclamos que se interpongan con relación al incumplimiento de
> > las normas sobre la protección de datos personales.
>
// based on mat/examples/tutorials/ex16.c
static char help[] = "Reads a matrix from PETSc binary file and saves its structure as an image. \n\n";
/*
Example:
./mat2img -f <matrix file> -size <size in pixels>
*/
#include <string.h>
#include <petscmat.h>
#include <petscdraw.h>
#define call(f) ierr=(f);CHKERRQ(ierr);
#undef __FUNCT__
#define __FUNCT__ "main"
int main(int argc,char **args)
{
Mat A;
PetscViewer fd; /* viewer */
char file[PETSC_MAX_PATH_LEN]; /* input file name */
PetscInt size;
PetscErrorCode ierr;
PetscBool flg;
PetscMPIInt rank;
PetscDraw draw;
PetscViewer viewer;
PetscInitialize(&argc,&args,(char*)0,help);
call(MPI_Comm_rank(PETSC_COMM_WORLD,&rank));
/* Determine files from which we read the linear systems. */
call(PetscOptionsGetString(NULL,"-f",file,PETSC_MAX_PATH_LEN,&flg));
if (!flg) {
strcpy(file, "matrix.bin");
}
call(PetscOptionsGetInt(NULL,"-size",&size,&flg));
if (!flg) {
size = 600;
}
/* Open binary file. Note that we use FILE_MODE_READ to indicate
reading from this file. */
call(PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd));
/* Load the matrix; then destroy the viewer. */
call(MatCreate(PETSC_COMM_WORLD,&A));
call(MatSetFromOptions(A));
call(MatLoad(A,fd));
call(PetscViewerDrawOpen(PETSC_COMM_WORLD, PETSC_NULL, file, 100, 100, size, size, &viewer));
call(MatView(A, viewer));
call(PetscViewerDrawGetDraw(viewer, 0, &draw));
call(PetscDrawFlush(draw));
call(PetscDrawSetSave(draw, "matrix", PETSC_FALSE));
call(PetscDrawSetSaveFinalImage(draw, "matrix2"));
call(PetscViewerDestroy(&fd));
call(MatDestroy(&A));
call(PetscFinalize());
return 0;
}
include ${PETSC_DIR}/conf/variables
all:
${CC} -c -o mat2img.o mat2img.c -Wall ${PETSC_CC_INCLUDES}
${CC} -o mat2img mat2img.o ${PETSC_LIB}