[petsc-users] Compiling Fortran Code

Matthew Knepley knepley at gmail.com
Wed Mar 13 19:31:17 CDT 2019


On Wed, Mar 13, 2019 at 7:36 PM Maahi Talukder via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Dear All,
>
> I am trying to compile a Fortran code. The make is as it follows-
>
>
> ............................................................................................................................................................................................................................
> # Makefile for egrid2d
>
> OBJS = main.o egrid2d.o
>
> FFLAGS = -I/home/maahi/petsc/include
> -I/home/maahi/petsc/arch-linux2-c-debug/include -Ofast -fdefault-real-8
>
> #
> # link
> #
> include ${PETSC_DIR}/lib/petsc/conf/variables
> include ${PETSC_DIR}/lib/petsc/conf/rules
>
> egrid2d: $(OBJS)
>
> ${FLINKER}  $(OBJS)  -o egrid2d ${PETSC_LIB}
>

Move this above your includes


>
> #
> # compile
> #
> main.o:
>    ${FLINKER} -c $(FFLAGS) main.f  ${PETSC_LIB}
>

You should not need this rule.

  Thanks,

    Matt


> #
> # Common and Parameter Dependencies
> #
>
> main.o:        main.f        par2d.f
> egrid2d.o:     egrid2d.f     par2d.f
>
> .....................................................................................................................................................................................................................................
>
> But I get the following error-
>
>
> ..............................................................................................................................................................................
> /home/maahi/petsc/arch-linux2-c-debug/bin/mpif90 -Wall
> -ffree-line-length-0 -Wno-unused-dummy-argument -g
> -I/home/maahi/petsc/include -I/home/maahi/petsc/arch-linux2-c-debug/include
> -Ofast -fdefault-real-8      -o egrid2d
> -Wl,-rpath,/home/maahi/petsc/arch-linux2-c-debug/lib
> -L/home/maahi/petsc/arch-linux2-c-debug/lib
> -Wl,-rpath,/home/maahi/petsc/arch-linux2-c-debug/lib
> -L/home/maahi/petsc/arch-linux2-c-debug/lib
> -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/7
> -L/usr/lib/gcc/x86_64-redhat-linux/7 -lpetsc -lflapack -lfblas -lm
> -lpthread -lstdc++ -ldl -lmpifort -lmpi -lgfortran -lm -lgfortran -lm
> -lgcc_s -lquadmath -lstdc++ -ldl
> /*usr/lib/gcc/x86_64-redhat-linux/7/../../../../lib64/crt1.o: In function
> `_start':*
> *(.text+0x20): undefined reference to `main'*
> collect2: error: ld returned 1 exit status
> make: *** [makefile:18: egrid2d] Error 1
>
> ........................................................................................................................................
>
> Any idea how to fix it ?
>
> Thanks,
> Maahi Talukder
>
>
>
>

-- 
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/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190313/8e19e946/attachment.html>


More information about the petsc-users mailing list