title: Data reading in Fortran
body: <p>EDIT: I am Making this just a question about the Fortran and will start a new question about converting to MATLAB.</p>
  
  <p>ORIGINAL:</p>
  
  <p>I am working on a project and am trying to port some old Fortran code into Matlab.  I have almost no Fortran experience so I am not quite sure what is going on in the following code.  The Fortran code is simply for interpreting data from a binary file and I have made some decent progress at porting stuff into MATLAB but have got stuck at the following part: </p>
  
  <pre><code>  IMPLICIT NONE
  
    DOUBLE PRECISION      SCALE
  
    CHARACTER*72          BLINE
    CHARACTER*72          DATA_FILE_FULL_NAME
    CHARACTER*6           DATA_FILE_NAME
  
    CHARACTER*4           CH4, CH4F
    REAL*4                RL4
    EQUIVALENCE          (RL4,CH4)
  
    CHARACTER*2           C2
    LOGICAL               LFLAG
  
    c2='69'
    LFLAG=.TRUE.
  
    DATA_FILE_FULL_NAME='./'//DATA_FILE_NAME//'.DAT'
  
    OPEN(UNIT=20, FILE=DATA_FILE_FULL_NAME, ACCESS='DIRECT',
   .     RECL=72, status='OLD')
      READ(20,REC=1) BLINE
      CH4f=BLINE(7:10)
      call flip(4,lflag,ch4f,ch4)
      SCALE=RL4
  
    RETURN
    END  
  
  c   ..................................................
      subroutine flip(n,lflag,ch1,ch2)
  c   ..................................................
  
    integer*4        n, i
    character*(*)    ch1, ch2
    logical          lflag
  
    if(lflag) then
      do i=1,n
        ch2(i:i)=ch1(n-i+1:n-i+1)
      enddo
    else
      ch2=ch1
    endif
  
    return
    end   
  </code></pre>
  
  <p>What I am stuck with is getting the correct value for <code>SCALE</code> because I am not exactly sure what is happening with the <code>RL4</code>.  Can someone explain to me why RL4 changes value and what process changes it so that I can put this process into MATLAB?</p>