[petsc-users] MatSetValue in Fortran
Yann Jobic
yann.jobic at univ-amu.fr
Wed Feb 9 11:16:12 CST 2022
Many thanks Barry !
It solved my problem, and my original question !!
I'm creating the matrix myself. On this projet, I'm begining to move the
ddl to the associated DMPlex datas, allowing much more possibilities.
But it's not done yet.
Sorry for messing up the threads of the list with my replied error.
Thanks again,
Yann
Le 2/9/2022 à 5:42 PM, Barry Smith a écrit :
>
> It is odd that the columns are not sorted
>
> row 125: (125, 0.) (107, 0.)
>
> How was this matrix created?
>
> It is erroring because it compares the 125 column in the matrix to the
> 107 column requested and concludes there is no slot for 107 column.
>
> Barry
>
>
>
>> On Feb 9, 2022, at 10:33 AM, Yann Jobic <yann.jobic at univ-amu.fr
>> <mailto:yann.jobic at univ-amu.fr>> wrote:
>>
>> I'm struggling for a very simple error that i can not see. I'm running
>> in a sequential program, for the test.
>>
>> MatView is giving me for the row 125 :
>> row 125: (125, 0.) (107, 0.)
>>
>> I'm getting those values with MatGetRow :
>> row=125
>> CALL MatGetRow(MATGLOB,row,nb,testcols,testvalues,IER)
>> write(*,*)row,testcols(1),testvalues(1),
>> & testcols(2),testvalues(2)
>> CALL MatRestoreRow(MATGLOB,row,nb,testcols,testvalues,IER)
>>
>> The output is :
>> 125 125 0.000000000000000E+000 107 0.000000000000000E+000
>> Which is what i want. It's ok.
>>
>> Then i'm doing the MatSetValue :
>> val = -1
>> row = 125
>> col = 107
>> CALL MatSetValue(MATGLOB,row,col,val,
>> & INSERT_VALUES, IER)
>>
>> And i've got the error :
>> [0]PETSC ERROR: --------------------- Error Message
>> --------------------------------------------------------------
>> [0]PETSC ERROR: Argument out of range
>> [0]PETSC ERROR: New nonzero at (125,107) caused a malloc
>> Use MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE) to
>> turn off this check
>> [0]PETSC ERROR: See https://petsc.org/release/faq/
>> <https://petsc.org/release/faq/> for trouble shooting.
>> [0]PETSC ERROR: Petsc Release Version 3.16.4, unknown
>> [0]PETSC ERROR:
>> /home/jobic/projet/fe-utils/marcus/3.16/test_MatSetValue_loem_3.16p4_openmpi_intel
>> on a named leto4.iusti-calcul.recherche by jobic Wed Feb 9 16:01:51 2022
>> [0]PETSC ERROR: Configure options
>> --prefix=/local/lib/petsc/3.16/p4/17/openmpi_intel-mkl-works
>> --with-single-library=0 --with-large-file-io=1 --with-debugging=0
>> --with-blacs=1
>> --with-blacs-dir=/opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/
>> --download-scalapack=1 --download-parmetis=1 --download-make=1
>> --download-mumps=1 --LIBS="
>> -Wl,-rpath,/opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/"
>> --with-blaslapack-dir=/opt/intel/compilers_and_libraries_2017.1.132/linux/compiler/lib/intel64/
>> --download-metis=1 --download-parmetis=1 --download-ptscotch=1
>> --download-cmake=1 --download-slepc=1 --download-hdf5=1 --with-zlib=1
>> --download-szlib=1 --download-suitesparse=1 --download-p4est=1
>> --download-netcdf=1 --download-triangle=1 --with-shared-libraries=0
>> --with-cxx-dialect=C++11 -CFLAGS=" -O3 -mtune=core-avx2 -mkl"
>> --COPTFLAGS="-D_POSIX_C_SOURCE=199309L" -CXXFLAGS=" -O3
>> -mtune=core-avx2 -mkl" -FFLAGS=" -O3 -mtune=core-avx2 -mkl"
>> PETSC_ARCH=openmpi_intel-mkl-17-works
>> [0]PETSC ERROR: #1 MatSetValues_SeqAIJ() at
>> /home/devel/src_linux/petsc-3.16.4/src/mat/impls/aij/seq/aij.c:520
>> [0]PETSC ERROR: #2 MatSetValues() at
>> /home/devel/src_linux/petsc-3.16.4/src/mat/interface/matrix.c:1398
>> [0]PETSC ERROR: #3 MatGetRow() at
>> /home/devel/src_linux/petsc-3.16.4/src/mat/interface/matrix.c:558
>> [0]PETSC ERROR: #4 MatRestoreRow_Fortran() at
>> /home/devel/src_linux/petsc-3.16.4/src/mat/interface/ftn-custom/zmatrixf.c:582
>>
>> I'm obviously doing something wrong, but where ?
>>
>> Thanks,
>>
>> Yann
>>
>> Le 2/9/2022 à 1:58 PM, Matthew Knepley a écrit :
>>> On Wed, Feb 9, 2022 at 7:24 AM Bruno Rammon Silva Souza via
>>> petsc-users <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov>
>>> <mailto:petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov>>> wrote:
>>> Hello everyone,
>>> I am using the LBFGS type in the SNES solver, and it's working fine.
>>> But I want to change the number of stored updates in this method.
>>> This variable of quasi-newton methods is usually chosen by the
>>> runtime option: -snes_qn_m <m>. However, I would like to change this
>>> variable inside my code, when calling a function, for example, but I
>>> can't find any kind of PETSc function that changes this variable
>>> directly. Is there any function like this? If not, is there some way
>>> to do that without using -snes_qn_m <m> at runtime?
>>> This is an oversight which we will fix. For now you can use
>>> https://petsc.org/main/docs/manualpages/Sys/PetscOptionsSetValue.html
>>> <https://petsc.org/main/docs/manualpages/Sys/PetscOptionsSetValue.html>
>>> <https://petsc.org/main/docs/manualpages/Sys/PetscOptionsSetValue.html <https://petsc.org/main/docs/manualpages/Sys/PetscOptionsSetValue.html>>
>>> in your code.
>>> Thanks,
>>> Matt
>>> Best regards,
>>> -- Bruno Souza
>>> --
>>> What most experimenters take for granted before they begin their
>>> experiments is infinitely more interesting than any results to which
>>> their experiments lead.
>>> -- Norbert Wiener
>>> https://www.cse.buffalo.edu/~knepley/
>>> <https://www.cse.buffalo.edu/~knepley/>
>>> <http://www.cse.buffalo.edu/~knepley/
>>> <http://www.cse.buffalo.edu/~knepley/>>
>
More information about the petsc-users
mailing list