previous page / next page


Tinysim Application

The preceeding discussion walked step-by-step through the code for tinysim. It directly uses the MDIO library, the Force library, and the Step library to perform a mature molecular dynamics simulation and is written in less than 200 lines of code, including comments. (Consider, though, that the program does no error checking and the configuration options are all hard-coded in the included default.h header file.)

To play with the program, download the following tinysim.tar.gz source tarball and expand it into your mdx/src/ directory. The following steps assume that you have already successfully built and run the MDSim application from MDX:

  • change into the mdx/src/tinysim/ subdirectory:
    $ cd tinysim
  • build the executable:
    $ make
  • install it:
    $ ( cd ../.. ; make install )
  • run it within the mdx/src/tinysim/ subdirectory:
    $ tinysim     # if it is in your default path
        OR
    $ ../../build/Linux_generic/bin/tinysim     # otherwise
        (where you replace "Linux_generic" by whatever you built)
In order for tinysim to work, the decalanine files must be within your current working directory. You should see results identical to those from running the mdx/demo/.

Any module that you add to MDX shares a similar basic form to tinysim. Correctly building it is controlled from the GNUmakefile:

# GNUmakefile
# definitions for building "tinysim"

TOP = ../..
NAME = tinysim
TYPE = bin
OBJ = tinysim
LIB = mdio force step random m
LINKCPP = no
HEADER =
DEMO =
DEMOOBJ =
DEMOLIB =
DEMOLINKCPP =

ifeq (0,$(MAKELEVEL))
.PHONY : src clean
src clean : ; $(MAKE) -C $(TOP) SRC="$(NAME)" $@
endif
The bottom four lines allow building and cleaning of this module from within the mdx/src/tinysim/ subdirectory. The most pertinent variables defined are:
  • TOP - must give relative path to the base directory mdx/
  • NAME - should be the same as the subdirectory name
  • TYPE - is "bin" for binary executable, "lib" for library
  • OBJ - gives the list of un-suffixed objects to be built (in this case there is only one, tinysim.o, built from tinysim.c)
  • LIB - gives the list of libraries to link to, which need to be listed in the order that keeps resolving earlier dependencies; for instance, step depends on random and everything depends on m, the math library (note that the libraries represented here are really named libmdio.so, libforce.so, ..., libm.so)
The full list of variables are explained in detail in the build.txt build system documentation.

previous page / next page