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.
  • #1
FUNKER
121
0
Mentor's note (May 2012):

This thread is closed to new posts. It is over five years old and has been resuscitated many many times by people finding it in Google searches or something. If you want to post a question about Fortran programming, please go to the parent forum

https://www.physicsforums.com/forumdisplay.php?f=165

and start a new thread (topic) by clicking the "New Topic" button. Give your new thread a suitably descriptive title.

------------------------------------------------------hey guys,
I was reading the sticky threads and did not find much help for fortran so I thought I might list a a website that has a bunch of helpful people on it. It has an awesome forum for Fortran 90-95 as well as other languages:

www.tek-tips.com

Its a no bull**** site for those who need it.

Plus another 5c :

I have been using FORTRAN 90/95 explained by Metcalf and Reid, not very helpful :grumpy:

Regards
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
Hi guys
As I m anew user for Fortran 77, so I am still struggling how to do the declaration, i mean what is the common block?I have written a code but gaveme error message about the declaration...
any one could help
 
  • #3
SallyGreen said:
Hi guys
As I m anew user for Fortran 77, so I am still struggling how to do the declaration, i mean what is the common block?I have written a code but gaveme error message about the declaration...
any one could help
Can you post the error message.

A COMMON block is a way of storing data in memory. One can store arrays, vectors and scalar data.

One can also label COMMON blocks.

They are placed in the main routine and subroutines as necessary. If one does this, then it's not necessary to put the variables in the argument of the subroutine or function subroutine.

http://labmon.io.usp.br/cursos/iof0227/fortran/common.htm [Broken]
Syntax - common / name / list-of-variables

You should know that
  • The common statement should appear together with the variable declarations, before the executable statements.
  • Different common blocks must have different names (just like variables). A variable can belong to more than one common block.
  • The variables in a common block do not need to have the same names each place they occur (although it is a good idea to do so), but they must be listed in the same order and have the same type.
 
Last edited by a moderator:
  • #4
implicit none
c * LOCAL SCALARS
integer i,N
real*8 X,Y,sum1,sum2,arc
c * COMMON BLOCKS
integer dim(X),dim(Y)
real*8 area,arc
common/matpara/ area,arc,dim(X),dim(Y)
1 read(*,*) dim(X),dim(Y)
if (dim(X).ne.dim(Y)) then
print *, 'The dim of X must be equal to dim of Y'
go to 1
else
if (dim(X).le.3)
print *, 'This is not a case'
end if
end if
N=5
Many thanks for ur help this is the code, but I do not know if the declaration is enough, also cos I need to call subroutine to do a job, so do I need to redefine varible again, is the way I have entered the array X Y correct,
do 10 i=0, N-1
read(*,*) X(i), Y(i)
10 continue
when I compiled I have got this error message

