Re: interpreting a piece of code



On Thu, 17 Aug 2006 17:02:35 +0200, Darius Blaszijk <dhkblaszyk@xxxxxxxxxxxxx>
wrote in <FLWdnVNxfPuMGHnZRVnyrw@xxxxxxxxxxxxx>:

I'm porting a fortran library to pascal, but I came a cross a piece of code
which I have no clue how to interpret. I put the code below. My question is
not if someone wants to translate it for me (although I wouldn't mind
ofcourse!), but rather how to interpret this. I appologise for just pasting
a big chunk in this mail, but I really don't even have a clue how to make a
simple example to show my problem. The problem I'm facing are the lines that
are numbered 1 to 18 before the instructions. Do I need to interpret them as
being labels or some kind of goto statements? What is the index variable?

do 1 i=1,12
if (ctrl(i).lt.0.) ctrl(i)=DFAULT(i)
1 continue

That's a loop with I running from 1 to 12, manipulating the
corresponding element of the array ctrl. "DO 1" means loop over statements
up to and including the one labelled 1.

np = ctrl(1)
ngen = ctrl(2)
nd = ctrl(3)
pcross = ctrl(4)
imut = ctrl(5)
pmut = ctrl(6)
pmutmn = ctrl(7)
pmutmx = ctrl(8)
fdif = ctrl(9)
irep = ctrl(10)
ielite = ctrl(11)
ivrb = ctrl(12)
status = 0
c
c Print a header
if (ivrb.gt.0) then

write(*,2) ngen,np,n,nd,pcross,pmut,pmutmn,pmutmx,fdif

2 format(/1x,60('*'),/,
+ ' *',13x,'PIKAIA Genetic Algorithm Report ',13x,'*',/,
+ 1x,60('*'),//,
+ ' Number of Generations evolving: ',i4,/,
+ ' Individuals per generation: ',i4,/,
+ ' Number of Chromosome segments: ',i4,/,
+ ' Length of Chromosome segments: ',i4,/,
+ ' Crossover probability: ',f9.4,/,
+ ' Initial mutation rate: ',f9.4,/,
+ ' Minimum mutation rate: ',f9.4,/,
+ ' Maximum mutation rate: ',f9.4,/,
+ ' Relative fitness differential: ',f9.4)

That's the format for the write statement to console (unit=*);
the non-blank character in column 5 signifies a continuation of the statement
above.

if (imut.eq.1) write(*,3) 'Uniform, Constant Rate'
if (imut.eq.2) write(*,3) 'Uniform, Variable Rate (F)'
if (imut.eq.3) write(*,3) 'Uniform, Variable Rate (D)'
if (imut.eq.4) write(*,3) 'Uniform+Creep, Constant Rate'
if (imut.eq.5) write(*,3) 'Uniform+Creep, Variable Rate (F)'
if (imut.eq.6) write(*,3) 'Uniform+Creep, Variable Rate (D)'
3 format(
+ ' Mutation Mode: ',A)
if (irep.eq.1) write(*,4) 'Full generational replacement'
if (irep.eq.2) write(*,4) 'Steady-state-replace-random'
if (irep.eq.3) write(*,4) 'Steady-state-replace-worst'
4 format(
+ ' Reproduction Plan: ',A)
endif

Again, 3 & 4 are format statements for the write. In fact all the
labels except 1 are for format statements; 1 is the terminal statement
of a do-loop.


--
Ivan Reid, Electronic & Computer Engineering, ___ CMS Collaboration,
Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN
.



Relevant Pages

  • Re: Code to sort out different dates
    ... I'm searching for a date in a word document. ... but sometimes they use very strange combination. ... "strange format" beforehand, your code will not be able to decipher it ... MessageBox to yourself and ask how you want the program to interpret a date ...
    (microsoft.public.vb.general.discussion)
  • Re: Open Office
    ... can't practically rule out interacting with users that lack that clue. ... format, it's the 97-2003 format, usually. ... better as - for example - any Windows etc. because the coherences are ... Instead of writing tools to produce MS-styled bits (which would ...
    (comp.sys.acorn.apps)
  • Re: formatting cells for minutes & seconds
    ... Excel will interpret it as ... "Tyro" wrote: ... format setting for cells and the values I've added are rounded. ...
    (microsoft.public.excel.misc)
  • Re: Interesting Thought Re: How to write a pseudo scientifical hoax
    ... >>might've given you a clue as to how to interpret that post and the ... as europe pulled itself out of the dark ages ... and the people were able to expand their activities ...
    (sci.physics)
  • Re: Interesting Thought Re: How to write a pseudo scientifical hoax
    ... >>might've given you a clue as to how to interpret that post and the ... as europe pulled itself out of the dark ages ... and the people were able to expand their activities ...
    (sci.physics.relativity)