Install RT2870/RT3070 Wireless Adapter on ubuntu 11.04 server

It is a alfaUSB wireless adapter using Ralink chips. Ubuntu 11.04 server doesn’t install drivers automatically (as one was used to windows 7). So ifconfig and iwconfig show no interface for the wireless router. I did the following.
1. download linux driver from Ralink (tar) and unzip it under /home/junwei as say STA, i.e., /home/junwei/STA
2. in the os/linux/, change from n to y

# Support Wpa_Supplicant
# Support Native WpaSupplicant for Network Maganger

3. under /home/junwei/STA/, type

sudo make
sudo make install
sudo modprobe rt5370sta

if you receive error messages saying the device is busy, then
4. add blacklist rt2870sta
to /etc/modprobe.d/blacklist.conf, and add rt5370sta to /etc/module
Now you should be able to see the network interface by typing ifconfig. If not, reboot the server.

ra0       Link encap:Ethernet  HWaddr xxxxxxxx
          inet addr:xxx  Bcast:xxx  Mask:xxx
          inet6 addr: xxx Scope:Link
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:17222066 (17.2 MB)  TX bytes:18470827 (18.4 MB)

5. You certainly don’t see things above coz you haven’t configure which access point to connect. An easy way is to change your interface file to

junwei@Junbuntu:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo ra0 eth0
iface lo inet loopback

# The secondary wireless network interface
iface ra0 inet dhcp
  wpa-ssid APname
  wpa-ap-scan 2
  wpa-proto RSN
  wpa-pairwise AES
  wpa-group AES
  wpa-key-mgmt WPA-PSK
  wpa-psk Mypassword

# The primary network interface
iface eth0 inet dhcp

Notice that this is only for a WPA2/AES wireless connection. For other type of connection, you should google by yourself.

sudo /etc/init.d/networking restart

Finally, you should have wireless internet connected.

Compile a trilino program 101

Offical trilino tutorials start from ex1.cpp, a program shows the basic usage of communicators.

// ***********************************************************************
//                      Didasko Tutorial Package
//                 Copyright (2005) Sandia Corporation
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
// Questions about Didasko? Contact Marzio Sala (marzio.sala _AT_
// ***********************************************************************

// Basic definition of communicator.
// This code should be run with at least two processes
// However, note that the SAME code works even if Epetra
// has been configured without MPI!

#include "Didasko_ConfigDefs.h"

#include "Epetra_ConfigDefs.h"
#ifdef HAVE_MPI
#include "mpi.h"
#include "Epetra_MpiComm.h"
#include "Epetra_SerialComm.h"

int main(int argc, char *argv[])

#ifdef HAVE_MPI
  MPI_Init(&argc, &argv);
  // define an Epetra communicator
  Epetra_MpiComm Comm(MPI_COMM_WORLD);
  Epetra_SerialComm Comm;

  // get the proc ID of this process
  int MyPID = Comm.MyPID();

  // get the total number of processes
  int NumProc = Comm.NumProc();

  // output some information to std output
  cout << Comm << endl;

  // ======================== //
  // now some basic MPI calls //
  // ------------------------ //

  int    ivalue;
  double dvalue, dvalue2;
  double* dvalues;  dvalues  = new double[NumProc];
  double* dvalues2; dvalues2 = new double[NumProc];
  int root = 0;

  // equivalent to MPI_Barrier


  if (MyPID == root) dvalue = 12.0;

  // On input, the root processor contains the list of values
  // (in this case, a single value). On exit, all processes will
  // have he same list of values. Note that all values must be allocated
  // vefore the broadcast

  // equivalent to  MPI_Broadcast

  Comm.Broadcast(&dvalue, 1, root);

  // as before, but with integer values. As C++ can bind to the appropriate
  // interface based on argument typing, the type of data is not required.

  Comm.Broadcast(&ivalue, 1, root);

  // equivalent MPI_Allgather

  Comm.GatherAll(dvalues, dvalues2, 1);

  // equivalent to MPI_Allreduce with MPI_SUM

  dvalue = 1.0*MyPID;

  Comm.SumAll( &dvalue, dvalues, 1);

  // equivalent to MPI_Allreduce with MPI_SUM

  Comm.MaxAll( &dvalue, dvalues, 1);

  // equiavant to MPI_Scan with MPI_SUM

  dvalue = 1.0 * MyPID;

  Comm.ScanSum(&dvalue, &dvalue2, 1);

  cout << "On proc " << MyPID << " dvalue2  = " << dvalue2 << endl;

  delete[] dvalues;
  delete[] dvalues2;

  // ======================= //
  // Finalize MPI and return //
  // ----------------------- //

#ifdef HAVE_MPI

  return( EXIT_SUCCESS );

} /* main */


#ifdef HAVE_MPI
#include "mpi.h"

int main(int argc, char *argv[])
#ifdef HAVE_MPI

  puts("Please configure Didasko with:n"

#ifdef HAVE_MPI
  return 0;

To compile,

junwei@Junbuntu:~/tmptest$ mpiCC -I/home/junwei/data/trilinos/10.8.3/include -L/home/junwei/data/trilinos/10.8.3/lib ex1.cpp -o ex1 -lepetra

Then run,

junwei@Junbuntu:~/tmptest$ mpirun -np 1 ./ex1
Epetra::MpiComm  Processor 0 of 1 total processors
On proc 0 dvalue2  = 0
junwei@Junbuntu:~/tmptest$ mpirun -np 2 ./ex1
Epetra::MpiComm  Processor 0 of 2 total processors
On proc 0 dvalue2  = 0
Epetra::MpiComm  Processor 1 of 2 total processors
On proc 1 dvalue2  = 1
junwei@Junbuntu:~/tmptest$ mpirun -np 3 ./ex1
Epetra::MpiComm  Processor 0 of 3 total processors
Epetra::MpiComm  Processor 2 of 3 total processors
Epetra::MpiComm  Processor 1 of 3 total processors
On proc 1 dvalue2  = 1
On proc 0 dvalue2  = 0
On proc 2 dvalue2  = 3
junwei@Junbuntu:~/tmptest$ mpirun -np 4 ./ex1
Epetra::MpiComm  Processor 0 of 4 total processors
Epetra::MpiComm  Processor 1 of 4 total processors
Epetra::MpiComm  Processor 2 of 4 total processors
Epetra::MpiComm  Processor 3 of 4 total processors
On proc 0 dvalue2  = 0
On proc 1 dvalue2  = 1
On proc 2 dvalue2  = 3
On proc 3 dvalue2  = 6