Fortran Forum for Programming Help: Resources, Tips, and Support

In summary, this conversation is about a closed thread on Fortran programming and the suggestion to visit a different forum for help. A new user also asks for help with Fortran 77 and is given a definition of a common block and how to use it. An example of a code using a common block is provided, but the user encounters errors when compiling.
  • #106
Thanks Mathmate for your help, can I put the body of subroutine in separate file, and in the main program just write

include 'subroutine_name.f'
the same of including the numerical recipes...
 
Technology news on Phys.org
  • #107
Yes, but you have to make sure the subroutine parameters allow you to return the arrays that you have just filled.
 
  • #108
Hi MATHmate, I found the angle between two adjacent side in rectangle and then divide by \pi, as I need to know wheather the angles are rational or irrational multiple of \pi, I've got this number 0.397583618, how do I know WEATHER rational or irrational?
 
  • #109
It doesn't look like rational to me.
It is almost impossible to know from a single number because of rounding errors.
Would you have an idea of the three sides?
 
  • #110
let say for polygon, the length of the five sides are 2.82842712, 2.82842712, 2, 2.82842712, 4.47213595, and the angles are after diving by pi 0.5,0.75, 0.75, 0.397583618, 0.852416382

I want to to know if the last two ones are rational or irrational, is there any role to distinguish between the two types, I think it easier if we can force the code to produce the number as numerator and denumertor, but how can we do that...
 
Last edited:
  • #111
The last number (4.47213595) appears to be 2sqrt(5), while the other ones (2.82842712) appear to be 2sqrt(2).
 
  • #112
mathmate said:
The last number (4.47213595) appears to be 2sqrt(5), while the other ones (2.82842712) appear to be 2sqrt(2).

Thanks mathmate, i meant the these two numbers 0.397583618 , 0.602416382 , are they rational or irrational? can one say that ...( if the length of the side of the triangle are irrational number, then the angle will be irrational multiple of \pi?)
 
  • #113
I do not think one implies the other.
Try a 30-60-90 triangle.
The side lengths are 1,2 and sqrt(3), the last side being irrational. Yet the angles are rational fractions (1/6, 1/3, 1/2) of π.
The converse is not valid either. For example, a triangle with rational sides such as 1,2,3 will have most probably all three angles irrational multiples of π.
 
  • #114
small question on fomatting in f77, I typed the line below to write the data in a file, but the data being separated in two lines in the data file, the first 6 numbers in th first line of the data file then the last two numbers in the second line of the data file, how can we write them in one line

999 FORMAT(2x,I2,5x,F9.6,5x,F9.6,5x,F9.6,5x
& ,F9.6,5x, F9.6,5x, F9.6,5x, F9.6)
 
  • #115
Try
999 FORMAT(2x,I2,5x,F9.6,5x,F9.6,5x,F9.6,5x,F9.6,5x, F9.6 / F9.6,5x, F9.6)
or
999 FORMAT(I4,F14.6,F14.6,F14.6,F14.6,F14.6 /F18.6,F14.6)
 
  • #116
Does anyone know of an algorithm to solve coupled first order differential equations?

Thanks,
 
  • #117
how can I integrate a function(f(x)) on polygonal area numerically on each point we can start with double summation and multiply by dx, dy, but how can we end the summation? the double summation seems to be difficult to implemented as a code...
 
  • #118
Are you looking for simply the area, or do you put weights throughout the area?

If it is a matter of simply the area, you do not need to integrate. There are formulae for calculating the area of a non-self intersecting polygon from the known vertices. See for example:
http://en.wikipedia.org/wiki/Polygon
under Area and centroid.

If the polygon is guaranteed convex, and you need to put weights throughout the surface of the polygon as a function of x and y, I suggest you write code for a triangle (which is simpler), and subdivide the polygon into a number of triangles all radiating from a given source vertex. If the polygon has only one concavity, subdivision into triangles will still work if the source vertex is at the concave point.
 
  • #119
