Wednesday, 19 December 2007

Another post, in which I continue to destroy/re-build my LaTeX installation with my hopeless fumblings.

So, for some reason, I downloaded the TeTeX documentation and stumbled across kpathsea.pdf in the TeTeX documentation menu in Kile. It seems that this is involved in searching for various files needed for LaTeX. For some reason, I tried to run mktexlsr instead of texhash. I probably wasn't managing to find the place where the script was saved, but something seemed to run. But then there was no ls-R file in /usr/local/share/texmf anymore. When I tried to compile any LaTeX code, the text came out ok, but any mathematical symbols, etc. were totally missing. On closer inspection, it was secretly crying that kpathsea couldn't find mf.base. So I managed to stop it finding metafont, or something crazy. I tried to compile the RevTeX sample which came out as a hopeless jumble of lines and which decided randomly to print itself on the group printer.
The shame! The despair!
I have since restored /usr/share/texmf/web2c/texmf.cnf to its former glory and run texhash and I now at least have a working LaTeX again.
Again, I make the changes to texmf.cnf that I made before, and this time run texhash. Boo hoo hoo. Computer says no:

This is dvips(k) 5.95b Copyright 2005 Radical Eye Software (
' TeX output 2007.12.19:1045' ->
kpathsea: Running mktexpk --mfmode ljfour --bdpi 600 --mag 1+57/600 --dpi 657 cmmi10
kpathsea: Running mktexfmt mf.base
fmtutil: format `mf' not available.
mktexpk: Mismatched mode ljfour and resolution 600; ignoring mode.
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1+57/600; nonstopmode; input cmmi10
This is METAFONT, Version 2.71828 (Web2C 7.5.5)
kpathsea: Running mktexfmt mf.base
fmtutil: format `mf' not available.
I can't find the base file `mf.base'!
grep: cmmi10.log: No such file or directory
mktexpk: `mf-nowin -progname=mf \mode:=ljfour; mag:=1+57/600; nonstopmode; input cmmi10' failed to make cmmi10.657pk.
kpathsea: Appending font creation commands to missfont.log.
dvips: Font cmmi10 not found, characters will be left blank.
kpathsea: Running mktexpk --mfmode ljfour --bdpi 600 --mag 1+0/600 --dpi 600 cmmi8
kpathsea: Running mktexfmt mf.base
fmtutil: format `mf' not available.
mktexpk: Mismatched mode ljfour and resolution 600; ignoring mode.
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1+0/600; nonstopmode; input cmmi8
This is METAFONT, Version 2.71828 (Web2C 7.5.5)
kpathsea: Running mktexfmt mf.base
fmtutil: format `mf' not available.
I can't find the base file `mf.base'!
grep: cmmi8.log: No such file or directory
mktexpk: `mf-nowin -progname=mf \mode:=ljfour; mag:=1+0/600; nonstopmode; input cmmi8' failed to make cmmi8.600pk.
dvips: Font cmmi8 not found, characters will be left blank.
. [1]

I think I must be creating the wrong files. A more intelligent approach is needed, ie. engage brain.

Tuesday, 18 December 2007

Mandriva sound problems

Unfortunately, the version of Mandriva that is installed on my machine at work appears to be incompatible with my soundcard. That means from time to time it will scream like a banshee, and there's not much I can do about it, except mute the whole sound system. It can be done on the command-line like this:
and then choose "mute" or somesuch. That should stop the screaming. Thanks Greg!

Monday, 17 December 2007

Installing LaTeX packages

This post is going to change a lot as I try this new feat. I'm writing as I go, and this may not even work. Worse, I might break my current LaTeX distribution. Wish me luck.

I'm using several very helpful pages. One is the readme file for the package I'm installing, and the other is here.

I download the package I want: it happens to be REVTeX4. It's saved as revtex4.tar.gz somewhere temporary. My path $TEXMFLOCAL happens to correspond to /usr/local/share/texmf. This is where all my updates will be stored- in a nice local file, so I can find them again. In this path, I created some handy directories...
mkdir /usr/local/share/texmf/tex
mkdir /usr/local/share/texmf/tex/latex

I changed directories here:
cd /usr/local/share/texmf/tex/latex
next moved the tar file into this location...
cp /temporarylocation/revtex4.tar.gz .
the full-stop is not a typo. I un-tarred it like so:
tar -zxvf revtex4.tar.gz
I had to be acting as a superuser, of course, to wield such fantastic powers. I now have a lovely directory named revtex4. The readme suggests I put the *.bst files in $TEXMFLOCAL/bibtex/bst/revtex4, so I do the following:
cd /usr/local/share/texmf/
mkdir bibtex
mkdir bibtex/bst
mkdir bibtex/bst/revtex4
cd bibtext/bst/revtex4
cp /usr/local/share/texmf/tex/latex/revtex4/*.bst .
I think I shall also delete them from their current home in /tex/latex/revtex4 for good measure. It is now time to instruct my TeX system where to find it all. I altered a cunning file:
kwrite /usr/share/texmf/web2c/texmf.cnf
From here on, I (almost) quote verbatim from this page.

I had already defined a directory for local material, and stuck everything there. This was /usr/local/share/texmf.

If your configuration file has a line that says something like:
...then you are fine; leave it alone. Some older distributions instead have a line like
...commented out (it starts with a percent sign). If yours is commented out, then below it put the non-commented $SELFAUTOPARENT line (and date the change in the file; sometimes that's helpful).
Mine had the "older distribution" option, but it wasn't commented out, so I left it as it was.

Turn on searching of that local directory. A bit further down I found this line
I commented this line out by prefixing a percent sign to the line. Below it I added a new line:
TEXMF={$HOMETEXMF,$TEXMFLOCAL,!!$TEXMFMAIN} which I've deleted the twin exclamation points. The twin exclamation points tell the system that if it does not find a file in the main tree's ls-R database then it should not go on to search the disk. That's OK because your main tree will never change since you will put new things into the local tree. So the rehashing done [later] will be up to date forever. (Older versions have a TEXMF=!!$TEXMFMAIN line which you can comment out and replace with what's above.)

The page also offers wisdom on what I'm actually doing. The re-hashing I do at the end.

Your TeX system can precompute the position of [certain] files so that, instead of scanning the directory tree on your physical disk, your system finds where a file is in a database file called 'ls-R', which lists that directory tree. Then your TeX goes straight to that spot in the directory structure on the disk to get the file's contents. (The software libraries that do this work are called `kpath'.) Point One: If you make any changes to a precomputed portion of your setup then you must rebuild (or `rehash') the database of files, or your changes won't be found.

I continue:

Insure that searching of that local directory is done on disk. For certain kinds of files (such as .vf files), if the system finds a filename database in the directory tree then it will look for that file only in the database -- it will not go on to search the disk (whether there are twin exclamation points or not). Thus, for those files, forgetting to rehash results in your system saying that it cannot find files that you know are in the right place. To avoid that puzzlement, we will omit creation of that database for the local tree... I found this line
...commented it out with a percent sign, and added this just below it:
The version with TEXMF would have caused TEXMFDBS to expand to include the local tree, but now with TEXMFMAIN it will only include the distribution's tree.

And now for the hashing of the database:

Run the command to remake the ls-R filename database. I first checked that there was no ls-R file in the local directory /usr/local/share/texmf and then I did this.
The system responded by telling me that it had made /usr/share/texmf/ls-R (and also a /var/lib/texmf/ls-R file that has to do with user-created fonts that I will not discuss). The main point is that the system did not make /usr/local/share/texmf/ls-R. Consequently, searches of the local material will be made on disk.

Et voila. Thank you, oh great author of handy page (and sorry for stealing your text- I reproduce it here in case it disappears, or I can't find it again!)

LATER: Ok, this appears to have broken my LaTeX as predicted. I'm having problems with finding Metafont. Will sort this out and post in a later post about it, if I can fix it.

Wednesday, 12 December 2007

A really silly post to remind myself of 4 letters

ps ux
... will show me all processes running for my user on my work (mandriva) linux computer. Then I can get rid of the process number that has hung up via the "kill" command.

Also, I think perhaps the following is true for mandriva:
urpmi -install a package
urpme -uninstall a package

Tuesday, 4 December 2007

Converting integers to strings in Fortran

Assisted by this page, I present the result:

character(11), parameter :: fstart = "Xfiles/Xbin"
character(4), parameter :: fend =".txt"
character(3) :: fnum
character(18) :: fname
integer :: blob

blob = 2
write (fnum,1000) blob
1000 format(I3)
fname = fstart//trim(adjustl(fnum))//fend

The double slash "//" concatenates strings. The strange form of the write command (rather than just char(blob) gives you the value of blob as a character, rather than the ascii character for that number. The adjustl(fnum) function moves the contents of string "fnum" to the left, to leave all trailing blanks to the right. The call to trim(string) then removes the trailing blanks. This is necessary to avoid spaces appearing in "fname" if the value of blob is only 2 digits or less, since I defined "fnum" to be three characters long.

Thursday, 29 November 2007

Three cheers for Greg

... who has informed me that when KDE crashes and the title bars disappear from the windows (which it seems to do with annoying regularity), you can just type:
kde-window-decorator &
to get them back again. Hoorah.

Disclaimer: Greg just said "This might not be a solution, it's crashing much more after that!"

Wednesday, 28 November 2007

More NAG problemos

So, to re-cap, the NAG library wants me to have gfortran 4.2.0 or better. I installed the only ready-built new version of gfortran I could find for linux (since Mandriva doesn't offer a package newer than version 4.1.2), which was 4.3.0. I have the NAG library working fine with this new version of gfortran, and it cries if I try to use the old fortran compiler. To re-cap, I now have two compilers on my computer:
gcc version 4.3.0 20071121 (experimental)
gcc version 4.1.2 20070302 (prerelease)

So all is splendid (when I use the routine S14BAF to find the incomplete gamma function) after a few angry words about data-types. You must use double-precision variables (not real(kind = 10) or anything) or else it just returns junk. This will only work if I compile with the new gfortran version.

However , (and there's always a "however" with me and linux!), now I try to compile a program which uses the random number routines G05MKF and similar. The new compiler now gets angry:
/opt/NAG/fll3a21dfl/lib/libnag_nag.a(g05mkxn.o): In function `g05mkxn_':
g05mkxn.f:(.text+0xde): undefined reference to `_gfortran_pow_r8_i4'
/opt/NAG/fll3a21dfl/lib/libnag_nag.a(g05mkzn.o): In function `g05mkzn_':
g05mkzn.f:(.text+0xb1): undefined reference to `_gfortran_pow_r8_i4'
collect2: ld returned 1 exit status
This subroutine "_gfortran_pow_r8_i4" is apparently supposed to be in libgfortran.a and many people have solved their problems by explicitly telling their compiler where to look for this when linking, eg.
/etc/irun/bin/gfortran -m32 simtest.f90 /opt/NAG/fll3a21dfl/lib/libnag_nag.a -o simtest -L/etc/irun/lib -lgfortran
But this still doesn't work. Anyway, I added this directory to the path before hand, so this probably is not the problem. I look at the contents of the libgfortran library using the command:
nm libgfortran.a |more
where I've piped it through the "more" doo-dah so it doesn't all flash by at once. There are lots of similar routines to "_gfortran_pow_r8_i4", but no actual version of the one I want. So my compiler is not lying! I have not so far found a new version of the library which contains this, but my old compiler library does! So for all my random number programs, I must still use the old compiler, which seems to work just fine. Perhaps I can add the subroutine from the old library into the new one? Or will there be other issues?
This page is quite helpful about libraries, I found...

Monday, 26 November 2007

NAG library- getting the thing to work!

So, I receive my license key, and I've installed the library that I needed (FLL3A21DFL, x86-32, Linux, gfortran compiler, Double Precision) and followed the installers instructions on this page. It installed in:
It's now time to run a test! The User's Note suggests to run an example, like thus:
nag_example e04ucf
...for which I moved to my own directory where I had write permission. However, then I need to tell it where the nag_example script is, so I actually had to run:
/opt/NAG/fll3a21dfl/scripts/nag_example e04ucf
The computer said:
Copying e04ucfe.f to current directory
cp /opt/NAG/fll3a21dfl/examples/source/e04ucfe.f .
Compiling and linking e04ucfe.f to produce executable e04ucfe.exe
gfortran -m32 e04ucfe.f /opt/NAG/fll3a21dfl/lib/libnag_nag.a -o e04ucfe.exe
Copying e04ucfe.d to current directory
cp /opt/NAG/fll3a21dfl/examples/data/e04ucfe.d .
Running e04ucfe.exe with data from e04ucfe.d
./e04ucfe.exe < e04ucfe.d > e04ucfe.r
/opt/NAG/fll3a21dfl/scripts/nag_example: line 58: 12681 Segmentation fault ./${example}.exe <${example}.d >${example}.r it happily seg-faulted. I guessed this is because it called "gfortran" which still refers to the old version of the compiler on my machine (I still haven't worked out how to change that!) But now I guess the correct commands to re-compile it:
/etc/irun/bin/gfortran -m32 e04ucfe.f /opt/NAG/fll3a21dfl/lib/libnag_nag.a -o e04ucfe.exe
Then to run it:
./e04ucfe.exe < e04ucfe.d > e04ucfe.r
And it cried:
./e04ucfe.exe: error while loading shared libraries: cannot open shared object file: No such file or directory
No matter, I had forgotten to type
export LD_LIBRARY_FLAG=/etc/irun/lib
export LD_LIBRARY_PATH=/etc/irun/lib
...because I still haven't managed to sort this problem out a better way. Perhaps making a symbolic link to the missing libraries as suggested in the NAG Installer's notes might work:
To simplify access to the libraries you may wish to create symbolic links in a system location such as /usr/lib pointing at the installed libraries. They would then be in the default search path of the linker during the link phase, and be available for execution at run time (in the case of shareable libraries).
Anyway, re-compiling and running now works fine. Time to call a routine from my program. Since this is the NAG library (and not the NAG f90 library), I must call functions with strange names like S14AAF. After adding the compilers own libraries to LD_LIBRARY_PATH (see above!), I additionally added the NAG libraries:

but really all on one line, and with no spaces. Then...
Such that typing:
Gives me:
I've no idea if that was strictly necessary. (Edit- it doesn't seem to be!) In my fortran code, I must declare the types of the NAG functions I call, as well as the fact that they are external:
real(kind = 10) :: factorial, S14AAF, S14BAF
external S14AAF, S14BAF
Where factorial is an internal function I wrote myself. Functions are then called as you would expect...
gam = S14AAF(n+1.0,ifail)
or somesuch line. The program is compiled using:
/etc/irun/bin/gfortran -m32 gammatest.f90 /opt/NAG/fll3a21dfl/lib/libnag_nag.a -o gammatest
...since I had to tell the compiler where to find the external functions.

Thursday, 22 November 2007

Fun and games with gfortran and the NAG library

I am trying to install the NAG library at work to run with gfortran. The problem is that it won't work with the old version of gfortran (4.1.2), which is the only package available for my version of the Mandriva linux kernel (2007). I had to update gfortran to 4.2.0 or better. First I needed to find out which kernel version I had (32 bit or 64 bit on a 64-bit processor?). I typed:
cat /etc/issue
which seemed to tell me that I have a 32 bit kernel. An alternative is to try:
uname =a
I then downloaded the 32 bit gfortran binaries for Linux, and saved them in a temporary file. I then changed to the directory in which I wished to install them:
cd /etc
Next I un-tarred them:
tar -zxvf $temp_folder_path/gfortran-linux.tar.gz
/etc/irun/bin/gfortran -v
told me all about the new version I had installed. When trying to compile my test code, I had to explicitly give the path to the new version, otherwise it used the old version (haven't worked out how to change this yet!)
/etc/irun/bin/gfortran -o test test.f90
So far, so good, but when I tried to run it:
The computer screamed:
./test: error while loading shared libraries: cannot open shared object file: No such file or directory
ldd test
showed me which libraries the program calls, and which (might) be missing. To solve this:
export LD_LIBRARY_FLAG=/etc/irun/lib
and similarly...
export LD_LIBRARY_PATH=/etc/irun/lib
To see what the variables contain:
More fun to come, as I try and get the NAG library to work...

Tuesday, 20 November 2007

Fortran 95

Here I am, installing Fortran 95 compilers at work on Mandriva One. It didn't seem to be installed, so I just installed the two packages pertaining to Fortran from rpmdrake, and now my file test.f90 compiles when I type:

f95 -o test test.f90

and runs with:


Hoorah for that.

Saturday, 3 November 2007

Linux distros, Rosegarden, MIDI files and other jollity.

This is a brief chronicle of my battles with my computer since my last update.

I for some reason I had made a move back to Windows. However, my patience with it was as short lived as most of my houseplants. I'd also recently been using Mandriva Linux at work, which is very yummy indeed. I'd always previously used Ubuntu with Gnome at home, but the wonder of Kile for editing LaTeX tempted me towards KDE. Thus, I spent many evenings installing new distros on my geriatric laptop. First up was Mandriva, but sadly even trying to boot from a live-cd, it hangs before even starting up. I switched again, and tried Fedora. This installed okay eventually, after a few arguments with the disk partitioning. The automatic partitioner failed to wipe the windows partition from the disk, requiring some serious expletives. After a few days, I tired of Fedora as it ran so very slowly on my ancient computer, and was full of all kinds of dowithoutables. Ever faithful to my first linux love, I tried Kubuntu Edgy. It seems to work fine, but is still a little slow. Not the last word by any means- I think I'm going to have to try a tiny version of Linux, but now is not the moment. So, I cope with Kubuntu for the moment.

Now, for various reasons I require a music notation editor. After a little research, I settle for a combination of Rosegarden for the editor, with Lilypond to do my typesetting. I don't recall how I installed them.

Rosegarden seems to work all fine and dandy except one little hitch:

System timer resolution is too low! cries as it opens. Apparently my kernel timer resolution is puny and not good enough to accurately time MIDI files on playback in real time. I could switch to a low-latency kernel, but I can't be bothered. I want a quick fix and instant results. I'm happy for my sound to get a bit squished and crap, any sound will do for the moment. However, apparently I should be hearing my crappy sound even with Rosegarden's little huff. But I have silence. I conclude my problems lie deeper than this. I can't listen to my MIDI file in anyway, Amarok won't recognise it either.

I find this lovely how-to which tells me to install TiMidiy and "freepats" samples. I reproduce some of it's wisdom here for my own benefit:

timidity music.mid

typed in the commandline now lets me here the funky music! Now, I load some modules

sudo modprobe snd-seq-device
sudo modprobe snd-seq-midi
sudo modprobe snd-seq-oss
sudo modprobe snd-seq-midi-event
sudo modprobe snd-seq

and run:

timidity -iA -B2,8 -Os1l -s 44100

on the command line. This loads TiMidity as a midi server and opens 2 midi ports, 128:0 and 128:1 Now Rosegarden makes sounds! Even with it's timing huff. To get TiMidity to do it's stuff on startup, I must edit /etc/default/timidity and uncomment:


I also add


to /etc/modules.

I now remember a neat way to get sheet music- some music editors can import MIDI files and create scores from them. Rosegarden can too, hoorah. So, I boldly import my MIDI file and lo, I can see the music and hear it too! Amarok still doesn't like my MIDI file, but I shall save that battle for another day.

Monday, 13 August 2007

PDF imposition

Apparently this is where you re-order your PDF pages so that when you print them out two per page and double sided it forms a cute little booklet.

You need "psutils" installed.

psbook -s44

where the -s tag sets the number of pages your document needs. This must be divisible by 4. So, for a 43 page document, you need -s44, and the extra blank page will be added. Neat.

Then you can do the following to go back to a pdf:

ps2pdf newoutputfile.pdf

When you print, you must select "duplex: short side" or else it comes out all screwy with the reverse pages rotated through 180 degrees.


Jabref is a marvelous program to sort out all my references. However, I always forget the command I need to run it under linux:

java -jar JabRef-2.2.jar

..and that's it.

Monday, 30 July 2007

You need to dress a cat. And you will say to a cat together with a family. "It has changed just for a moment".

I'm putting off doing the washing up. After just one glass of wine, I find the following sites hilarious. I need help.

Cat Prin- the tailor for a cat you know
It is spring new work! They are frog transformation goods!

The muffler of the car which does the shape of a kitty
Is this probably for the person who likes the kitty?  Or for hateful person?

Oh dear.

Tuesday, 29 May 2007

More excitement from the world of my computer.

Horror of horrors, I now find that my computer didn't come with gcc already! Because I was in a clicky-clicky mood, I went to synaptic package manager, and installed all the gcc- looking things.
I made some crappy C++ program, and tried to compile:

gcc test.cxx

But my computer cried:

gcc: installation problem, cannot exec 'cc1plus': No such file or directory

Boo hoo hoo. The oracle (internet) suggested:

sudo apt-get install g++

And all was merry. However, mostly I want to remind myself how to compile, since I write so little C code recently:

gcc test.c -o test

Where the last flag is to put the output in "test". Huzzah.

Saturday, 14 April 2007

Play mp3 files in Ubuntu

For my second post of ubuntu battles, I'm going to delve back into historic battles (last night) and talk about how to get mp3's to play in Rhythmbox. The first time I did it, it was bizzarre and involved lots of messing about, but now I find the following AMAZING program...
Immense. So easy.

The best thing is, Rhythmbox has AudioScrobbler built-in, so if you are a fanatic, you only have to enter your username and password in Preferences>AudioScrobbler.

Note to self: Actually RUN the EasyUbuntu program after you download it, before you wonder why mp3's are still not recognised. Doh.

Free Pascal

For my first thrilling post, I'd like to tell you all about my entire evening trying to install Free Pascal on my laptop which runs Ubuntu Linux (Dapper Drake, no less). Since I'm not a very experienced user (not at all!) I have been mainly fumbling in the dark. However, since I just managed to compile my first pascal program, I thought I'd share those fumblings with you, incase you're interested. So.

I visited this marvellous website, and downloaded the 2.0.4 release for Linux as a .tar file:
So far, so good. I could have had the .deb packages, but they were numerous, and I didn't know what to do with them, or which ones I needed. So, the .tar version it was. I un-tarred it like so:

tar -xvf fpc-2.0.4.i386-linux.tar

And then I ran the shell script to install it thus:

sudo ./

I wrote an incredible program, and named the file "hello.pp" (my first ever pascal program!)

program hello;
writeln ('Hello, world.');

And then I typed...

fpc hello.pp

But! Woe is me! The computer told me:

hello.pp(4,1) Error: Util ld not found, switching to external linking

Which was very rude. However, after much head scratching and manual searching, I found the following enlightenment from the freepascal user manual:

Under UNIX systems (such as LINUX) you need to have the following programs installed :
1. GNU as, the GNU assembler.
2. GNU ld, the GNU linker.
3. Optionally (but highly recommended) : GNU make. For easy recompiling of the compiler and Run-Time Library, this is needed.

Compiling a compiler? I can't cope with this! A bit more detective work lead me to install binutils using the synaptic package manager, which gave me the gnu assembler and linker. Then my program compiled sweetly and ran when I typed:


Great stuff.

Hello, World.

Hello, deep abyss of cyberspace.

I feel compelled to start my own blog, mainly to chronicle my battles against my computer. It's going to be a fascinating read, I can just tell.

Everytime I work out how to do something with Linux (ie. Installing my printer, taking a whole day) I mean to write it down. However, I never do, and when my computer finally goes mental (I spill a glass of water on it) I have to re-install everything. By this time I've forgotten exactly how I ever got it to play mp3s. But this is getting more regular, as my computer becomes more geriatric. So here's my blog of reminders for myself next time it all goes tits up.

Useful, that is, providing it's not my Ethernet card that gets fried (again).

So, welcome, complete lack of readers, to this most fascinating and fishy blog.