<div dir="ltr"><div class="gmail_default" style="font-size:large">Hi Satish and Barry,</div><div class="gmail_default" style="font-size:large"><br></div><div class="gmail_default" style="font-size:large">Thanks very much for the feedback !</div><div class="gmail_default" style="font-size:large"><br></div><div class="gmail_default" style="font-size:large">It looks like my include file path was not correct ! </div><div class="gmail_default" style="font-size:large"><br></div><div class="gmail_default" style="font-size:large">Bests,</div><div class="gmail_default" style="font-size:large">Jianbo</div><div class="gmail_default" style="font-size:large"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 4, 2022 at 6:08 AM Satish Balay <<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">For ex83f.F90:<br>
<br>
>>>>><br>
balay@p1 /home/balay/test<br>
$ ls<br>
ex83f.F90<br>
balay@p1 /home/balay/test<br>
$ ls<br>
ex83f.F90<br>
balay@p1 /home/balay/test<br>
$ export PETSC_DIR=$HOME/petsc<br>
balay@p1 /home/balay/test<br>
$ cp $PETSC_DIR/src/ksp/ksp/tests/makefile .<br>
balay@p1 /home/balay/test<br>
$ make ex83f<br>
mpif90 -fPIC -Wall -ffree-line-length-none -ffree-line-length-0 -Wno-lto-type-mismatch -Wno-unused-dummy-argument -g -O0 -I/home/balay/petsc/include -I/home/balay/petsc/arch-linux-c-debug/include ex83f.F90 -Wl,-rpath,/home/balay/petsc/arch-linux-c-debug/lib -L/home/balay/petsc/arch-linux-c-debug/lib -Wl,-rpath,/home/balay/soft/mpich-4.0.1/lib -L/home/balay/soft/mpich-4.0.1/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/12 -L/usr/lib/gcc/x86_64-redhat-linux/12 -lpetsc -llapack -lblas -lm -lX11 -lstdc++ -ldl -lmpifort -lmpi -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lstdc++ -ldl -o ex83f<br>
balay@p1 /home/balay/test<br>
$ <br>
<<<<<<<br>
<br>
Also when you are adding PETSc to your current project - are you using source files with .f or .f90 suffix? If so rename them to .F or .F90 suffix.<br>
<br>
If you still have issues send more details - As Barry indicated - the makefile [with the sources compiled by this makefile] - and the compile log when you attempt to build these sources with this makefile.<br>
<br>
Satish<br>
<br>
On Thu, 3 Nov 2022, Barry Smith wrote:<br>
<br>
> <br>
> Please send your attempted makefile and we'll see if we can get it working.<br>
> <br>
> I am not sure if we can organize the include files as Fortran compiler include files easily. We've always used the preprocessor approach. The Intel compiler docs indicate the procedure for finding the Fortran compiler include files <a href="https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/program-structure/use-include-files.html" rel="noreferrer" target="_blank">https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/program-structure/use-include-files.html</a> is the same as for the preprocessor include files so I don't understand how the using the Fortran compiler include file approach would make the makefiles any simpler for users?<br>
> <br>
> <br>
> Barry<br>
> <br>
> <br>
> > On Nov 3, 2022, at 8:58 PM, Jianbo Long <<a href="mailto:longtuteng249@gmail.com" target="_blank">longtuteng249@gmail.com</a>> wrote:<br>
> > <br>
> > Hello,<br>
> > <br>
> > I'm struggling to make my FORTRAN code work with petsc as I cannot link the required header files (e.g., petscksp.h) and compiled library files to my FORTRAN code. <br>
> > <br>
> > Compiling petsc was not a problem. However, even with the fortran examples (see those on <a href="https://petsc.org/main/docs/manual/fortran/" rel="noreferrer" target="_blank">https://petsc.org/main/docs/manual/fortran/</a>) and the guide on using petsc in c++ and fortran codes (see Section "Writing C/C++ or Fortran Applications" at <a href="https://petsc.org/main/docs/manual/getting_started/" rel="noreferrer" target="_blank">https://petsc.org/main/docs/manual/getting_started/</a>), I still cannot make my FORTRAN code work. <br>
> > <br>
> > The Fortran test code is exactly the example code ex83f.F90 (see attached files). Aftering following the 2nd method in the Guide (see the picture below), I still get errors:<br>
> > <br>
> > petsc/finclude/petscksp.h: No such file or directory<br>
> > <br>
> > Even if I set up the path of the header file correctly in my own makefile without using environment variables, I still can only find the file "petscksp.h" for my code. Of course, the trouble is that all other headers files required by KSP are recursively included in this petscksp.h file, and I have no way to link them together for my Fortran code. <br>
> > <br>
> > So, here are my questions:<br>
> > 1) in the Guide, how exactly are we supposed to set up the environment variables PETSC_DIR and PETSC_ARCH ? More details and examples would be extremely helpful !<br>
> > 2) Is there a way to get rid of the preprocessor statement <br>
> > #include <petsc/finclude/petscvec.h><br>
> > when using c++/Fortran codes ?<br>
> > <br>
> > For example, when using MUMPS package in a Fortran code, we can simply use compiler 'include', rather than a preprocessor, to extract all required variables for the user's codes :<br>
> > INCLUDE 'zmumps_struc.h'<br>
> > where the header file zmumps_struc.h is already provided in the package. Similarly, I think it's much more portable and easier when using petsc in other codes if we can make it work to use petsc. <br>
> > <br>
> > (Note: similar issues were discussed before, see <a href="https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2019-January/037499.html" rel="noreferrer" target="_blank">https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2019-January/037499.html</a>. Unfortunately, I have no clue about the solution archived there ...)<br>
> > <br>
> > Any thoughts and solutions would be much appreciated !<br>
> > <br>
> > Thanks,<br>
> > Jianbo Long<br>
> > <br>
> > <image.png><br>
> > <ex83f.F90><br>
> <br>
> <br>
<br>
</blockquote></div>