[petsc-users] compilation of fortran program that uses petsc hangs
Matthew Knepley
knepley at gmail.com
Tue Jul 7 04:51:01 CDT 2026
This sounds like a CMake bug. Have you tried to compile it with a PETSc
makefile?
ex16f: ex1f.o
${FLINKER} -o $@ $^ ${PETSC_LIB}
include ${PETSC_DIR}/lib/petsc/conf/variables
include ${PETSC_DIR}/lib/petsc/conf/rules
THanks,
Matt
On Tue, Jul 7, 2026 at 5:01 AM Ruyter de Wildt, Martijn de via petsc-users <
petsc-users at mcs.anl.gov> wrote:
> Good morning,
>
> When I try to compile a fortran program that uses petsc, the make command
> hangs and I can only stop it by killing the make process. I could not find
> any information about this problem and hope that you can shed some light on
> it.
>
>
> I can reproduce the problem with one of the examples that is included in
> the PETSc installation. To do this, I used the following steps:
>
> - export PETSC_DIR=[PETSC_INSTALL_DIR]
> - export PETSC_ARCH=
> - mkdir -p test_petsc/build
> - cp
> [PETSC_INSTALL_DIR]/share/petsc/examples/src/sys/tutorials/ex16f.F90
> test_petsc
> - cp [PETSC_INSTALL_DIR]/share/petsc/CMakeLists.txt test_petsc
> - in CMakeLists.txt, I replaced all ‘ex1’ with ’ex16f’ and all ‘.c’
> with ‘F.90’.
> - cd test_petsc/build
> - cmake ..
> - make VERBOSE=1
>
> The last command hangs after showing “Scanning dependencies of target
> test”.
>
>
>
> Environment:
>
> - HPC with Rocky Linux 9.7
> - PETSc version 3.25.3, compiled from source using cmake
> - mpi implementation: Intel 2021.16
> - compiler: fortran Intel 2025.2.0 ifx
> - CMake version 3.31.6
>
> Other remarks:
>
> - the problem did not occur when we still used an older version of
> PETSc, version 3.22.4 (without any changes in environment and/or build
> process)
> - I can build the c version of the same file, ex16.c, without any
> problems and delay
> - the problem seems to occur only when a .h file that depends on
> petscys.h is included in the fortran file (so also petscmath.h,
> petscerror.h, petscviever.h, etc.)
> - it seems that the process gets stuck in an endless loop while
> scanning dependencies
> - the actual fortran preprocessor:
> ifx -I[PETSC_INSTALL_DIR]/include -E ../ex16f.F90 > test.i
> does not hang and completes immediately
> - the problem does not occur for PETSC 3.22.4 but it does occur for
> versions 3.24.6 and later
> - with cmake 3.26.5 and 3.29.1 the problem also occurs
>
>
>
> Kind regards,
>
> Martijn de Ruyter de Wildt
>
> dr. Martijn de Ruyter de Wildt | senior software engineer
> Research & Development | CFD Development
> T +31 317 49 35 60 <+31%20317%2049%2035%2060> | M +31 639 27 86 06
> <+31%20639%2027%2086%2006> | M.d.Ruyterd-Wildt at marin.nl |
> https://urldefense.us/v3/__http://www.marin.nl__;!!G_uCfscf7eWS!brMoHqimX0QQzqaqMTure-piAukXMcU21sZ9r_KZO1INSP5cUhGsekzMKwy8htu8RvCMnk7J6ewR59Ut0RAL$
> <https://urldefense.us/v3/__https://www.marin.nl/__;!!G_uCfscf7eWS!Y6BnHJQKe2DGuqnJjk_yE1OUk7XUP-Nmg8aBT0f4h7TGV2qF_Bkf3Sf6n3XP-EKNVytXBEMbq9UBedSMcYjI1ZJXwTKjZltOog$>
> [image: Facebook]
> <https://urldefense.us/v3/__https://www.facebook.com/marin.wageningen__;!!G_uCfscf7eWS!Y6BnHJQKe2DGuqnJjk_yE1OUk7XUP-Nmg8aBT0f4h7TGV2qF_Bkf3Sf6n3XP-EKNVytXBEMbq9UBedSMcYjI1ZJXwTJ5Iles-Q$>
> [image: LinkedIn]
> <https://urldefense.us/v3/__https://www.linkedin.com/company/marin__;!!G_uCfscf7eWS!Y6BnHJQKe2DGuqnJjk_yE1OUk7XUP-Nmg8aBT0f4h7TGV2qF_Bkf3Sf6n3XP-EKNVytXBEMbq9UBedSMcYjI1ZJXwTKqWw4bhg$>
> [image: YouTube]
> <https://urldefense.us/v3/__https://www.youtube.com/marinmultimedia__;!!G_uCfscf7eWS!Y6BnHJQKe2DGuqnJjk_yE1OUk7XUP-Nmg8aBT0f4h7TGV2qF_Bkf3Sf6n3XP-EKNVytXBEMbq9UBedSMcYjI1ZJXwTK1JKYAGw$>
>
--
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://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!brMoHqimX0QQzqaqMTure-piAukXMcU21sZ9r_KZO1INSP5cUhGsekzMKwy8htu8RvCMnk7J6ewR589NOq8X$ <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!brMoHqimX0QQzqaqMTure-piAukXMcU21sZ9r_KZO1INSP5cUhGsekzMKwy8htu8RvCMnk7J6ewR5yfcc1pd$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260707/e1ec863f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image919862.png
Type: image/png
Size: 5004 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260707/e1ec863f/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image584880.png
Type: image/png
Size: 487 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260707/e1ec863f/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image383088.png
Type: image/png
Size: 504 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260707/e1ec863f/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image837199.png
Type: image/png
Size: 482 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260707/e1ec863f/attachment-0007.png>
More information about the petsc-users
mailing list