[petsc-users] fortran TYPE IS statement vs petsc index set IS
Barry Smith
bsmith at petsc.dev
Sun Jan 26 18:11:53 CST 2025
Sorry for the delay in responding.
The easiest way is to simply skip the #include "petsc/finclude/petscksp.h" and use type(tIS) instead of IS.
Explanation: the #include "petsc/finclude/petscksp.h" defines a few macros to make the current PETSc Fortran API look like the old PETSc API. For example
#define IS type(tIS)
Barry
> On Jan 23, 2025, at 3:16 AM, Klaij, Christiaan via petsc-users <petsc-users at mcs.anl.gov> wrote:
>
> In fortran I'm using the following structure to check the type of
> an incoming variable:
>
> SELECT TYPE (myvar)
> TYPE IS (mytype)
> ...
> END SELECT
>
> Here IS is a fortan intrinsic, so far so good. However, when I
> add a petsc index set as follows
>
> #include "petsc/finclude/petscksp.h"
>
> use petscksp, only: tIS
>
> IS :: myIS
>
> the compiler gets confused and thinks that the intrinsic fortran
> IS is the petsc index set IS, and errors-out on the SELECT
> TYPE:
>
> error #8245: SELECT TYPE statement must be immediately followed by CLASS IS, TYPE IS, CLASS DEFAULT or END SELECT statement.
> SELECT TYPE (myvar)
> ----^
> error #6410: This name has not been declared as an array or a function. [TYPE]
> TYPE type(tIS) (mytype)
> ---------^
> compilation aborted
>
> What would be the right way to deal with this problem?
> <image870949.png>
> dr. ir.
> Christiaan
> Klaij
> |
> Senior Researcher
> |
> Research & Development
> T +31 317 49 33 44 <tel:+31%20317%2049%2033%2044>
> |
> C.Klaij at marin.nl <mailto:C.Klaij at marin.nl>
> | https://urldefense.us/v3/__http://www.marin.nl__;!!G_uCfscf7eWS!YHMEsXfJ-XNk5b6HgivxkchNuwt2FjCj_pmjkzHYlkXw1xWEKDDXrJx9_kU4X76OwINhpeSRGozWLg-nNI4YirE$ <https://urldefense.us/v3/__https://www.marin.nl/__;!!G_uCfscf7eWS!ci7RiI8WEqh81becsu6CMRqmK1It91JWMStWzWcFLARdy0n8d2WiqmINXWd-0992Ex6wcTfqupvy9nnMVdrITEk$>
> <image753651.png> <https://urldefense.us/v3/__https://www.facebook.com/marin.wageningen__;!!G_uCfscf7eWS!ci7RiI8WEqh81becsu6CMRqmK1It91JWMStWzWcFLARdy0n8d2WiqmINXWd-0992Ex6wcTfqupvy9nnMJEayozg$>
> <image316694.png> <https://urldefense.us/v3/__https://www.linkedin.com/company/marin__;!!G_uCfscf7eWS!ci7RiI8WEqh81becsu6CMRqmK1It91JWMStWzWcFLARdy0n8d2WiqmINXWd-0992Ex6wcTfqupvy9nnMHWYJziY$>
> <image966725.png> <https://urldefense.us/v3/__https://www.youtube.com/marinmultimedia__;!!G_uCfscf7eWS!ci7RiI8WEqh81becsu6CMRqmK1It91JWMStWzWcFLARdy0n8d2WiqmINXWd-0992Ex6wcTfqupvy9nnMGp7QgsM$>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250126/89c746cf/attachment.html>
More information about the petsc-users
mailing list