[Fortran] Help Reading Complex 2D data

  • Fortran
  • Thread starter komp
  • Start date
  • #1
5
0
Dear All, Please, I am trying to read in a data shown in array form but no luck. The data is 10 by 10 with each 10 by 10 depicted by a local array, for e.g. 0 0 0 0 0 0. A sample of the code I tried using is as shown below and the data is as attached. Please, any help or suggestion will be highly appreciated.
Code:
Program readdata

real*8 r1,r2,r3,r4,r5,r6,r7,r8,r9,fill,akx,aky,akz,akx1,aky1,akz1
real*8 w(2500)
complex*16 Gsc(100,100)
integer i,j,k,l,m,i1
character*80 linemc

open(unit=40,file='datain.txt',status='unknown')

do i=1,1000
  READ(40,*) akx, aky,akz,akx1,aky1,akz1 ! local array
  READ(40,*) (Gsc(:,l),l=1,10) ! Read an array corresponding to each local component
!   do k=1,10
!  read(40,'(2f8.2)',advance='no') (Gsc(k,l),l=1,10 )
  ! read(40,*) (Gsc(k,l),l=1,10 )
READ (40,*) ((Gsc(k,l), l = 1, 10), k = 1, 10)

!enddo
   read(40,*)
enddo

end program readdata
 

Attachments

  • datain.txt
    48.3 KB · Views: 431
Last edited by a moderator:

Answers and Replies

  • #2
Dr. Courtney
Education Advisor
Insights Author
Gold Member
2020 Award
3,332
2,497
Space or tab delimited data is much easier to read.

Have you tried converting the format, or do you really need to handle this awkward format?
 
  • #3
5
0
This is how the data is supplied. I haven't tried converting the data. As data are in real and then imaginary per bracket.

Thanks for your help.
 

Related Threads on [Fortran] Help Reading Complex 2D data

  • Last Post
Replies
4
Views
2K
Replies
6
Views
1K
Replies
7
Views
1K
Replies
7
Views
2K
  • Last Post
Replies
8
Views
2K
Replies
1
Views
5K
Replies
2
Views
1K
Replies
2
Views
29K
Replies
2
Views
2K
Top