×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Need help to understand a code

 Forum Search FAQs Links MVPs

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) ?'

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

Hi Hugo Henris,

fort.i files are generated in the loops by these write statements

CODE

do 800 i=1,IN
...
...
do 200 k=0,IPAS
...
...
write(30+i,98) tau,x,y
if(k.eq.0) write(30,98) tau,x,y
...
200 continue

800 continue 

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

\$ ./Hugo-lissajou
itype, p, q, N, phi0, aphix (*pi = phix) ?
1 2 3 10 4.5 0 5 
and got the files fort.30 ... fort.40, where my last file fort.40 contains these data:

CODE

0.000000000   -0.000000000   -0.707106781
0.005000000    0.062790520   -0.637423990
0.010000000    0.125333234   -0.562083378
0.015000000    0.187381315   -0.481753674
0.020000000    0.248689887   -0.397147891
...
...
0.980000000   -0.248689887   -0.917754626
0.985000000   -0.187381315   -0.876306680
0.990000000   -0.125333234   -0.827080574
0.995000000   -0.062790520   -0.770513243
1.000000000   -0.000000000   -0.707106781 

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

(OP)
Thank you very much and have a good day

Hugo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!