Anders Andreasen Blog

Just another weblog

Archive for the ‘GNU/Linux’ Category

gfortran headaque reading from piped input

leave a comment »

UPDATE: I have investigated further and it seems that it is somehow related to differences between stdin when read from a redirected file and a pipe stream. I tested with Sun Studio and received a similar error, so it seems that this is not compiler specific. Btw. the code I am testing/wrapping fails when trying to “BACKSPACE”  (previous record) in the read input. Found some info that might relate somehow to the difficulties I am facing at the Intel Forum.

My current  hobby project is trying to wrap a NASA legacy program for chemical equilibrium calculations (NASA CEA) in python. The first step has been tweaking the program to read input from stdin (unit 5 in fortran)  and write output to stdout (unit 6 in fortran). In its current state it reads from an input file and writes to another file. This was faily easy to accomplish by changing the unit numbers. So far so good. It works fine if a run the program with stdin and stdout redirected like

cea2 < input > output

However, things go wrong if i use piped stdin like

cat input | cea2 > output

I really need this, since I would like to use the subprocess.Popen in python in order to communicate with the program through piped input.

I am not a fortran programmer, and it is likely that I have done something wrong. This has been my working hypothesis so far. The program fails with a message saying somthing like “Illegal seek” and the IOSTAT exit code is 29 (STATUS= specifier on an OPEN statement is invalid. According to this site), and it happens when the program tries to “backspace” in the read input. Somehow it may be stock at the end of file or something like that. A lot of googling didn’t bring up much, except this bug report for gfortran. According to the mail archive it should be fixed in versions 4.4, 4.5, and 4.6. I am running Linux Mint 11 with gcc 4.5.2. However, the upstream bug fix may not have surfaced in the downstream gcc package installed on Mint 11. I will try a live distro with gcc 4.6 one of these days, likely Mint 12, to see if it helps.

I have set up a google code site in order to maintain the work done, I have called the python wrap for cea2py.


Written by aandreasen

January 17, 2012 at 11:21 am

Install and run GNU/linux Mint 11 from a usb memory stick

with 2 comments

In this post I will briefly go through the steps of creating a Mint 11 installation on a memory stick. Some of the things may be specific for my own setup i.e. hardware, choice of distro etc. However, most of it will be of general applicability I hope. Basically there are three ways to run a linux installation off a usb memory stick/SSD memory card etc.

  1. Make a live usb from an installation medium by using e.g. Universal USB installer  from windows or Start-up disk creator on Ubuntu/Mint. Any changes made during a live session will be lost upon reboot.
  2. Make a live usb, but also enabling persistence. This way it is possible to store files, chages to the profile, add additional packages with apt etc.
  3. Make a “real” installation on the usb stick as if it was just another hard disk.

Although the second point seems to work surprisingly well, due to security reasons I chose a real installation. Actually I started off with method 2 and installed from one usb to another (no cd-rom/dvd drive in my laptop). The first usb was prepared from my windows installation with the universal USB installer. The second usb was prepared with the gparted tool from within Mint (running from the first usb). An ext2 extended partition was made covering the entire 8 GB disk space.

Installation was started from the Mint 11 Live desktop icon. Once the installer is running choose to do a manual disk partition. In the first Try I chose to install alongside Windows, but it was not possible to control the size of the swap space. Swap ended up taking up 4 GB space (equal to ram amount), leaving too little room for the installation (with 1 GB reserved for a fat  partition). This made the installation incomplete rendering the usb un-bootable.

Remember to place the boot loader on the usb device

Add a ext2 primary partition iwth the “/” (root) mount point.

Do not bother making a swap partition if you have a sufficient amount of RAM. The installation was ended (self-explanatory). On reboot  GRUB would not boot into the newly installed Mint system on my usb stick since it was now /dev/sdb insted of /dev/sdc during installation (Live USB was /dev/sdb). In  order to change that I followed the steps outlined here.  I basically follwed the steps outlined (except booting from the Mint Live usb stick used for the original installation). Before running  update-grub2 I corrected the file /mnt/etc/defaults/grub and corrected any references to sdc to sdb. This seemed to fix the boot problems.

After the installation I made the following modifications based on advice found on the web, in order to improve system response and memory stick lifetime (minimizing writes).

  1. Changed /tmp to RAM. Add the following line to /etc/fstab:
    tmpfs /tmp tmpfs nodev,nosuid,noatime,noexec,size=1G 0 0
    Change the size to whatever seems fit.
  2. All entries in /etc/fstab are added the noatime option. The should eliminate file system writes for files that are read.
  3. To minimize disk write during browser session the cache can be located in RAM e.g. for chromium the following line is added to /etc/fstab
    cache-chromium /home/username/.cache/chromium tmpfs rw,noatime 0 0
    Delete already existing cache and recreate:
    rm -r /home/your_user/.cache/chromium
    mkdir /home/your_user/.cache/chromium
    See also this page.
  4. The also applies to firefox. See e.g. the description here (3. point).
  5. It is recommended in several places to use the noop scheduler (or deadline) instead of the default (completely fair scheduler) for solid state storage. I have tried this but didn’t find any positive difference.
  6. I also considered adding some of the /var stuff into RAM, but I haven’t come so far yet.

