ARSC HPC Users' Newsletter 310, February 25, 2005

ARSC Technology Panel Talks

There will be several open talks in conjunction with the ARSC Technology Panel (ATP) and the Science Investment Review. Three talks will be held in West Ridge Research Building, Room 010 on March 9th with the final talk given on March 11th in Butrovich 109.


Wednesday, March 9, 2005:
  ATP 

  10:45 a.m. - 11:30 a.m. (WRRB 010)
  "The Virtual Grid Application Development Software (VGrADS) Project: An Overview"
  -- Charles (Chuck) Koelbel, Research Scientist, Rice University

  11:30 a.m. - 12:15 p.m (WRRB 010)
  "Towards a High Performance Computing Economy"
  -- Kevin Wohlever, Director Springfield Technology Center, Ohio Supercomputing Center

  1:30 p.m. - 2:30 p.m. (WRRB 010)
  "Improving Productivity in Supercomputing"
  -- Burton Smith, Chief Scientist, Cray Inc.


Friday, March 11, 2005:
  Science Investment Review

  11:00 a.m. - 12:00 p.m. (Butrovich 109)
  "Shedding Light on Dark Matter with Supercomputers"
  -- Thomas Quinn, Professor of Astronomy, University of Washington

Environment Variables and Command Line Arguments in Fortran


[ Thanks to Lee Higbie of ARSC ]

According to the Fortran 03 "standard" there are a number of new intrinsic functions. I have only seen these implemented by Cray, starting with PrgEnv 5.3, but they are described by J3, formerly formally X3J3, meaning we should probably start using them. Included in the set of new intrinsics are some which allow a program to determine values of environment variables and command line arguments in a manner that will eventually be platform-independent.

The program below illustrates their use. Documentation for these subroutines can be found in Cray's man pages. Some counter-intuitive constructs that I noticed are:

  • Most of these are subroutines, not functions
  • The character variables for returned args and environment vars must be 80 characters long
  • The system_clock function returns a kind=8 integer of roughly the number of 10 ns ticks (on Klondike) since your job started. (An optional 2nd arg to system_clock gives the clock-tick-per-second value.)

The Klondike man pages have illustrations of their use. Here is a sample program.


program  TestFortran03
!  Example showing a few of the Fortran03 intrinsic procedures.
   integer           :: cagCt, leng, stat, i
   character(80)     :: cmd, envVar, var, var2
   character(20)     :: cmd1
   integer (kind = 8):: timeSt, timeEl
   var = 'PWD'
   var2 = 'SHELL'
   !  Start clock for demo
   call system_clock(timeSt)
   
   !  First check command line arguments: ./run arg1 arg2 ...  
   !  These arguments can be in your PBS script
   cagCt = command_argument_count()
   call get_command(cmd, leng, stat)
   print *, "Argument data returned: ", cagCt, " from ", cmd, leng, &
   stat

   !  Checks to see what happens when you fall off the end
   do i = 1, 4   
      call get_command_argument(i, cmd1, leng, stat)
      print *, "The ", i,"th individual command arg = ", cmd1, leng, &
      stat
   enddo         
   !  End do i loop

   !  Second Check for a pair of typical environment variables
   call get_environment_variable(var, envVar)
   print *, "Requested ", trim(var), " returned val = ", trim(envVar)
   call get_environment_variable(var2, envVar)
   print *, "Requested ", trim(var2), " returned val = ", &
   trim(envVar)
   
   !  Last check the new system clock function
   call system_clock(timeEl)
   timeEl  = timeEl - timeSt
   print *, "System clock: ", timeSt,";  elapsed time ", timeEl
   
end program  TestFortran03

Compiling on the X1 doesn't require any additional compiler flags, however the source file extension must be f90.


$ ftn TestFortran03.f90 -o run
$ 

Running the program from the command line a couple of times yielded:


$ ./run this is a test
 Argument data returned:  4  from ./run this is a test <blanks removed> 20,  0
 The  1 th individual command arg = this                 4,  0
 The  2 th individual command arg = is                   2,  0
 The  3 th individual command arg = a                    1,  0
 The  4 th individual command arg = test                 4,  0
 Requested PWD returned val = /u1/uaf/higbie/sol/test
 System clock:  1776289803 ;  elapsed time  1140535

$ ./run Hello Crayons
 Argument data returned:  2  from ./run Hello Crayons <blanks removed>  19,  0
 The  1 th individual command arg = Hello                5,  0
 The  2 th individual command arg = Crayons              7,  0
 The  3 th individual command arg =                      0,  3
 The  4 th individual command arg =                      0,  4
 Requested PWD returned val = /u1/uaf/higbie/sol/test
 Requested SHELL returned val = /bin/ksh
 System clock:  50368566 ;  elapsed time  1736628

Using the following rather generic PBS script, I got the output shown below.

Script:


#PBS -N Fortran03-Test
#PBS -q default
#PBS -l mppe=1
#PBS -l walltime=0:02:00
#PBS -j eo              
#PBS -S /bin/sh         

cd sol/test
date
  ./run Hello ARSC                       # run program
date

Output:


Mon Feb 21 09:53:55 AKST 2005
 Argument data returned:  2  from ./run Hello ARSC <blanks removed>  17,  0
 The  1 th individual command arg = Hello                6,  0
 The  2 th individual command arg = ARSC                 4,  0
 The  3 th individual command arg =                      0,  3
 The  4 th individual command arg =                      0,  4
 Requested PWD returned val = /u1/uaf/higbie/sol/test
 Requested SHELL returned val = /bin/sh
 System clock:  1785702190 ;  elapsed time  332547
Mon Feb 21 09:53:56 AKST 2005

ScaLAPACK News


[ Thanks to Dave Cronk and Julien Langou of the University of Tennessee 
  Knoxville for this LAPACK/ScaLAPACK news. ]

> We are in the process of preparing a patch for the current LAPACK and
> ScaLAPACK software. We would like to hear about any problems you may
> have encountered with the software. Please send us bugs in the
> software and documentation that you are aware of. You can submit a
> bug report by going to 
> http://icl.cs.utk.edu/lapack-forum/lapack_bugs.html . Please be as
> specific as possible. The best way would be by providing us a way to
> reproduce the problem on our computers. We would like to receive all
> the information by February 28th, 2005.
>
>
> Thanks, 
> The LAPACK/ScaLAPACK Team.

FrostByte and Permafrost

ARSC's March Discovery Tuesday will feature Visualization Specialist Bill Brody presenting his recent work visualizing permafrost data with UAF and ARSC researchers. The application, called FrostByte, in its present incarnation, shows data from 13 points from 64 to 70 degrees north latitude at 148.5 west longitude, roughly paralleling the Trans-Alaska Pipeline from Prudhoe Bay to the north side of the Alaska Range.

FrostByte is the result of collaborative work between researchers at the Geophysical Institute, ARSC Summer Interns, ARSC researchers, and Computer Science Faculty. The presentation will last about an hour, with time for questions and answers.

You can catch "Visualizing Permafrost Data" on Tuesday, March 1, at 1p.m. in the Discovery Lab (375 C Rasmuson Library).

Quick-Tip Q & A



