<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div>    Search through all your code looking for calls to VecGetArray()/VecRestoreArray(). For all uses where you only need to read from the array, replace<div>the calls with VecGetArrayRead()/VecRestoreArrayRead().  And add the const modifier to the array declaration.</div><div><br></div><div><br><div><br><blockquote type="cite"><div>On Jun 24, 2023, at 5:32 AM, Paweł Stebliński <psteb@bobolin.com.pl> wrote:</div><br class="Apple-interchange-newline"><div>
  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  
  <div><p>Welcome</p><p>If library nr 3.17.5 is compiled  --with-debuging=yes there
      apears an error. This exception is not thrown, and all system
      seems to work well when one compiles --with-debugging=no.</p><p>------ Error Message
      --------------------------------------------------------------<br>
      [79]PETSC ERROR: Object is in wrong state<br>
      [79]PETSC ERROR:  Vec is already locked for read-only or
      read/write access, argument # 1<br>
      [79]PETSC ERROR: See <a class="moz-txt-link-freetext" href="https://petsc.org/release/faq/">https://petsc.org/release/faq/</a> for trouble
      shooting.<br>
      [79]PETSC ERROR: Petsc Release Version 3.17.5, Sep 30, 2022 <br>
      [79]PETSC ERROR:
      /home/psteb/PRACA/KODY/SYMETRYLLBINTERTWOMODELS_NEW3.9/src/magpar.exe
      on a PETSc-config-magpar named magmain-1 by root Sat Jun 24
      11:18:46 2023<br>
      [79]PETSC ERROR: Configure options --with-precision=double
      --download-fblaslapack=1 --with-avx512-kernels=1
      --with-mpi-dir=/home/psteb/PRACA/LIB_NEW3.9/../LIB_NEW/mpi
      --with-x=0 --with-clanguage=C++ --with-debugging=yes
      PETSC_ARCH=PETSc-config-magpar<br>
      [79]PETSC ERROR: #1 VecSetErrorIfLocked() at
      /home/psteb/PRACA/LIB_NEW3.9/petsc-3.17.5.DEBUG/include/petscvec.h:618<br>
      [79]PETSC ERROR: #2 VecGetArray() at
/home/psteb/PRACA/LIB_NEW3.9/petsc-3.17.5.DEBUG/src/vec/vec/interface/rvector0e+00  
      0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00  
      0.000000e+00<br>
        9.930000e-04   0.000000e+00   3.110177e+00   0.000000e+00  
      2.353828e-45   0.000000e+00   0.000000e+00   0.000000e+00  
      3.000000e+02   0.000000e+00   0.000000e+00   0.000000e+00  
      0.000000e+00   0.000000e+00  -7.952733e-40   0.000000e+00  
      0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00  
      0.000000e+00<br>
        9.940000e-04   0.000000e+00   3.110177e+00   0.000000e+00  
      1.558555e-45   0.000000e+00   0.000000e+00   0.000000e+00  
      3.000000e+02   0.000000e+00   0.000000e+00   0.000000e+00  
      0.000000e+00   0.000000e+00  -5.271514e-40   0.000000e+00  
      0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00  
      0.000000e+00<br>
        9.950000e-04   0.000000e+00   3.110177e+00   0.000000e+00  
      1.031404e-45   0.000000e+00   0.000000e+00   0.000000e+00  
      3.000000e+02   0.000000e+00   0.000000e+00   0.000000e+00  
      0.000000e+00   0.000000e+00  -3.492309e-40   0.000000e+00  
      0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00  
      0.000000e+00]PETSC ERROR: #3 JAC3() at
/home/psteb/PRACA/KODY/SYMETRYLLBINTERTWOMODELS_NEW3.9/src/llb/countmeq.c:161<br>
      [0]PETSC ERROR: #4 TaoComputeJacobian() at
/home/psteb/PRACA/LIB_NEW3.9/petsc-3.17.5.DEBUG/src/tao/interface/taosolver_hj.c:316<br>
      [0]PETSC ERROR: #5 Tao_SSLS_FunctionGradient() at
/home/psteb/PRACA/LIB_NEW3.9/petsc-3.17.5.DEBUG/src/tao/complementarity/impls/ssls/ssls.c:51<br>
      [0]PETSC ERROR: #6 TaoLineSearchComputeObjectiveAndGradient() at
/home/psteb/PRACA/LIB_NEW3.9/petsc-3.17.5.DEBUG/src/tao/linesearch/interface/taolinesearch.c:938<br>
      [0]PETSC ERROR: #7 TaoSolve_SSILS() at
/home/psteb/PRACA/LIB_NEW3.9/petsc-3.17.5.DEBUG/src/tao/complementarity/impls/ssls/ssils.c:54<br>
      [0]PETSC ERROR: #8 TaoSolve() at
/home/psteb/PRACA/LIB_NEW3.9/petsc-3.17.5.DEBUG/src/tao/interface/taosolver.c:136<br>
      [0]PETSC ERROR: #9 createMeq() at
/home/psteb/PRACA/KODY/SYMETRYLLBINTERTWOMODELS_NEW3.9/src/llb/countmeq.c:259<br>
      [0]PETSC ERROR: #10 countMeq() at
