Users Guide:Installation: Makefiles


SPRNG Makefiles

The following information may help you port SPRNG to your machine.

Platform dependent compilation

There is a file included in the SPRNG distribution called make.CHOICES which sets the platform for compilation. Once this file is properly edited, the user can build the SPRNG libraries by simply using the make command.

The make.CHOICES file looks like this:

 
#PLAT = CONVEX 
PLAT = SGI 
#PLAT = SP2 
#PLAT = T3E 

If users wish to build SPRNG on the HP/Convex Exemplar, then they should comment out the line specifying the SGI and uncomment the line specifying the CONVEX as follows:

 
PLAT = CONVEX 
#PLAT = SGI 
#PLAT = SP2 
#PLAT = T3E 

Then, the make command will build the libraries using the compiler options set in the file SRC/make.CONVEX The user may wish to edit this file if a different compiler or different compiler options are wanted.

Variables in the Make.PLAT

We shall next describe the different variables defined in the make.platform files. The makefile includes information from this file in order to determine the values of certain variables. We take as an example platform the make.INTEL for use in our INTEL machine. The relevant portion of the file is as follows:

 
AR = ar
ARFLAGS = cr
#If your system does not have ranlib, then replace next statement with 
#RANLIB = echo
RANLIB = ranlib
CC = g++
CLD = $(CC)
# Set f77 to echo if you do not have a FORTRAN compiler
F77 = g77
#F77 = echo
F77LD = $(F77)
FFXN = -DAdd_
FSUFFIX = F

MPIF77 = mpif77
MPICC = mpiCC

# To use MPI, set the MPIDIR to location of mpi library, and MPILIB 
# to name of mpi library. Remove # signs from beginning of next 3 lines.
# Also, if the previous compilation was without MPI, type: make realclean
# before compiling for mpi.
# Moreover, comment out the line for MPIDEF in sprng4.0/make.CHOICES

MPIDIR = $(shell mpiCC --showme:compile)
MPILIB = $(shell mpiCC --showme:link)

CFLAGS = -O3 -DLittleEndian $(MPIDEF) -D$(PLAT) $(MPIDIR) -Wno-deprecated -g -ansi 
CLDFLAGS = -O3
FFLAGS =  $(MPIDEF) -D$(PLAT) $(MPIDIR) -I. 
F77LDFLAGS = -O3

CPP = cpp -P

Descriptions of variables

AR is the command to archive the library.

ARFLAGS is the flag to the archiver. Here we create the library or replace the object files already archived.

RANLIB is essentially used to generate the table of contents to the library. You can set this to "echo" if ranlib is not available on your machine.

CC and CLD are the C++ compiler and loader respectively.

F77 and F77LD are the FORTRAN77 compiler and loader respectively. If they are not avaiable, then set them to 'echo'.

FFXN is needed for the following reason. SPRNG 4.0 is written in C++. FORTRAN wrappers are also available, which provide an interface to FORTRAN users. These wrappers are actually C++ functions. When a FORTRAN user calls a wrapper function fxn, FORTRAN compilers often change the name to something else, for example fxn_. Thus the wrappers should also have their function names modified the same way. The flag FFXN ensures that the correct modification is made to the wrapper function names during SPRNG installation. You can ignore FFXN if you do not wish to get a FORTRAN interface, and have set F77 to "echo".

CFLAGS and CLDFLAGS are the flags to the C++ compiler and loader respectively.

FFLAGS and F77LDFLAGS are the flags to the FORTRAN77 compiler and loader respectively.

CPP is provided for the sake of those FORTRAN compilers which are not capable of calling the C++ preprocessor. SPRNG executables and example programs in FORTRAN have names of the form filename.F, and involve preprocessing directives. If some compiler cannot accept such a file, then we preprocess the file using the command:

CPP filename.F

The resulting file is called either filename.f or filename.i. In the latter case, the user should move it to a file called filename.f by issuing the following command:

mv filename.i filename.f

filename.f can be processed by the user's FORTRAN compiler. You can ignore this if your FORTRAN compiler can invoke the preprocessor itself, or if you do not wish to compile FORTRAN programs.

MPIDEF in make.CHOICES should be set to -DSPRNG_MPI if the user is installing the MPI version of SPRNG. This line should be commented out, by appending a # sign, or removed otherwise. This flag causes a macro called SPRNG_MPI to be defined in the SPRNG code, which enables calls to MPI functions.

MPIDIR indicates the path to the MPI library.
Instead of the specifying the path to the MPI library, we can use the output of the command
mpiCC --showme:compile

MPILIB indicates the name of the MPI library. Instead of the specifying the name the MPI library, we can use the output of the command
mpiCC --showme:link

Note: MPIDEF, MPIDIR and MPILIB should be commented out or removed if the user does not wish to install the MPI version of SPRNG.

Users may wish to use the above variables and flags in compiling their programs too. However, the flags -DSPRNG_MPI and -D_LONG_LONG, and the variables MPIDEF and FFXN are needed only during the SPRNG installation. Users can take a look at the Makefile in the EXAMPLES directory in order to see some compilation flags that they might wish to use.

The flag -DPOINTERSIZE=8 may be defined to indicate that the size of the pointer is 8 bytes. The default value assumed by SPRNG is 4 bytes. You must set this to the 8 if your machine has 8-bit pointers.

Porting SPRNG to new machines

Please set the PLAT variable in make.CHOICES to GENERIC and edit the make.GENERIC to suit your system, after reading the explanations above. Little Endian machines may need the option: -DLittleEndian added to CFLAGS. In order to optimize the performance, please try the following: (i) Add -D_LONG_LONG to CFLAGS and/or(ii) Add -DGENERIC to CFLAGS. If checksprng passes, then SPRNG is installed correctly. If not, please remove whichever option caused SPRNG to fail and recompile.
[Quick 
Start] [User's 
Guide] [Reference 
Manual] [Quick 
Reference]