## Need help to understand a code

## Need help to understand a code

(OP)

Hello everyone,

I'm a student in Belgium in Mathematics and for my master's thesis, I've to create some Lissajous curves

One of my teachers helps me and send me this code in Fortran! But I don't understand anything, my lesson in Fortran was in a new fortran version and this code is written in an old one.

I have to compile this code with "gfortran Hugo-lissajou.f -o test" in the terminal and generate some figures. But I receive some illegible files like "fort.32" that I can't plot on my laptop

program lissajou

implicit real*8(a-h,m-z)

pi=4.d0*datan(1.d0)

twopi=2.d0*pi

x0=1.d0

y0=1.d0

write(*,*) 'itype, p, q, N, phi0, aphix (*pi = phix) ?'

read(*,*) itype,ip,iq,IN,phi0,aphix

p=ip

q=iq

GN=IN

phix=pi*aphix

phiy=(q*phix-pi*phi0)/p

write(*,*) (q*phix-p*phiy)/pi,phi0

do 800 i=1,IN

IPAS=200

GPAS=IPAS

per=1.0d0

pas = per/GPAS

write(*,*) IPAS,GPAS,Per,pas

do 200 k=0,IPAS

tau=k*pas

if(itype.eq.1) then

t=tau+I/GN

x=x0*dsin(twopi*p*t+phix)

y=y0*dsin(twopi*q*t+phiy)

else

t1=p*tau+I/GN

x=x0*dsin(twopi*t1+phix)

t2=q*tau+I/GN

y=y0*dsin(twopi*t2+phiy)

endif

write(30+i,98) tau,x,y

if(k.eq.0) write(30,98) tau,x,y

98 format(1x,3(f13.9,2x))

200 continue

800 continue

stop

end

Thank you very much and sorry for my English level

Hugo

I'm a student in Belgium in Mathematics and for my master's thesis, I've to create some Lissajous curves

One of my teachers helps me and send me this code in Fortran! But I don't understand anything, my lesson in Fortran was in a new fortran version and this code is written in an old one.

I have to compile this code with "gfortran Hugo-lissajou.f -o test" in the terminal and generate some figures. But I receive some illegible files like "fort.32" that I can't plot on my laptop

program lissajou

implicit real*8(a-h,m-z)

pi=4.d0*datan(1.d0)

twopi=2.d0*pi

x0=1.d0

y0=1.d0

write(*,*) 'itype, p, q, N, phi0, aphix (*pi = phix) ?'

read(*,*) itype,ip,iq,IN,phi0,aphix

p=ip

q=iq

GN=IN

phix=pi*aphix

phiy=(q*phix-pi*phi0)/p

write(*,*) (q*phix-p*phiy)/pi,phi0

do 800 i=1,IN

IPAS=200

GPAS=IPAS

per=1.0d0

pas = per/GPAS

write(*,*) IPAS,GPAS,Per,pas

do 200 k=0,IPAS

tau=k*pas

if(itype.eq.1) then

t=tau+I/GN

x=x0*dsin(twopi*p*t+phix)

y=y0*dsin(twopi*q*t+phiy)

else

t1=p*tau+I/GN

x=x0*dsin(twopi*t1+phix)

t2=q*tau+I/GN

y=y0*dsin(twopi*t2+phiy)

endif

write(30+i,98) tau,x,y

if(k.eq.0) write(30,98) tau,x,y

98 format(1x,3(f13.9,2x))

200 continue

800 continue

stop

end

Thank you very much and sorry for my English level

Hugo

## RE: Need help to understand a code

fort.ifiles are generated in the loops by these write statements## CODE

So if you enter IN = 10 you will get the files fort.30, fort.31, ..., fort.40

These are normal text files, with 3 columns of numbers.

For example I entered on the input of the program these numbers

## CODE

## CODE

It seems that the columns contain parameter t increased by 0.005 and the computed point coordinates x(t), y(t).

To plot the curve you have to use these text files as an input for a program for plotting curves, e.g.

gnuplot.## RE: Need help to understand a code

Hugo