Fortran Program Doubt: Plotting DST Index Values

Click For Summary

Discussion Overview

The discussion revolves around a Fortran program intended to plot DST index values using PGPlot. Participants explore issues related to data plotting, variable declarations, and input formats, focusing on the technical aspects of programming and data handling.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their Fortran program and the issue of data points not being plotted correctly despite formatted output working as expected.
  • Another participant questions whether the variable dst_val1(j) has been defined as an integer, noting that Fortran defaults to floating point for variables starting with A-H and O-Z unless specified otherwise.
  • A participant confirms that they declared the arrays as real and that the data points are read as integers, suggesting a potential mismatch in expected formats.
  • Another participant suggests that the problem may stem from the declaration of variables and recommends using a floating format for reading in real numbers.
  • The original poster later acknowledges that the issue was related to variable declaration and indicates that the program is functioning correctly after making the necessary corrections.

Areas of Agreement / Disagreement

Participants generally agree that the issue was related to variable declarations and input formats, with one participant confirming the resolution of the problem. However, the discussion included various perspectives on how to handle data types and formats in Fortran.

Contextual Notes

The discussion highlights potential limitations in understanding variable types and input formats in Fortran, as well as the importance of confirming data types during both input and output operations.

agalya
Messages
9
Reaction score
0
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 I am converting the 2d array to 1d array which I am using to plot.
when i try to plot them it is not coming properly, but when I am trying to write the samething (in c), it is writing properly (formatted output). can somebody please help me to solve this problem
 
Technology news on Phys.org
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?
 
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
 

Attachments

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).
 
hi
thank you for your help,
as you said, the problem was with the declaration only,
after correcting the program is okey now

regards
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 22 ·
Replies
22
Views
5K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K