[petsc-users] compilation of fortran program that uses petsc hangs

Ruyter de Wildt, Martijn de M.d.Ruyterd-Wildt at marin.nl
Wed Jul 8 06:29:08 CDT 2026


Hello Matt,

Compiling it with a PETSc makefile works fine, so the problem only occurs when CMake is used. The CMake version that I used  is 3.31.6 and I just tried the newest version, 4.3.4. With that version of CMake compilation succeeds, so it is the combination of the new PETSc version and an older CMake version that caused the problem.

Thank you for your reply!

Regards,

Martijn



dr. Martijn de Ruyter de Wildt | senior software engineer
Research & Development | CFD Development
T +31 317 49 35 60 | M +31 639 27 86 06  | M.d.Ruyterd-Wildt at marin.nl | https://urldefense.us/v3/__http://www.marin.nl__;!!G_uCfscf7eWS!Z6NmTuPaMO0B2_bhydh8Nog8Dx8V6qAut_xID62kyr7UzeqznH2m3S5WXHh_dYOegfc30fQqJPGeSa3eSukuS0pxtnxytNXUmQ$ 
From: Matthew Knepley <knepley at gmail.com>
Sent: 07 July 2026 11:51
To: Ruyter de Wildt, Martijn de <M.d.Ruyterd-Wildt at marin.nl>
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] compilation of fortran program that uses petsc hangs

You don't often get email from knepley at gmail.com<mailto:knepley at gmail.com>. Learn why this is important<https://urldefense.us/v3/__https://aka.ms/LearnAboutSenderIdentification__;!!G_uCfscf7eWS!Z6NmTuPaMO0B2_bhydh8Nog8Dx8V6qAut_xID62kyr7UzeqznH2m3S5WXHh_dYOegfc30fQqJPGeSa3eSukuS0pxtnw7HHlgsg$ >
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<mailto: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
[cid:image001.png at 01DD0ED0.9AB0FE20]
​​​​
dr.
Martijn
 de Ruyter de Wildt
 |
senior software engineer
Research & Development
 |
CFD Development
T +31 317 49 35 60<tel:+31%20317%2049%2035%2060>
 |
M +31 639 27 86 06<tel:+31%20639%2027%2086%2006>
 |
M.d.Ruyterd-Wildt at marin.nl<mailto:M.d.Ruyterd-Wildt at marin.nl>
 |
https://urldefense.us/v3/__http://www.marin.nl__;!!G_uCfscf7eWS!Z6NmTuPaMO0B2_bhydh8Nog8Dx8V6qAut_xID62kyr7UzeqznH2m3S5WXHh_dYOegfc30fQqJPGeSa3eSukuS0pxtnxytNXUmQ$ <https://urldefense.us/v3/__https:/www.marin.nl/__;!!G_uCfscf7eWS!Y6BnHJQKe2DGuqnJjk_yE1OUk7XUP-Nmg8aBT0f4h7TGV2qF_Bkf3Sf6n3XP-EKNVytXBEMbq9UBedSMcYjI1ZJXwTKjZltOog$>
[Facebook]<https://urldefense.us/v3/__https:/www.facebook.com/marin.wageningen__;!!G_uCfscf7eWS!Y6BnHJQKe2DGuqnJjk_yE1OUk7XUP-Nmg8aBT0f4h7TGV2qF_Bkf3Sf6n3XP-EKNVytXBEMbq9UBedSMcYjI1ZJXwTJ5Iles-Q$>
[LinkedIn]<https://urldefense.us/v3/__https:/www.linkedin.com/company/marin__;!!G_uCfscf7eWS!Y6BnHJQKe2DGuqnJjk_yE1OUk7XUP-Nmg8aBT0f4h7TGV2qF_Bkf3Sf6n3XP-EKNVytXBEMbq9UBedSMcYjI1ZJXwTKqWw4bhg$>
[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!Z6NmTuPaMO0B2_bhydh8Nog8Dx8V6qAut_xID62kyr7UzeqznH2m3S5WXHh_dYOegfc30fQqJPGeSa3eSukuS0pxtnzIrjO8cg$ <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Z6NmTuPaMO0B2_bhydh8Nog8Dx8V6qAut_xID62kyr7UzeqznH2m3S5WXHh_dYOegfc30fQqJPGeSa3eSukuS0pxtnyoY53ufA$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260708/f997e83b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 5004 bytes
Desc: image001.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260708/f997e83b/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 487 bytes
Desc: image002.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260708/f997e83b/attachment-0009.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 504 bytes
Desc: image003.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260708/f997e83b/attachment-0010.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 482 bytes
Desc: image004.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260708/f997e83b/attachment-0011.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image043759.png
Type: image/png
Size: 5004 bytes
Desc: image043759.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260708/f997e83b/attachment-0012.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image647984.png
Type: image/png
Size: 487 bytes
Desc: image647984.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260708/f997e83b/attachment-0013.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image432138.png
Type: image/png
Size: 504 bytes
Desc: image432138.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260708/f997e83b/attachment-0014.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image832842.png
Type: image/png
Size: 482 bytes
Desc: image832842.png
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260708/f997e83b/attachment-0015.png>


More information about the petsc-users mailing list