親愛的所有人,我正在編寫一個代碼,將輸出寫入多個文件,名爲1.dat,2.dat,.....這是我的代碼,但它提供了一些不尋常的輸出。你能告訴我我的代碼有什麼問題嗎?基本上我無法獲得正確的語法來打開多個文件,寫入它們並在下一個文件打開之前關閉。謝謝。 我的代碼:在Fortran中寫入多個輸出文件
implicit double precision (a-h,o-z),integer(i-n)
dimension b(3300,78805),bb(78805)
character*70,fn
character*80,fnw
nf = 3600 ! NUMBER OF FILES
nj = 360 ! Number of rows in file.
do j = 1, nj
bb(j) = 0.0
end do
c-------!Body program-----------------------------------------------
iout = 0 ! Output Files upto "ns" no.
DO i= 1,nf ! LOOP FOR THE NUMBER OF FILES
if(mod(i,180).eq.0.0) then
open(unit = iout, file = 'formatted')
x = 0.0
do j = 1, nj
bb(j) = sin(x)
write(iout,11) int(x),bb(j)
x = x + 1.0
end do
close(iout)
iout = iout + 1
end if
END DO
11 format(i0,'.dat')
END
什麼是模數應該在這裏做? – talonmies 2011-05-27 12:57:02