[petsc-users] Compilation error with ifort: invalid return statement in main
Jose E. Roman
jroman at dsic.upv.es
Sun Nov 19 06:12:41 CST 2017
> El 19 nov 2017, a las 13:08, Matthew Knepley <knepley at gmail.com> escribió:
>
> On Sun, Nov 19, 2017 at 4:43 AM, Jose E. Roman <jroman at dsic.upv.es> wrote:
>
> > El 19 nov 2017, a las 10:16, Praveen C <cpraveen at gmail.com> escribió:
> >
> > Dear all
> >
> > In the main program, if I have a line like
> >
> > call PetscInitialize('param.in', ierr); CHKERRQ(ierr)
> >
> > compiling with mpifort gives
> >
> > main.f95(17): error #6353: A RETURN statement is invalid in the main program.
> > call PetscInitialize('param.in', ierr); if (ierr .ne. 0) then ; call PetscErrorF(ierr); return; endif
> > —————————————————————————————————————————————^
> >
> > It compiles fine with gfortran. What can I do for the ifort case ?
> >
> > Thanks
> > praveen
>
> Use CHKERRA(ierr) in the main program and CHKERRQ(ierr) in the subroutines.
>
> On the other hand, you should not use CHKERRA(ierr) after PetscInitialize
>
> Do you mean after PetscFinalize()? You should not call any PETSc functions after this.
I mean to check the error code returned by PetscInitialize().
In C examples it is done this way
ierr = PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
instead of with CHKERRQ.
>
> Thanks,
>
> Matt
>
> because it assumes that MPI has been correctly initialized.
>
> Jose
>
>
>
>
> --
> 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://www.cse.buffalo.edu/~knepley/
More information about the petsc-users
mailing list