#!/usr/local/bin/wish -f
#  Modify the previous line to indicate the correct pathname of wish
#  Some systems will misbehave in confusing ways if the first
#  line of the script file is longer than 32 characters, so beware if the full
#  path name of the wish binary is longer than 27 characters.
#
#  NIST Parallel Applications Development Environment (PADE)
#
#  For PADE to run correctly, the PADE_ROOT variable must be set with the
#  pathname of the location of then PADE distribution
#
#  PADE maintained by:  
#
#  Robert Lipman
#  National Institute of Standards and Technology
#  Scientific Visualization Group
#  Building 225, Room B146
#  Gaithersburg, MD  20899
#  (301) 975-3829
#  lipman@cam.nist.gov
# 
#  PADE originally written by:  Justin Turner
#

set version 1.0.0
global version

wm title .    "PADE - Release $version"
wm iconname . "PADE"
wm geometry . +140+158

puts "\nWelcome to PADE ($version)"

global pvmmakefil pvmmakelab hostfile filename
global env penv
global localpath remotepath
global entry1 entry2
global hlist hflist plist pcompile compile
global confirm
global nwin tmpfil ntmpfil
global ntcol ntrow

set status     0
set nwin       0
set ntmpfil    0
set ntcol      4
set ntrow      24
set localpath  ""
set remotepath ""
set hostfile   ""
set pvmmakefil ""
set pvmmakelab ""
set entry1     ""
set entry2     ""
set hlist      ""
set hflist     ""
set plist      ""
set pcompile   ""
set confirm    "on"
set wwwcmd     "mosaic"
set moncmd     ""
set pvmapp     ""
set filename   ""

#------------------------------------------------------------------------------
#  check environment variables

puts "\nChecking environment variables"
set env_name {PADE_ROOT PVM_ROOT PVM_ARCH XPVM_ROOT EDITOR WWW_HOME HOME PATH}
foreach j $env_name {
   set penv($j) ""
   foreach i [array name env] {
      if {($i == $j)} {
         set penv($j) $env($i)
         if {$j == "WWW_HOME"} {unset env(WWW_HOME)}
      }
   }
   if {$penv($j)=="" && $j!="WWW_HOME" && $j!="EDITOR"} {
      puts "$j environment variable not found"
   }
}
if {$penv(PADE_ROOT)==""} {
   puts "\nPADE can be run only if the PADE_ROOT environment variable is set\n"
   exit
}
set auto_path [linsert $auto_path 0 $env(PADE_ROOT)/pade]

if {$penv(PVM_ROOT)==""} {puts "PVM_ROOT needs to be set to run PVM"}
if {$penv(PVM_ARCH)==""} {puts "PVM_ARCH might need to be set to run PVM"}
if {$penv(XPVM_ROOT)==""} {puts "XPVM_ROOT needs to be set to run XPVM"}
if {$penv(PATH)==""} {puts "PATH needs to be set to check for commands"}

#------------------------------------------------------------------------------
#  check commands

puts "\nChecking commands"
set cmd_name {pvm pvmd3 xpvm pvmmake pvmstat pvmtidy xab3\
   mosaic col}
foreach j $cmd_name {
   set pcmd($j) [Find $j]
}

if {![Find $penv(EDITOR)]} {set penv(EDITOR) ""}

#------------------------------------------------------------------------------
#  the col command is used for listing man pages properly

if {$pcmd(col)} {
   set uname [exec uname]
   if {$penv(PVM_ARCH)=="SGI5" || $penv(PVM_ARCH)=="RS6K" || \
      $penv(PVM_ARCH)=="CRAY" || $penv(PVM_ARCH)=="SGIMP" || 
      $uname=="IRIX" || $uname=="AIX"} {
      set colcmd "| col -b -x"
   } else {
      set colcmd "| col -b"
   }
} else {
  set colcmd ""
}

#------------------------------------------------------------------------------
#  main window

frame .f1 -bd 1 -relief raised
frame .f2 -relief raised
frame .f3 -relief raised
frame .f4 -bd 1 -relief raised

