IBM Books

Parallel Engineering and Scientific Subroutine Library for AIX Version 2 Release 3: Guide and Reference


Sample Makefiles and Run Script

You can use the following makefile and run script with the sample thermal diffusion and sparse linear algebraic equations programs.

Makefile

#  Makefile to build the diffusion program, sparse solver and utility routines
#
 
#  add rule for making mod files
.SUFFIXES:  .mod
 
#
# Compilers and such
#
 
CC=mpcc
FORT=mpxlf
LINK=mpxlf
 
LDFLAGS =  -lblacs -lessl -lpessl $(LIB)
FCOPT = -O3 -C -qsource -qxref -qattr $(INCLUDE)
 
# default for include and lib directories
 
INCLUDE=
LIB=
 
## DISTRIBUTED DATA samples
 
# OBJS list objects module used in the diffusion program
#
OBJS = main.o scalemod.o param.o diffusion.o fourier.o
 
BASEOBJS = broadcast.o create.o delete.o init.o scatter_gather.o \
           pdata.o northsouth.o eastwest.o index.o
 
UTILOBJS = $(BASEOBJS) cdata.o putilities.o
 
UTILLIB = libputils.a
 
LIBOBJS = $(UTILLIB)(broadcast.o) $(UTILLIB)(create.o) \
          $(UTILLIB)(delete.o) $(UTILLIB)(init.o)      \
          $(UTILLIB)(scatter_gather.o) $(UTILLIB)(pdata.o)      \
          $(UTILLIB)(northsouth.o) $(UTILLIB)(eastwest.o)      \
          $(UTILLIB)(index.o) $(UTILLIB)(cdata.o)      \
          $(UTILLIB)(putilities.o)
 
 
distribute: diffusion pdgexmp image simple
 
#
#  Rule for building diffusion program
#
diffusion: $(OBJS)
 $(LINK) -o diffusion $(OBJS) -lpessl -lblacs -lessl
  
pdgexmp:  pdgexmp.o  $(UTILLIB)
 $(LINK) -o pdgexmp pdgexmp.o  -L . -lputils $(LDFLAGS)
 
image:  image.o  $(UTILLIB)
 $(LINK) -o image image.o -L . -lputils $(LDFLAGS)
 
simple:  simple.o  $(UTILLIB)
 $(LINK) -o simple simple.o  -L . -lputils $(LDFLAGS)
 
#rule to create the library
 
$(UTILLIB): $(LIBOBJS)
 ar rv $(UTILLIB) $%
 
# rules to create library objects
 
init.o: init.f pdata.o
 xlf -c $(FFLAGS) init.f
 
exchange.o: init.f pdata.o
 xlf -c $(FFLAGS) exchange.f
 
cdata.o: cdata.f pdata.o
 xlf -c $(FFLAGS) cdata.f
 
create.o: create.f pdata.o
 xlf -c $(FFLAGS) create.f
 
broadcast.o: broadcast.f pdata.o
 xlf -c $(FFLAGS) broadcast.f
 
delete.o: delete.f pdata.o
 xlf -c $(FFLAGS) delete.f
 
scatter_gather.o: scatter_gather.f pdata.o
 xlf -c $(FFLAGS) scatter_gather.f
 
putilities.o: putilities.f $(BASEOBJS) cdata.o
 xlf -c $(FFLAGS) putilities.f
 
eastwest.o: eastwest.f pdata.o
 xlf -c $(FFLAGS) eastwest.f
 
northsouth.o: northsouth.f pdata.o
 xlf -c $(FFLAGS) northsouth.f
 
$(UTILLIB)(broadcast.o): broadcast.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(create.o): create.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(delete.o): delete.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(init.o): init.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(scatter_gather.o): scatter_gather.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(pdata.o): pdata.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(northsouth.o): northsouth.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(eastwest.o): eastwest.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(index.o): index.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(cdata.o): cdata.o
 ar rv $(UTILLIB) $%
 
