Understanding Common Blocks in Fortran 77

  • Context: Fortran 
  • Thread starter Thread starter *FaerieLight*
  • Start date Start date
  • Tags Tags
    Blocks Fortran
Click For Summary
SUMMARY

The discussion centers on the concept of common blocks in Fortran 77, specifically the syntax and usage of the common statement. The example provided, common /hmat/ a,b,c,d, illustrates that variables a, b, c, and d are grouped under the common block named hmat. It is established that hmat does not need to be defined prior to its first use in a common block. To access the variables stored in hmat, users can refer to the provided tutorial link for further guidance on named common blocks.

PREREQUISITES
  • Understanding of Fortran 77 syntax
  • Familiarity with variable declaration in Fortran
  • Basic knowledge of memory management in programming
  • Awareness of common block usage in Fortran
NEXT STEPS
  • Review the Fortran 77 documentation on common blocks
  • Explore variable scope and lifetime in Fortran 77
  • Learn about the implications of using common blocks for data sharing
  • Investigate alternatives to common blocks in modern Fortran standards
USEFUL FOR

This discussion is beneficial for Fortran developers, educators teaching Fortran 77, and programmers looking to understand data sharing techniques in legacy codebases.

*FaerieLight*
Messages
43
Reaction score
0
Hi

I'm having some trouble with understanding the whole concept of the common block in Fortran 77.

Here is an example:

common /hmat/ a,b,c,d

It means that all the variables a,b,c,d are all contained in hmat. But does hmat need to be defined previously for the above example to make sense? Or can the first time you refer to it be in a common block code, as above? And if all the variables are stored in hmat, how do I open hmat to see them?

Thanks
 
Technology news on Phys.org

Similar threads

  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 59 ·
2
Replies
59
Views
12K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
6K
  • · Replies 17 ·
Replies
17
Views
5K
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
2
Views
2K