Anders Andreasen Blog

Just another weblog

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 , ,

Check-out MAN Diesel & Turbo “Diesel Facts” publication

leave a comment »

I recently co-authored a draft version of a press release/article on reduced green house gas emissions (GNG) and low methane slip of the new ME-GI duel fuel engine. The ME-GI can be run on both conventional liquid fuel (diesel, heavy fuel oil etc) as well as natural gas. Check out the front page story in “Diesel Facts” 3rd issue 2011.

Written by aandreasen

November 2, 2011 at 1:51 pm

Nexus s wifi connection problem

with one comment

On my recently purchased Google/Samsung nexus s I have experienced problems with the wifi connection. When turning wifi on the wifi icon goes from green to grey (indicating no connection ) after a short while and although I am connected and have a dynamically assigned IP address it is not possible to browse the web or use e.g. marked. It turns out that changing the wireless network settings to always “on”, solves all my problems.
Goto “settings”, “wireless and network”, “wifi settings “, press the menu button and choose “advanced”, “wifi sleep policy.”, set to never.
Thanks to this forum I was led in the right direction.

Written by aandreasen

July 24, 2011 at 9:42 pm

Posted in Android

Tagged with , , ,

Where to publish non-physics preprints? or where to find a chemistry preprint server without the like endorsement system?

leave a comment »

A good friend, and former follow graduate student, and I recently finished a scientific manuscript we have been working for some years now. Since we are both out of academia, and busy with other things, putting an article into peer review is not our top priority at the moment. Nevertheless, we would still like the world (or at least a few people) know about our work, and also secure our intellectual property, by not letting others publish the exact same ideas. We came up with the idea of publishing it on a pre-print server, and then time should tell if we would submit to a peer-reviewed journal. The best known (physics) pre-print server is the hosted by Cornell University Library. Although our work probably could be classified into some subtopic physics category, strictly speaking, chemistry would  be more appropriate, chemical kinetics and catalysis to be more accurate. Furthermore, the endorsement system used by is also frustrating, to put it mildly. Once you’re out of research it seems very difficult to get endorsement. I consider my scientific network to be quite broad and large, however I do not know a single soul who can endorse me. Thus, seemed out of the question. Then, where to find a chemistry pre-print server with a less strict endorsement system? It turns out that Nature has started their own pre-print service known as Nature precedings, and they are embracing chemistry. Thank you.  So now our manuscript is public available. As a note to those wanting to publish physics preprints without endorsement (and chemistry as well), the so-called (arxiv reversed) is an option. However, I have not been able to really judge the quality of the content being published. Well to be honest the same goes to Nature precedings, but since Nature Scientific Publishing is behind, it sounds better in my ears.

Written by aandreasen

July 10, 2011 at 9:11 pm

Things I hate about my HTC Tattoo

leave a comment »

For the last year my cell phone has been a HTC Tattoo. It is my first smart phone and I bought after some considerations, mainly due to the following features:

  • Relatively affordable price
  • Small size
  • The ability to synchronize with my company Exchange account via the ActiveSync
  • VPN connection ability
  • Wireless networking

It tuned out that I got only 3 out of 5 or maybe 3.5 on good day. Here it is. VPN should work, however not with Cisco IPSec. Some have reported that on a rooted Tattoo you can load the kernel module to allow vpnc to work. I am yet to take the plunge and root my Tattoo.

Exchange sync works to some extent. I can read mail and update my calender, but for some strange reason I have not managed to send mail via my Exchange account, or download attachments for that matter.

In addition to these shortcomings the below issues are

  • slow CPU
  • Android lock-in to an ancient android version (1.6) , HTC Sense is part of the explanation.
  • Poor battery capacity (this applies to most smartphones I guess)
  • Completely impossible to read anything on the screen outdoor in sunshine.
  • Too small screen size. It is very difficult to use the soft keyboard. The number of typos is just too high.

I am considering a new Samsung galaxy S Google phone, due to the vanilla android which should enable android updating without delays for GUI customization. On the other hand I find the iphone 4 very appealing also, but I dislike the “Apple lock-in” and their desire to make decisions limiting the freedom of the user/customer.

Written by aandreasen

May 30, 2011 at 8:54 pm

Posted in Android

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


Get every new post delivered to your Inbox.