[petsc-users] Problems with fortran subroutine DMDAVecGetArrayF90
Smith, Barry F.
bsmith at mcs.anl.gov
Fri Oct 26 20:33:11 CDT 2018
In the two fortran examples that use this construct
src/ksp/ksp/examples/tutorials/ex22f.F90 and ex45f.F90
the JJ and jac matrix are the same object so only one of them needs to have values set.
In general (for KSP and SNES) either
1) the JJ and jac matrices are the same object
or
2) the JJ is a matrix-free operator (obtained for example with -snes_mf_operator) so doesn't need to have its values set but just needs to know the current location that the Jacobian is computed at which is set with the code:
if ( A .ne. B) then
call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)
endif
Note: that if you want JJ and jac to be two regular matrices with different numerical values (for example JJ is 4th order discretization and jac is 2nd order) then you are correct the one must set values (different of course) into each of the matrices.
Barry
> On Oct 26, 2018, at 9:22 PM, SONG Pengyang <Peterspy at outlook.com> wrote:
>
> Thanks Barry.
> Another question is about subroutine ComputeMatrix(ksp,JJ,jac,ctx,ierr), which is called by KSPSetComputeOperators(ksp,ComputeMatrix,ctx,ierr).
> In the tutorials, it seems that Mat JJ, the linear operator, is not assigned in ComputeMatrix. Only Mat jac, which supposed to be preconditioning matrix, is set. I am confused with this part. Why is the linear operator used without being set?
> Looking forward to your reply.
> Regards,
> Pengyang
> ----------------------------------------------------------------
> Pengyang Song(宋朋洋)
> MSc candidate in Physical Oceanography
> College of Oceanic and Atmospheric Sciences
> Ocean University of China
> No. 238 Songling Road, Qingdao 266100, Shandong, China
> TEL: (+86) 15762264643
>
> -----邮件原件-----
> 发件人: Smith, Barry F. <bsmith at mcs.anl.gov>
> 发送时间: 2018年10月27日 9:02
> 收件人: SONG Pengyang <Peterspy at outlook.com>
> 抄送: petsc-users at mcs.anl.gov
> 主题: Re: [petsc-users] Problems with fortran subroutine DMDAVecGetArrayF90
>
>
> You are calling the routine incorrectly. Take a look at usage in src/dm/examples/tutorials/ex11f90.F90
>
> Barry
>
>
>> On Oct 26, 2018, at 5:16 AM, SONG Pengyang <Peterspy at outlook.com> wrote:
>>
>> Hi all,
>> I am trying to change a KSP tutorial code ex34.c to ex34f.F90. I found that after I changed DMDAVecGetArray to DMDAVecGetArrayF90, and DMDAVecRestoreArray to DMDAVecRestoreArrayF90. Compilation errors say that there is no matching specific subroutine for this generic subroutine call. Can anyone help me with the problem?
>> The error massage is listed below and the fortran code is also attached. Many thanks.
>>
>> ex34f.F90(83): error #6285: There is no matching specific subroutine for this generic subroutine call. [DMDAVECGETARRAYF90]
>> call DMDAVecGetArrayF90(x,array,ierr) -----------^
>> ex34f.F90(91): error #6285: There is no matching specific subroutine for this generic subroutine call. [DMDAVECRESTOREARRAYF90]
>> call DMDAVecRestoreArrayF90(x,array,ierr)
>> -----------^
>> compilation aborted for ex34f.F90 (code 1)
>>
>> ----------------------------------------------------------------
>> Pengyang Song(宋朋洋)
>> MSc candidate in Physical Oceanography College of Oceanic and
>> Atmospheric Sciences Ocean University of China No. 238 Songling Road,
>> Qingdao 266100, Shandong, China
>> TEL: (+86) 15762264643
>>
>> <ex34f.F90>
>
More information about the petsc-users
mailing list