attaching fixed files.

$ make test
mpif90 -c -fPIC -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -g    
-I/home/balay/tmp/petsc/include 
-I/home/balay/tmp/petsc/arch-linux2-c-debug/include    -o my_module.o 
my_module.F90
mpif90 -c -fPIC -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -g    
-I/home/balay/tmp/petsc/include 
-I/home/balay/tmp/petsc/arch-linux2-c-debug/include    -o test.o test.F90
mpif90 -fPIC -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -g   -o test 
test.o my_module.o -Wl,-rpath,/home/balay/tmp/petsc/arch-linux2-c-debug/lib 
-L/home/balay/tmp/petsc/arch-linux2-c-debug/lib 
-Wl,-rpath,/home/balay/soft/mpich-3.3a2/lib -L/home/balay/soft/mpich-3.3a2/lib 
-Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/7 
-L/usr/lib/gcc/x86_64-redhat-linux/7 -lpetsc -llapack -lblas -lX11 -lpthread 
-lm -lmpifort -lgfortran -lm -lgfortran -lm -lquadmath -lmpicxx -lstdc++ -lm 
-Wl,-rpath,/home/balay/soft/mpich-3.3a2/lib -L/home/balay/soft/mpich-3.3a2/lib 
-Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/7 
-L/usr/lib/gcc/x86_64-redhat-linux/7 -ldl 
-Wl,-rpath,/home/balay/soft/mpich-3.3a2/lib -lmpi -lgcc_s -ldl 
$

Satish

On Wed, 14 Jun 2017, Fabien Tholin wrote:

> Hello,
> 
> I am a beginner with Petsc and i'm trying
> 
> to compile a very simple fortran program "test" with
> 
> a calling program in "test.F90" and a module "my_module.F90".
> 
> Unfortunately, i do not know how to write properly the makefile
> 
> to be able to compile the module with "#include petsc" statements inside:
> 
> I can not find any example on how to do it.
> 
> here is my non-working makefile:
> 
> 
> CFLAGS         =
> FFLAGS         =
> PETSC_DIR=/home/fab/Program/PETSC/petsc-3.7.6
> PETSC_ARCH=arch-linux2-c-debug
> FLINKER=mpif90
> CLINKER=mpicc
> 
> include ${PETSC_DIR}/lib/petsc/conf/variables
> include ${PETSC_DIR}/lib/petsc/conf/rules
> 
> list=my_module.o
> 
> test: test.o $(list) chkopts
>     -${FLINKER} -o test test.o  $(list)
> 
> my_module.o my_module.mod: my_module.F90
>     -${FLINKER} -c my_module.F90
> 
> 
> Thank you very much for helping me.
> 
> Regards,
> 
> Fabien THOLIN
> 
CFLAGS           =
FFLAGS           =

include ${PETSC_DIR}/lib/petsc/conf/variables
include ${PETSC_DIR}/lib/petsc/conf/rules

list = test.o my_module.o
test.o:my_module.o

test: ${list} chkopts
        -${FLINKER} -o test ${list} ${PETSC_LIB}
module my_module

implicit none
!!#include <petsc/finclude/petsc.h90>
#include <petsc/finclude/petscsysdef.h> 
#include <petsc/finclude/petscvecdef.h>
#include <petsc/finclude/petscmatdef.h>    
#include <petsc/finclude/petscpcdef.h>
#include <petsc/finclude/petsckspdef.h>    

contains

subroutine toto
implicit none
integer :: i

i=1

end subroutine toto

end module my_module
program test

use my_module
implicit none
#include <petsc/finclude/petsc.h90>

PetscInt :: j = 2
                                      
print *, 'j = ', j

end program test

Reply via email to