mathmate said:
Are you looking for simply the area, or do you put weights throughout the area?

If it is a matter of simply the area, you do not need to integrate. There are formulae for calculating the area of a non-self intersecting polygon from the known vertices. See for example:
http://en.wikipedia.org/wiki/Polygon
under Area and centroid.

If the polygon is guaranteed convex, and you need to put weights throughout the surface of the polygon as a function of x and y, I suggest you write code for a triangle (which is simpler), and subdivide the polygon into a number of triangles all radiating from a given source vertex. If the polygon has only one concavity, subdivision into triangles will still work if the source vertex is at the concave point.
nooooooo not the area, I have some function with given value at points in the polygon with regular grids, what I need is how to code the numerical integral over the polygon, for example if I have a rectangle I will integrate by doing summation over the region by increasing x till the length and increase y till the width of the rectangle, but for ploygon how can I do this with double summation
 
  • #120
If there are no libraries available for this purpose, you will have to write your own.

If the polygon is convex, I would subdivide the polygon into triangles and write a double integration function for a triangle with the given vertices, together the given weight function.

For integration over the area of the triangle, you will need to split the integration into two regions through the line that passes through the middle vertex (along the x-axis). This is where there is a discontinuity in the integration.
 
  • #121
anyone know how to configure a file as VTK file to be able to plot it by paraview??
 
  • #122
Nusc said:
Does anyone know of an algorithm to solve coupled first order differential equations?

Thanks,

There are several NAG routines that can do this - provided that you have access to the nag libraries anyway.
 
  • #123
I'm looking for a way to write to strings in Fortran. Basically I'd like to do something along the lines of
k = 'A'
at the top of the code, and then throughout have lines like
OPEN(file = 'mesh' k, unit = 11),
which would therefore give
OPEN(file = meshA, unit = 11).

I use the same code to print a lot of different output files and manually changing all the OPEN statements, even with a replaceall command, gets tedious.

Thanks
 
  • #124
This snippet should help you. If your suffixes are letters, you only need to create an array of suffixes to append to the base name. If it is numeric, convert it to a character as shown in the snippet.

Code:
      character*12 filename
      character*1 num
      do 20 I=1,9
      write(num,999)I
 999  format(I1)
      filename='A'//num//'.dat'
      print *,filename
      open(unit=5,file=filename, status='unknown')
   20 continue
 
  • #125
Thanks mathmate - that has saved me an extraordinary amount of time.
 
  • #126
anyone know how to measure the running time for a FORTRAN 77 code?is there any function for this purpose??
 
  • #127
Some compilers have profilers built-in for this purpose. Most profilers can decompose the running time spent in different programming units. Profilers are compiler dependent and most probably operating system dependent, and are not part of the Fortran language.

If you run on Unix, you can use to time command which is probably less accurate, and gives only the total running time.
 
  • #128
mathmate said:
Some compilers have profilers built-in for this purpose. Most profilers can decompose the running time spent in different programming units. Profilers are compiler dependent and most probably operating system dependent, and are not part of the Fortran language.
thanks mathmate for your help, how can have such profilers built-in, do I need to download anything, or how can I check cos I might have them on my unix machine...
mathmate said:
If you run on Unix, you can use to time command which is probably less accurate, and gives only the total running time.

I did the command time, so it gave me
real 0m0.000s
user 0m0.000s
sys 0m0.000s
-------
so did the command time filename.f, so it gave me
real 0m0.020s
user 0m0.000s
sys 0m0.000s
...so the running time is ?
 
  • #129
can anyone show me how to search for a specific program such as Graphics tool or whatever on my computer, as I forget where is I installed, I mean which directory it is stored in??what is the shell command for this job?
 
  • #130
Hi,

I want to learn Fortran language,if it is possible Fortran 77.

The question is if this compiler is available to run in Windows XP Operative System.

