From: Zack V. <jan...@gm...> - 2017-11-07 18:05:48
|
I don't quite understand why my libmesh-config is in '$HOME/src/libmesh/build/contrib/bin' so that, I suppose, my LIBMESH_DIR is $HOME/src/libmesh/build/contrib/ but if I make this so in .bashrc, then it seems to work. I copied introduction_ex1.C into another directory and renamed as foo.cc and ran make, then did: $ mpirun -np 1 foo-opt -d 2 $LIBMESH_DIR/../../reference_elements/3D/one_hex27.xda (in the spirit of what is written at http://libmesh.github.io/examples/introduction_ex1.html) and receive: Mesh Information: elem_dimensions()={3} spatial_dimension()=3 n_nodes()=27 n_local_nodes()=27 n_elem()=1 n_local_elem()=1 n_active_elem()=1 n_subdomains()=1 n_partitions()=1 n_processors()=1 n_threads()=1 processor_id()=0 WARNING! There are options you set that were not used! WARNING! could be spelling mistake, etc! Option left: name:-d value: 2 So it seems to work and this answers my initial question, thank you very much! I am wondering why I get these warnings, though. I also tried "-d 3" and that gave a similar result (with "Option left: name:-d value: 3") I also tried ./foo-opt -d 3 $LIBMESH_DIR/../../reference_elements/3D/one_hex27.xda but this again gave the same warnings. Any idea why this is? Thank you very much for answering the original question leading to much ease! On Tue, Nov 7, 2017 at 12:40 PM, Zack Vitoh <jan...@gm...> wrote: > Thank you very much! I'll try this and update. > > On Tue, Nov 7, 2017 at 11:55 AM, John Peterson <jwp...@gm...> > wrote: > >> >> >> On Tue, Nov 7, 2017 at 9:48 AM, Zack Vitoh <jan...@gm...> wrote: >> >>> Hi, I am new to libmesh, and have installed it to >>> $HOME/src/libmesh/build/ >>> >>> I am trying the simplest thing I can think of: copy the source for >>> introduction_ex1.C into a 'myexamples' subdirectory of >>> $HOME/src/libmesh/build and create a simple, comprehensible makefile to >>> run >>> the code. >>> >>> Do I simply copy and modify the makefile.in from the original example >>> like >>> so? >>> >>> example_name = introduction_ex1 >>> >>> install_dir = $HOME/src/libmesh/build/myexamples/introduction/ex1 >>> data = introduction_ex1.C run.sh >>> sources = $(data) run.sh >>> >>> check_SCRIPTS = run.sh >>> CLEANFILES = output.xda output.xdr >>> >>> >>> ############################################## >>> # include common example environment >>> include $(top_srcdir)/examples/Make.common >>> >>> PS: I do not understand automake, and so do not understand the 1200 lines >>> of the makefile.am in the original example, but I sense that I should >>> not >>> try to modify this since it is generated by automake >>> >> >> >> >> My advice is actually to not try and copy an example when getting started >> since, as you have seen, the automake system is difficult to work with. >> >> After "make install" into $LIBMESH_DIR, I'd create your new application >> in a different directory (not in the libmesh source tree or installation >> directory) and use a human readable Makefile like the one below. >> >> Put your main program in a file called "foo.cc" and then simply run >> "make". Let us know if you run into issues... >> >> -- >> John >> >> >> >> # This Makefile assumes you have libmesh built and installed in >> $LIBMESH_DIR. >> >> # If the user has no environment variable >> # called METHOD, he gets optimized mode. >> ifeq (x$(METHOD),x) >> METHOD := opt >> endif >> >> # installed libmesh location of libmesh-config script >> libmesh_config := $(LIBMESH_DIR)/bin/libmesh-config >> >> # Use the libmesh-config script to determine the usual make variables. >> # Note: passing $METHOD along to the libmesh-config script handles the >> # case where METHOD is not set and the user does >> # make METHOD=dbg foo >> # since in this case, METHOD is never set in the environment and thus >> # never passed to libmesh-config correctly. >> libmesh_CXX := $(shell METHOD=$(METHOD) $(libmesh_config) --cxx) >> libmesh_INCLUDE := $(shell METHOD=$(METHOD) $(libmesh_config) --include) >> libmesh_CPPFLAGS := $(shell METHOD=$(METHOD) $(libmesh_config) --cppflags) >> libmesh_CXXFLAGS := $(shell METHOD=$(METHOD) $(libmesh_config) --cxxflags) >> libmesh_LIBS := $(shell METHOD=$(METHOD) $(libmesh_config) --libs) >> >> # File management variables. >> headers := $(wildcard *.h) >> srcs := $(wildcard *.C) >> # Note: spaces are treated as literal characters in patsubst commands! >> objs := $(patsubst %.C,%-$(METHOD).o,$(srcs)) >> deps := $(patsubst %.C,%-$(METHOD).d,$(srcs)) >> >> mainfile := $(wildcard *.cc) >> mainexe := $(patsubst %.cc,%-$(METHOD),$(mainfile)) >> maindep := $(patsubst %.cc,%.d,$(mainfile)) >> >> .PHONY: clean >> >> # Disable make builtin rules for compiling .C files into objects >> # https://stackoverflow.com/questions/4122831/disable-make- >> builtin-rules-and-variables-from-inside-the-make-file >> .SUFFIXES: >> >> # .SECONDARY with no prerequisites causes all targets to be treated as >> # secondary (i.e., no target is removed because it is considered >> # intermediate). >> .SECONDARY: >> >> all: $(mainexe) >> >> # Generate object files. >> %-$(METHOD).o: %.C >> @echo "Compiling" $< >> @$(libmesh_CXX) -MMD -MP -MT $@ $(libmesh_INCLUDE) $(libmesh_CPPFLAGS) >> $(libmesh_CXXFLAGS) -c $< -o $@ >> >> # How to build executables. If you have a source file called foo.cc, >> # type 'make foo' to build an executable from it. >> %-$(METHOD): %.cc $(objs) >> @echo "Compiling" $< >> @$(libmesh_CXX) -MMD -MP -MT $@ -MF $(maindep) $(libmesh_INCLUDE) >> $(libmesh_CPPFLAGS) $(libmesh_CXXFLAGS) $< -o $@ $(libmesh_LIBS) >> $(libmesh_LDFLAGS) $(EXTERNAL_FLAGS) $(objs) >> >> echo: >> @echo "$(srcs)" >> @echo "$(objs)" >> @echo "$(deps)" >> @echo "$(maindeps)" >> >> # File management rules. >> clean: >> rm -f *~ $(mainexe) $(objs) $(deps) $(maindep) >> >> # Include all the .d files generated by the compiler, but don't error >> # if the files don't exist yet. >> -include $(deps) >> -include $(maindep) >> >> >> >> >> > |