Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Help needed with CVF!

rokko
Beginner
900 Views

Please help, I did not find anything to solve my problem with Compaq Visual Fortran.

The problem is that I cannot make CVF to draw realistic 2D graphs with Compaq Array Visualizer. For example I want to construct the graph of function y=x*x on the segment [0,2]. The code I use is below:

program pp

!we consider y=x*x function on segment [0,2]

use AVDef

use DFLIB

IMPLICIT NONE

integer n

parameter (n=100)

real y(n)

integer i

integer status

character(1) :: key

do i=1,n

y(i)=(0+2*i/n)*(0+2*i/n)

print *, y(i)

end do

call faglStartWatch(y, status)

print *, "Starting Array Viewer"

call faglShow(y, status)

call faglName(y, "My graph", status)

print *, "press any key to continue"

key = GETCHARQQ()

call faglEndWatch(y, status)

print *, "Done!"

end program pp

This code results in Compaq Array Visualizer 1.6 in the graph with 100 units on X-axis. Could you help me how to scale the X-axis so that I receive correct number (2)? The form of the graph is not correct also in spite of how much steps (n) I take.

Thank you very much.

0 Kudos
3 Replies
rwg
Novice
900 Views
First of all you have to change the calculation of your function values y(i). You did only integer calculations so i/n will always give 0. Try something like

do i=1,n

y(i)=(0+(2.0*i)/n)*(0+(2.0*i)/n) ! or (0+2*REAL(i)/n)*(0+2*RAEL(i)/n)

print *, y(i)

end do


0 Kudos
rokko
Beginner
900 Views
Quoting - rwg
First of all you have to change the calculation of your function values y(i). You did only integer calculations so i/n will always give 0. Try something like

do i=1,n

y(i)=(0+(2.0*i)/n)*(0+(2.0*i)/n) ! or (0+2*REAL(i)/n)*(0+2*RAEL(i)/n)

print *, y(i)

end do


Thanks rwg, it was very helpful
0 Kudos
rokko
Beginner
900 Views
OK, the code looks like

program pp
!we consider y=x*x function on segment [0,2]
use AVDef
use DFLIB
implicit none
integer n
parameter (n=1000)
real y(n)
integer i

integer status


do i=1,n
y(i)=(0+(2.0*i)/n)*(0+(2.0*i)/n) ! or (0+2*REAL(i)/n)*(0+2*RAEL(i)/n)
print *, y(i)
end do

call faglStartWatch(y, status)
print *, "Starting Array Viewer"
call faglShow(y, status)
print *, "Done!"

end program pp



After Data->Dimensions->Import(Scale Data) in CAV I receive the graph with proper numbers on axes, but still their ratio is not correct. How to make them to display on axes numbers which are in correct ratio, i.e. segment [0,4] of Y-axis should not be of the same length (or even less) as segment [0,2] of X-axis.

What to do to construct several curves in the same XY axes system?

Thanks.
0 Kudos
Reply