label .f2.nistbit -bitmap @$env(PADE_ROOT)/pade/nist.xbm
label .f2.padebit -bitmap @$env(PADE_ROOT)/pade/pade.xbm
pack  .f2.nistbit .f2.padebit -side left -padx 2m -pady 5m -fill x -expand 1

label .f3.line1 -font -*-helvetica-bold-r-normal--*-180-*-*-* \
   -text "Parallel Applications"
label .f3.line2 -font -*-helvetica-bold-r-normal--*-180-*-*-* \
   -text "Development Environment"
pack .f3.line1 .f3.line2 -side top -pady 5m -fill x -expand 1

text	.f4.text -height 2 -font -*-helvetica-bold-r-normal--*-120-*-*-* \
  -fg red -relief sunken -bd 2 -width 1
pack    .f4.text -anchor w -padx 2m -pady 2m -fill x -expand 1 -anchor center
.f4.text delete 1.0 end
.f4.text insert end "Welcome to PADE ($version)" 

pack .f1 -side top
pack .f2 .f3 -side top
pack .f4 -fill x -expand 1 -anchor center
. config -cursor {arrow red white}

#------------------------------------------------------------------------------
#  SETUP

button .f1.setup -text "Setup" -command {
   .f4.text delete 1.0 end
   SetUp
   set plist $hflist
   set pcompile $compile
   if {$filename!=""  && [file exists $filename]} {
      if {[file exists $filename.pvmmake]} {
	 set pvmmakefil "$filename.pvmmake"
	 set pvmmakelab [file tail $pvmmakefil]
         if {$pcmd(pvmmake)} {.f1.run.menu entryconfigure 2 -state normal}
	 .f1.run.menu entryconfigure 0 \
            -label "pvmmake configuration file: $pvmmakelab" -state normal
	 .f1.run.menu entryconfigure 1 -state normal
      }      
   }      
   if {$hlist!=""} {
      .f1.pvm.menu entryconfigure 10 -state normal
   } else {
      .f1.pvm.menu entryconfigure 10 -state disabled
   }
}

#------------------------------------------------------------------------------
#  BUILD

menubutton .f1.run -text "Run" -menu .f1.run.menu \
   -relief raised -borderwidth 2
menu .f1.run.menu

#------------------------------------------------------------------------------
#  PVMMAKE CONFIG FILE

.f1.run.menu add command \
   -label "pvmmake config file: $pvmmakelab" -command {
   .f4.text delete 1.0 end
   if {$pcmd(pvmmake)} {
      Entry 170 218 {Enter pvmmake config file:} $pvmmakefil
      if {$entry1!=""} {
	 if {[file isfile $entry1]} {
	    set pvmmakefil $entry1
	    set pvmmakelab [file tail $pvmmakefil]
	    .f1.run.menu entryconfigure 2 -state normal
	    .f1.run.menu entryconfigure 1 -state normal
	    .f1.run.menu entryconfigure 0 \
               -label "pvmmake config file: $pvmmakelab"
	 } else {
	    .f4.text delete 1.0 end
	    .f4.text insert end "$entry1 is not a file" 
	 }   
      } else {
	 set pvmmakefil $entry1
	 set pvmmakelab [file tail $pvmmakefil]
	 .f1.run.menu entryconfigure 2 -state disabled
	 .f1.run.menu entryconfigure 1 -state disabled
	 .f1.run.menu entryconfigure 0 \
	    -label "pvmmake config file: $pvmmakelab"
      }
   }
}

.f1.run.menu add command -label "List pvmmake config file" -command {
   .f4.text delete 1.0 end
   ListFile $pvmmakefil [concat "Current pvmmake config file " $pvmmakefil]
}
if {$pvmmakefil==""} {
   .f1.run.menu entryconfigure 1 -state disabled
}

#------------------------------------------------------------------------------
#  PVMMAKE

