#############################################################
# Illustration of general technique for porting Fortran
# code to Cray J90.  It is highly recommended that you port 
# only thoroughly tested codes to minimize the amount of 
# debugging etc. you need to do on the J90
#############################################################

#############################################################
# All class members should be able to 'rlogin' into 'charon'
# via
#
# % rlogin charon.cc.utexas.edu -l phas761
#
# from any of the course machines.  E-mail me if you can't.
# From your account on einstein, this can be abbreviated to
#
# % rlogin phas761@charon
#
# NOTE: Use ONLY 'rlogin' (not 'telnet') to connect to the 
# J90 since I will NOT be distributing a password for the 
# account.
#############################################################
charon% who am i
phas761    ttyp037      Sep 28 10:01  (newton.ph.utexas.edu)

charon% pwd
/home/utexas/ph/phas761

#############################################################
# Each student has a working directory rooted in phas761's
# home directory.  Note: The home directory has very limited 
# space, so your directories are actually located on an
# archive partition which has essentially unlimited space.
# Your "top level" directories are actually symbolic links 
# to the real directories. 
#
# When using this Cray account, work ONLY within your 
# own directory.
#############################################################
charon% ls
Teaching@     jmholmes@     marcelo@      onager@       schaefer@
benton@       kelbird@      martin@       phy329@       slinger@
cray_output   lamadorj@     matt@         rcrane@
doc@          lib@          mcarthur@     ristroph@
eromberg@     liwj@         moter@        sandor@

charon% ls -l phy329
lrwxrwxrwx   1 phas761  phas          33      \
    Sep 28 09:51 phy329 -> /archive/utexas/ph/phas761/phy329/

#############################################################
# 'tdm' example 
#############################################################
charon% cd ~/phy329/f77/ex7

#############################################################
# Download files from the SGIs using 'ftp'
#############################################################
charon% ftp einstein.ph.utexas.edu
Connected to einstein.ph.utexas.edu.
                           .
                           .
                           .
Remote system type is UNIX.
Using binary mode to transfer files.
Name (einstein.ph.utexas.edu:phas761): phy329
331 Password required for phy329.
Password:
230 User phy329 logged in.

ftp> cd f77/ex7
250 CWD command successful.

ftp> prompt
Interactive mode off.

ftp> mget *.f Makefile
200 PORT command successful.
150 Opening BINARY mode data connection for 'dmroutines.f' (7392 bytes).
226 Transfer complete.
7392 bytes received in 0.0031 seconds (2.3e+03 Kbytes/s)
200 PORT command successful.
150 Opening BINARY mode data connection for 'tdm.f' (2047 bytes).
226 Transfer complete.
2047 bytes received in 0.023 seconds (87 Kbytes/s)
200 PORT command successful.
150 Opening BINARY mode data connection for 'Makefile' (946 bytes).
226 Transfer complete.
946 bytes received in 0.0023 seconds (4e+02 Kbytes/s)

ftp> quit
221 Goodbye.

charon% ls
Makefile       dmroutines.f   tdm.f

#############################################################
# The instructor-supplied script 'f77transcray' will 
# convert Fortran source files to Cray-compatible form.
#
# WARNING: The script may fail if you violate any of the    
# conventions discussed in class; particularly those having
# to do with the specification of real*8 constants!
#############################################################
charon% f77transcray
usage: f77transcray <f77 source file> [<f77 source file> ...]

Converts 'canonical' double precision FORTRAN programs written for 
a 32-bit machine to equivalent Cray FORTRAN.  Source code is modified 
in place, but original source is always saved in '.O' files.

#############################################################
# Build the application.  Note that 'f77transcray' is 
# automatically invoked by the Makefile prior to compilation
# of any Fortran source file.
#############################################################
charon% make
	f77transcray tdm.f
f77transcray: Translating tdm.f
	cf77 -g -c tdm.f
	f77transcray dmroutines.f
f77transcray: Translating dmroutines.f
	cf77 -g -c dmroutines.f
	cf77 -g -L/home/utexas/ph/phas761/lib tdm.o dmroutines.o -lp329f -o tdm

#############################################################
# Test the application
#############################################################
charon% tdm
 usage: tdm <file name>
 
        Use 'tdm -' to read from standard input
 STOP executed at line 60 in Fortran routine 'TDM'
 CPU: 0.004s,  Wallclock: 0.034s,  1.4% of 8-CPU Machine
 Memory HWM: 401465, Stack HWM: 204161, Stack segment expansions: 0

charon% tdm -
2 2
1 2 3 4
 2*2
 7.,  10.,  15.,  22.
 STOP executed at line 52 in Fortran routine 'TDM'
 CPU: 0.006s,  Wallclock: 3.249s
 Memory HWM: 411707, Stack HWM: 204161, Stack segment expansions: 0