Thursday 23 July 2009

Battles won against my laptop

My 7 year old laptop is now too geriatric to run anything too meaty. Windows is definitely out of the question, so I have Xubuntu.
Today, I bring you:

How to add a terminal launcher to the xfce panel:
right-click>add new item>launcher
Then find the terminal program in /usr/bin/xfce4-terminal and drag it into the launcher. Or, just set command to "/usr/bin/xfce4-terminal" and uncheck the "run in terminal" box. Give it a nice name and picture of a terminal window.


How to connect to a windows shared area when smb4k is acting up:
If you can see the various windows computers in smb4k (eg ACOMPUTER) but it won't let you mount ACOMPUTER/afile, then try this on the command line...
sudo mount -t smbfs //ACOMPUTER/afile/ -o username=myname /home/myfile/MyMount/
...where you have provided your username to access the shared area. When prompted, give the corresponding password.
To unmount:
sudo umount /home/myfile/MyMount/

Friday 17 July 2009

Greek letters in Inkscape

To get greek letters, press Ctrl+u. You'll see "Unicode (Enter to finish)" come up in the status bar. Let go of Ctrl+u and type in your unicode number followed by the return key.

w00.

Friday 3 July 2009

Formatted Read Statements yet again.

Further to my last post, I want to add a code snippet for reading in large arrays with many columns. It has some nice implicit do-loops. "myfile.ans" contains 1 column of integers, followed by Ncols of data that I want to read into "Blam" and Ncols that I want to read into "Dlam".

integer :: i, Nrows, Ncols
real :: Blam(Nrows, Ncols), Dlam(Nrows, Ncols)
integer :: pixies(Nrows)
character(1) :: tmp

open(unit=2,file='myfile.ans',status='OLD',action='READ')
do i = 1,Nrows,
read(2,20) pixies(i), (tmp,Blam(i,j), j=1,Ncols), (tmp,Dlam(i,j), j=1,Ncols)
enddo
close(2)
20 format(I3, 36(A1,F6.4))

Annoyingly, I can't seem to replace 36 (=2*Ncols) with a variable name or my compiler shouts. A mystery for another time I think.

Monday 22 June 2009

Formatted Read Statements again.

Grrr. I'm trying to read in a formatted file of integers such as:
1 1 1
10 10 10
100 100 100
(... three characters wide, one space between each column)
Fortran is giving me junk unless I format my read statement with
10 format(I3,A1,I3,A1,I3)
where I read the single space into a temporary variable declared as:
character(1) :: tmp
This is why I am in a bad mood with Fortran today. I put faith in it, and this is how it repays me. Plus, the fridge has frozen my tomatoes. I wonder if they are in league.

Friday 19 June 2009

Compiling modules separately

When I have a module declared in mymodule.f90, I can compile it like so:
gfortran -m32 -c mymodule.f90
... I can also compile the main file this way:
gfortran -m32 -c mainfile.f90
Finally I must link it, possibly also with the NAG library:
gfortran -m32 mymodule.o mainfile.o /opt/NAG/fll3a21dfl/lib/libnag_nag.a -o mainfile

Thursday 18 June 2009

Fortran array initialization

This webpage here is very helpful for fortran arrays.

I'd forgotten that you can initialize vectors like this:
x = (/(i,i=0,maxx-1)/)
Instead of:
do i=1,maxx
x(i) = i-1
enddo

Wednesday 13 May 2009

gcc fails to find header files

Because I have clearly been neglecting the guts of my gcc installation too much recently (oh happy respite from commandline errors!), my computer decided to throw a wobbly about compiling a C program that included (amongst other friends) io.h, conio.h and dir.h.
A simple "hello world" program would compile when including stdio.h but not when I added io.h, screaming:
error: io.h: No such file or directory
I thought gcc would search /usr/include/sys automatically, but it appears not. I have to tell it on the command line:
gcc -o andorsif andorsif.c -I /usr/include/sys -L /usr/include/sys
After I cleared up that heap of doodoo then I still get errors from the program that look like:
error: ‘MAXPATH’ was not declared in this scope
but replacing incidences of MAXPATH with FILENAME_MAX seems to clear up that one.