README file for PS_TranspSubs Module

Prepared by C.Ludescher-Furth -- ludescher@pppl.gov 04/21/09

****************
REVISION HISTORY
****************
      date          Description

  Apr 21, 2009  -- Created
----------------------------------------------------------------


Index:
   1. CONTENTS
   2. UNPACKING INSTRUCTIONS
   3. DESTINATIONS
   4. BUILDING INSTRUCTIONS
   5. TESTING INSTRUCTIONS
   6. DOCUMENTATION
   7. FINAL INSTALLATION


************
1. CONTENTS:
************
The directory into which plasma_state{zip,tar.gz} was extracted, should contain
the following files:

README_PS_TranspSubs: This file.  Brief descriptions of the other files, and
                instructions for compiling, and installing the
                libraries.

Makefile:       NOTE, "GNU make" must be used
                (usually in /usr/gnu/bin or /usr/local/bin).
		Main Makefile to envoke Makefile(s) in subdirectories.  

-- in subdirectory fpreproc:
   Python scripts for fortran pre-processing.

-- in subdirectory include/fpreproc:
   *.h files for source pre-processing.



-- in subdirectory portlib:
   Makefile
   Sources to build internally used library libportlib.a.

-- in subdirectory share:
   Make.flags:        Include file for Makefile, to setup Flags, etc.
   Make.local.sample: Include file for Makefile, to setup non-conventional,
                      site specific locations.
 
-- in subdirectory comput:
   Makefile 
   Sources to build libcomput.a, an internally used library 
	with transformation/interpolation routines.
   
-- in subdirectory fluxav:
   Makefile 
   Sources to build libfluxav.a, an internally used library 
	for flux zone / flux surface averages and integrals.

-- in subdirectory r8bloat:
   Makefile 
   Sources to build libr8bloat.a, an internally used library 
	with miscelanious math routines.

-- in subdirectories vaxonly, lsode,
	lsode_linpack, mdstransp, nscrunch
   	sources and Makefiles to build these libraries.

For Program cstate:
   in subdirectories cstate_lib, xplasma_debug, trgraf,
        ureadsub, sglib 
 	sources and Makefiles to build these libraries.

For Program, plasma_state_test:
   trgraf
   mds_dummy

For Program, ps_nbline_driver:
   ps_nbline
   random: Karney's random number generation

**************************
2. UNPACKING INSTRUCTIONS:
**************************
Note: Download the module(s) into an empty directory.

for tarfiles:
  > tar zxvf ps_transpsubs.tar.gz

or, for zip archives:
  > unzip ps_transpsubs.zip


****************
3. DESTINATIONS:
****************
Or where do the files go?
(this refers to building and testing; see FINAL INSTALLATION for end result) 


When you extract the tar file you get sub directories:
./comput               --  transformation/interpolation routines
./fluxav               --  flux zone / flux surface averages and integrals
./fpreproc             --  scripts for pre-processing of fortran
./geqdsk_mds           --  
./include/fpreproc     --  *.h files for cpp
./lsode                --  REAL*8 version of netlib odepack
./lsode_linpack        --  linpack routines used by lsode
./mds_dummy            --  Dummy routines for mdsplus
./mdstransp            --  fortran/c interface for mdsplus
./nscrunch             --  moment representation of nested flux surfaces
./portlib              --  internally used library
./random               --  Karney's random number generator
./r8bloat              --  miscelanious math routines
./share                --  include file Make.flags, Make.local.sample
./trgraf
./ureadsub
./vaxonly	       --  Low level code for machine dependence
./xplasma2             --  
./xplasma_debug


The makefile will create more sub directories,