.f1.run.menu add command -label "Run pvmmake" -command {
   .f4.text delete 1.0 end
   if {[file exists $pvmmakefil]} {
      . config -cursor {watch red white}
      update idletasks
      catch \
         {exec pvmmake -f $pvmmakefil >& /tmp/pade.pvmmake_output}
      . config -cursor {arrow red white}
      ListFile /tmp/pade.pvmmake_output "Output of pvmmake"
      catch {exec rm /tmp/pade.pvmmake_output}
   } else {
      .f4.text delete 1.0 end
      .f4.text insert end "No PVMMAKE configuration file" 
   }
}
if {!$pcmd(pvmmake) || $pvmmakefil==""} {
   .f1.run.menu entryconfigure 2 -state disabled
}

#------------------------------------------------------------------------------
#  ENTER PVM APP

.f1.run.menu add separator
.f1.run.menu add command \
   -label "PVM application:" -command {
   .f4.text delete 1.0 end
   Entry 170 218 {Enter PVM application command:} $pvmapp
   if {$entry1!=""} {
      set pvmapp $entry1
      .f1.run.menu entryconfigure 5 -state normal -label "Run: $pvmapp"
      .f1.run.menu entryconfigure 4 -label "PVM application: $pvmapp"
   }
}

#------------------------------------------------------------------------------
#  RUN PVM APP

.f1.run.menu add command -label "Run PVM application" -command {
   .f4.text delete 1.0 end
   exec xterm -geometry +170+218 -sl 1000 \
      -title $pvmapp -e sh -c "$pvmapp; sleep 3600" &
}
if {$pvmapp==""} {.f1.run.menu entryconfigure 5 -state disabled}

#------------------------------------------------------------------------------
#  PVM 

menubutton .f1.pvm -text "PVM" -menu .f1.pvm.menu \
   -relief raised -borderwidth 2
menu .f1.pvm.menu

#------------------------------------------------------------------------------
#  PVM CONSOLE

.f1.pvm.menu add command -label "PVM console" -command {
   .f4.text delete 1.0 end
   if {$hostfile==""} {
      set pick [Dialog .d 170 218 {PADE Question} \
         {No hostfile has been set.  The PVM console (pvm)\
         can be started with or without a hostfile.} questhead 1 \
         {Edit Hostfile} {Set Hostfile and Start} {Start Without Hostfile} \
         {Cancel}]
      if {$pick==0} {
         set name ""
         set hostfile ""
         EditFile $name
         set hostfile $name
      } elseif {$pick==1} {
         set hostfile [FSBox "Pick a hostfile for PVM"]
      }
   } else {
      set pick 2
   }
   if {$pick==1 || $pick==2} {
      if {$hostfile=="" || [file isfile $hostfile]} {
	 exec xterm -geometry +170+218 -sl 1000 \
             -title "PVM console - hostfile is: $hostfile" -e pvm $hostfile &
      } elseif {$hostfile!=""} {
	 .f4.text delete 1.0 end
	 .f4.text insert end "$hostfile is not a file" 
      }
   }
   if {$hostfile!="" && [file isfile $hostfile]} {
      .f1.pvm.menu entryconfigure 9 -state normal
   } else {
      .f1.pvm.menu entryconfigure 9 -state disabled
   }
}
if {$penv(PVM_ROOT)=="" || !$pcmd(pvm)} {
   .f1.pvm.menu entryconfigure 0 -state disabled
}

#------------------------------------------------------------------------------
#  PVMD3 DAEMON

.f1.pvm.menu add command -label "PVM daemon" -command {
   .f4.text delete 1.0 end
   if {$hostfile==""} {
      set pick [Dialog .d 170 218 {PADE Question} \
         {No hostfile has been set.  The PVM daemon (pvmd3)\
         can be started with or without a hostfile.} questhead 1 \
         {Edit Hostfile} {Set Hostfile and Start} {Start Without Hostfile} \
         {Cancel}]
      if {$pick==0} {
         set name ""
         set hostfile ""
         EditFile $name
         set hostfile $name
      } elseif {$pick==1} {
         set hostfile [FSBox "Pick a hostfile for PVMD3"]
      }
   } else {
      set pick 2
   }
   if {$pick==1 || $pick==2} {
      if {$hostfile=="" || [file isfile $hostfile]} {
	 .f4.text delete 1.0 end
	 .f4.text insert end "PVMD3 output is sent to the shell window" 
	 exec pvmd3 $hostfile &
      } elseif {$hostfile!=""} {
	 .f4.text delete 1.0 end
	 .f4.text insert end "$hostfile is not a file" 
      }   
   }
   if {$hostfile!="" && [file isfile $hostfile]} {
      .f1.pvm.menu entryconfigure 9 -state normal
   } else {
      .f1.pvm.menu entryconfigure 9 -state disabled
   }
}
if {$penv(PVM_ROOT)=="" || !$pcmd(pvmd3)} {
   .f1.pvm.menu entryconfigure 1 -state disabled
}

