I apologize in advance if this is somewhat redundant, I have reviewed the other posts that reference the use of Metis with Fortran code. Also I am very much a noobie, so please use small words and say them slow! :p
I am trying to us Metis 5.1.0 to partition a mesh in a fortran code I have written. I am wondering about the basics of compiling fortran code with calls to c libraries? How do I do that? Is that done at compile time or do I need some sort of include statement in the code? Currently when I try to compile I have the following relevant snippets:
The top of the program ( do I even need to have an include or use statement?)
PROGRAM ONEDGRIDGEN
IMPLICIT NONE
!include 'meshpart.c'
!use 'meshpart.c'
The makefile (in which I am sure there are errors)
CC = gcc
FC = gfortran
FCFLAG1 = -g -fbacktrace -ffree-line-length-0 -fdefault-real-8
FCFLAG2 =
CCFLAG =
OBJ = 1Dgridgen_Mod
OBJ2 = meshpart
1Dgridgen: ${OBJ}.f95
${FC} -o ${OBJ} ${OBJ}.f95 ${OBJ2}.c ${FCFLAG1}
The subroutine relevant to call the metis partitioning (using direct calling)
SUBROUTINE METIS_CALL(ne,nn,eptr,eind)
use iso_c_binding
IMPLICIT NONE
integer(c_int),INTENT(IN):: ne,nn
integer(c_int)::nparts,objval,ncommon
integer(c_int),dimension(0:((nn)*2-1)),INTENT(IN)::eind
integer(c_int),dimension(nn),INTENT(IN)::eptr
integer(c_int),dimension(:),allocatable::epart,npart
integer,pointer::vwgt=>null(), vsize=>null(), options=>null()
real(kind=8),pointer::tpwgts=>null()
ALLOCATE(epart(ne),npart(nn))
ncommon = 1
write(*,*) 'How many domains do you wish to have?'
read(*,*) nparts
CALL METIS_PartMeshDual(ne,nn,eptr,eind,vwgt,vsize,ncommon,nparts,tpwgts,options,objval,epart,npart)
write(*,*) 'epart', epart
write(*,*) 'npart', npart
END SUBROUTINE METIS_CALL
When I try to compile I get the following error
gfortran -o 1Dgridgen_Mod 1Dgridgen_Mod.f95 meshpart.c -g -fbacktrace -ffree-line-length-0 -fdefault-real-8
cc1: warning: command line option "-fbacktrace" is valid for Fortran but not for C
cc1: warning: command line option "-ffree-line-length-0" is valid for Fortran but not for C
cc1: warning: command line option "-fdefault-real-8" is valid for Fortran but not for C
In file included from meshpart.c:15:
metislib.h:17:19: error: GKlib.h: No such file or directory
metislib.h:24:19: error: metis.h: No such file or directory
metislib.h:25:20: error: rename.h: No such file or directory
metislib.h:26:24: error: gklib_defs.h: No such file or directory
metislib.h:28:18: error: defs.h: No such file or directory
metislib.h:29:20: error: struct.h: No such file or directory
metislib.h:30:20: error: macros.h: No such file or directory
metislib.h:31:19: error: proto.h: No such file or directory
meshpart.c:22: error: expected ')' before '*' token
meshpart.c:90: error: expected ')' before '*' token
meshpart.c:179: error: expected ')' before 'nrows'
make: *** [1Dgridgen] Error 1
I can see that my make file is wrong, but I'm wondering why when I reference the c library I need from metis why it gives me errors for the c library, when my code and everything 'lives' in the same folder as the metis library meshpart.c. Would metis installed properly not have it's libraries and necessary components linked or referenced properly?
Thanks for any help anyone can offer!! And once again thanks for you patience I understand this is a pretty basic question.