This was my steps in getting a Mint 11 sysstem up and running from a USB stick.

Written by aandreasen

November 19, 2011 at 9:09 pm

Posted in Computers, GNU/Linux

Tagged with , ,

The Arch Way

leave a comment »

I have recently replaced ubuntu 10.10 on my home laptop with Arch Linux. I have been wanting to try this distro for a while, but as I am getting older the need for long nights struggling with new linux installations, configurations, package installations, tweaking and fine tuning this and that is getting much smaller. I just want something that works. Then again I am still curious, and I still remember the good things about Gentoo (although it took almost one week of compiling X, gnome, openoffice, firefox etc. back in 2004), the bsd-like portage system, I also like apt, and the high availability of pre-built binary packages, but I am not sure I agree 100% with the direction of Ubuntu. Furthermore I have been looking for a distro that supports the gnome 3 desktop.

A long story short, although the installation of Arch is not as polished as e.g. Ubuntu, OpenSuse, etc., and the fact that only a base system is installed from the beginning (no X, no desktop, no GUI browser etc), it is not that difficult thanks to the great documentation (
Official installation guide and Unofficial beginners guide). One thing to mention which I missed in my first attempt was to include the wifi driver in the packages to be installed, this caused some confusion, but in the second try everything went fine. With Arch some of the system configuration must be done by editing a few configuration files (again this is very well described in the documentation), the most common and pivotal being /etc/rc.conf. Basically it is about setting the hostname, specifying DHCP or static IP for network adapters, specifying kernel modules, specifying which daemons to start at boot etc.

The thing I am most impressed by is the pacman package manager/dependency handler. I mean if you like apt, you will probably also like pacman. The build system is also very easy to get familiar with (again good documentation is the key). It is very easy to build packages (including dependency handling by pacman) from so-called PKGBUILDs (see e.g. AUR for additional user supplied package build instructions for building packages). I was impressed to find a PKGBUILD for the Citrix Receiver (ICAClient). I found that this PKGBUILD specified openmotif as a dependency. Set this to lesstif instead, else some dependency issues may occur with applications specifying lesstif as a dependency (e.g. xpdf, xmgrace and other legacy stuff), since either one or the other should be used.

It was very easy to get Gnome 3 thanks to these easy basic steps. Install gdm as well and start the daemon on boot (edit /etc/rc.conf) in order to have graphical login screen after boot-up. I also like the NetworkManager applet in Gnome, which makes wireless networking a breeze. I installed vpnc and the netwokmanager-vpnc packages to connect to a cisco VPN. As with previous attempts in Ubuntu, Fedora, and Centos, it seems necessary to log out and in again in order for it to work properly in the applet.

Should I also mention that installing plugins (flash, java, video etc) and codecs etc is also accomplished in a very easy way. Other things to like is that default python is 2.7.

Written by aandreasen

May 18, 2011 at 8:19 pm

Flaky vpn connection with vpnc on Ubuntu 9.10

with one comment

I have had trouble keeping my vpn connection alive when connecting to the internal net of my company through the vpnc client. Usually I can be connected for, say, 5-10 min and then vpnc disconnects. I found out that by ticking the “disable dead per detection” box helped a lot. Goto “System -> Preferences -> Network Connections” choose the VPN pane and click “Edit”.

If vpnc is started from the command line do the following to disable dead peer detection
vpnc --dpd-idle 0
Once I disabled DPD I have been able to keep the vpn connection alive without disconneting for several hours. Btw
vpnc --version
vpnc version 0.5.3
Copyright (C) 2002-2006 Geoffrey Keating, Maurice Massar, others
vpnc comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of vpnc under the terms of the GNU General
Public License. For more information about these matters, see the files
named COPYING.
Built without openssl (certificate) support.

Supported DH-Groups: nopfs dh1 dh2 dh5
Supported Hash-Methods: md5 sha1
Supported Encryptions: null des 3des aes128 aes192 aes256
Supported Auth-Methods: psk psk+xauth

Written by aandreasen

April 15, 2010 at 6:36 pm

Posted in GNU/Linux, Ubuntu

Tagged with ,

Using Oracle SQL developer as a GUI front-end for MS SQL server

with 3 comments

