Thanks Mark. It dawned on me to Gemini my problem just after I posted it. I switched to .F90 and the problem resolved itself. 
-sanjay

Sent from my iPhone

On May 8, 2026, at 4:52 AM, Mark Adams <[email protected]> wrote:


Result from (cut and paste into) Claude: 

## Diagnosis

The compile error is caused by **fixed-form Fortran line truncation at column 72**. Your file `parstop.F` uses the `.F` extension, which tells `gfortran` to use **fixed-form** parsing (72-column limit by default).

In PETSc 3.25, the [`PetscObjectIsNull`](include/petsc/finclude/petscsysbase.h:132) macro expanded significantly. It is now defined as:

```fortran
#define PetscObjectIsNull(obj) (obj%v == 0 .or. obj%v == PETSC_FORTRAN_TYPE_INITIALIZE .or. obj%v == -3)
```

When the preprocessor expands `PetscObjectIsNull(Mdiag)`, the resulting line is far longer than 72 characters and gets truncated mid-_expression_, producing the syntax error. The compiler warnings confirm this:

```
parstop.F:64:72:
Warning: Line truncated at (1) [-Wline-truncation]
```

## Solution: Rename `.F` to `.F90`

**Rename `parstop.F` → `parstop.F90`** (and do the same for any other `.F` files that use `PetscObjectIsNull`).

Your code is already written in free-form Fortran style (`!` comments, `::` declarations, `implicit none`), so the `.F` extension is misleading. The `.F90` extension will:

1. Invoke the C preprocessor (uppercase `F` is preserved)
2. Use **free-form** parsing (132-column default limit)
3. Work with your existing `-ffree-line-length-none` flag, which removes the line length limit entirely

This is the cleanest fix and requires no code changes — only a file rename.

### Alternative: Keep `.F` and add a compiler flag

If renaming is not feasible, add `-ffixed-line-length-none` to your `mpif90` flags to remove the 72-column truncation for fixed-form files.

On Thu, May 7, 2026 at 6:26 PM Sanjay Govindjee via petsc-users <[email protected]> wrote:
I am trying to update our code to petsc 3.25.1.  We were previously on 3.22.4.  I am running into a compile error that I can not understand.  I went through the release notes but can not see what is wrong.  Any suggestions will be appreciated.

-sanjay

/Users/sg/petsc/gnu/bin/mpif90 -o parstop.o -c -fPIC -Wall -ffree-line-length-none -ffree-line-length-0 -Wno-lto-type-mismatch -Wno-unused-dummy-argument -g -O   -I/Users/sg/petsc/include -I/Users/sg/petsc/gnu/include -I/opt/X11/include -I/Users/sg/Feap/ver87/include -I/Users/sg/Feap/ver87/modules -I/usr/local/include -J/Users/sg/Feap/ver87/modules       parstop.F
parstop.F:64:72:

   64 |       if(.not.PetscObjectIsNull(Mdiag)) then
      |                                                                        1
Warning: Line truncated at (1) [-Wline-truncation]
parstop.F:64:70:

   64 |       if(.not.PetscObjectIsNull(Mdiag)) then
      |                                                                      1
Error: Syntax error in IF-clause after (1)
parstop.F:66:9:

   66 |       endif
      |         1
Error: Expecting END SUBROUTINE statement at (1)
parstop.F:68:72:

   68 |       if(.not.PetscObjectIsNull(Msqrt)) then
      |                                                                        1
Warning: Line truncated at (1) [-Wline-truncation]
parstop.F:68:70:

   68 |       if(.not.PetscObjectIsNull(Msqrt)) then
      |                                                                      1
Error: Syntax error in IF-clause after (1)
parstop.F:70:9:

   70 |       endif
      |         1
Error: Expecting END SUBROUTINE statement at (1)

The subroutine is super simple:

#     include   <petsc/finclude/petscksp.h>
      use                       petscksp
      use                       pfeapc
      implicit   none

#     include   "pfeapb.h"

      PetscErrorCode ierr

      logical     :: eflag

      save

!     Close out PETSc matrices
      if(.not.PetscObjectIsNull(Kmat)) then
        call MatDestroy(Kmat, ierr)
      endif

      if(.not.PetscObjectIsNull(Pmat)) then
        call MatDestroy(Pmat, ierr)
      endif

      if(.not.PetscObjectIsNull(Mmat)) then
        call MatDestroy(Mmat, ierr)
      endif

      if(pfeap_dstr) then
        call KSPDestroy(kspsol, ierr)
      endif

!     Close out PETSc vectors
      if(.not.PetscObjectIsNull(Mdiag)) then
        call VecDestroy(Mdiag, ierr)
      endif

      if(.not.PetscObjectIsNull(Msqrt)) then
        call VecDestroy(Msqrt, ierr)
      endif

The custom module pfeapc contains the objects:

      module pfeapc
#     include   <petsc/finclude/petscksp.h>
      use                       petscksp
      implicit none

      Vec          :: rhs, sol, xvec
      Vec          :: yvec, zvec
      Vec          :: Mdiag, Msqrt
      Mat          :: Kmat, Mmat, Pmat
      KSP          :: kspsol
      end module pfeapc



------

Reply via email to