If it is, I would like to know how I can get it, because I have been searching some pages about Fortran, but unfortunately, I haven`t found clear information where I can download it

Also, I would like to know where I can obtain, documentation like manuals or tutorials.

Thanks with anticipation

Regards
 
  • #131
For Lanz, try the following link:
http://www.cse.yorku.ca/~roumani/fortran/ftn.htm
and see if you could find anything here:
http://www.thefreecountry.com/compilers/fortran.shtml

For Anglea,
Since you are looking for the detailed usage of a Unix command "find -name...", you may want to make a new post called "help on Unix command". Most unix users (outside of NASA) are not interested in Fortran, so they don't get to read your post. Also, you need more hint so Unix can search fo0r your files, such as the name of the executable, or source file, or the name of the software, etc.
 
  • #133
Hi guys,

It is my first time to visit here so I am not sure if I am supposed to post my question here.
If I am supposed to post my question somewhere else, let me know!
I want to compute a huge, ugly equation with different values of a parameter, let's say c.
My program remains same except c varying from 1 to 7000.
So I want to get data file s1.dat for c=1,
s2.dat for c=2,
...
s700.dat for c=7000.
Can I somehow use unix command to change the values of c and the name of the data files corresponding to different values of c?
Or should I change c and the name of the data file in the program and compile one by one?
Because I should submit the batch job to the school server, it will be really tedious job if I have to do it one by one.
I am not sure that this is fortran question or unix question.
But could you please let me know if you know the way to deal with this?
Thank you so much!
 
  • #134
It depends how your data are arranged.

If the data files are named in a systematic way, it is easy to process them one by one. See post#124 of this thread (on page 8) for an example.

If your data file is generated on the fly in Unix, and you have a script to run the fortran program immediately after generation of the data file, then it is easier to run the script through the various values of the parameter c using the unix script, while the data file could retain the same name if you don't need to keep it.
 
  • #135
HI, I'm a new user and from google it seems you are the last forum who talks about fortran in the last month...so here I am.
I'm a new fortran user and I'm going to compile my program but I find a message:" This application has requested the runtime to terminate in an unusual way " etc...
I use:
- macbook intel core 2Duo
- running windows xp with service pack 2 (the teacher suggested us force that works on win)
- force 2.0.8

I attach the program (extension .txt and .zip with .f inside)

thank you
 

Attachments

  • Ci provo.txt
    5.7 KB · Views: 425
  • Ci provo.zip
    1.8 KB · Views: 177
  • #137
Hi Mathmate

I am looking for your help in this...
I would like to use this NAG routine ( D06AAF) as attached with the post , to generate a mesh on Rectangle,but it is not a clear for me where do I need to give the coordinates of my rectangle

please help me out
 

Attachments

  • d06aaf.pdf
    142.2 KB · Views: 315
  • #138
I have a mesh on the interior of a square as a triangles grids, 950 points in the interior which construct 1890 triangles, with the connectivity

how can I link these data to generate VTK format, as I need this format to be able to plot the data.
 
  • #139
can anyone please, help me how to construct a matrix with matrices elements, my main matrix A is constructed of 6 matrices, and I have all the element of these matrices, but the problem I do not know how to write the main matrix A, how the indices look like??
 
  • #140
Hello guys,

I'm a beginner in Fortran. i was trying to compile a program but errors below appeared:

/tmp/ifortMMF3EI.o: In function `MAIN__':
file5.f:(.text+0x404): undefined reference to `ddriv2_'
file5.f:(.text+0x702): undefined reference to `rffti_'
file5.f:(.text+0x712): undefined reference to `rfftf_'

what does this mean? I am using Fortran 95. the program comes with subprograms.

it would be great if anyone can give me some hints to solve this. Thanks in advance :-)
 

Similar threads

  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
7
Views
6K
  • Programming and Computer Science
Replies
13
Views
4K
  • Programming and Computer Science
Replies
16
Views
4K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
14
Views
3K
  • Sticky
  • DIY Projects
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
11
Views
5K
Back
Top