A:[[ To keep track of versions of files, I often apply the current date 
  [[ as a suffix or prefix to the filename, and I always use the format
  [[ YYYYMMDD so the versions will sort in order.
  [[
  [[ In other words, I often find myself figuring out what day it is and
  [[ then typing the YYYYMMDD string... like this for example:
  [[
  [[  $ cp valentine.jpg valentines.jpg.20050211
  [[  $ cp bad_ideas bad_ideas.20050211
  [[ 
  [[ Is there some Unix alias or something that could do this for me? 


#
# Jesse Niles gets a bonus for using every quotation mark possible and 
# for introducing both editors to the BSD "apply" command. 
# 

csh:
  alias dateme "apply 'cp %1 %1."\`date +%Y%m%d\`"'"

ksh:
  alias dateme="apply 'cp %1 %1.\`date +%Y%m%d\`'"


The alias can be used on more than one argument:

  % ls
  test1  test2  test3
  % dateme *
  % ls
  test1  test1.20050222  test2  test2.20050222  test3  test3.20050222


Note: "apply" is available on all ARSC systems except the Cray.


#
# From Martin Luthi:
#

First a recommendation: use a version control system (RCS, CVS,
Subversion, or similar).

To answer your question, the date string can be produced with: 
  date +%Y%m%d 
("man date" has all options). So the script would look something like:

-----------------------
#!/bin/sh
cp $1 $1.`date +%Y%m%d`
-----------------------

$1 is the argument to the script (i.e. the filename), and the command in
back-ticks (`date +%Y%m%d`) is evaluated on the fly and the result
inserted. Unix shells can be really nice!


#
# From Harper Simmons:
#

Here's my trivial solution to the date stamp question:

shell script "datestamp"

#! /bin/csh

echo cp $1 $1.`date +%Y%m%d`
     cp $1 $1.`date +%Y%m%d`


#
# Rich Griswold
#

Add this to your Bash (or ZSH) startup script:

  cpd()
  {
    for i in $*; do
    cp $i $i.`date "+%Y%m%d"`
    done
  }

To use it, just call:

  cpd valentine.jpg bad_ideas ...

#
# From Jed Brown:
#

A simple solution is:

  % alias today='date +%Y%m%d'
  % mv foo foo.`today`

More elaborate options are possible using, for instance, the 'zmv'
function from zsh.


#
# From Bob Clark
#

I use ksh and have a mini script called 'today' that I use
for generating filenames with an embedded date.  For example,

  $ cat ~/bin/today
  # today - print out today's date in yymmdd format
  date +%y%m%d

  $ touch test.$(today)
  $ ls test*
  test.050216


#
# Wendy Palm: 
#

What you want to use is "date +%Y%m%d" appended to the end of the file
name.  You don't say which shell you're using as your login shell, so
I've included csh and ksh answers.  One way is to create an alias and
then use that alias when creating the filename.

E.g.  (csh example)

  $ alias mydate "date +%Y%m%d"
  $ somecommand >  file.`mydate`  # note the backquotes that execute the command
  $ ls file*
  file.20050214

However, if you just want to constantly rename a file (rather than
creating new files), you can use something like this:

  $ alias mycp cp '\!* \!*.`date +%Y%m%d`'
  $ mycp ff
  $ ls ff*
  ff              ff.20050214

E.g.  (ksh example)

  $ alias mydate="date +%Y%m%d"

And more complicated ones should be functions instead:

  function mycp
  {
    cp $1 $1.`date +%Y%m%d`
  }

You can get more sophisticated if you want to ensure that you're not
overwriting a currently existing file, add a timestamp, etc.


Q: Is there an easy way to get the contents of a web page via the
   command line?  I would like to download several web pages.  It
   would be nice to automate the process some how.  Is this kind of
   functionality available in any programming languages or in a command
   line utilities?

[[ Answers, Questions, and Tips Graciously Accepted ]]


Current Editors:
Ed Kornkven ARSC HPC Specialist ph: 907-450-8669
Kate Hedstrom ARSC Oceanographic Specialist ph: 907-450-8678
Arctic Region Supercomputing Center
University of Alaska Fairbanks
PO Box 756020
Fairbanks AK 99775-6020
E-mail Subscriptions: Archives:
    Back issues of the ASCII e-mail edition of the ARSC T3D/T3E/HPC Users' Newsletter are available by request. Please contact the editors.
Back to Top