lib:     for the library, libplasma_state.a
mod:     for the f90 modules
obj/*:   for compiled objects and pre-processed sources
test:    for the test programs and the sample output files.

By default these directories are created in  
./<MACHINE>, which is determined by Make.flags.
e.g.: if you are running Linux, and the tar file resides in $HOME/foo,
      the directories would be in
      $HOME/foo/LINUX/...

You can overwrite the destination by defining OBJ, as an environment
variable (e.g. export OBJ=/dir1/dir2),
or with make (e.g. "make all OBJ=.").
If OBJ is defined, the destinations will be
$OBJ/lib and $OBJ/test.
If OBJ is defined as "." then, in the example above, the destination
would be $HOME/foo/lib.

The rationale behind <MACHINE> is to facilitate building for various platforms.

Note: If you define OBJ as option to gmake, you have to consistently do so;
      e.g: gmake clean OBJ=., gmake install OBJ=.

 
*************************
4. BUILDING INSTRUCTIONS:
*************************

Required Compilers:
===================
           Fortran 90 or 95
           C 

Required Libraries:
===================
           libpspline.a   -> NTCC module PSPLINE, now on GitHub

           netCDF         -  network Common Data Form

Optional Libraries:
===================
	   readline, history, termcap  for Command Line Editing
           Note: if not all three libraries are installed
                 you must define NO_EDITLIBS
		 e.g.: gmake NO_EDITLIBS=Y

Check with your systems administrator where these libraries and modules are.


netCDF
---------------------------
netCDF is assumed to be in /usr/local/lib,
if not, you can specify the location with LIBROOT,

e.g.: "gmake LIBROOT=/usr/contrib".

If netCDF is in a separate location, specify NETCDF_DIR

e.g.: "gmake NETCDF_DIR=/usr/local/my-netcdf LIBROOT=/my-libroot".

Alternatively you can modify Make.local.sample
and rename it to Make.local.

pspline
---------------------------
If your site already has the pspline library installed,
specify it's location  with PREFIX, 

e.g. "gmake PREFIX=$NTCCHOME"

At PPPL these libraries are in $NTCCHOME.

Note: If you don't have all required NTCC libraries, you may download
      them together into the same work directory. The Makefile will build
      them all in one step. 


Building libraries and programs
-------------------------------- 
> gmake            -- to compile library and link all test programs

> gmake checklibs  -- tells you what the makefile will do
                      (without any action);
                      it says which libraries it will make and
                      which ones it already found and where.
 
> gmake clean      -- to remove objects
> gmake realclean  -- to remove objects and library

> gmake show_makeflags -- to see what flags, definitions Make will use

Compiling on Linux:
-------------------
By default the Makefile will select LaheyFujitsu.

To select a different compiler define
FORTRAN_VARIANT to "Portland" "PathScale" " GCC" "NagWare"  "Fujitsu" "Intel" or "Absoft"

e.g.:
setenv FORTRAN_VARIANT Portland (csh)
FORTRAN_VARIANT=Portland; export  FORTRAN_VARIANT (sh)

Alternatively, FORTRAN_VARIANT can be passed directly to the gmake
command, as in:
gmake  FORTRAN_VARIANT=Portland

Note: some test programs are linked with g++; to find the Fortran libraries,
      you need to define FLIBROOT
      e.g. export FLIBROOT=/usr/pppl/lf64x/lf6480

To use vastf90:
> gmake VAST90=y

To use NAG90: 
> gmake NAG90=y

Note: By default the test programs, plasma_state_test and plasma_state_driver,
      are linked with lf95. If you encounter a problem, try linking with g++:

> gmake USEFC=N 


Compiling on Alpha Linux:
-------------------------
The Makefile assumes the Compaq compiler and specifies the 
 " -assume no2underscores " option.

Therefore the calling user software must also be compiled with this
option, or you should edit share/Make.flags to remove the option.


Compiling on SUN:
-----------------
The Makefile specifies the -dalign option.
Therefore the calling user software must also be compiled with this
option, or you should edit share/Make.flags to remove the option.



************************
5. TESTING INSTRUCTIONS:
************************

If you downloaded plasma_state, see README_plasma_state
To link a program, you need all plasma_state, xplasma, pspline libraries.

e,g:

-L<PREFIX>/lib  \
         -lplasma_state -lps_xplasma2 -lplasma_state_kernel \ 
         -lxplasma2 -lgeqdsk_mds -lmdstransp -lvaxonly -lnscrunch \
	 -lfluxav -lr8bloat -lpspline -lezcdf \
         -llsode -llsode_linpack -lcomput -lportlib

Make sure users know what <PREFIX> is.


************************
6. DOCUMENTATION:
************************

PLASMA_STATE Home Page:
http://w3.pppl.gov/NTCC/PlasmaState


NTCC Home Page:
http://w3.pppl.gov/NTCC


**********************
7. FINAL INSTALLATION:
**********************

Choose or create the root directory in which you wish to install the software.
A common location would be /usr/ntcc, but installation can occur in any
directory where you have appropriate permissions.

You define your choice of root directory via PREFIX.
The default for PREFIX is /usr/ntcc.

The assumptions are:

libraries in:       $PREFIX/lib        = $LIBDIR
f90 modules in:     $PREFIX/mod        = $MODDIR
man pages in:       $PREFIX/man/man3   = $MANDIR/man3

To install the software, return to the top directory (the directory,
where you downloaded the tar files) and type

> gmake install  
    to install into /usr/ntcc/...

> gmake install PREFIX=/dir1/dir2/
    to install into /dir1/dir2/...

If you want things elsewhere, you can overwrite the default with
> gmake install LIBDIR=/xxx MODDIR=yyy MANDIR=zzz


After you have installed the software, you can delete the entire tree
with
> cd ..
> rm -r foo
   assuming the previous example.

----------------------------------------------------------------------------

IF YOU HAVE ANY PROBLEMS, PLEASE CONTACT EITHER:


        Doug McCune, Princeton University
                dmccune@pppl.gov
        or

        Christiane Ludescher-Furth, Princeton University
                cludescher@pppl.gov
        or      
                ntcc_webmaster@pppl.gov