#------------------------------------------------------------------------------
#  XPVM

.f1.pvm.menu add command -label "xpvm" -command {
   .f4.text delete 1.0 end
   set exist [file exists ~/.xpvm_hosts]
   if {$exist} {
      set pick 1
   } else {
      set pick [Dialog .d 170 218 {PADE Question} \
         {No ~/.xpvm_hosts file exists.  XPVM can be started\
         with or without a ~/.xpvm_hosts file} questhead 1 \
         {Edit ~/.xpvm_hosts} {Start Without ~/.xpvm_hosts} {Cancel}]
      if {$pick==0} {
         if {$env(HOME)!=""} {
            EditFile $env(HOME)/.xpvm_hosts
         } else {
            EditFile ""
         }
      }
   }
   if {$pick==1} {
      .f4.text delete 1.0 end
      .f4.text insert end "Some XPVM output is sent to the shell window" 
      exec xpvm &
   }
}
if {$penv(XPVM_ROOT)=="" || !$pcmd(xpvm)} {
   .f1.pvm.menu entryconfigure 2 -state disabled
}

#------------------------------------------------------------------------------
#  PVMSTAT

.f1.pvm.menu add separator
.f1.pvm.menu add command -label "pvmstat" -command {
   .f4.text delete 1.0 end
   . config -cursor {watch red white}
   update idletasks
   catch {exec pvmstat >& /tmp/pade.pvmstat_output}
   . config -cursor {arrow red white}
   ListFile /tmp/pade.pvmstat_output "Output of pvmstat"
   catch {exec rm /tmp/pade.pvmstat_output}
}
if {!$pcmd(pvmstat)} {.f1.pvm.menu entryconfigure 4 -state disabled}

#------------------------------------------------------------------------------
#  PVMTIDY

.f1.pvm.menu add command -label "pvmtidy" -command {
   .f4.text delete 1.0 end
   if {$hostfile==""} {
      set pick [Dialog .d 170 218 {PADE Question} \
         {No hostfile has been set.  A Hostfile must be set to run PVMTIDY.} \
         questhead 0 {Set Hostfile} {Edit Hostfile} {Cancel}]
      if {$pick==0} {
         set hostfile [FSBox "Pick a hostfile for PVMTIDY"]
      } elseif {$pick==1} {
         set hostfile ""
         set name ""
         EditFile $name
         set hostfile $name
      }
   }
   if {$hostfile!=""} {
      if {[file isfile $hostfile]} {
	 exec xterm -geometry +170+218 -sl 1000 -title "PVMTIDY" \
             -e sh -c "pvmtidy $hostfile; sleep 3600" &
      } else {
	 .f4.text delete 1.0 end
	 .f4.text insert end "$hostfile is not a file" 
      }
   }
   if {$hostfile!="" && [file isfile $hostfile]} {
      .f1.pvm.menu entryconfigure 9 -state normal
   } else {
      .f1.pvm.menu entryconfigure 9 -state disabled
   }
}
if {!$pcmd(pvmtidy)} {.f1.pvm.menu entryconfigure 5 -state disabled}

#------------------------------------------------------------------------------
#  PICK HOSTFILE

