[petsc-users] Warning and Error in Makefile

Ivan Luthfi ivanluthfi5 at gmail.com
Thu Jul 18 02:07:34 CDT 2024


Hi friend,

I get many warning (but its ok for the warning). However I didnt get the
result of my code when i compile it, is there any possible mistake in my
makefile? can you please help me?

The attached file is my error and warning (error in makefile line 27) , and
the makefile .


Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240718/e4a1beb5/attachment.html>
-------------- next part --------------
MsFEM_poisson2D_DMDA.c: In function ‘int main(int, char**)’:
MsFEM_poisson2D_DMDA.c:184:48: warning: variable ‘finest’ set but not used [-Wunused-but-set-variable]
  184 |                         PetscInt mg_level = 2, finest;
      |                                                ^~~~~~
MsFEM_poisson2D_DMDA.c:55:44: warning: variable ‘pi’ set but not used [-Wunused-but-set-variable]
   55 |         PetscScalar             a,b,c,d,dt,pi;
      |                                            ^~
MsFEM_poisson2D_DMDA.c:56:35: warning: variable ‘Lx’ set but not used [-Wunused-but-set-variable]
   56 |         PetscInt                M,Lx,Ly,Nx,Ny,Mx,My;
      |                                   ^~
MsFEM_poisson2D_DMDA.c:56:38: warning: variable ‘Ly’ set but not used [-Wunused-but-set-variable]
   56 |         PetscInt                M,Lx,Ly,Nx,Ny,Mx,My;
      |                                      ^~
MsFEM_poisson2D_DMDA.c:57:33: warning: variable ‘hx’ set but not used [-Wunused-but-set-variable]
   57 |         PetscScalar             hx,hy,Hx,Hy;
      |                                 ^~
MsFEM_poisson2D_DMDA.c:57:36: warning: variable ‘hy’ set but not used [-Wunused-but-set-variable]
   57 |         PetscScalar             hx,hy,Hx,Hy;
      |                                    ^~
MsFEM_poisson2D_DMDA.c:57:39: warning: variable ‘Hx’ set but not used [-Wunused-but-set-variable]
   57 |         PetscScalar             hx,hy,Hx,Hy;
      |                                       ^~
MsFEM_poisson2D_DMDA.c:57:42: warning: variable ‘Hy’ set but not used [-Wunused-but-set-variable]
   57 |         PetscScalar             hx,hy,Hx,Hy;
      |                                          ^~
MsFEM_poisson2D_DMDA.c:59:58: warning: variable ‘Nondimensionalization’ set but not used [-Wunused-but-set-variable]
   59 |         PetscInt                Compute_finegridsolution,Nondimensionalization;
      |                                                          ^~~~~~~~~~~~~~~~~~~~~
MsFEM_poisson2D_DMDA.c:282:54: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow=]
  282 |                                 sprintf(filename,"%sc%d_N%dM%d_Bf.log",up.problem_description,up.problem_flag,up.Nx,up.Mx);
      |                                                      ^~
MsFEM_poisson2D_DMDA.c:282:40: note: ‘sprintf’ output between 15 and 144 bytes into a destination of size 100
  282 |                                 sprintf(filename,"%sc%d_N%dM%d_Bf.log",up.problem_description,up.problem_flag,up.Nx,up.Mx);
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MsFEM_poisson2D_DMDA.c:288:55: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow=]
  288 |                                 sprintf(filename, "%sc%d_Nx%dNy%dMx%dMy%d_Bf.log",up.problem_description,up.problem_flag,up.Nx,up.Ny,up.Mx,up.My);
      |                                                       ^~
MsFEM_poisson2D_DMDA.c:288:40: note: ‘sprintf’ output between 23 and 172 bytes into a destination of size 100
  288 |                                 sprintf(filename, "%sc%d_Nx%dNy%dMx%dMy%d_Bf.log",up.problem_description,up.problem_flag,up.Nx,up.Ny,up.Mx,up.My);
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MsFEM_poisson2D_DMDA.c:286:55: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow=]
  286 |                                 sprintf(filename, "%sc%d_Nx%dNy%dM%d_Bf.log",up.problem_description,up.problem_flag,up.Nx,up.Ny,up.Mx);
      |                                                       ^~
