<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi all,</p>
<p style="margin-top:0;margin-bottom:0">I wrote a petsc code, and I defined my variables in a separate file, namely common.h, and common.c as following</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">common.h:</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>
<blockquote>extern int i;<br>
extern int n;</blockquote>
</div>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">common.c:<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>
<blockquote>#include <petsc.h><br>
#include "common.h<br>
PetscScalar i; // Define i and initialize<br>
PetscScalar n; // Define n and initialize<br>
i=2.2;<br>
n=3.5;</blockquote>
</div>
Now in my prog.c code I have:
<p></p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>
<blockquote>#include <petsc.h><br>
#include <common.h><br>
static char help[]="program main";<br>
int main (int argc, char **argv){<br>
PetscInitialize(&argc,&argv, (char*) 0,help);<br>
PetscPrintf(PETSC_COMM_WORLD,"i=%f!\n",a);<br>
PetscPrintf(PETSC_COMM_WORLD,"n=%f!\n",b) ;<br>
PetscFinalize();<br>
}<br>
<br>
</blockquote>
if my it was not using petsc and it was a normal c code, I could run it using the following command:</div>
<div> gcc prog. c common.c</div>
<div>but now that I am using petsc, I do not know how should I include common.c in my makefile.</div>
<div>my makefile looks like this:</div>
<div><br>
</div>
<div>
<div>
<blockquote>include ${PETSC_DIR}/lib/petsc/conf/variables<br>
include ${PETSC_DIR}/lib/petsc/conf/rules<br>
prog: prog.o chkopts<br>
<blockquote>-${CLINKER} -o prog.out prog.o ${PETSC_LIB} <br>
</blockquote>
<blockquote>${RM} *.o<br>
</blockquote>
</blockquote>
</div>
<div>
<blockquote>.PHONY: distclean rune_1 test<br>
distclean:<br>
<blockquote>@rm -f *~ prog<br>
</blockquote>
</blockquote>
Thanks,</div>
<div>Sepideh<br>
</div>
<br>
</div>
<div><br>
</div>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
</div>
</body>
</html>