.f1.pvm.menu add separator
.f1.pvm.menu add command -label "Pick Hostfile" -command {
   .f4.text delete 1.0 end
   set hostfile [FSBox "Pick a hostfile"]
   if {$hostfile!="" && ![file isfile $hostfile]} {
      .f4.text delete 1.0 end
      .f4.text insert end "$hostfile is not a file" 
   }
   if {$hostfile!="" && [file isfile $hostfile]} {
      .f1.pvm.menu entryconfigure 9 -state normal
   } else {
      .f1.pvm.menu entryconfigure 9 -state disabled
   }
}

#------------------------------------------------------------------------------
#  EDIT HOSTFILE

.f1.pvm.menu add command -label "Edit Hostfile" -command {
   .f4.text delete 1.0 end
   set name $hostfile
   EditFile $name
   set hostfile $name
   if {$hostfile!="" && [file isfile $hostfile]} {
      .f1.pvm.menu entryconfigure 9 -state normal
   } else {
      .f1.pvm.menu entryconfigure 9 -state disabled
   }
}

#------------------------------------------------------------------------------
#  LIST HOSTFILE

.f1.pvm.menu add command -label "List Hostfile" -command {
   .f4.text delete 1.0 end
   ListFile $hostfile [concat "Current hostfile " $hostfile]
}

#------------------------------------------------------------------------------
#  WRITE HOST LIST TO HOSTFILE

.f1.pvm.menu add command -label "Write Host list to Hostfile" -command {
   .f4.text delete 1.0 end
   set hostfile [FSBox "Write Host list to Hostfile"]
   if {$hostfile!=""} {
      if {[file isdirectory $hostfile]} {
	 .f4.text delete 1.0 end
	 .f4.text insert end "$hostfile is not a file" 
         return
      }
      if {[file exists $hostfile]} {
         set pick [Dialog .d 200 278 {PADE Question} \
            [concat "Overwrite " $hostfile " ?"] questhead 0 \
            {Overwrite} {Cancel}]
         if {$pick} return
      }
      set f_hostfile [open "$hostfile" w]
      set i 0
      foreach item $hlist {
	 if {[expr $i%2==0]} {puts $f_hostfile "$item"}
	 set i [expr $i+1]
      }
      close $f_hostfile
   }
   if {$hostfile!="" && [file isfile $hostfile]} {
      .f1.pvm.menu entryconfigure 9 -state normal
   } else {
      .f1.pvm.menu entryconfigure 9 -state disabled
   }
}

if {$hostfile!="" && [file isfile $hostfile]} {
   .f1.pvm.menu entryconfigure 9 -state normal
} else {
   .f1.pvm.menu entryconfigure 9 -state disabled
}
if {$hlist!=""} {
   .f1.pvm.menu entryconfigure 10 -state normal
} else {
   .f1.pvm.menu entryconfigure 10 -state disabled
}

#------------------------------------------------------------------------------
#  MONITOR

menubutton .f1.monitor -text "Monitor" -menu .f1.monitor.menu \
   -relief raised -borderwidth 2
menu .f1.monitor.menu

#------------------------------------------------------------------------------
#  XAB

.f1.monitor.menu add command -label "xab3" -command {
   .f4.text delete 1.0 end
   exec xterm -geometry +170+218 -sl 1000 -title "xab3" -e xab3 &
}
if {!$pcmd(xab3)} {.f1.monitor.menu entryconfigure 0 -state disabled}

#------------------------------------------------------------------------------
#  USER-DEFINED MONITOR

.f1.monitor.menu add separator
.f1.monitor.menu add command \
   -label "User-defined monitor: $moncmd" -command {
   .f4.text delete 1.0 end
   Entry 170 218 {Enter monitor command:} $moncmd
   if {$entry1!=""} {
      set moncmd $entry1
      if {![Find [lindex [split $moncmd { }] 0]]} {
	 .f4.text delete 1.0 end
	 .f4.text insert end \
            "$moncmd not found searching PATH environment variable"
      } 
      .f1.monitor.menu entryconfigure 4 -state normal -label "Run: $moncmd"
      .f1.monitor.menu entryconfigure 3 \
         -label "User-defined monitor: $moncmd"
   } else {
      set moncmd $entry1
      .f1.monitor.menu entryconfigure 4 -state disabled \
         -label "Run user-defined monitor"
      .f1.monitor.menu entryconfigure 3 -label "User-defined monitor:"
   }
}

