<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">However, I changed the makefile,but I still received the following error: </p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div>HiDACX/obj/debug/optimal_mechanical_part.o</div>
<div>mpif90 -cpp -JHiDACX/obj/debug/ -Wall -fcheck=bounds -I/usr/local/include -I/Users/yaxiong/Downloads/petsc-3.9.4/include -c /Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_Petsc/Hidac_Fortran_Lib/HiDAC_Test/optimal_mechanical_part.F90 -o HiDACX/obj/debug/optimal_mechanical_part.o</div>
<div>/Users/yaxiong/Downloads/petsc-3.9.4/include/petsc/finclude/petscsys.h:13:2:</div>
<div><br>
</div>
<div> #if defined (PETSC_HAVE_MPIUNI)</div>
<div> 1~~~~~~~~~~~~</div>
<div>Fatal Error: petscconf.h: No such file or directory</div>
<div>compilation terminated.</div>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Yaxiong Chen<br>
<b>Sent:</b> Thursday, January 24, 2019 9:50 AM<br>
<b>To:</b> Matthew Knepley<br>
<b>Subject:</b> Re: [petsc-users]Integrate PETSC with existing Fortran</font>
<div> </div>
</div>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0">I see. This is because I have one .c file in the bunch of files. </p>
<p style="margin-top:0; margin-bottom:0">!==============================================================</p>
<p style="margin-top:0; margin-bottom:0"></p>
<div>$(OBJS_DIR)%.o:</div>
<div><span style="white-space:pre"></span>@mkdir -p $(OBJS_DIR)</div>
<div><span style="white-space:pre"></span>@echo $@</div>
<div><span style="white-space:pre"></span>$(if $(findstring .f90, $<), \</div>
<div><span style="white-space:pre"></span>$(FC) $(FCFLAGS) $(FIDIR) -c $< -o $@, \</div>
<div><span style="white-space:pre"></span>$(CC) $(CCFLAGS) $(CIDIR) -c $< -o $@)</div>
This command in makefile will use CC instead of FC since I change f90 to F90.
<p></p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Thanks</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><span style="color:rgb(33,33,33); font-size:13.3333330154419px">Yaxiong Chen, </span><br style="color:rgb(33,33,33); font-size:13.3333330154419px">
<span style="color:rgb(33,33,33); font-size:13.3333330154419px">Ph.D. Student </span><br style="color:rgb(33,33,33); font-size:13.3333330154419px">
<br style="color:rgb(33,33,33); font-size:13.3333330154419px">
<span style="font-size:13.3333330154419px"></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">School of Mechanical Engineering, 3171 </span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px"><span style="color:rgb(34,34,34); font-family:Roboto,arial,sans-serif; font-size:13px">585 Purdue Mall</span></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">West Lafayette, IN 47907</span></p>
<div><span style="font-size:13.3333px"><br>
</span></div>
<p></p>
<p><br style="color:rgb(33,33,33); font-size:13.3333330154419px">
<br>
</p>
</div>
</div>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matthew Knepley <knepley@gmail.com><br>
<b>Sent:</b> Thursday, January 24, 2019 5:54 AM<br>
<b>To:</b> Yaxiong Chen<br>
<b>Cc:</b> petsc-users@mcs.anl.gov<br>
<b>Subject:</b> Re: [petsc-users]Integrate PETSC with existing Fortran</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Wed, Jan 23, 2019 at 2:31 PM Yaxiong Chen <<a href="mailto:chen2018@purdue.edu" id="LPlnk66876" class="x_OWAAutoLink" previewremoved="true">chen2018@purdue.edu</a>> wrote:<br>
</div>
<div class="x_x_gmail_quote">
<blockquote class="x_x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px">Hi Matt, </p>
<p style="margin-top:0px; margin-bottom:0px"><span style="color:rgb(0,0,0)"> I changed</span><span style="font-family:Calibri,Helvetica,sans-serif,Helvetica,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px; color:rgb(0,0,0)"> </span><span style="font-size:16px; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">optimal_mechanical_</span><span style="font-size:16px; color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif"><span style="color:rgb(0,0,0)">part.f90
to </span><span style="font-family:Calibri,Helvetica,sans-serif,Helvetica,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px; color:rgb(0,0,0)"> </span><span style="font-size:16px; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">optimal_mechanical_</span><span style="font-size:16px; color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif"><span style="color:rgb(0,0,0)">part.</span><span style="color:rgb(0,0,0)">F</span><span style="color:rgb(0,0,0)">90.
But I still received the following error: </span></span></span></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:16px; color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif"><span style="font-size:16px; color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif"><span style="color:rgb(0,0,0)"></span></span></span></p>
<div>HiDACX/obj/debug/optimal_mechanical_part.o</div>
<div>mpicc -Dqh_QHpointer -ansi -Wall -I/usr/local/include/libqhull -c /Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_Petsc/Hidac_Fortran_Lib/HiDAC_Test/optimal_mechanical_part.F90 -o HiDACX/obj/debug/optimal_mechanical_part.o</div>
<div>error: invalid value 'f95-cpp-input' in '-x f95-cpp-input'</div>
<div>make[1]: *** [HiDACX/obj/debug/optimal_mechanical_part.o] Error 1</div>
<div>make: *** [debug] Error 2</div>
<br>
<p></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:16px; color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif"><span style="font-size:16px; color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif"><span style="color:rgb(0,0,0)">Is
there anything wrong with the flag?</span></span></span></p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>You are compiling a Fortran file with mpicc, instead of mpif90?</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote class="x_x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px">Thanks</p>
<p style="margin-top:0px; margin-bottom:0px"><br>
</p>
<div id="x_x_gmail-m_-1340540159560242287Signature">
<div id="x_x_gmail-m_-1340540159560242287divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><span style="color:rgb(33,33,33); font-size:13.3333px">Yaxiong Chen, </span><br style="color:rgb(33,33,33); font-size:13.3333px">
<span style="color:rgb(33,33,33); font-size:13.3333px">Ph.D. Student </span><br style="color:rgb(33,33,33); font-size:13.3333px">
<br style="color:rgb(33,33,33); font-size:13.3333px">
<span style="font-size:13.3333px"></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">School of Mechanical Engineering, 3171 </span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px"><span style="color:rgb(34,34,34); font-family:Roboto,arial,sans-serif; font-size:13px">585 Purdue Mall</span></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">West Lafayette, IN 47907</span></p>
<div><span style="font-size:13.3333px"><br>
</span></div>
<p></p>
<p><br style="color:rgb(33,33,33); font-size:13.3333px">
<br>
</p>
</div>
</div>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block; width:98%">
<div id="x_x_gmail-m_-1340540159560242287divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" id="LPlnk214259" class="x_OWAAutoLink" previewremoved="true">knepley@gmail.com</a>><br>
<b>Sent:</b> Wednesday, January 23, 2019 1:30 PM<br>
<b>To:</b> Yaxiong Chen<br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank" id="LPlnk502002" class="x_OWAAutoLink" previewremoved="true">
petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users]Integrate PETSC with existing Fortran</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Wed, Jan 23, 2019 at 1:27 PM Yaxiong Chen <<a href="mailto:chen2018@purdue.edu" id="LPlnk840817" class="x_x_gmail-m_-1340540159560242287OWAAutoLink x_OWAAutoLink" target="_blank" previewremoved="true">chen2018@purdue.edu</a>> wrote:<br>
</div>
<div class="x_x_gmail-m_-1340540159560242287x_gmail_quote">
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px">Hi Matt,</p>
<p style="margin-top:0px; margin-bottom:0px"><br>
</p>
<p style="margin-top:0px; margin-bottom:0px">I tried to modify the structure of present code and use KSP in the main program(<span style="font-family:Calibri,Helvetica,sans-serif,Helvetica,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">optimal_mechanical_part</span>).
Now the makefile is as following :</p>
<p style="margin-top:0px; margin-bottom:0px">#================================================================================</p>
<p style="margin-top:0px; margin-bottom:0px"></p>
<div>OUT_DIR := HiDACX/</div>
<div><br>
</div>
<div>## Define mode</div>
<div>ifndef MODE</div>
<div><br>
</div>
<div>.PHONY: debug release</div>
<div><br>
</div>
<div>debug: export MODE := debug</div>
<div>release: export MODE := release</div>
<div>debug release:</div>
<div><span style="white-space:pre-wrap"></span>@$(MAKE) $@</div>
<div><br>
</div>
<div>clean:</div>
<div><span style="white-space:pre-wrap"></span>rm -rf $(OUT_DIR)obj/ $(OUT_DIR)lib/ $(OUT_DIR)bin/</div>
<div><br>
</div>
<div>else</div>
<div><br>
</div>
<div>## SRCS = $(shell find ../../MyGit/Hidac_Fortran_Lib/ "*.f90")</div>
<div>SRCS_DIR := $(HOME)/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_Petsc/Hidac_Fortran_Lib/</div>
<div>FSRCS := \</div>
<div>HiDAC_Utils/HiDAC_parameter.f90 \</div>
<div>HiDAC_Utils/HiDAC_dataStructure.f90 \</div>
<div>HiDAC_Utils/HiDAC_Math/HiDAC_mathFunction.f90 \</div>
<div>HiDAC_Utils/HiDAC_Math/HiDAC_mathType.f90 \</div>
<div>HiDAC_Utils/HiDAC_Math/HiDAC_tensor.f90 \</div>
<div>HiDAC_Utils/HiDAC_Math/HiDAC_Math.f90 \</div>
<div>HiDAC_Utils/HiDAC_Port/HiDAC_IGES.f90 \</div>
<div>HiDAC_Utils/HiDAC_Port/IR_Precision.f90 \</div>
<div>HiDAC_Utils/HiDAC_Port/Lib_Pack_Data.f90 \</div>
<div>HiDAC_Utils/HiDAC_Port/Lib_Base64.f90 \</div>
<div>HiDAC_Utils/HiDAC_Port/Lib_VTK_IO.f90 \</div>
<div>HiDAC_Utils/HiDAC_Port/HiDAC_VTK.f90 \</div>
<div>HiDAC_Utils/HiDAC_Port/HiDAC_Port.f90 \</div>
<div>HiDAC_Utils/HiDAC_DistanceField/HiDAC_QhullInterface_F.f90 \</div>
<div>HiDAC_Utils/HiDAC_DistanceField/HiDAC_BezierHull.f90 \</div>
<div>HiDAC_Utils/HiDAC_DistanceField/HiDAC_DistanceField.f90 \</div>
<div>HiDAC_Utils/HiDAC_Utils.f90 \</div>
<div>HiDAC_Material/HiDAC_baseMat.f90 \</div>
<div>HiDAC_Material/HiDAC_isoElasticMat.f90 \</div>
<div>HiDAC_Material/HiDAC_thermoMat.f90 \</div>
<div>HiDAC_Material/HiDAC_Material.f90 \</div>
<div>HiDAC_Approximation/HiDAC_node.f90 \</div>
<div>HiDAC_Approximation/HiDAC_nodeNet.f90 \</div>
<div>HiDAC_Approximation/HiDAC_baseApproximation.f90 \</div>
<div>HiDAC_Approximation/HiDAC_Approximation.f90 \</div>
<div>HiDAC_Approximation/HiDAC_Approximation_NURBS/HiDAC_knot.f90 \</div>
<div>HiDAC_Approximation/HiDAC_Approximation_NURBS/HiDAC_BezierApproximation.f90 \</div>
<div>HiDAC_Approximation/HiDAC_Approximation_NURBS/HiDAC_NURBSApproximation.f90 \</div>
<div>HiDAC_Approximation/HiDAC_Approximation_NURBS/HiDAC_THBApproximation.f90 \</div>
<div>HiDAC_Domain/HiDAC_primitive.f90 \</div>
<div>HiDAC_Domain/HiDAC_enrichment.f90 \</div>
<div>HiDAC_Domain/HiDAC_composedDomain.f90 \</div>
<div>HiDAC_Domain/HiDAC_Domain.f90 \</div>
<div>HiDAC_Quadrature/HiDAC_quadType.f90 \</div>
<div>HiDAC_Quadrature/HiDAC_directQuadrature.f90 \</div>
<div>HiDAC_Quadrature/HiDAC_adaptiveQuadrature.f90 \</div>
<div>HiDAC_Quadrature/HiDAC_Quadrature.f90 \</div>
<div>HiDAC_Analysis/HiDAC_BC.f90 \</div>
<div>HiDAC_Analysis/HiDAC_baseAnalysis.f90 \</div>
<div>HiDAC_Analysis/HiDAC_elastostatics.f90<span style="white-space:pre-wrap"> </span>
\</div>
<div>HiDAC_Analysis/HiDAC_heatConduction.f90 \</div>
<div>HiDAC_Analysis/HiDAC_phaseTransition.f90 \</div>
<div>HiDAC_Analysis/HiDAC_fracture.f90 \</div>
<div>HiDAC_Analysis/HiDAC_lineenrich.f90 \</div>
<div>HiDAC_Analysis/HiDAC_sensitivityAnalysis.f90 \</div>
<div>HiDAC_Analysis/HiDAC_Analysis.f90 \</div>
<div>HiDAC_Solver/HiDAC_baseSolver.f90 \</div>
<div>HiDAC_Solver/HiDAC_LapackSolver.f90 \</div>
<div>HiDAC_Solver/HiDAC_MumpsSolver.f90 \</div>
<div>HiDAC_Solver/HiDAC_Solver.f90 \</div>
<div>IGES/read_iges_file.f90 \</div>
<div>IGES/nrb.f90 \</div>
<div>IGES/parse.f90 \</div>
<div>IGES/map.f90 \</div>
<div>DXF/dxf_reader.f90 \</div>
<div><br>
</div>
<div>TSRCS_DIR := $(SRCS_DIR)HiDAC_Test/</div>
<div><br>
</div>
<div>CSRCS := \</div>
<div>HiDAC_Utils/HiDAC_DistanceField/HiDAC_QhullInterface_C.c \</div>
<div><br>
</div>
<div>SRCS := $(addprefix $(SRCS_DIR), $(FSRCS) $(CSRCS))</div>
<div><br>
</div>
<div>OBJS_DIR := $(OUT_DIR)obj/$(MODE)/</div>
<div>LIB_DIR := $(OUT_DIR)lib/$(MODE)/</div>
<div>EXE_DIR := $(OUT_DIR)bin/$(MODE)/</div>
<div>EXT_DIR := /usr/local/</div>
<div><br>
</div>
<div>#petsc lib</div>
<div>include ${PETSC_DIR}/lib/petsc/conf/variables</div>
<div>include ${PETSC_DIR}/lib/petsc/conf/rules</div>
<div><br>
</div>
<div><br>
</div>
<div>#========================</div>
<div><br>
</div>
<div>OBJS := $(addprefix $(OBJS_DIR), \</div>
<div><span style="white-space:pre-wrap"></span>$(patsubst %.f90, %.o, $(notdir $(FSRCS))) \</div>
<div><span style="white-space:pre-wrap"></span>$(patsubst %.c, %.o, $(notdir $(CSRCS))))</div>
<div><br>
</div>
<div>LIB = $(LIB_DIR)libhidac.a</div>
<div><br>
</div>
<div>VPATH := $(sort $(dir $(SRCS))) $(TSRCS_DIR)</div>
<div><br>
</div>
<div>FC := mpif90</div>
<div>CC := mpicc</div>
<div>AR := ar rcs</div>
<div><br>
</div>
<div>FCFLAGS := -cpp -J$(OBJS_DIR) # ${PETSC_KSP_LIB}# -fprofile-arcs -ftest-coverage </div>
<div>CCFLAGS := -Dqh_QHpointer -ansi</div>
<div>LFLAGS := -Wl,-rpath,$(EXT_DIR)lib, ${PETSC_KSP_LIB}</div>
<div><br>
</div>
<div>FIDIR := \</div>
<div>-I$(EXT_DIR)include \</div>
<div>-I$(PETSC_DIR)/include</div>
<div>CIDIR := \</div>
<div>-I$(EXT_DIR)include/libqhull</div>
<div><br>
</div>
<div># sequence does matter</div>
<div>EXTLIBS := \</div>
<div>-L$(EXT_DIR)lib \</div>
<div>-ldmumps -lmumps_common \</div>
<div>-lparmetis -lmetis -lpord -lscalapack \</div>
<div>-llapack -lblas -lqhullstatic_p \</div>
<div>-lpetsc</div>
<div><br>
</div>
<div><br>
</div>
<div>.PHONY: debug release all clean</div>
<div><br>
</div>
<div># Handle different mode using target-specific variable</div>
<div>debug: FCFLAGS += -Wall -fcheck=bounds</div>
<div>debug: CCFLAGS += -Wall</div>
<div>debug: LFLAGS += -Wall -fcheck=bounds</div>
<div><br>
</div>
<div>release: FCFLAGS += -O2</div>
<div>release: CCFLAGS += -O2</div>
<div>release: LFLAGS += -O2</div>
<div><br>
</div>
<div>debug release: $(EXE_DIR)optimal_mechanical_part.hdc</div>
<div><br>
</div>
<div>## Rules</div>
<div>.SUFFIXES: .hdc</div>
<div># Note the sequence of $(OBJS_DIR)%.o $(LIB) and $(EXTLIBS) does matter! Lib later!</div>
<div>$(EXE_DIR)%.hdc: $(OBJS_DIR)%.o $(LIB)</div>
<div><span style="white-space:pre-wrap"></span>@mkdir -p $(EXE_DIR)</div>
<div><span style="white-space:pre-wrap"></span>echo $(OBJS_DIR)</div>
<div><span style="white-space:pre-wrap"></span>$(FC) $(LFLAGS) -o $@ $^ $(EXTLIBS) ${PETSC_KSP_LIB}</div>
<div><br>
</div>
<div>$(LIB): $(OBJS)</div>
<div><span style="white-space:pre-wrap"></span>echo $(OBJS)</div>
<div><span style="white-space:pre-wrap"></span>@mkdir -p $(LIB_DIR)</div>
<div><span style="white-space:pre-wrap"></span>$(AR) $@ $^</div>
<div><br>
</div>
<div>$(OBJS_DIR)%.o:</div>
<div><span style="white-space:pre-wrap"></span>@mkdir -p $(OBJS_DIR)</div>
<div><span style="white-space:pre-wrap"></span>@echo $@</div>
<div><span style="white-space:pre-wrap"></span>$(if $(findstring .f90, $<), \</div>
<div><span style="white-space:pre-wrap"></span>$(FC) $(FCFLAGS) $(FIDIR) -c $< -o $@, \</div>
<div><span style="white-space:pre-wrap"></span>$(CC) $(CCFLAGS) $(CIDIR) -c $< -o $@)</div>
<div><br>
</div>
<div>## Dependencies of files</div>
<div>$(OBJS_DIR)optimal_mechanical_part.o: \</div>
<div><span style="white-space:pre-wrap"></span>optimal_mechanical_part.f90 \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)read_iges_file.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Approximation.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Domain.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Material.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Quadrature.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Analysis.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Utils.o</div>
<div><br>
</div>
<div>$(OBJS_DIR)read_iges_file.o: \</div>
<div><span style="white-space:pre-wrap"></span>read_iges_file.f90 \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Approximation.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Utils.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)nrb.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)parse.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)map.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)dxf_reader.o</div>
<div><br>
</div>
<div>$(OBJS_DIR)test_main.o: \</div>
<div><span style="white-space:pre-wrap"></span>test_main.f90 \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)read_iges_file.o</div>
<div><br>
</div>
<div>$(OBJS_DIR)dxf_reader.o: \</div>
<div><span style="white-space:pre-wrap"></span>dxf_reader.f90 \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)nrb.o</div>
<div><br>
</div>
<div>$(OBJS_DIR)parse.o: \</div>
<div><span style="white-space:pre-wrap"></span>parse.f90 \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)nrb.o</div>
<div><br>
</div>
<div>$(OBJS_DIR)map.o: \</div>
<div><span style="white-space:pre-wrap"></span>map.f90 \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)nrb.o</div>
<div><br>
</div>
<div><Other dependencies ></div>
<div>
<div># $(OBJS_DIR)HiDAC_PetscSolver.o : HiDAC_PetscSolver.f90 $(OBJS_DIR)HiDAC_baseSolver.o $(OBJS_DIR)HiDAC_Utils.o</div>
<div># <span style="white-space:pre-wrap"></span>mpif90 -cpp -JHiDACX/obj/debug/ -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -g -I/Users/yaxiong/Downloads/petsc-3.9.4/include \</div>
<div># <span style="white-space:pre-wrap"></span>-I/Users/yaxiong/Downloads/petsc-3.9.4/arch-darwin-c-debug/include \</div>
<div># <span style="white-space:pre-wrap"></span>-I/opt/X11/include -o $(OBJS_DIR)HiDAC_PetscSolver.o \</div>
<div># <span style="white-space:pre-wrap"></span>/Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_PETSC/Hidac_Fortran_Lib/HiDAC_Solver/HiDAC_PetscSolver.f90 \</div>
<div># <span style="white-space:pre-wrap"></span>/Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_PETSC/Hidac_Fortran_Lib/HiDACX/obj/debug/HiDAC_baseSolver.o \</div>
<div># <span style="white-space:pre-wrap"></span>/Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_PETSC/Hidac_Fortran_Lib/HiDACX/obj/debug/HiDAC_Utils.o \</div>
<div># This part is removed </div>
<br>
</div>
<span>endif</span><br>
<p></p>
<p style="margin-top:0px; margin-bottom:0px"><span>#============================Makefile finished ===============================</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span><br>
</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span><br>
</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span>and the main program starts like this:</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span><br>
</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span>!============================ Main program starts=========================</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span></span></p>
<div>program main</div>
<div> !******************************************************!</div>
<div> ! Import all HiDAC library</div>
<div> !******************************************************! </div>
<div> include 'mpif.h'</div>
<div>#include <petsc/finclude/petscksp.h></div>
<div> use petscksp</div>
<div> use read_iges_file</div>
<div> use HiDAC_Approximation </div>
<div> use HiDAC_Domain</div>
<div> use HiDAC_Material</div>
<div> use HiDAC_Analysis</div>
<div> use HiDAC_Utils</div>
<div> use HiDAC_quadType</div>
<div><br>
</div>
<div> implicit none</div>
!====================<i>=============</i>================================
<p></p>
<p style="margin-top:0px; margin-bottom:0px"><span>I have not call the function in PETSC yet. Just add the KSP library in my main program. But I received the following error when compiling: </span></p>
<p style="margin-top:0px; margin-bottom:0px"><span><br>
</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span></span></p>
<div><span style="color:rgb(117,123,128)">HiDACX/obj/debug/optimal_mechanical_part.o</span></div>
<div><span style="color:rgb(117,123,128)">mpif90 -cpp -JHiDACX/obj/debug/ -Wall -fcheck=bounds -I/usr/local/include -I/Users/yaxiong/Downloads/petsc-3.9.4/include -c /Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_Petsc/Hidac_Fortran_Lib/HiDAC_Test/optimal_mechanical_part.f90
-o HiDACX/obj/debug/optimal_mechanical_part.o</span></div>
<div><span style="color:rgb(117,123,128)">/Users/yaxiong/Downloads/petsc-3.9.4/include/petsc/finclude/petscsys.h:13:2:</span></div>
<div><br>
</div>
<div><span style="color:rgb(117,123,128)"> #if defined (PETSC_HAVE_MPIUNI)</span></div>
<div><span style="color:rgb(117,123,128)"> 1~~~~~~~~~~~~</span></div>
<div><span style="color:rgb(117,123,128)">Fatal Error: petscconf.h: No such file or directory</span></div>
<div><span style="color:rgb(117,123,128)">compilation terminated.</span></div>
<div><span style="color:rgb(117,123,128)">make[1]: *** [HiDACX/obj/debug/optimal_mechanical_part.o] Error 1</span></div>
<div><span style="color:rgb(117,123,128)">make: *** [debug] Error 2</span></div>
<div><span style="color:rgb(117,123,128)"><br>
</span></div>
<p></p>
<p style="margin-top:0px; margin-bottom:0px">How can I solve this problem? </p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>You named the file</div>
<div><br>
</div>
<div> <span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px">optimal_mechanical_</span><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px">part.f90</span></div>
<div><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px"><br>
</span></div>
<div><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px">but it has to be</span></div>
<div><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px"><br>
</span></div>
<div><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px"> </span><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px">optimal_mechanical_</span><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px">part.F90</span></div>
<div><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px"><br>
</span></div>
<div><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px">in order for the compiler to preprocess it.</span></div>
<div><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px"><br>
</span></div>
<div><span style="color:rgb(117,123,128); font-family:Calibri,Helvetica,sans-serif; font-size:16px"> Matt</span></div>
<div> </div>
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px">Thanks</p>
<p style="margin-top:0px; margin-bottom:0px"><br>
</p>
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858Signature">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><span style="color:rgb(33,33,33); font-size:13.3333px">Yaxiong Chen, </span><br style="color:rgb(33,33,33); font-size:13.3333px">
<span style="color:rgb(33,33,33); font-size:13.3333px">Ph.D. Student </span><br style="color:rgb(33,33,33); font-size:13.3333px">
<br style="color:rgb(33,33,33); font-size:13.3333px">
<span style="font-size:13.3333px"></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">School of Mechanical Engineering, 3171 </span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px"><span style="color:rgb(34,34,34); font-family:Roboto,arial,sans-serif; font-size:13px">585 Purdue Mall</span></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">West Lafayette, IN 47907</span></p>
<div><span style="font-size:13.3333px"><br>
</span></div>
<p></p>
<p><br style="color:rgb(33,33,33); font-size:13.3333px">
<br>
</p>
</div>
</div>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block; width:98%">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" id="LPlnk371662" class="x_x_gmail-m_-1340540159560242287OWAAutoLink x_OWAAutoLink" target="_blank" previewremoved="true">knepley@gmail.com</a>><br>
<b>Sent:</b> Friday, January 18, 2019 2:21 PM<br>
<b>To:</b> Yaxiong Chen; PETSc<br>
<b>Subject:</b> Re: [petsc-users]Integrate PETSC with existing Fortran</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail_quote">
<div dir="ltr">On Fri, Jan 18, 2019 at 2:06 PM Yaxiong Chen <<a href="mailto:chen2018@purdue.edu" id="LPlnk740945" class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858OWAAutoLink x_x_gmail-m_-1340540159560242287OWAAutoLink x_OWAAutoLink" target="_blank" previewremoved="true">chen2018@purdue.edu</a>>
wrote:<br>
</div>
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px">Hi Matt,</p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Do not drop the Cc.</div>
<div> </div>
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px">I have hundreds .F90 files to compile as well as an .c file to compile in this project. The present makefile is more complex than the PETSC makefile. Do you mean I should use the PETSC makefile as a template and
add all the dependencies in it?</p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>If you want to do it by hand you can, its just more error prone and verbose.</div>
<div> </div>
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px">My present Makefile is like the following(Red parts are news added related to Petsc). Is this the right direction? Since a static pattern is defined while the compiling for PetscSolver is a little different. I guess
I should list it as a specific case instead of using the pattern.</p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>I will comment inline.</div>
<div> <br>
</div>
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px"></p>
<div># ============================================================================</div>
<div># Name : Makefile</div>
<div># Author : Tao Song</div>
<div># Version : 2.1</div>
<div># Copyright : GNU 2.1</div>
<div># Description : Makefile for HiDACX</div>
<div># ============================================================================</div>
<div><br>
</div>
<div>OUT_DIR := HiDACX/</div>
<div><br>
</div>
<div>## Define mode</div>
<div>ifndef MODE</div>
<div><br>
</div>
<div>.PHONY: debug release</div>
<div><br>
</div>
<div>debug: export MODE := debug</div>
<div>release: export MODE := release</div>
<div>debug release:</div>
<div><span style="white-space:pre-wrap"></span>@$(MAKE) $@</div>
<div><br>
</div>
<div>clean:</div>
<div><span style="white-space:pre-wrap"></span>rm -rf $(OUT_DIR)obj/ $(OUT_DIR)lib/ $(OUT_DIR)bin/</div>
<div><br>
</div>
<div>else</div>
<div><br>
</div>
<div>## SRCS = $(shell find ../../MyGit/Hidac_Fortran_Lib/ "*.f90")</div>
<div>SRCS_DIR := $(HOME)/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_Petsc/Hidac_Fortran_Lib/</div>
<div>FSRCS := \</div>
<div>HiDAC_Utils/HiDAC_parameter.f90 \</div>
<div>HiDAC_Utils/HiDAC_dataStructure.f90 \</div>
<div>......</div>
<div><other .f90 files></div>
<div></div>
<div></div>
<div>HiDAC_Domain/HiDAC_primitive.f90 \</div>
<div><span style="color:rgb(255,0,0); font-size:12pt">HiDAC_Solver/HiDAC_PetscSolver.F90 \</span><br>
</div>
<div>HiDAC_Solver/HiDAC_Solver.f90 \</div>
<div>IGES/read_iges_file.f90 \</div>
<div>IGES/nrb.f90 \</div>
<div>IGES/parse.f90 \</div>
<div>IGES/map.f90 \</div>
<div>DXF/dxf_reader.f90 \</div>
<div><br>
</div>
<div>TSRCS_DIR := $(SRCS_DIR)HiDAC_Test/</div>
<div><br>
</div>
<div>CSRCS := \</div>
<div>HiDAC_Utils/HiDAC_DistanceField/HiDAC_QhullInterface_C.c \</div>
<div><br>
</div>
<div>SRCS := $(addprefix $(SRCS_DIR), $(FSRCS) $(CSRCS))</div>
<div><br>
</div>
<div>OBJS_DIR := $(OUT_DIR)obj/$(MODE)/</div>
<div>LIB_DIR := $(OUT_DIR)lib/$(MODE)/</div>
<div>EXE_DIR := $(OUT_DIR)bin/$(MODE)/</div>
<div>EXT_DIR := /usr/local/</div>
<div><br>
</div>
<div><span style="color:rgb(255,0,0)">#petsc lib</span></div>
<div><span style="color:rgb(255,0,0)">include ${PETSC_DIR}/lib/petsc/conf/variables</span></div>
<div><span style="color:rgb(255,0,0)">include ${PETSC_DIR}/lib/petsc/conf/rules</span></div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>You do not need 'rules' if you are doing things by hand. Although it is easier to just use the builtin rule for building source.</div>
<div> </div>
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<div><br>
</div>
<div>#========================</div>
<div><br>
</div>
<div>OBJS := $(addprefix $(OBJS_DIR), \</div>
<div><span style="white-space:pre-wrap"></span>$(patsubst %.f90, %.o, $(notdir $(FSRCS))) \</div>
<div><span style="white-space:pre-wrap"></span>$(patsubst %.c, %.o, $(notdir $(CSRCS))))</div>
<div><br>
</div>
<div>LIB = $(LIB_DIR)libhidac.a</div>
<div><br>
</div>
<div>VPATH := $(sort $(dir $(SRCS))) $(TSRCS_DIR)</div>
<div><br>
</div>
<div>FC := mpif90</div>
<div>CC := mpicc</div>
<div>AR := ar rcs</div>
<div><br>
</div>
<div>FCFLAGS := -cpp -J$(OBJS_DIR) # ${PETSC_KSP_LIB}# -fprofile-arcs -ftest-coverage </div>
<div>CCFLAGS := -Dqh_QHpointer -ansi</div>
<div>LFLAGS := -Wl,-rpath,$(EXT_DIR)lib, ${PETSC_KSP_LIB}</div>
<div><br>
</div>
<div>FIDIR := \</div>
<div>-I$(EXT_DIR)include \</div>
<div>-I$(PETSC_DIR)/include</div>
<div>CIDIR := \</div>
<div>-I$(EXT_DIR)include/libqhull</div>
<div><br>
</div>
<div># sequence does matter</div>
<div>EXTLIBS := \</div>
<div>-L$(EXT_DIR)lib \</div>
<div>-ldmumps -lmumps_common \</div>
<div>-lparmetis -lmetis -lpord -lscalapack \</div>
<div>-llapack -lblas -lqhullstatic_p \</div>
<div>-lpetsc</div>
<div><br>
</div>
<div><br>
</div>
<div>.PHONY: debug release all clean</div>
<div><br>
</div>
<div># Handle different mode using target-specific variable</div>
<div>debug: FCFLAGS += -Wall -fcheck=bounds</div>
<div>debug: CCFLAGS += -Wall</div>
<div>debug: LFLAGS += -Wall -fcheck=bounds</div>
<div><br>
</div>
<div>release: FCFLAGS += -O2</div>
<div>release: CCFLAGS += -O2</div>
<div>release: LFLAGS += -O2</div>
<div><br>
</div>
<div>debug release: $(EXE_DIR)optimal_mechanical_part.hdc</div>
<div><br>
</div>
<div></div>
<div>## Rules</div>
<div>.SUFFIXES: .hdc</div>
<div># Note the sequence of $(OBJS_DIR)%.o $(LIB) and $(EXTLIBS) does matter! Lib later!</div>
<div>$(EXE_DIR)%.hdc: $(OBJS_DIR)%.o $(LIB)</div>
<div><span style="white-space:pre-wrap"></span>@mkdir -p $(EXE_DIR)</div>
<div><span style="white-space:pre-wrap"></span>echo $OBJS_DIR</div>
<div><span style="white-space:pre-wrap"></span>$(FC) $(LFLAGS) -o $@ $^ $(EXTLIBS)</div>
<div><br>
</div>
<div>$(LIB): $(OBJS)</div>
<div><span style="white-space:pre-wrap"></span>echo $OBJS</div>
<div><span style="white-space:pre-wrap"></span>@mkdir -p $(LIB_DIR)</div>
<div><span style="white-space:pre-wrap"></span>$(AR) $@ $^</div>
<div><br>
</div>
<div>$(OBJS_DIR)%.o:</div>
<div><span style="white-space:pre-wrap"></span>@mkdir -p $(OBJS_DIR)</div>
<div><span style="white-space:pre-wrap"></span>@echo $@</div>
<div><span style="white-space:pre-wrap"></span>$(if $(findstring .f90, $<), \</div>
<div><span style="white-space:pre-wrap"></span>$(FC) $(FCFLAGS) $(FIDIR) -c $< -o $@, \</div>
<div><span style="white-space:pre-wrap"></span>$(CC) $(CCFLAGS) $(CIDIR) -c $< -o $@)</div>
<div><br>
</div>
<div>## Dependencies of files</div>
<div>$(OBJS_DIR)read_iges_file.o: \</div>
<div><span style="white-space:pre-wrap"></span>read_iges_file.f90 \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Approximation.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)HiDAC_Utils.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)nrb.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)parse.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)map.o \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)dxf_reader.o</div>
<div><br>
</div>
<div>$(OBJS_DIR)test_main.o: \</div>
<div><span style="white-space:pre-wrap"></span>test_main.f90 \</div>
<div><span style="white-space:pre-wrap"></span>$(OBJS_DIR)read_iges_file.o</div>
<div><br>
</div>
<div></div>
<div><.... Other dependencies></div>
<div><br>
</div>
<div>
<div><span style="color:rgb(255,0,0)">$ (OBJS_DIR)HiDAC_PetscSolver.o : HiDAC_PetscSolver.F90 $(OBJS_DIR)HiDAC_baseSolver.o $(OBJS_DIR)HiDAC_Utils.o</span></div>
<div><span style="white-space:pre-wrap; color:rgb(255,0,0)"></span><span style="color:rgb(255,0,0)">mpif90 -cpp -JHiDACX/obj/debug/ -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -g -I/Users/yaxiong/Downloads/petsc-3.9.4/include \</span></div>
<div><span style="white-space:pre-wrap; color:rgb(255,0,0)"></span><span style="color:rgb(255,0,0)">-I/Users/yaxiong/Downloads/petsc-3.9.4/arch-darwin-c-debug/include \</span></div>
<div><span style="white-space:pre-wrap; color:rgb(255,0,0)"></span><span style="color:rgb(255,0,0)">-I/opt/X11/include -o $(OBJS_DIR)HiDAC_PetscSolver.o \</span></div>
<div><span style="white-space:pre-wrap; color:rgb(255,0,0)"></span><span style="color:rgb(255,0,0)">/Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_PETSC/Hidac_Fortran_Lib/HiDAC_Solver/HiDAC_PetscSolver.F90 \</span></div>
<div><span style="white-space:pre-wrap; color:rgb(255,0,0)"></span><span style="color:rgb(255,0,0)">/Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_PETSC/Hidac_Fortran_Lib/HiDACX/obj/debug/HiDAC_baseSolver.o \</span></div>
<div><span style="white-space:pre-wrap; color:rgb(255,0,0)"></span><span style="color:rgb(255,0,0)">/Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_PETSC/Hidac_Fortran_Lib/HiDACX/obj/debug/HiDAC_Utils.o \</span></div>
<div><span style="white-space:pre-wrap; color:rgb(255,0,0)"></span><span style="color:rgb(255,0,0)">${PETSC_KSP_LIB}</span></div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>You can do this, but to be certain you should should use</div>
<div><br>
</div>
<div> ${FC} -c ${FC_FLAGS} ${FFLAGS} ${FCPPFLAGS}</div>
<div><br>
</div>
<div>along with your flags (-J, etc.). Notice that you do not need the *.o files here since you are only compiling.</div>
<div><br>
</div>
<div>You can simplify this by includeing 'rules' and just putting the $ (OBJS_DIR)HiDAC_PetscSolver.o as a</div>
<div>dependence for your link.</div>
<div><br>
</div>
<div> Thanks,</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<div></div>
<div>endif</div>
<div><br>
</div>
<br>
<p></p>
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548Signature">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><span style="color:rgb(33,33,33); font-size:13.3333px">Yaxiong Chen, </span><br style="color:rgb(33,33,33); font-size:13.3333px">
<span style="color:rgb(33,33,33); font-size:13.3333px">Ph.D. Student </span><br style="color:rgb(33,33,33); font-size:13.3333px">
<br style="color:rgb(33,33,33); font-size:13.3333px">
<span style="font-size:13.3333px"></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">School of Mechanical Engineering, 3171 </span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px"><span style="color:rgb(34,34,34); font-family:Roboto,arial,sans-serif; font-size:13px">585 Purdue Mall</span></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">West Lafayette, IN 47907</span></p>
<p><br>
</p>
</div>
</div>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block; width:98%">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" id="LPlnk861073" class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858OWAAutoLink x_x_gmail-m_-1340540159560242287OWAAutoLink x_OWAAutoLink" target="_blank" previewremoved="true">knepley@gmail.com</a>><br>
<b>Sent:</b> Friday, January 18, 2019 11:57 AM<br>
<b>To:</b> Yaxiong Chen; PETSc<br>
<b>Subject:</b> Re: [petsc-users]Integrate PETSC with existing Fortran</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548x_gmail_quote">
<div dir="ltr">On Fri, Jan 18, 2019 at 11:37 AM Yaxiong Chen <<a href="mailto:chen2018@purdue.edu" id="LPlnk787763" class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548OWAAutoLink x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858OWAAutoLink x_x_gmail-m_-1340540159560242287OWAAutoLink x_OWAAutoLink" target="_blank" previewremoved="true">chen2018@purdue.edu</a>>
wrote:<br>
</div>
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548x_gmail-m_-8546846387184789408divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px">Hi Matt,</p>
<p style="margin-top:0px; margin-bottom:0px">Now I have some problem with makefile.I want to integrate PETSC with a previous FEM Fortran code. To do that, I add a module named PetscSolver. It starts as the following:</p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>It needs to have suffix .F or .F90 so the preprocessor is invoked. Use the PETSc makefiles to avoid problems.</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548x_gmail-m_-8546846387184789408divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px">!===================================================================</p>
<p style="margin-top:0px; margin-bottom:0px"></p>
<div> module HiDAC_PetscSolver</div>
<div>#include <petsc/finclude/petscksp.h> </div>
<div> use petscksp</div>
<div> use HiDAC_Utils</div>
<div> use HiDAC_baseSolver</div>
<div> implicit none</div>
<div> private</div>
<div></div>
<div> type, extends(Solver), public :: PetscSolver</div>
<div> private</div>
<div> Vec xvec,bvec,uvec</div>
<div> Mat Amat</div>
<div> KSP ksp </div>
<div> contains</div>
<div> procedure :: initialize => initialize_PetscSolver</div>
<div> procedure :: assemble => assemble_PetscSolver</div>
<div> procedure :: solve => solve_PetscSolver</div>
<div> procedure :: postprocess => postprocess_PetscSolver</div>
<div> procedure :: finalize => finalize_PetscSolver</div>
<div> procedure :: getID</div>
<div> end type PetscSolver</div>
<div>......</div>
<div><Functions></div>
<div><span>end module HiDAC_PetscSolver</span><br>
</div>
<div><span>!===================================================================</span></div>
<div><span>However, it did not compile successfully. It gave me the error:</span></div>
<div><span>
<div><br>
</div>
<div> #include <petsc/finclude/petscksp.h></div>
<div> 1</div>
<div>Warning: Illegal preprocessor directive</div>
<div>/Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_PETSC/Hidac_Fortran_Lib/HiDAC_Solver/HiDAC_PetscSolver.f90:23:5:</div>
<div><br>
</div>
<div> Vec xvec,bvec,uvec</div>
<div> 1</div>
<div>Error: Unclassifiable statement at (1)</div>
<div>/Users/yaxiong/Documents/HiDAC_Code_Git/HiDAC_Tao_NURBS_PETSC/Hidac_Fortran_Lib/HiDAC_Solver/HiDAC_PetscSolver.f90:24:5:</div>
<div><br>
</div>
<div> Mat Amat</div>
All function and type related to Petsc are not defined. </span></div>
<div><span><br>
</span></div>
<div><span>I must have made a very silly mistake. Can you show me how to fix it?</span></div>
<div><span><br>
</span></div>
<div><span>Thanks</span></div>
<div><br>
</div>
<p></p>
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548x_gmail-m_-8546846387184789408Signature">
<div id="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548x_gmail-m_-8546846387184789408divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><span style="color:rgb(33,33,33); font-size:13.3333px">Yaxiong Chen, </span><br style="color:rgb(33,33,33); font-size:13.3333px">
<span style="color:rgb(33,33,33); font-size:13.3333px">Ph.D. Student </span><br style="color:rgb(33,33,33); font-size:13.3333px">
<br style="color:rgb(33,33,33); font-size:13.3333px">
<span style="font-size:13.3333px"></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">School of Mechanical Engineering, 3171 </span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px"><span style="color:rgb(34,34,34); font-family:Roboto,arial,sans-serif; font-size:13px">585 Purdue Mall</span></span></p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px"><span style="font-size:13.3333px">West Lafayette, IN 47907</span></p>
<div><span style="font-size:13.3333px"><br>
</span></div>
<p></p>
<p><br style="color:rgb(33,33,33); font-size:13.3333px">
</p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548x_gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" id="LPlnk465135" class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail-m_-786091167183111548OWAAutoLink x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858OWAAutoLink x_x_gmail-m_-1340540159560242287OWAAutoLink x_OWAAutoLink" target="_blank" previewremoved="true">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858x_gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" id="LPlnk383372" class="x_x_gmail-m_-1340540159560242287x_gmail-m_8356030437527891858OWAAutoLink x_x_gmail-m_-1340540159560242287OWAAutoLink x_OWAAutoLink" target="_blank" previewremoved="true">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="x_x_gmail-m_-1340540159560242287x_gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" id="LPlnk513148" class="x_x_gmail-m_-1340540159560242287OWAAutoLink x_OWAAutoLink" target="_blank" previewremoved="true">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="x_x_gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" id="LPlnk222640" class="x_OWAAutoLink" previewremoved="true">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>