<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <font face="Droid Serif">Thanks Barry,<br>
      <br>
      I did that, the problem was when setting values to the matrix.<br>
      <br>
      The matrix is set row by row, although only the first element of
      the vectors is given. Here is how I modified it:<br>
    </font><br>
    <font face="Droid Serif"><font face="Droid Serif">call
        MatSetValuesBlocked(mat,1,[N-1],<wbr>IROW,LC(nnz:IROW),BB(nnz:IROW),INSERT_<wbr>VALUES,ierr)</font><br>
      <br>
      Thanks for the help,<br>
      <br>
      Hector<br>
      <br>
      <br>
    </font>
    <div class="moz-cite-prefix">On 05/23/2018 07:15 PM, Smith, Barry F.
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:B2A28F7A-8793-4B86-8156-57901B019E6E@anl.gov">
      <pre wrap=""> Use -mat_view on the new and old code to verify that the same matrix is actually being generated.

   Barry


</pre>
      <blockquote type="cite">
        <pre wrap="">On May 23, 2018, at 6:18 PM, Hector E Barrios Molano <a class="moz-txt-link-rfc2396E" href="mailto:hectorb@utexas.edu"><hectorb@utexas.edu></a> wrote:

Thanks Jed for the Answer.

I am still having problems with this code. In summary what I changed from PETSc 3.7 to 3.9 was:

- use of PETSC_NULL_MAT to evaluate if the matrix was defined

mat = PETSC_NULL_MAT
...
if(mat .eq. PETSC_NULL_MAT)then
    create matrix,vectors, ksp
else
    KSPSetInitialGuessNonzero
    VecResetArray
end if

- modified MatSetValuesBlocked call
Previously it was:

call MatSetValuesBlocked(mat,1,N-1,IROW,LC(nnz),BB(nnz),INSERT_VALUES,ierr)

with N-1, LC(nnz), and BB(nnz) scalar values, the elements where inserted one at a time

Modified to:

call MatSetValuesBlocked(mat,1,[N-1],IROW,[LC(nnz)],[BB(nnz)],INSERT_VALUES,ierr)

After the matrix is built there is a call to 

KSPSolve

When I run the program I get a lot of these errors:

[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Object is in wrong state
[0]PETSC ERROR: Matrix is missing diagonal entry 1
[0]PETSC ERROR: See <a class="moz-txt-link-freetext" href="http://www.mcs.anl.gov/petsc/documentation/faq.html">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.9.2, unknown 
[0]PETSC ERROR: ../../../UTCOMPRS on a  named bandera by hector Wed May 23 18:08:07 2018
[0]PETSC ERROR: Configure options --prefix=/home/hector/installed/petsc_git-intel-debug --PETSC_DIR=/home/hector/dwnld_prog/petsc --PETSC_ARCH=linux-intel-debug --CC=mpiicc --FC=mpiifort --CXX=mpiicpc --with-openmp=1 --with-valgrind=1 --with-valgrind-dir=/home/hector/installed --with-parmetis-dir=/home/hector/installed/parmetis/ --with-metis-dir=/home/hector/installed/parmetis/ --with-zoltan-dir=/home/hector/installed/zoltan/ --with-hypre-dir=/home/hector/installed/hypre --download-ptscotch --with-blaslapack-lib="[/home/hector/installed/intel/compilers_and_libraries_2019.0.046/linux/mkl/lib/intel64/libmkl_intel_lp64.a,/home/hector/installed/intel/compilers_and_libraries_2019.0.046/linux/mkl/lib/intel64/libmkl_core.a,/home/hector/installed/intel/compilers_and_libraries_2019.0.046/linux/mkl/lib/intel64/libmkl_intel_thread.a]" --with-scalapack-include=/home/hector/installed/intel/compilers_and_libraries_2019.0.046/linux/mkl/include --with-scalapack-lib="[/home/hector/installed/intel/compilers_and_libraries_2019.0.046/linux/mkl/lib/intel64/libmkl_scalapack_lp64.a,/home/hector/installed/intel/compilers_and_libraries_2019.0.046/linux/mkl/lib/intel64/libmkl_blacs_intelmpi_lp64.a]" --with-shared-libraries=0 --FC_LINKER_FLAGS="-qopenmp -qopenmp-link static" --FFLAGS="-qopenmp -qopenmp-link static" --LIBS="-Wl,--start-group /home/hector/installed/intel/compilers_and_libraries_2019.0.046/linux/mkl/lib/intel64/libmkl_intel_lp64.a /home/hector/installed/intel/compilers_and_libraries_2019.0.046/linux/mkl/lib/intel64/libmkl_core.a /home/hector/installed/intel/compilers_and_libraries_2019.0.046/linux/mkl/lib/intel64/libmkl_intel_thread.a -Wl,--end-group -liomp5 -ldl -lpthread -lm"
[0]PETSC ERROR: #305869 MatILUFactorSymbolic_SeqBAIJ() line 369 in /home/hector/dwnld_prog/petsc/src/mat/impls/baij/seq/baijfact2.c
[0]PETSC ERROR: #305870 MatILUFactorSymbolic() line 6522 in /home/hector/dwnld_prog/petsc/src/mat/interface/matrix.c
[0]PETSC ERROR: #305871 PCSetUp_ILU() line 144 in /home/hector/dwnld_prog/petsc/src/ksp/pc/impls/factor/ilu/ilu.c
[0]PETSC ERROR: #305872 PCSetUp() line 923 in /home/hector/dwnld_prog/petsc/src/ksp/pc/interface/precon.c
[0]PETSC ERROR: #305873 KSPSetUp() line 381 in /home/hector/dwnld_prog/petsc/src/ksp/ksp/interface/itfunc.c
[0]PETSC ERROR: #305874 KSPSolve() line 612 in /home/hector/dwnld_prog/petsc/src/ksp/ksp/interface/itfunc.c


What could be the problem?

Thanks for your help,

Hector



On 05/22/2018 06:28 PM, Jed Brown wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">Hector E Barrios Molano <a class="moz-txt-link-rfc2396E" href="mailto:hectorb@utexas.edu"><hectorb@utexas.edu></a>
 writes:


</pre>
          <blockquote type="cite">
            <pre wrap="">Hi PETSc Experts!

I am updating a Fortran code that use PETSc 3.7 to version 3.9.2 (from 
git repository).

Such code declares:

Mat mat

and used it as an integer, for example, to assign an initial value and 
test it to know if the matrix has been created by PETSc.

data mat/-1/
if (mat .eq. -1) then

</pre>
          </blockquote>
          <pre wrap="">You can use PETSC_NULL_MAT


</pre>
          <blockquote type="cite">
            <pre wrap="">With the new PETSc Fortran modules the compiler complains about this and 
stops.

Is there a better way to achieve this? So that I do not have to set an 
predefined value to Mat type to test if it was already created by PETSc?

If not, Is there a way to access the value in mat?
Looking at the source code type(tMat) has "v" variable, so could I used 
as mat%v?

</pre>
          </blockquote>
          <pre wrap="">Please no.

</pre>
        </blockquote>
        <pre wrap="">
</pre>
      </blockquote>
      <pre wrap="">
</pre>
    </blockquote>
    <br>
  </body>
</html>