#------------------------------------------------------------------------------
#  RUN USER-DEFINED MONITOR

.f1.monitor.menu add command -label "Run user-defined monitor" -command {
   .f4.text delete 1.0 end
   exec xterm -geometry +170+218 -sl 1000 \
      -title $moncmd -e sh -c "$moncmd; sleep 3600" &
}
if {$moncmd==""} { .f1.monitor.menu entryconfigure 4 -state disabled}

#------------------------------------------------------------------------------
#  HELP

menubutton .f1.help -text "Help" -menu .f1.help.menu \
   -relief raised -borderwidth 2
menu .f1.help.menu
.f1.help.menu add cascade -label "Man Pages" -menu .f1.help.menu.man
.f1.help.menu add cascade -label "WWW" -menu .f1.help.menu.mosaic

#------------------------------------------------------------------------------
#  WWW BROWSER

.f1.help.menu add separator
.f1.help.menu add command \
   -label "WWW browser is: $wwwcmd" -command {
   .f4.text delete 1.0 end
   Entry 170 218 {Enter WWW browser command:} $wwwcmd
   if {$entry1!=""} {
      set wwwcmd $entry1
      .f4.text insert end "WWW browser is: $wwwcmd"
      .f1.help.menu entryconfigure 1 -state normal
      .f1.help.menu entryconfigure 3 -label "WWW browser is: $wwwcmd"
      if {$wwwcmd=="mosaic" || $wwwcmd=="Mosaic" } {
         set wwwopt "-home"
      } elseif {$wwwcmd=="netscape"} {
         set wwwopt ""
      } else {
         set wwwopt ""
      }
   }
}
if {![Find $wwwcmd]} {.f1.help.menu entryconfigure 1 -state disabled}

#------------------------------------------------------------------------------
#  CONFIRMATION DIALOG

.f1.help.menu add command \
   -label "Confirmation dialog is: $confirm" -command {
   .f4.text delete 1.0 end
   set oconfirm $confirm
   if {$oconfirm=="on"} {set confirm "off"}
   if {$oconfirm=="off"} {set confirm "on"}
   .f1.help.menu entryconfigure 4 -label "Confirmation dialog is: $confirm"
   .f4.text delete 1.0 end
   .f4.text insert end "Confirmation dialog is: $confirm" 
}

#------------------------------------------------------------------------------
#  BUG REPORT

.f1.help.menu add command -label "Report bugs to: pade@cam.nist.gov"

#------------------------------------------------------------------------------
#  LIST MAN PAGES

menu .f1.help.menu.man
.f1.help.menu.man add command -label "pvm_intro" -command {
   .f4.text delete 1.0 end
   . config -cursor {watch red white}
   update idletasks
   eval exec man pvm_intro $colcmd >& /tmp/pade.manpvm_intro
   . config -cursor {arrow red white}
   ListFile /tmp/pade.manpvm_intro "man pvm_intro"
   catch {exec rm /tmp/pade.manpvm_intro}
}
.f1.help.menu.man add command -label "pvm (console)" -command {
   .f4.text delete 1.0 end
   . config -cursor {watch red white}
   update idletasks
   eval exec man pvm $colcmd >& /tmp/pade.manpvm
   . config -cursor {arrow red white}
   ListFile /tmp/pade.manpvm "man pvm"
   catch {exec rm /tmp/pade.manpvm}
}
.f1.help.menu.man add command -label "pvmd3 (daemon)" -command {
   .f4.text delete 1.0 end
   . config -cursor {watch red white}
   update idletasks
   eval exec man pvmd3 $colcmd >& /tmp/pade.manpvmd3
   . config -cursor {arrow red white}
   ListFile /tmp/pade.manpvmd3 "man pvmd3"
   catch {exec rm /tmp/pade.manpvmd3}
}

