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

  • Thread starter Thread starter FUNKER
  • Start date Start date
  • Tags Tags
    Fortran Forum
Click For Summary
The discussion revolves around programming in Fortran, specifically addressing issues related to Fortran 77 and 90/95. A user seeking help with array declarations and common blocks encounters multiple errors in their code. Key points include the importance of correctly declaring arrays and understanding the limitations of common blocks in Fortran. It is emphasized that array dimensions must be defined using integer values, and the use of floating-point numbers for array sizes is incorrect. The conversation also touches on the need for proper syntax, such as starting code lines in the correct column to avoid compilation errors. Users are advised to break down their programming tasks into manageable steps, utilize pseudocode for clarity, and compile code frequently to identify errors early. Additionally, there are discussions about the inability to dynamically allocate memory in Fortran 77, contrasting it with more modern versions that allow for such flexibility. The thread concludes with inquiries about breaking loops in subroutines and plotting functions, indicating ongoing challenges faced by users in mastering Fortran programming.
  • #121
anyone know how to configure a file as VTK file to be able to plot it by paraview??
 
Technology news on Phys.org
  • #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

  • #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

  • #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 :-)
 
  • #141
please try to make your own thread, and upload your question there, anyway I think you need to compile by the following commaand
f95nag file_name
 
  • #142
Hi, can I call a subroutine inside another subroutine in Fortran 77?, also can I call a function in a subroutine?

advance thank for help
 
  • #143
Hi everyone
I've got a problem when I build a function, I need my function to produce a matrix, then I called the function in the main program by its name to give the matrix to the main program, but it does not work at all, I mean the matrix is computed correctly in the function but I failed to call it to the main program, here what I have in my code

Code:
main_program
c
complex*16 A(m1,m2), Mat
EXTERNAL Mat
c
A = MainMat(n,m)
.
..
end
complex*16 function Mat(n,m)
c calculate the elemnts of Mat
Mat = A
.
end
I need to return the matrix Mat, which I computed by the function to the main program
I took off the external statement, and declare the function (Mat) in my main program as

Code:
complex*16 A, Mat
C then I call it as
A = MainMat(S1,S2)
But when I've done the following loop, it does not work

Code:
do i = 1,N
do j = 1,M
write(7,*) A(i,j)
end do
end do

so I changed in the declaration as A(N,M), BUT IT DOES NOT WORK AS WELL
 
  • #144
What does the code for your function MainMat look like? When you say that your nested loop in your last code example "doesn't work" what does that mean? Does it produce any results or no results? Did you set N and M? You don't show these variables being initialized.
 
  • #145
Opr

Please do not give me the answer but if you can direct me to site that will tell me what OPR represent in the statement dp_reduce(array, "opr"). I think opr represent operation but I need to find out what it does in this statement. Please don't give me the answer-just direct me to the right site to learn more about this.

thanks in advance.
 
  • #146
Mark44 said:
What does the code for your function MainMat look like? When you say that your nested loop in your last code example "doesn't work" what does that mean? Does it produce any results or no results? Did you set N and M? You don't show these variables being initialized.

thanks, the code in the main function call some subroutines to produce a complex matrix and let the function return this matrix to the main program, actually I've everything correct and the function produce the right matrix,...just I have a problem of return this matrix t the main program.

please don't worry about the initialization and so on as I delete them for not making my post too long...shall I declare the function name in the main program as
complex MainMat

or complex MainMat(N,N)
BECAUSE IN THE MAIN PROGRAM I have the nested loop to print the resulted matrix from the function

thanks
 
  • #147
i'm heading a problem in mathematical equation about the initial condition, what methode should we used if there is an addition force, such as damping force. This equation will be applied to performed oscillatory system in fortran language programme .
 
  • #148
I have been learning Fortran but I have a question
Is It possible to find a job as fortran programmer or Where is Fortran used I mean where in which divisions
 
  • #149
How Call C routines present in archive from Fortran on UNIX

Hello All,

I have created a library, an archive of C routines on UNIX, which we need to use with Fortran programs (call from Fortran program). I am linking the library at the time of compiling.
The command which I am using is as follows,
$ xlf add.o alenia.a - L /home/oracle/oracle/product/db_1/lib -lclnuts -q64

Here the alenia.a is C routines archive and add.o is fortran programm calling C function preasnt in alenia.a.

So plse tell me that any prototype I should add in Fortran program? if yes how to do that or now then how to link the C library to the Fortran program & call the C routines in Fortran program.

Thanx.
Harshal
 
  • #150
I have a problem, here's what the,
should be from ascii file to extract data that is the n-th row and n-th column
I do not know how. Could someone help me.
 

Similar threads

  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 7 ·
Replies
7
Views
6K
  • · Replies 16 ·
Replies
16
Views
5K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
Replies
6
Views
4K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
38K
  • · Replies 11 ·
Replies
11
Views
6K