fortran语言里a(1)和a(2),代表什么意思啊,有什么区别啊?

如题所述

第1个回答  2016-01-27
I was so surprised to find there is still the one who makes fortran language alive!!!
That's good news for me at least.
I am here to try fortran 95 to explain your question (assumed you use this version other rather 77) under linux OS environment.
For more detail in I/O statement, fortran documentation is always a good place to give it a go!

[open] ---> open a file called 'out' and mark it as integer 1.
[write] ---> write a string 'input: m' into file 'out' supposed, despite 1 should replace *.
[read] ---> read the content from your target file, which is supposed to be file marked as 1

for the sake of better understanding fortran I/O statement, I wrote a sample code combined with above command.

program write4read
implicit none
!
integer, parameter :: n=4;
integer :: i;
integer, dimension(1:n) :: a;
!
open(unit=10,file='data.txt',status='old')
! |
! |--- file status
! |--- existed file

open(unit=20,file='data-copy.txt',status='new')
! |
! |--- file status
! |--- new file
do i=1,n
read(10,100) a(i)
! read 'data.txt'
!
write(20,100) a(i)
! write a(i) into 'data-copy.txt'

print*, a(i)
! print a(i) on terminal screen
!
100 format (I3)
enddo
!
close(10)
! close 'data.txt'
!
close(20)
! close 'data-copy.txt'
!
end program write4read
Before you run this code, just ensure you save 'data.txt' file in the same directory of this fortran code.
'data.txt'

123
234
345
456
The running result should display as本回答被网友采纳
第2个回答  2016-01-26
a是数组,a(1)、a(2)分别是数组a的第一、二个元素。追问

iold=0是什么意思

相似回答