MsFEM_poisson2D_DMDA.c:286:40: note: ‘sprintf’ output between 19 and 158 bytes into a destination of size 100
  286 |                                 sprintf(filename, "%sc%d_Nx%dNy%dM%d_Bf.log",up.problem_description,up.problem_flag,up.Nx,up.Ny,up.Mx);
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MsFEM_poisson2D_DMDA.c:284:54: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow=]
  284 |                                 sprintf(filename,"%sc%d_N%dMx%dMy%d_Bf.log",up.problem_description,up.problem_flag,up.Nx,up.Mx,up.My);
      |                                                      ^~
MsFEM_poisson2D_DMDA.c:284:40: note: ‘sprintf’ output between 19 and 158 bytes into a destination of size 100
  284 |                                 sprintf(filename,"%sc%d_N%dMx%dMy%d_Bf.log",up.problem_description,up.problem_flag,up.Nx,up.Mx,up.My);
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MsFEM_poisson2D_DMDA.c:302:54: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow=]
  302 |                                 sprintf(filename,"%sc%d_N%dM%d_final_xf.log",up.problem_description,up.problem_flag,up.Nx,up.Mx);
      |                                                      ^~
MsFEM_poisson2D_DMDA.c:302:40: note: ‘sprintf’ output between 21 and 150 bytes into a destination of size 100
  302 |                                 sprintf(filename,"%sc%d_N%dM%d_final_xf.log",up.problem_description,up.problem_flag,up.Nx,up.Mx);
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MsFEM_poisson2D_DMDA.c:308:54: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow=]
  308 |                                 sprintf(filename,"%sc%d_Nx%dNy%dMx%dMy%d_final_xf.log",up.problem_description,up.problem_flag,up.Nx,up.Ny,up.Mx,up.My);
      |                                                      ^~
MsFEM_poisson2D_DMDA.c:308:40: note: ‘sprintf’ output between 29 and 178 bytes into a destination of size 100
  308 |                                 sprintf(filename,"%sc%d_Nx%dNy%dMx%dMy%d_final_xf.log",up.problem_description,up.problem_flag,up.Nx,up.Ny,up.Mx,up.My);
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MsFEM_poisson2D_DMDA.c:306:54: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow=]
  306 |                                 sprintf(filename,"%sc%d_Nx%dNy%dM%d_final_xf.log",up.problem_description,up.problem_flag,up.Nx,up.Ny,up.Mx);
      |                                                      ^~
MsFEM_poisson2D_DMDA.c:306:40: note: ‘sprintf’ output between 25 and 164 bytes into a destination of size 100
  306 |                                 sprintf(filename,"%sc%d_Nx%dNy%dM%d_final_xf.log",up.problem_description,up.problem_flag,up.Nx,up.Ny,up.Mx);
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MsFEM_poisson2D_DMDA.c:304:54: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow=]
  304 |                                 sprintf(filename,"%sc%d_N%dMx%dMy%d_final_xf.log",up.problem_description,up.problem_flag,up.Nx,up.Mx,up.My);
      |                                                      ^~
