Angel de Vicente’s Weblog

An HPC User’s Blog

Archive for April, 2008

Brute-force solver for Eternity II (in Fortran)

Posted by angeldevicente on April 30, 2008

An interesting programming puzzle (with a $2M prize!!) is the Eternity II puzzle. At Yahoo there is quite active group (of which I am a member) to discuss all things Eternity II.

Recently I have made available in that group (with nickname Txibilis) a
solver written in Fortran. Needless to say that the solver doesn’t solve the real puzzle… So far, a puzzle of size 13×13 is feasible, but the real puzzle is a monster 16×16, which is far beyond what this solver can do… Still, the puzzle is a nice excuse to learn about code optimization, etc. Soon (I hope) I will be releasing parallel versions (with MPI and others) of the code.

Posted in Fortran | Tagged: | No Comments »

Building A Virtual Cluster with Xen

Posted by angeldevicente on April 25, 2008

I just visited the Cluster Monkey page, and I was amazed to see that my article on Building a Virtual Cluster with Xen got nearly 48000 visits!!! I guess it was a popular one… I should update it, since Xen has had a lot of progress since I wrote it.

Posted in Admin | Tagged: | No Comments »

Anti-blot system (SPOJ)

Posted by angeldevicente on April 25, 2008

I just decided a couple of days ago to start a daily “programming gym” session, to keep my programming skills sharp, since otherwise there are long periods of time in which I don’t do any programming, and the “trade” suffers.

Languages to practice will vary, but at present the focus will be in Fortran. And the problems to solve will come from Sphere Online Judge.

The first program to try has been ABSYS, and here is the code for it:

PROGRAM ABSYS
IMPLICIT NONE

CHARACTER :: mas, igual
CHARACTER (LEN=50) :: dato1,dato2,resultado
INTEGER :: sets,count,idato1,idato2,iresultado

READ*, sets

DO count=1,sets
READ*, dato1,mas,dato2,igual,resultado
CALL convert(dato1,idato1)
CALL convert(dato2,idato2)
CALL convert(resultado,iresultado)

IF (idato1 .EQ. -1) WRITE(*,’(I0,A,I0,A,I0)’) iresultado-idato2, ” + “, idato2, ” = “, iresultado
IF (idato2 .EQ. -1) WRITE(*,’(I0,A,I0,A,I0)’) idato1, ” + “, iresultado-idato1, ” = “, iresultado
IF (iresultado .EQ. -1) WRITE(*,’(I0,A,I0,A,I0)’) idato1, ” + “, idato2, ” = “, idato1+idato2
END DO

CONTAINS

SUBROUTINE convert(dato,idato)
CHARACTER (LEN=*) :: dato
INTEGER :: idato, pos

pos = INDEX(dato,”machula”)
IF (pos .EQ. 0) THEN
READ (dato,’(I50)’), idato
ELSE
idato = -1
END IF

END SUBROUTINE convert

END PROGRAM ABSYS

The program is trivial, but there are a couple of things to note:

    In Fortran, to print a number with just the minimum necessary width, the edit descriptor is I0.
    There are no intrinsic functions to convert a string to a number or viceversa, but instead we use what it is called an internal file, and we can write something like “READ (dato,’(I50)’), idato”

Posted in Fortran | Tagged: | No Comments »

Fortran Compiler Comparisons

Posted by angeldevicente on April 25, 2008

Just yesterday, Polyhedron Software announced a comparative study of different Fortran compilers, which can be found at: http://www.polyhedron.com/compare0html

Posted in Fortran | No Comments »

Hello world!

Posted by angeldevicente on April 23, 2008

Fine, I have been welcomed to WordPress.com. Now I will have to keep it up-to-date with some info, but not today…. I’m just too busy!

Posted in Uncategorized | No Comments »