In my previous post I described how to use OpenOffice Base as a MS SQL server GUI front-end. On some occasions I have experienced OObase to hang when executing queries or otherwise communicating with the SQL server. For a more professional experience the Oracle SQL developer can be used instead. Oracle SQL developer can be downloaded free-of-charge from the Oracle website.

Download and install Oracle SQL developer

  1. Goto Oracle website
  2. Accept the license agreement
  3. Unless you have an rpm based distribution choose the Oracle SQL Developer for other platforms(this will be assumed throughout this how-to)
  4. Unzip the downloaded zip archive to e.g. /opt or /usr/local. Assuming pwd is the directory to which Oracle SQL developer was downloaded to
    sudo unzip -d /opt
  5. sqldeveloper can be started by the command
    sh /opt/sqldeveloper/ For convenience an alias can be added to .bashrc e.g.
    alias sqldeveloper='sh /opt/sqldeveloper/'

Install jTDS JDBC driver

As with OOBase the jTDS JDBC driver is required for connecting to MS SQL server. Here’s how-to make it work.

  1. If not already downloaded, download the latest JDBC driver from sourceforge
  2. Unpack the archive and copy the jtds-1.2.5.jar into your java environment. On ubuntu 9.10 with Sun Java this is somewhere like /usr/lib/jvm/java-6-sun- This should enable Oracle SQL developer to locate the driver
  3. Start sqldeveloper. You should see the following screen
  4. Click the big green plus in the connections pane and the following window will pop-up
  5. If, for some reason, the (MS) SQLserver pane/entry is not there (only the Oracle) them the jTDS JDBC driver was not successfully loaded (perhaps copied to the wrong destination). The JDBC driver can be installed manually by choosing Preferences in the Tools menu
    Click “Add enty” and located the jtds-1.2.5.jar file on your system
  6. Enter the address of the MS SQL server and your log-in credentials and you’re ready to go. Read more in the documentation on the Oracle website

Written by aandreasen

April 6, 2010 at 9:54 pm

Connecting to MS SQL server from OpenOffice Base using jTDS JDBC driver on linux

with one comment

I have been using the Microsoft Enterprise Manager to connect to MS SQL server in order to test SQL queries before being used in applications etc. Clearly this is not an option on a linux platform. However, different methods for connecting to Microsoft SQL server exists. From Python e.g. the freeTDS driver can be used (not covered here). Sometimes a gui administration tool is nice to have. For this purpose I will cover how to connect to a MS SQL server using the jTDS JDBC driver in OpenOffoce Base. According to the website: “jTDS is an open source 100% pure Java (type 4) JDBC 3.0 driver for Microsoft SQL Server (6.5, 7, 2000, 2005 and 2008)…”.

Download driver

The first step is to download the jTDS driver from Unpack the zip archive somewhere.

Install driver

Open OpenOffice base (on Ubuntu install it with sudo apt-get install Create a new database and call it e.g. “test”

Pres next and choose not to register the db in openoffice base and press finish. Give the db a name. This db is simple used in order to access the ooBase gui in order to add the jTDS JDBC driver. Choose options in the “Tools” menu

Go to the java options and press the Class Path button.

Add the jtds-1.2.5.jar archive file by pressing the “Add archive” button.

Exit OpenOffice Base

Connect to database

Open OpenOffice Base. Choose to connect to existing database using JDBC

Click next.

In the data source URL type the following:
Usually the port number is 1433. Hostname and database name depends on the actual setup.
In the JDBC driver class field type in
Press the Test Class button. If you get a message that says “The JDBC driver was loaded successfully” the driver is OK. Click next to setup authentication.

Test the connection by clicking “Test connection”. If the connection was successful the following message box is displayed

Written by aandreasen

April 5, 2010 at 9:55 pm

pydb not working properly on Ubuntu 9.10

with 7 comments

I was trying to use pydb with ddd in order to debug a python script. However when invoking ddd with e.g.
ddd clamied that it could not find pydb. I tried running pydb from the command line and I was left with a message like
The program 'pydb' is currently not installed. You can install it by typing:
sudo apt-get install pydb
pydb: command not found

Ok, so I tried to install it
sudo apt-get install pydb
Reading package lists... Done
Building dependency tree
Reading state information... Done
pydb is already the newest version.

Hmmm, strange. Google, google, google……….
It turned out that some else had experienced the same problem as me and provided a fix. Apparently the link to pydb in /usr/bin is broken. The fix is
sudo rm /usr/bin/pydb
sudo ln -s /usr/lib/python2.4/site-packages/pydb/ /usr/bin/pydb

Written by aandreasen

March 18, 2010 at 8:46 pm

Posted in GNU/Linux, Programming, Python, Ubuntu

Tagged with , , ,