MsFEM_poisson2D_DMDA.c:304:40: note: ‘sprintf’ output between 25 and 164 bytes into a destination of size 100
  304 |                                 sprintf(filename,"%sc%d_N%dMx%dMy%d_final_xf.log",up.problem_description,up.problem_flag,up.Nx,up.Mx,up.My);
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc4ILnLc.o: in function `main':
/home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:69: undefined reference to `SetUserParameter(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:93: undefined reference to `CreateComputeTools(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:102: undefined reference to `ComputeExactsolution(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:120: undefined reference to `MsFEMCreate(MsFEM*, _p_DM*, _p_DM*, _p_IS*, _p_IS*, double, double, double, double, int)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:121: undefined reference to `MsFEMSetFromOptions(MsFEM*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:122: undefined reference to `MsFEMSetOperators(MsFEM*, _p_Mat*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:124: undefined reference to `MsFEMSolve(MsFEM, _p_Vec*, _p_Vec*, _p_Vec*, _p_Vec**, _p_Vec*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:125: undefined reference to `MsFEMSolve(MsFEM, _p_Vec*, _p_Vec*, _p_Vec*, _p_Vec**, _p_Vec*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:129: undefined reference to `MsFEMSolve(MsFEM, _p_Vec*, _p_Vec*, _p_Vec*, _p_Vec**, _p_Vec*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:130: undefined reference to `MsFEMSolve(MsFEM, _p_Vec*, _p_Vec*, _p_Vec*, _p_Vec**, _p_Vec*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:132: undefined reference to `MsFEMDestroy(MsFEM*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:259: undefined reference to `PCContextCreate_MsFEM(_p_KSP*, _p_DM*, _p_DM*, _p_IS*, _p_IS*, double, double, double, double, int)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:317: undefined reference to `DestroyBoundary(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:320: undefined reference to `ComputeMassMatrix(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:322: undefined reference to `ConstructInitialCondition(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:324: undefined reference to `ConstructOperator(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:325: undefined reference to `SetMatrixBoundaryCondition(_p_Mat**, _p_DM*, _p_IS*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:339: undefined reference to `MsFEMCreate(MsFEM*, _p_DM*, _p_DM*, _p_IS*, _p_IS*, double, double, double, double, int)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:340: undefined reference to `MsFEMSetFromOptions(MsFEM*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:341: undefined reference to `MsFEMSetOperators(MsFEM*, _p_Mat*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:353: undefined reference to `DestroyBoundary(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:361: undefined reference to `ConstrctBoundary(UserParameter*, _p_IS**, _p_Vec**, int, int)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:362: undefined reference to `ConstrctBoundary(UserParameter*, _p_IS**, _p_Vec**, int, int)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:363: undefined reference to `ComputeBf(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:367: undefined reference to `ConstructRHS(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:368: undefined reference to `SetVectorBoundaryCondition(_p_Vec**, _p_DM*, _p_IS*, _p_Vec*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:379: undefined reference to `SetVectorBoundaryCondition(_p_Vec**, _p_DM*, _p_IS*, _p_Vec*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:383: undefined reference to `MsFEMSolve(MsFEM, _p_Vec*, _p_Vec*, _p_Vec*, _p_Vec**, _p_Vec*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:387: undefined reference to `DestroyBoundary(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:391: undefined reference to `MsFEMDestroy(MsFEM*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:464: undefined reference to `DestroyComputeTools(UserParameter*)'
/usr/bin/ld: /tmp/cc4ILnLc.o: in function `FormMatrix(UserParameter*)':
/home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:488: undefined reference to `LoadPermeabilityFile(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:490: undefined reference to `ConstrctBoundary(UserParameter*, _p_IS**, _p_Vec**, int, int)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:491: undefined reference to `ConstrctBoundary(UserParameter*, _p_IS**, _p_Vec**, int, int)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:495: undefined reference to `ComputeStiffMatrix(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:507: undefined reference to `SetMatrixBoundaryCondition(_p_Mat**, _p_DM*, _p_IS*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:515: undefined reference to `ComputeBf(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:516: undefined reference to `SetVectorBoundaryCondition(_p_Vec**, _p_DM*, _p_IS*, _p_Vec*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:518: undefined reference to `SetVectorBoundaryCondition(_p_Vec**, _p_DM*, _p_IS*, _p_Vec*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:522: undefined reference to `ComputeFinegridsolution(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:524: undefined reference to `SetInitialGuess(UserParameter*)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:525: undefined reference to `SetVectorBoundaryCondition(_p_Vec**, _p_DM*, _p_IS*, _p_Vec*)'
/usr/bin/ld: /tmp/cc4ILnLc.o: in function `PrintRE(UserParameter*, int*)':
/home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:543: undefined reference to `Com_Residual(UserParameter*, _p_Vec**)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:545: undefined reference to `Com_Error(UserParameter*, _p_Vec**)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:546: undefined reference to `Com_Error(UserParameter*, _p_Vec**)'
/usr/bin/ld: /home/ivan/MsFEMbub/MsFEM_poisson2D_DMDA.c:550: undefined reference to `Com_Error(UserParameter*, _p_Vec**)'
collect2: error: ld returned 1 exit status
make: *** [makefile:27: MsFEM_poisson2D_DMDA.o] Error 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makefile
Type: application/octet-stream
Size: 1900 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240718/e4a1beb5/attachment.obj>


More information about the petsc-users mailing list