fortran program doubt


by agalya
Tags: doubt, fortran, program
agalya
agalya is offline
#1
Apr22-09, 08:52 PM
P: 9
i have written a program to plot dst index values using fortran + pgplot, read the input as formatted input
when i'm trying to plot the data points are not plotted correctly.
k = 0
do i = isdt, iedt --------------start date to end date
do j = 1,24
k = k+1
x_val1(j) = x_val(i,j) ---------------------(a)
dst_val1(j) = dst_val(i,j) ----------------(b)
call pgdraw(x_val1(j),dst_val1(j))
enddo
c call pgline(k, x_val1,dst_val1)
c call pgpoint(k-1, x_val1,dst_val1,17)
write(*,'(f11.3,2x,i5)')(x_val1(j),dst_val1(j),j = 1,24) -------------------(c)
enddo
this is the routine to plot, in a & b im converting the 2d array to 1d array which im using to plot.
when i try to plot them it is not coming properly, but when im trying to write the samething (in c), it is writing properly (formatted output). can somebody please help me to solve this problem
Phys.Org News Partner Science news on Phys.org
Better thermal-imaging lens from waste sulfur
Hackathon team's GoogolPlex gives Siri extra powers
Bright points in Sun's atmosphere mark patterns deep in its interior
mathmate
mathmate is offline
#2
Apr23-09, 09:32 PM
P: 366
Has dst_val1(j) been previously defined as an integer? The format assumes it to be an integer.
In Fortran, implicit variables beginning with A-H and O-Z are assumed floating point variables. Integers default to names beginning with I-N... unless of course if the IMPLICIT statement was executed.

If the program does not print properly, could you post some of the results, and also post what you expect to see?
agalya
agalya is offline
#3
Apr23-09, 10:01 PM
P: 9
hi
thank u for ur comment
I've declared the arrays as real
the data points are read as integers(because there is no floating value in the data file)
I've attached the program and the data file
please take a look at it
Attached Files
File Type: txt dst_plot.txt (3.0 KB, 3 views)
File Type: txt dst1989.txt (43.1 KB, 2 views)

mathmate
mathmate is offline
#4
Apr23-09, 10:20 PM
P: 366

fortran program doubt


I believe that's where the problem lies.
If you have declared a variable as real, you would have to read it in using a floating format. The data itself could very well be integer. The format could be f4.0 to read in a real.
You could confirm this by printing some values as soon as you read it in. The same goes for output (write).
agalya
agalya is offline
#5
Apr28-09, 11:04 PM
P: 9
hi
thank you for your help,
as you said, the problem was with the declaration only,
after correcting the program is okey now

regards


Register to reply

Related Discussions
need help about FORTRAN program Mechanical Engineering 7
With FORTRAN I may program Microcontrollers ? Electrical Engineering 5
help with fortran program Programming & Computer Science 6
running a Fortran 77 program in a C++ enviorment/program Programming & Computer Science 2
help with simple Fortran program Programming & Computer Science 1