- #1
vjramana
- 15
- 0
Hi,
I am trying to write a loop to open four main-data-files. At each open of main-data-file, I want the loop to open another four sub-files and split the data from mail-data-file according to the creteria and dump into the four files. And the process goes on. That means I will have total of 16 sub files for the four main-data-files.
I have tried to write the code as below but it doesn't seems to work.
***************************************************************************************************
program final
implicit none
!
integer :: i,j, k, m, jj, kk
integer, parameter :: dist_lines=256
real, DIMENSION(dist_lines) :: dist
! main-data-files
open(unit=100,status="old",file="selected_MAXdistance_only_malto_THERMO_1st.dat")
open(unit=101,status="old",file="selected_MAXdistance_only_malto_THERMO_2nd.dat")
open(unit=102,status="old",file="selected_MAXdistance_only_malto_THERMO_3rd.dat")
open(unit=103,status="old",file="selected_MAXdistance_only_malto_THERMO_4th.dat")
do kk = 100,103
! sub-files
open(unit=(10+kk), file="maximum_dist_001_064.dat")
open(unit=(11+kk), file="maximum_dist_065_128.dat")
open(unit=(12+kk), file="maximum_dist_129_192.dat")
open(unit=(13+kk), file="maximum_dist_193_256.dat")
read(kk,'(F8.3)') (dist(i), i = 1,dist_lines)
do k = 1, 256
if (k < 65 ) then
write ((kk+10),'(F8.3)'), dist(k)
elseif ( k >=65 .and. k < 129 ) then
write( (kk+11),'(F8.3)'), dist(k)
elseif ( k >=129 .and. k < 193 ) then
write ((kk+12),'(F8.3)'), dist(k)
elseif ( k >=193 .and. k < 257 ) then
write ((kk+13),'(F8.3)'), dist(k)
end if
end do
end do
stop
end
Could anyone help ?
Thanks in advance.
Vijay
I am trying to write a loop to open four main-data-files. At each open of main-data-file, I want the loop to open another four sub-files and split the data from mail-data-file according to the creteria and dump into the four files. And the process goes on. That means I will have total of 16 sub files for the four main-data-files.
I have tried to write the code as below but it doesn't seems to work.
***************************************************************************************************
program final
implicit none
!
integer :: i,j, k, m, jj, kk
integer, parameter :: dist_lines=256
real, DIMENSION(dist_lines) :: dist
! main-data-files
open(unit=100,status="old",file="selected_MAXdistance_only_malto_THERMO_1st.dat")
open(unit=101,status="old",file="selected_MAXdistance_only_malto_THERMO_2nd.dat")
open(unit=102,status="old",file="selected_MAXdistance_only_malto_THERMO_3rd.dat")
open(unit=103,status="old",file="selected_MAXdistance_only_malto_THERMO_4th.dat")
do kk = 100,103
! sub-files
open(unit=(10+kk), file="maximum_dist_001_064.dat")
open(unit=(11+kk), file="maximum_dist_065_128.dat")
open(unit=(12+kk), file="maximum_dist_129_192.dat")
open(unit=(13+kk), file="maximum_dist_193_256.dat")
read(kk,'(F8.3)') (dist(i), i = 1,dist_lines)
do k = 1, 256
if (k < 65 ) then
write ((kk+10),'(F8.3)'), dist(k)
elseif ( k >=65 .and. k < 129 ) then
write( (kk+11),'(F8.3)'), dist(k)
elseif ( k >=129 .and. k < 193 ) then
write ((kk+12),'(F8.3)'), dist(k)
elseif ( k >=193 .and. k < 257 ) then
write ((kk+13),'(F8.3)'), dist(k)
end if
end do
end do
stop
end
Could anyone help ?
Thanks in advance.
Vijay