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

Fortran help

  1. Sep 11, 2012 #1
    Hello everyone,

    I am new to fortran language but I am trying to code , however i face one difficulty which I am not being able to debug, A little guidance form experts will be helpful,I have a file which looks like this , the '--------------------------------------' is the starting string for each block.

    ----------------------------------------------
    Excited State 1: Triplet-A' 0.5335 eV 2324.11 nm f=?
    Right Eigenvector
    Alpha Singles Amplitudes
    I SymI A SymA Value
    28 1 29 1 0.668416
    Beta Singles Amplitudes
    I SymI A SymA Value
    28 1 29 1 -0.668416
    Total Energy, E(EOM-CCSD) = -504.940780117

    ----------------------------------------------
    Excited State 2: Triplet-A" 1.1271 eV 1099.99 nm f=?
    Right Eigenvector
    Alpha Singles Amplitudes
    I SymI A SymA Value
    28 1 30 2 0.631576
    28 1 37 2 0.183901
    28 1 39 2 -0.170392
    Beta Singles Amplitudes
    I SymI A SymA Value
    28 1 30 2 -0.631576
    28 1 37 2 -0.183901
    28 1 39 2 0.170392

    ----------------------------------------------
    The value of the excited state gives the number of main blocks, and in my case the block is 30. and in each block there are sub blocks such as Alpha Singles Amplitudes/Beta Singles amplitudes/Alpha-Alpha Doubles/Beta-Beta Doubles , the number of elements in each sub block is not fixed and changes in each main block.I want to extract the NUMERICAL values in each sublock and write them in a file neglecting the 'Right Eigen Vector String'.At the end of the numerical block there is a blank line that shows the end point of each block.but everytime I execute the code there are no compilation errors but I dont get exactly what I need as I find a problem in reading the sub-blocks so the loop doesnt excute perfectly. My pseudo code looks like this :

    nstates=0
    linecount=1

    115 dummy(2:47)='----------------------------------------------' ! checks for the
    state : , Multiplicity , Energy
    call findtext(10,dummy,stat)
    if (stat.eqv..false.) then
    goto 1000

    end if


    117 read(10,'(a70)')dummy

    if(dummy(1:14)==' Beta Singles')then
    read(10,*)
    print*,'Beta Singles',nstates

    end if

    if ((dummy(26:32)=='Triplet').or.(dummy(26:32)=='Singlet'))then
    read(10,*)
    nstates=nstates+1
    end if

    if(dummy(1:14)==' Alpha Singles')then
    print*,'Alpha Singles',nstates
    read(10,*)
    j=0
    120 read(10,'(a4,i2,a6,i1,a4,i2,a6,i1,f12.6)')du1,b,du2,c,du3,d,du4,e,r

    do while(du1(1:4).ne.' Bet')
    j=j+1
    write(20,'(a4,i2,a6,i1,a4,i2,a6,i1,f12.6,2x,i2,2x,i2,2x,a2)')du1,b,du2,c,du3,d,du4,e,r,j,nstates,'AS'

    read(10,'(a4,i2,a6,i1,a4,i2,a6,i1,f12.6,2x,i2)')du1,b,du2,c,du3,d,du4,e,r
    ! j=j+1
    end do
    end if



    if(dummy(1:14)==' Alpha-Alpha D')then
    print*,'Alpha-Alpha D',nstates
    read(10,*)
    read(10,'(a4,i2,a6,i1,a4,i2,a6,i1,a4,i2,a6,i1,a4,i2,a6,i1,f12.6)')du9,b,du10,c,du11,d,du12,e,du13,b1,du14,c1,du15,d1,du16,e1,r
    do while(du9(1:4).ne.' Alp')
    j=j+1
    write(20,'(a4,i2,a6,i1,a4,i2,a6,i1,a4,i2,a6,i1,a4,i2,a6,i1,f12.6,2x,i2,2x,i2,2x,a3)')du9,b,du10,c,du11,d,du12,e,du13,b1,du14,c1,du15,d1,du16,e1,r,j,nstates,'AAD'
    read(10,'(a4,i2,a6,i1,a4,i2,a6,i1,a4,i2,a6,i1,a4,i2,a6,i1,f12.6)')du9,b,du10,c,du11,d,du12,e,du13,b1,du14,c1,du15,d1,du16,e1,r
    ! j=j+1
    end do
    end if

    if(dummy(1:14)==' Beta-Beta D')then
    print*,' Beta-Beta D',nstates
    end if

    if(dummy(2:8)=='SavETr:')then
    goto 305
    elseif(dummy == '')then
    goto 115

    else
    goto 117

    end if

    The 'SavETr:' is the first line after all the blocks have been read so I take this as the terminating condition. A little guidance is needed regarding the accuracy of my code
     
    Last edited: Sep 11, 2012
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Fortran help
  1. Fortran Help (Replies: 1)

  2. Help in fortran (Replies: 2)

  3. [Fortran] help (Replies: 2)

  4. FORTRAN Help (Replies: 1)

  5. Fortran Help (Replies: 2)

Loading...