Fortran [Fortran] Help Reading Complex 2D data

Click For Summary
The discussion revolves around a user seeking assistance with reading a 10 by 10 array of complex data from a text file using Fortran. The user provides a code snippet that attempts to read local arrays and complex data but encounters difficulties. Key points include the format of the data being space or tab delimited, which complicates the reading process. Suggestions are made regarding the potential for converting the data format to simplify the reading process, although the user indicates that conversion has not been attempted due to the specific requirements of handling real and imaginary components. The focus remains on finding effective methods to read the data as it is currently formatted.
komp
Messages
5
Reaction score
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

Last edited by a moderator:
Technology news on Phys.org
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?
 
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.
 
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 10 ·
Replies
10
Views
26K
Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 4 ·
Replies
4
Views
9K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
8K
  • · Replies 11 ·
Replies
11
Views
3K