Fortran Program Doubt: Plotting DST Index Values

In summary,I have written a program to plot dst index values using fortran + pgplot, but when I'm trying to plot the data points are not plotted correctly. The problem may be resolved by declaring the arrays as real. After this, the data can be read in using a floating format and the program will run properly.
  • #1
agalya
9
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
  • #2
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?
 
  • #3
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

  • dst_plot.txt
    3 KB · Views: 359
  • dst1989.txt
    43.1 KB · Views: 391
  • #4
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).
 
  • #5
hi
thank you for your help,
as you said, the problem was with the declaration only,
after correcting the program is okey now

regards
 

Related to Fortran Program Doubt: Plotting DST Index Values

What is Fortran Program Doubt?

Fortran Program Doubt is a specific issue or question related to writing or running a program using the Fortran programming language. It is a common term used by programmers to describe a problem they are facing while working with Fortran.

What is the purpose of Plotting DST Index Values in a Fortran program?

The purpose of plotting DST (Disturbance Storm Time) index values in a Fortran program is to visualize and analyze the variations in the Earth's magnetic field caused by solar disturbances. This can help scientists understand and predict the effects of these disturbances on power grids, communication systems, and other technological infrastructure.

How do I plot DST Index Values in a Fortran program?

To plot DST Index Values in a Fortran program, you will need to use a plotting library or package, such as PLplot or GNUplot. These libraries have built-in functions that allow you to create graphs and charts from your data. You will also need to have your DST Index values stored in an array or data file, which can be read and plotted using the plotting functions.

What are some common errors or issues when plotting DST Index Values in a Fortran program?

Some common errors or issues when plotting DST Index Values in a Fortran program include incorrect data formatting, mismatched data types, and incorrect use of plotting functions. It is also important to properly label and scale your axes to ensure accurate and meaningful visualizations.

How can I troubleshoot and fix errors when plotting DST Index Values in a Fortran program?

To troubleshoot and fix errors when plotting DST Index Values in a Fortran program, you should carefully review your code and check for any syntax errors or logical errors. You can also use debugging tools or print statements to track the values of your variables and identify any issues. Additionally, you can consult online resources or seek help from other programmers who are familiar with Fortran programming.

Similar threads

  • Programming and Computer Science
Replies
4
Views
639
  • Programming and Computer Science
Replies
20
Views
3K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
12
Views
972
  • Programming and Computer Science
Replies
22
Views
4K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
20
Views
1K
  • Programming and Computer Science
Replies
25
Views
2K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
12
Views
1K
Back
Top