What is the meaning of COE & COK in Fortran?

  • Fortran
  • Thread starter yabi
  • Start date
  • Tags
    Fortran
In summary: In 1974, Fortran 77 hadn't been officially established yet, but some compilers had "extensions" from Fortran 66 which allowed some features that were taken into Fortran 77.Without a type declaration, arrays in Fortran 77 are assumed to be real (floating point), according to Fortran's default rule for implicit data types: names beginning with 'i' through 'n' are integer, others are real. Without a dimension declaration, arrays in Fortran 77 are assumed to have the same number of rows and columns as declared in the dimension statement.If you don't declare the 'a' as integer, the compiler will assume it's real (floating point), according to Fortran's default rule
  • #1
yabi
23
1
In an old (1974) FORTRAN program, I have following two lines

IF(FX.GT.COE(KOP,1)) GOTO 1

F=X*COK(KOP,1)

I can't understand the meaning of COE and COK commands.
Are they standard FORTRAN commands?

PS) If you could kindly guide me to a site whee I can find list of fortran commands, I will be very happy to have it.

BR
Khoshravan
 
Technology news on Phys.org
  • #2
COE and COK are the names of two array variables.

If you check elsewhere in the program, you should find them declared in a DIMENSION statement, giving the number of rows and columns in each array.

Inside the parentheses, KOP and 1 reference a specific location in each array.
 
  • #3
Dear SteamKing

Thanks for your reply.
You are correct. I am absolutely absent minded regarding this foolish question.
 
  • #4
A dimension statement is not a must to declare an array; so, don't count on that, simply look for the variable name somewhere else...a simple search or a grep from the command line would do.
 
  • #5
In a FORTRAN program from 1974, I'm pretty sure a DIMENSION statement is lurking somewhere in the program. FORTRAN IV or FORTRAN 66 was pretty particular about declaring array variables.
 
  • #6
Really?
I never have seen an array without dimension statement in the beginning.
Could you please explain in detail how it could be possible to have arrays without using dimension statement?
 
  • #7
Code:
program nodim
integer a(2,2)
a = 0
a(1,1) = 4
a(2,2) = 8
write(*,*) a
end program nodim
 
  • #8
Is the command integer a(2,2) compulsary?
If yes, then it is sort of substitute for Dimension command!
 
  • #9
The references a(1,1) and a(2,2) are setting one particular value within the array to the indicated constants. These references are not substitutes for a DIMENSION statement.
 
  • #10
yabi said:
Is the command integer a(2,2) compulsary?
If yes, then it is sort of substitute for Dimension command!

There are (at least) two ways to declare 'a' as a 2x2 array of integers:

integer a
dimension a(2,2)

which "declares as integer" and "declares as array" in separate statements; and

integer a(2,2)

which combines the two declarations.
 
  • #11
I am not talking about

a(1,1) = 4
a(2,2) = 8

But this one:
integer a(2,2)

Will your program working without integer command?
 
  • #12
If you don't declare the 'a' as integer, the compiler will assume it's real (floating point), according to Fortran's default rule for implicit data types: names beginning with 'i' through 'n' are integer, others are real.
 
  • #13
No, it will not work without a type declaration, must be declared something...character, integer or real; implicit typing does not with arrays.
 
  • #14
The exact rules probably depend on which version of Fortran is being used. My own experience is mainly with Fortran 77, and I'm pretty sure that the default typing rules apply to arrays in that version.

In 1974, of course Fortran 77 hadn't been officially established yet, but some compilers had "extensions" from Fortran 66 which allowed some features that were taken into Fortran 77.
 
  • #15
Dear jtbell

Thanks for your comments.
So Integer will do what dimension do and without integer and dimension it is impossible to declare and array.
I hope gsal also reads this comment.
 
  • #16
gsal said:
No, it will not work without a type declaration, must be declared something...character, integer or real; implicit typing does not with arrays.

yabi said:
Dear jtbell

Thanks for your comments.
So Integer will do what dimension do and without integer and dimension it is impossible to declare and array.
I hope gsal also reads this comment.

I don't think you understood what gsal wrote, which was that you need to declare the type of the array.
 
  • #17
jtbell said:
The exact rules probably depend on which version of Fortran is being used. My own experience is mainly with Fortran 77, and I'm pretty sure that the default typing rules apply to arrays in that version.

In 1974, of course Fortran 77 hadn't been officially established yet, but some compilers had "extensions" from Fortran 66 which allowed some features that were taken into Fortran 77.

What I meant to say about "something" not applying to arrays was that arrays cannot benefit from implicit typing the way scalars do.

For example, while typing a fortran program and needing a new scalar in the middle of it, I can simply start using it right there and then without having to go back to the top and declare such variable; and, yes, if the name of the scalar variable starts with any of the letters from I to N, it will be an integer variable...I-Nteger, get it?

BUT, if I need an array variable in the middle of the program, I DO NEED to go back and do some kind of declaration, either a type declaration or a dimension declaration. If I start using an array variable without declaring, the compiler immediately complains about "Unexpected array reference".

Should you have any other questions...please ask the compiler :biggrin:
 

1. What is COE and COK in Fortran?

The terms COE and COK in Fortran refer to the coefficient and constant terms, respectively, in an equation. In Fortran, these terms are used to represent the numerical values in an equation, allowing for more efficient and concise coding.

2. How are COE and COK used in Fortran?

COE and COK are used in Fortran to represent the numerical values in an equation. These terms are typically defined and assigned values before being used in the main equation.

3. Can COE and COK be used interchangeably in Fortran?

No, COE and COK cannot be used interchangeably in Fortran. COE specifically refers to the coefficient term, while COK refers to the constant term. They have different purposes and should not be used interchangeably.

4. How do COE and COK affect the outcome of a Fortran program?

COE and COK can significantly impact the outcome of a Fortran program, as they directly affect the values used in the equations. If these terms are not defined or assigned correctly, it can lead to incorrect calculations and ultimately impact the program's accuracy.

5. Are COE and COK specific to Fortran or can they be used in other programming languages?

While COE and COK are commonly used in Fortran, they are not specific to this programming language. These terms can also be used in other languages, such as MATLAB, to represent the coefficient and constant terms in an equation.

Similar threads

  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
20
Views
5K
Back
Top