Area.f: In program `MAIN__':
Area.f:6:
real*8 X,Y,sum1,sum2,arc
1
Area.f:8: (continued):
integer dim(X),dim(Y)
2
Invalid declaration of or reference to symbol `x' at (2)
Area.f:6:
real*8 X,Y,sum1,sum2,arc
1
Area.f:8: (continued):
integer dim(X),dim(Y)
2
Invalid declaration of or reference to symbol `y' at (2)
Area.f:8:
integer dim(X),dim(Y)
1 2
Invalid declaration of or reference to symbol `dim' at (2)]
Area.f:6:
real*8 X,Y,sum1,sum2,arc
1
Area.f:9: (continued):
real*8 area,arc
2
Invalid declaration of or reference to symbol `arc' at (2)]
Area.f:6:
real*8 X,Y,sum1,sum2,arc
1
Area.f:10: (continued):
common/matpara/ area,arc,dim(X),dim(Y)
2
Invalid declaration of or reference to symbol `arc' at (2)]
Area.f:8:
integer dim(X),dim(Y)
1
Area.f:10: (continued):
common/matpara/ area,arc,dim(X),dim(Y)
2
Invalid declaration of or reference to symbol `dim' at (2)]
Area.f:11:
1 read(*,*) dim(X),dim(Y)
^
Non-numeric character at (^) in label field [info -f g77
Area.f:12:
if (dim(X).ne.dim(Y)) then
^
Invalid first character at (^) [info -f g77 M LEX]
Area.f:13:
print *, 'The dim of X must be equal to dim of Y'
^
Non-numeric character at (^) in label field [info -f g77
Area.f:14:
go to 1
^
Non-numeric character at (^) in label field [info -f g77
Area.f:15:
else
^
Invalid first character at (^) [info -f g77 M LEX]
Area.f:16:
if (dim(X).le.3)
^
Non-numeric character at (^) in label field [info -f g77
Area.f:17:
print *, 'This is not a Polygon'
^
Non-numeric character at (^) in label field [info -f g77
Area.f:18:
end if
^
Non-numeric character at (^) in label field [info -f g77
Area.f:19:
end if
^
Invalid first character at (^) [info -f g77 M LEX]
Area.f:20:
N=5
^
Invalid first character at (^) [info -f g77 M LEX]
Area.f:22:
read(*,*) X(i), Y(i)
^
Invalid first character at (^) [info -f g77 M LEX]
Area.f:23:
10 continue
 
  • #5
SallyGreen said:
if (dim(X).ne.dim(Y)) then
print *, 'The dim of X must be equal to dim of Y'

If they are identical, why do you read both of them, instead of reading one and use it twice?
 
  • #6
The statement:
integer dim(X),dim(Y)

requires the X and Y be integers. In F77, the subscripted variables are integers. Later versions for Fortran may be more flexible, but I'm not familiar with these.

By convention, variable names starting with I, J, K, L, M, N are integers in FORTRAN (F77), and A-H,O-Z are real unless otherwise declared.

Also, I'm not by the listing if the FORTRAN statements start in the 7th column, or 1st, but the 1st column is reserved for C (comment statements) and cols 2-6 for STATEMENT numbers.

Here is another tutorial - http://web.utk.edu/~prdaves/Computerhelp/Unix_Fortran_Overview.htm

We do have another Fortran thread around here since F77 a legacy language, which is still used by us dinosaurs from the pre-internet age.
 
  • #7
Hi guyes
I would be highly grateful if you could help me in these questions as I need to build code in Fotran 77 for the first time
In fortran 77 what is the difference between write(*, 'ghghfy') and write(9, 'ghghf)
Why we do this declaration
Parameter (zero=0.0d0, one=1.0d0, two=2.0d0, thr=3.0d0)
what is the meaing of
pi=two*dacos(zero)
I mean what is the job of dcos function
 
  • #8
It looks like you want to use two arrays named X and Y, but you don't know (before you run the program) how big you want those arrays to be. Instead, you want the program to read the array size, before reading the data for the arrays. Is this correct?

I don't want to proceed further until I know for sure what you are trying to do.
 
  • #9
jtbell said:
It looks like you want to use two arrays named X and Y, but you don't know (before you run the program) how big you want those arrays to be. Instead, you want the program to read the array size, before reading the data for the arrays. Is this correct?

I don't want to proceed further until I know for sure what you are trying to do.

thanks, actually I need dim of the arrays to be 5, in the case which I am dealing with now, but I want to write a general code.
 
  • #10
Then you can declare the arrays either using

Code:
      real*8 x(5), y(5)

or as

Code:
      parameter (n=5)
      real*8 x(n), y(n)

The "parameter" statement declares a named constant with the name "n". "n" is not a variable and does not even have any memory allocated for it. The compiler substitutes "5" whenever it sees "n" in the code. So you cannot change its value while the program is running (i.e. after the program is compiled). Its advantage is that you can easily change 5 to, say, 100, in the "parameter" statement, and re-compile your code, without having to search for all the places where you use 5 as the array size.
 
  • #11
Hey there, please anyone could give me a hand
your help is greatly appreciated, actually I have written that code, but still giving me an errors, so still struggling as a begginer in Fortran 77, here the code and the errors
c * This program reads the five vertices of an irregular Polygon then c* calculate its area and periemeter
c * The area of an irrigular Polygon with n vertices is(x0*y1+x1*y2+...+x_n-1*y0)-(y0*x1+y1*x2+...+y_n-1*x0)
c *
c *
c *
implicit none
c * LOCAL SCALARS
integer i,n
c * PARAMETER
parameter (n=5.0d0)
real*8 X(1,n),Y(1,n),sum1,sum2
c * COMMON BLOCKS
real*8 area,arc
common/matpara/ area,arc
c * 1 read(*,*) dim(X),dim(Y)
c *if (dim(X).ne.dim(Y)) then
c * print *, 'The dim of X must be equal to dim of Y'
c * go to 1
c *else
c * if (dim(X).le.3)
c * print *, 'This is not a Polygon'
c * end if
c *end if
do 10 i=1, n
read(*,*) X(1,i), Y(1,i)
10 continue
call calarea(X,Y,sum1)
call calarea(Y,X,sum2)
c * area=(calarea(X,Y)-calarea(Y,X))/2.0
area=(sum1-sum2)/2.0
c * THis subroutine to calculate the area
subroutine calarea(A,B,sum)
implicit none
c * LOCAL VARIABLES
integer i, n
c * PARAMETER
parameter (n=5.0d0)
c * ARGUMENTS
real*8 A(1,n),B(1,n),sum
sum=0.0
do 10 i=1,n-1
sum=sum+(A(i)*B(i+1))
end do
sum=sum+(A(n)*B(1))
end
c * The following step to calculate the arc length of the Polygon by summing over the distance between its vertices
arc=0.0
do 10 i=1, n-1
arc=arc+dsqrt((X(i)-X(i+1))**2 + (Y(i)-Y(i+1))**2)
end do
arc=arc+dsqrt((X(n-1)-X(1))**2 + (Y(n)-Y(1))**2)
print*,area,arc
**********
Area-PoLygon.f: In program `MAIN__':
Area-PoLygon.f:25:
read(*,*) X(1,i), Y(1,i)
^
Invalid first character at (^) [info -f g77 M LEX]
Area-PoLygon.f:26:
10 continue
^
Non-numeric character at (^) in label field [info -f g77 M LEX]
Area-PoLygon.f:30:
area=(sum1-sum2)/2.0
^
Invalid first character at (^) [info -f g77 M LEX]
Area-PoLygon.f:32:
subroutine calarea(A,B,sum)
^
Invalid first character at (^) [info -f g77 M LEX]
Area-PoLygon.f:33:
implicit none
^
Invalid first character at (^) [info -f g77 M LEX]
Area-PoLygon.f:8:
integer i,n
1
Area-PoLygon.f:35: (continued):
integer i, n
2
Invalid declaration of or reference to symbol `i' at (2) [initially seen at (1)]
Area-PoLygon.f:8:
integer i,n
1
Area-PoLygon.f:35: (continued):
integer i, n
 
  • #12
Have you tried putting 7 or 8 leading spaces before your code lines yet?

Columns 1 to 6 are reserved for labels and the continuation character.

Obviously something like
Code:
123      continue
Wouldn't need leading spaces in front of the 123, but does need the spaces between the 3 of 123 and the c of continue.
 
  • #13
zeitghost said:
Have you tried putting 7 or 8 leading spaces before your code lines yet?

Columns 1 to 6 are reserved for labels and the continuation character.

Obviously something like
Code:
123      continue
Wouldn't need leading spaces in front of the 123, but does need the spaces between the 3 of 123 and the c of continue.

yes you right, but Is the way I define the array X &Y which contains real numbers correct or no?
 
  • #14
SallyGreen said:
yes you right, but Is the way I define the array X &Y which contains real numbers correct or no?

No, it is not correct. Array indexes (inside the parentheses) must be integers.
 
  • #15
jtbell said:
No, it is not correct. Array indexes (inside the parentheses) must be integers.

Hi there yes they are integers cos I have already changed n to 5 not 5.0d, I mean X(1,n)is correct declaration for an array of n elements?
 
  • #16
Code:
       parameter (n=5.0d0)
       real*8 X(1,n),Y(1,n),sum1,sum2

This doesn't look right to me...

You appear to be defining n as a real number (floating point), then using it to define an array.

Also, why are you defining X and as two dimensional arrays?

Surely X(n) and Y(n) would be simpler?

So I reckon that
Code:
       Parameter( n=5)
       real*8 X(n), Y(n)
would be a step forward.
 
  • #17
zeitghost said:
Code:
       parameter (n=5.0d0)
       real*8 X(1,n),Y(1,n),sum1,sum2

This doesn't look right to me...

You appear to be defining n as a real number (floating point), then using it to define an array.

Also, why are you defining X and as two dimensional arrays?

Surely X(n) and Y(n) would be simpler?

So I reckon that
Code:
       Parameter( n=5)
       real*8 X(n), Y(n)
would be a step forward.
thanks, yeah I have n=5 not 5.0d0, if I define the array as real*8 X(n) , then how can I refer to the nth term in the array which is X(n) isnit??
 
  • #18
zeitghost said:
Code:
       parameter (n=5.0d0)
       real*8 X(1,n),Y(1,n),sum1,sum2

This doesn't look right to me...

You appear to be defining n as a real number (floating point), then using it to define an array.

Also, why are you defining X and as two dimensional arrays?

Surely X(n) and Y(n) would be simpler?

So I reckon that
Code:
       Parameter( n=5)
       real*8 X(n), Y(n)
would be a step forward.

if I define the array like this then how can I refer to the nth term of it which is X(n)?
 
  • #19
If you want to access the 5th element of X (FORTRAN arrays start at 1, by the way, or at least they used to when I was programming), then it's simply X(5).

for instance:

Code:
       do 100 i = 1,5
       print ( *,1000 ) X(i)
100  continue

      stop
1000 format ( 1x, f6.2 )
        end

should print out all five elements of X.
 
  • #20
I have written this bit of code in Fortran 77 but it gives me an errors message about n
integer n
real u(n), v(n)
c
c
print*, "Enter the number n="
read *, n

It gives me invaild declaration of n,u,v?/should be something easy, hope anyone could point it out:confused:
 
  • #21
Sally,
I have read your code and understand what you are trying to do. In fact, I have done exactly the same exercise two days ago for a different reason, except the perimeter did not interest me.

First, I suggest you do your programming (in any language) step by step.
You have done very well the first step in figuring out and documenting the formula required to do the work.
The second step is to write a pseudo-code which you will follow when coding in the language of your choice, which in your case is Fortran. By the way, is Fortran your first computer language (it was in my case), or you already programme in other languages?
The pseudocode is a sequence of steps that describes the algorithm you follow to solve your problem. It can be in any language (English, Fortran...) that you can understand. It can even be an imaginary language.
The third step is to code the programme in the language of your choice. You need to have a rudimentary knowledge of the language, which it seems to me is lacking in your case. All is not lost, because if you don't, you need a compiler to help you do tests, together with your textbook and your teacher, you will acquire the knowledge.
In your particular case, I think it is important to code a few lines at a time, compile, get rid of compilation errors. If you cannot, read up the textbook or the compiler's user guide to find the errors before you move on. This way, you will have a smaller problem at hand.

Having said all that, I will give you a few hints as to where to start. I suggest you start from scratch, using all the materials you have done so far as reference.

Step 1. Documentation.
To find the area S of a polygon where the n vertices are (x1,y1), (x2, y2), ...(xn,yn), the forllowing formula may be used:
S=[Sum of (x(i)*y(i+1)-x(i)-y(i+1))]/2
for i=1 to n, and assuming (x(n+1)=x(1), and (y(n+1)=y1)
The Perimeter P of the same polygon is the same as in your code:
P=[sum of sqrt((x(i+1)-x(i))**2+(y(i+1)-y(i))**2))]
for i=1 to n, and assuming (x(n+1)=x(1), and (y(n+1)=y1)

Your idea of calling the area twice and subtacting before dividing by 2 is therefore not required. It can be done in one and the same step.Now the pseudocode:
1. Input the number of points, n
2. Input the coordonates of each point Pi= (x(i), y(i)) for points 1 to n
3. print the input data (for purposes of checking).
4. copy point P1 to Pn+1 to facilitate the summation.
5. calculate s=area(x,y,n) where area is a function that returns the value
6. calculate p=perimeter(x,y,n) where periimeter is a function that returns the value
7. output the values of and p.
8. end of program.

Program structuring
The program should have three units, main, functions area and perimeter.
They would look like this. All you have to do is to use the following template and fill in your code where there are...
Coompile as often as possible so you will know exactly where the problem lies. Post if you have errors you do not understand. I am sure Zeitghost and I will be glad to help.
Code:
C      MAIN PROGRAM
C      Step 1: input given data
        REAL*8 AREA          !Function 
        REAL*8 PERIMETER  !Function
        REAL*8 X,Y            ! Input parameter
        INTEGER N              ! Inpu parrameter
C        ...
        S=AREA(X,Y,N)
        P=PERIMETER(X,Y,N)
        PRINT *, "AREA=",S
        PRINT *,"PERIMETER=",P
        STOP
        END
C
        REAL*8 FUNCTION AREA(X,Y,N)
C        ...
        RETURN
        END
C
        REAL*8 FUNCTION PERIMETER(X,Y,N)
        ...
        RETURN
        END
 
Last edited:
  • #22
Angela,
Unfortunately, in fortran, we cannot declare the dimension (i.e assign memory) using a variable that is yet unknown to the compiler, contrary to what we can do in C and C++ using malloc().
The only exception is when this happens in a sub-program where the memory has already been assigned in the calling program. If the array and the dimensions appear in the formal parameters, the compiler will accept it. For example, it is OK to code the following, because the compiler will be sure that the calling program assigns memory properly before passng onto the subprogram.
Code:
      SUBROUTINE SUB1(U, V, n)
      INTEGER n
      REAL U(n), V(n)
      RETURN
      END
      REAL A(5), B(5)
      INTEGER I
      I=4
      CALL SUB1(A,B,I)
      STOP
      END

To do what you want to do, most of the time people would assign a maximum dimension to the array and use only part of it, as much as the input requires, up to the maximum. A check should be made to ensure that the maximum is not exceeded.
 
  • #23
mathmate said:
Angela,
Unfortunately, in fortran, we cannot declare the dimension (i.e assign memory) using a variable that is yet unknown to the compiler, contrary to what we can do in C and C++ using malloc().
The only exception is when this happens in a sub-program where the memory has already been assigned in the calling program. If the array and the dimensions appear in the formal parameters, the compiler will accept it. For example, it is OK to code the following, because the compiler will be sure that the calling program assigns memory properly before passng onto the subprogram.
Code:
      SUBROUTINE SUB1(U, V, n)
      INTEGER n
      REAL U(n), V(n)
      RETURN
      END
      REAL A(5), B(5)
      INTEGER I
      I=4
      CALL SUB1(A,B,I)
      STOP
      END

To do what you want to do, most of the time people would assign a maximum dimension to the array and use only part of it, as much as the input requires, up to the maximum. A check should be made to ensure that the maximum is not exceeded.
The matter is that I need to write a general code for any n and then I can enter n as input after compile the code
Code:
        print*, "Enter  n="
        read(*,*)  n
and I need to do some calculation on the arrays U and V in the main program, so as far as I understand from you this is impossible, cos the idea of calling subroutine not enough as I want use just n and not giving any value to it at any stage of the program
 
  • #24
Anglea,

Anglea said:
The matter is that I need to write a general code for any n and then I can enter n as input after compile the code
Code:
        print*, "Enter  n="
        read(*,*)  n
and I need to do some calculation on the arrays U and V in the main program, so as far as I understand from you this is impossible, cos the idea of calling subroutine not enough as I want use just n and not giving any value to it at any stage of the program


I don't believe this is possible in fortran77 in your main program, as mathmate pointed out. You can do it in fortran95, if that is an option for you.
 
  • #25
I have included a common block in my code, but it gives me an error message saying my common block is too large, I s there anything in particular I need to be careful with using common Blocks, any help would be much appreciated...:zzz:
 
  • #26
How big have you made your common block?
If it is too big, you may have to consider writing the information onto disk. Perhaps you are putting things that may not have to be put in the common blcok.
You can also use named common blocks, which give you addition space, if the limitation was for individual blocks.
Do some tests for your compiler and find out the limit of the unnamed common block. After that, try to add some named blocks. That may give you extra space (or maybe not).
 
  • #27
mathmate said:
How big have you made your common block?
Really appreciate your time and help,:smile:not really big, actually first I used 3 named common blocks with different names, both of them contains 2 matrices each, and the third stores just numbers and it does work fine, but the first one give me an error message says my block is too large which is not cos my matrices are just arrays with 5 elements.
mathmate said:
If it is too big, you may have to consider writing the information onto disk. Perhaps you are putting things that may not have to be put in the common blcok.
I s there any limitations of the data which stored in common blocks??
mathmate said:
You can also use named common blocks, which give you addition space, if the limitation was for individual blocks.
Do some tests for your compiler and find out the limit of the unnamed common block. After that, try to add some named blocks. That may give you extra space (or maybe not).
:cry::cry:
 
  • #28
Urgent question::can I break a loop in subroutine by return statement, because when some condition is true I need to break the loop and go back to the point in the main program where I have called the subroutine:frown::uhh:
 
  • #29
please can anyone tell me how can I declare a matrix on n elements and their elements are vectors of two component, e.g(2,3)(3,3)(4,7)(8,8)(9,1)

real*8 u(n,2)
do i=1,n
print*, u(i,1), u(i,2)
end do


but these steps do not give the right result, another thing how can I plot a function in Fortran 77
 
  • #30
Urgent question::can I break a loop in subroutine by return statement, because when some condition is true I need to break the loop and go back to the point in the main program where I have called the subroutine
Yes, you can do that. In fact, you can even do better than that. It is possible, if I remember right, to choose a return point not necessary where the subroutine was called. The syntax is return i. In your case, you just simply do a return.

Code:
real*8 u(n,2)
do i=1,n
print*, u(i,1), u(i,2)
end do

but these steps do not give the right result,
It should work, but it all depends on how you assigned those elements.
For example, if you do
integer n
Code:
real*8 u(n,2)
n=10
do 10 i=1,n
do 10 j=1,2
u(i,j)=i*10+j
10 continue
It should give you u(1,1)=11, u(1,2)=12, and so on.

Perhaps I did not answer your question. If that's the case, you could post the code that assigns the values, so we can look at it together.
 
  • #31
Urgent question::can I break a loop in subroutine by return statement, because when some condition is true I need to break the loop and go back to the point in the main program where I have called the subroutine
Here is an example, the output of the program is 5.0000, which correspond to what you'd like to do, I think.
Code:
      FUNCTION F1(n)
      INTEGER n
      DO 10 I=1,n
      IF (I.GE.5) THEN
        F1=I
        RETURN
      ENDIF
10    CONTINUE      
      F1=I
      RETURN
      END
	  PRINT *, F1(10)
      STOP
      END
 
  • #32
oh I have got any help on the common block(please have a look at the thread above)
 
  • #33
how can I creat an input file to save my data in F77, and how can I plot a function in F77
 
  • #34
oh I have got any help on the common block(please have a look at the thread above)
Perhaps it would be something trivial and not related to size.
Could you post the code, or part of it, and the related message?
 
  • #35
mathmate said:
Perhaps it would be something trivial and not related to size.
Could you post the code, or part of it, and the related message?
Code:
c 
        implicit none
	integer		i,n
c *      PARAMETER
        parameter       (n=5)
        real*8          sum1,sum2
	real*8		area
c        common Block
        real*8        x(n+1), y(n+1)
        common/alpha/ x(n+1), y(n+1)
        write(*,*) 'Enter the arrays elements'
        do 10 i=1, n
           read(*,*) x(i), y(i)
 10     continue
        call calarea(sum1)
        call calarea(sum2)
        area=(sum1-sum2)/2.0
end 
c
         subroutine calarea(sum)
         implicit none
	 integer	i,n
c *      PARAMETER
         parameter (n=5)
	 real*8 	sum
c        common Block
        real*8        x(n+1), y(n+1)
        common/alpha/ x(n+1), y(n+1)
         sum=0.0
         do  i=1,n-1
           sum=sum+(x(i)*y(i+1))
         end do
         sum=sum+(x(n)*y(1))
         end
and this is error message
A.f: In program `MAIN__':
A.f:14:
real*8 x(n+1), y(n+1)
1
A.f:15: (continued):
common/alpha/ x(n+1), y(n+1)
2
Invalid declaration of or reference to symbol `x' at (2) [initially seen at (1)]
A.f:14:
real*8 x(n+1), y(n+1)
1
A.f:15: (continued):
common/alpha/ x(n+1), y(n+1)
2
Invalid declaration of or reference to symbol `y' at (2) [initially seen at (1)]
A.f: In subroutine `calarea':
A.f:53:
real*8 x(n+1), y(n+1)
1
A.f:54: (continued):
common/alpha/ x(n+1), y(n+1)
2
Invalid declaration of or reference to symbol `x' at (2) [initially seen at (1)]
A.f:53:
real*8 x(n+1), y(n+1)
1
A.f:54: (continued):
common/alpha/ x(n+1), y(n+1)
2
Invalid declaration of or reference to symbol `y' at (2) [initially seen at (1)]
A.f: Outside of any program unit:
In file included from A.f:0:
A.f:15: error: size of variable 'alpha_' is too large
This is a sample, I know I can do it without subroutine and without common blocks, but later in my code I need to include coomon blocks as my data increas and I will add some calculation in my subroutine, the main point I need to know what is wrong with the common blocks, any help would be much appreciated:smile::cry:
 
<h2>1. What is Fortran?</h2><p>Fortran is a high-level programming language used for scientific and numerical computing. It was developed in the 1950s and is still widely used today in fields such as engineering, physics, and finance.</p><h2>2. Why should I use Fortran?</h2><p>Fortran is known for its efficiency and speed in handling complex mathematical and scientific calculations. It also has a large library of built-in functions and is supported by many compilers, making it a reliable choice for scientific programming.</p><h2>3. Where can I find resources for learning Fortran?</h2><p>There are many online resources available for learning Fortran, such as tutorials, forums, and documentation. Some popular websites include Fortran Wiki, Fortran Library, and Fortran Forum.</p><h2>4. How can I get help with my Fortran code?</h2><p>If you encounter any issues with your Fortran code, you can seek help from online forums and communities, such as Fortran Forum. You can also consult with experienced Fortran programmers or refer to official documentation for troubleshooting.</p><h2>5. Is Fortran still relevant in today's programming landscape?</h2><p>Yes, Fortran is still widely used in scientific and numerical computing, especially in fields that require high-performance computing. It continues to evolve and adapt to modern programming practices, making it a relevant and valuable language for many applications.</p>

1. What is Fortran?

Fortran is a high-level programming language used for scientific and numerical computing. It was developed in the 1950s and is still widely used today in fields such as engineering, physics, and finance.

2. Why should I use Fortran?

Fortran is known for its efficiency and speed in handling complex mathematical and scientific calculations. It also has a large library of built-in functions and is supported by many compilers, making it a reliable choice for scientific programming.

3. Where can I find resources for learning Fortran?

There are many online resources available for learning Fortran, such as tutorials, forums, and documentation. Some popular websites include Fortran Wiki, Fortran Library, and Fortran Forum.

4. How can I get help with my Fortran code?

If you encounter any issues with your Fortran code, you can seek help from online forums and communities, such as Fortran Forum. You can also consult with experienced Fortran programmers or refer to official documentation for troubleshooting.

5. Is Fortran still relevant in today's programming landscape?

Yes, Fortran is still widely used in scientific and numerical computing, especially in fields that require high-performance computing. It continues to evolve and adapt to modern programming practices, making it a relevant and valuable language for many applications.

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
3K
  • 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