.f1.help.menu.man add separator
.f1.help.menu.man add command -label "gams" -command {
   .f4.text delete 1.0 end
   . config -cursor {watch red white}
   update idletasks
   eval exec man gams $colcmd >& /tmp/pade.mangams
   . config -cursor {arrow red white}
   ListFile /tmp/pade.mangams "man gams"
   catch {exec rm /tmp/pade.mangams}
}

#------------------------------------------------------------------------------
#  START UP WWW PAGES

if {$wwwcmd=="mosaic" || $wwwcmd=="Mosaic" } {
   set wwwopt "-home"
} elseif {$wwwcmd=="netscape"} {
   set wwwopt ""
} else {
   set wwwopt ""
}

menu .f1.help.menu.mosaic
.f1.help.menu.mosaic add command -label "PADE Home Page" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://physics.nist.gov/ResOpp/hpcc/pade.html &
}
.f1.help.menu.mosaic add command -label "PADE Manual" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt file://localhost/$env(PADE_ROOT)/pade_doc/pade_man/pade_man.html &
}
.f1.help.menu.mosaic add command \
   -label "NIST Parallel Processing Environments" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt \
      http://doc.cam.nist.gov/caml/sced/parallel/envir1.html &
}
.f1.help.menu.mosaic add command \
   -label "pvmmake, pvmstat, pvmtidy, and more" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt \
      http://doc.cam.nist.gov/caml/sced/parallel/envir1a.html &
}
.f1.help.menu.mosaic add separator
.f1.help.menu.mosaic add command -label "PVM (Parallel Virtual Machine)" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://hebe.nectar.cs.cmu.edu:8001/ &
}
.f1.help.menu.mosaic add command -label "PVM Man Pages" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://hebe.nectar.cs.cmu.edu:8001/manpages.html &
}
.f1.help.menu.mosaic add command -label "Xab (X Analysis and deBugging for PVM programs)" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt \
      http://www.cs.cmu.edu:8001/afs/cs.cmu.edu/project/nectar-adamb/web/Xab.html &
}
.f1.help.menu.mosaic add command -label "HeNCE (Heterogeneous Network Computing Env.)" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://www.netlib.org/hence/ &
}
.f1.help.menu.mosaic add command -label "ParaGraph (display of parallel program performance)" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://www.netlib.org/paragraph/ &
}
.f1.help.menu.mosaic add separator
.f1.help.menu.mosaic add command -label "IBM SP2" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://lscftp.kgn.ibm.com/pps/products/ &
}
.f1.help.menu.mosaic add command -label "Maui HPCC IBM SP2 Workshop" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://www.mhpcc.edu/training/workshop/html/workshop.html &
}
.f1.help.menu.mosaic add separator
.f1.help.menu.mosaic add command -label "Parallel Tools Projects Around the World" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://www.llnl.gov/ptools/projects.world.html &
}
.f1.help.menu.mosaic add command -label "MPI (Message Passing Interface)" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://www.mcs.anl.gov/Projects/mpi/index.html &
}
.f1.help.menu.mosaic add command -label "GAMS Guide to Available Mathematical Software" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://gams.nist.gov/ &
}
.f1.help.menu.mosaic add separator
.f1.help.menu.mosaic add command -label "Search the Web" -command {
   .f4.text delete 1.0 end
   eval exec $wwwcmd $wwwopt http://webcrawler.cs.washington.edu/WebCrawler/WebQuery.html &
}

#-------------------------------------------------------------------------------
#  EXIT

button .f1.exit -text "Exit" -command {
   .f4.text delete 1.0 end
   if {$confirm=="on"} {
      set pick [Dialog .d 170 218 {PADE Question} \
	 {Are you sure you want to exit NIST PADE?} questhead 0 {Yes} {No}]
   } else {
      set pick 0
   }	 
   if {$pick==0} {
      if {$penv(WWW_HOME)!=""} {set env(WWW_HOME) $penv(WWW_HOME)}
      destroy .
   }
}

#-------------------------------------------------------------------------------

pack .f1.setup .f1.run .f1.pvm .f1.monitor .f1.help .f1.exit \
   -side left -ipadx 2m -ipady 1m