$(UTILLIB)(putilities.o): putilities.o
 ar rv $(UTILLIB) $%
 
#
#  List of object module dependencies for distributed data sample.
main.o: main.f scalemod.o param.o  diffusion.o fourier.o
diffusion.o: diffusion.f scalemod.o param.o
fourier.o: fourier.f diffusion.o scalemod.o param.o
scalemod.o: scalemod.f param.o
param.o: param.f
pdgexmp.o: pdgexmp.f $(UTILLIB)
simple.o: simple.f $(UTILLIB)
image.o: image.f $(UTILLIB)
 
 
##  SPARSE MATRIX samples
 
# HBOBJS and PARTOBJS list objects module used in the SPARSE programs.
#
HBOBJS=read_mat.o mat_dist.o desym.o
PARTOBJS= part_block.o  partbcyc.o partrand.o
 
sparse: hb_sample pde90 pde77
 
pde90: pde90.o part_block.o
 $(LINK) $(LDFLAGS)  pde90.o part_block.o -o pde90
 
 
 
pde77: pde77.o  part_block.o
 $(LINK) $(LDFLAGS)  pde77.o  part_block.o -o pde77
 
hb_sample: $(HBOBJS) hb_sample.o $(PARTOBJS)
 $(LINK) $(LDFLAGS)  hb_sample.o -o hb_sample \
 $(HBOBJS) $(PARTOBJS)
 
#
#  List of object module dependencies for sparse matrix sample.
$(HBOBJS) hb_sample.o: read_mat.mod mat_dist.mod  part_bcyc.mod partrand.mod
part_bcyc.mod: partbcyc.o
 
#
#  Rule to clean executable and program
cleanall:
 rm -f *.lst *.o *.mod diffusion core image pdgexmp simple hb_sample pde90 pde77 libputils.a
 #
clean:
 /bin/rm -f *.o *.mod *.lst
 
#
# definitions for compiles
.f.mod:
 $(FORT) $(INCLUDE) $(FCOPT) -c $<
.c.o:
 $(CC) $(INCLUDE) $(CCOPT) -c  $<
.f.o:
 $(FORT) $(INCLUDE) $(FCOPT)  -c  $<

Run Script

#!/bin/ksh
#
# USING THE FORTRAN EXAMPLE
# Copy the files from /usr/lpp/pessl.rte.common/example/fortran to a directory that
# is part of a shared file system (e.g. NFS mounted).  You can not run
# the program from a private file system.
#
# You must have the same userid on the home node and each remote node.
#
# You must have remote execution authority on all the nodes.
#
# Invoke 'make'.
#
# In run.script, edit EXAMP_PATH below to point to the working directory
# which contains the files.
#
# Invoke 'run.script'.
#
 
#
# Script file to execute a sample program.
# The first argument is the name of the sample to run
# The remaining arguments are any needed to by the sample
#
 
#
#  Set the number of processors to be 8.
export MP_PROCS=8
#
#  Set the program to run in user space.
export MP_EUILIB=us
#
#  Use the switch.
export MP_EUIDEVICE=css0
#
#  Use the resource manager.
export MP_RESD=yes
#
#  Use the resource pool 0, this may need to be changed
#  depending on installation defaults used.
export MP_RMPOOL=0
#
#  Do not use a hostfile list.
export MP_HOSTFILE=NULL
#
#  Use low information output level.
export MP_INFOLEVEL=1
#
#
export MP_PGMMODEL=spmd
#
#  Standard output is not node ordered.
export MP_STDOUTMODE=unordered
#
#  Retry node allocation every 60 seconds.
export MP_RETRY=60
#
#  Retry node allocation five times.
export MP_RETRYCOUNT=5
#
#
export MP_CSS_INTERRUPT=yes
#
export MP_PULSE=0
#
#  Label standard I/O by task number.
export MP_LABELIO=yes
poe $*


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]