Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran [Fortran] Help Reading Complex 2D data

  1. Jul 14, 2015 #1
    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 (Text):

    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


    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)


    end program readdata  

    Attached Files:

    Last edited by a moderator: Jul 14, 2015
  2. jcsd
  3. Jul 14, 2015 #2
    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?
  4. Jul 14, 2015 #3
    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook