Fortran Arrays with parameter and data statements in fortran 77

  • Thread starter JoAuSc
  • Start date
197
0
Let's say you have an array A and a variable B (both reals). Apparently

parameter (A = (/1.2, 3.4, .../) )

is illegal, so you have to do

data A /1.2, 3.4, .../

instead. However, what if you have a statement afterwards like this?

1 parameter (A = (/1.2, 3.4, .../) )
...
2 parameter (B = A(3))

If you change 1 to a data statement, 2 becomes illegal since you can only declare parameters with other parameters, but 1 is illegal as is. How would I declare something like this that's legal?
 

DrClaude

Mentor
6,820
2,939
Treating something as a parameter is a protection against modifying that variable by mistake. There is nothing essential about it, so you could simply not declare B as a parameter.

Alternatively, you could set the parameter B to the actual value of A(3). (What is the risk here? If it is set as a hard-coded parameter, it shouldn't be expected to change. I would say it is bad practice to compile the same version of a code with different values of the parameters...)
 

Want to reply to this thread?

"Arrays with parameter and data statements in fortran 77" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top