/home/psteb/PRACA/KODY/SYMETRYLLBINTERTWOMODELS_NEW3.9/src/llb/countmeq.c:296<br>
      [0]PETSC ERRO[server]: PMIU_parse_keyvals: unexpected key
      delimiter at character 48 in cmd<br>
      <br>
    </p><p>For petsc nr from 3.19.2 to 3.18.0 for options</p><p>--with-debugging=1 --with-cflags='-g -O0'   --with-cxxflags='-g
      -O0' --with-fflags='-g -O0'</p><p>or <br>
    </p><p>without these options, during execution<br>
    </p><p>There is an error:</p><p>[6]PETSC ERROR: --------------------- Error Message
      --------------------------------------------------------------<br>
      [6]PETSC ERROR: Object is in wrong state<br>
      [6]PETSC ERROR: Not for unassembled vector, did you call
      VecAssemblyBegin()/VecAssemblyEnd()?<br>
      [6]PETSC ERROR: WARNING! There are option(s) set that were not
      used! Could be the program crashed before they were used or a
      spelling mistake, etc!<br>
      [6]PETSC ERROR:   Option left: name:-addcalorics value: 0 source:
      command line<br>
      [6]PETSC ERROR:   Option left: name:-addhtomeq value: 0 source:
      command line<br>
      [6]PETSC ERROR:   Option left: name:-addjtog value: 0 source:
      command line<br>
      [6]PETSC ERROR:   Option left: name:-addterm value: 0 source:
      command line<br>
      [6]PETSC ERROR:   Option left: name:-condinp_j value: 1e99 source:
      file<br>
      [6]PETSC ERROR:   Option left: name:-condinp_t value: 1e-4 source:
      command line<br>
      [6]PETSC ERROR:   Option left: name:-countG value: 0 source:
      command line<br>
      [6]PETSC ERROR:   Option left: name:-countN value: 0 source: file<br>
      [6]PETSC ERROR:   Option lef[8]PETSC ERROR: ---------------------
      Error Message
      --------------------------------------------------------------<br>
    </p><p><br>
    </p><div><br class="webkit-block-placeholder"></div><p><br>
    </p>
    <div class="moz-cite-prefix">W dniu 23.06.2023 o 23:41, Barry Smith
      pisze:<br>
    </div>
    <blockquote type="cite" cite="mid:ACE3B0C6-BAA1-4CE4-857A-21A4AC65F667@petsc.dev">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div><br>
      </div>
        Could you send us the exact error output that occurs? Cut and
      paste the run command and the entire error message.
      <div><br>
      </div>
      <div>   Also send the configure options you used. Have you tried
        configuring the later PETSc versions with all optimization
        turned off; use --with-debugging=1 --with-cflags='-g -O0'  
        --with-cxxflags='-g -O0' --with-fflags='-g -O0'  Does the same
        error occur?</div>
      <div><br>
      </div>
      <div>  Barry</div>
      <div><br>
        <div><br>
        </div>
        <div><br>
          <div><br>
            <blockquote type="cite">
              <div>On Jun 23, 2023, at 5:30 PM, Paweł Stebliński via
                petsc-users <a class="moz-txt-link-rfc2396E" href="mailto:petsc-users@mcs.anl.gov"><petsc-users@mcs.anl.gov></a> wrote:</div>
              <br class="Apple-interchange-newline">
              <div>
                <meta http-equiv="content-type" content="text/html;
                  charset=UTF-8">
                <div><p>I am micromagnetic (MAGPAR) software developer. Old
                    Magpar version has been using petsc 3.1-p8. I have
                    decided to upgrade to petsc 3.19.2 with avx512
                    support. <span class="Y2IQFc" lang="en">Unfortunately
                      there appeared an error during software testing.
                      Error appeares in ranning code after proper
                      compiling and linking. The bug is in a code part
                      which initializes matrix in petsc library
                      versions: 3.19.2, 3.19.1, 3.19.0 and also from
                      3.18.5 to 3.18.0. If we use petsc version 3.17.5
                      the error doesn't appear. With this version
                      (3.17.5) all is ok and simulation is running
                      without any errors or throwing exceptions. My
                      guess is linked to avx512 implementation which is
                      good up to 3.17.5 version and buggy in upper
                      mentioned versions with higher numbers. Avx512 is
                      buggy according to tested SeqAij matrices.</span></p><p><span class="Y2IQFc" lang="en">The exception is not
                      thrown if we comment code fragment below.<br>
                    </span></p><p><span class="Y2IQFc" lang="en">ierr =
                      MatCreateSeqAIJ(<br>
                          PETSC_COMM_SELF,<br>
                          nvert,nvert,<br>
                          0,ia,<br>
                          &mat<br>
                        );CHKERRQ(ierr);<br>
                        ierr = MatSetFromOptions(mat);CHKERRQ(ierr);</span></p><p><span class="Y2IQFc" lang="en">ia - is number of
                      nonzeros array which is obtained according
                      parmetis partitioning. There were the same version
                      of parmetis  (3.1.1) in the all considered cases.<br>
                    </span></p>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
  </div>

</div></blockquote></div><br></div></body></html>