      Program readfile

      parameter (nx=320,ny=160,nz=12)

C This sample fortran code will read the O2 flux data files
C H. Garcia ; 10May2001
C
C Input variable
C
C value(k,l,m)= input flux data of dimension 320,160,12 (x,y,z directions)
C               positive fluxes (sea-to-air flux)
C               begative fluxes (air-to-sea fluxes)
C
C Calculated variables
c
C ec_lat(k,l)= latitude in degrees (-90S to 90N)
C ec_lon1(k,l)= Longitude in degrees (-180W to 180E)
C ec_lon2(k,l)= Longitude in degrees (0 to 360)
C
C---------------------------------------------------

      real value(nx,ny,nz),ec_lat(nx,ny),ec_lon1(nx,ny),ec_lon2(nx,ny)
      integer k,l,m

C Calculate the latitude (positive= northern hemisphere) and longitude 
C (positve=eastern hemisphere) coordinates. 
C
C l=1,k=1 = Latitude: 90°S, 180°W
C ....
C
C ec_lat(k,l)= latitude in degrees (-90S to 90N)
C ec_lon1(k,l)= Longitude in degrees (-180W to 180E)
C ec_lon2(k,l)= Longitude in degrees (0 to 360)
C
C Note: Calculation of latitude/longitude values is not necessary to read 
C       the O2 flux data files.
C
      rdy=180./160.
      rdx=180./160.

      do l=1,160
       rstep1=float(l-1)
       ry=-90.+(l-1)*rdy

       do k=1,320

        rstep2=float(k-1)
        ec_lat(k,l)=-90.+rstep1*rdy    ! Latitude (-90S to +90N)
        ec_lon1(k,l)=-180.+rstep2*rdx  ! Longitude in degrees (-180W to +180E)

        if (ec_lon1(k,l) .lt. 0.) then ! Longitude in degrees (0 to 360)
         ec_lon2(k,l)=ec_lon1(k,l)+180.
        else
         ec_lon2(k,l)=ec_lon1(k,l)
        endif

       enddo
      enddo

C Open input data file

      open (15,file='file_name',status='old') 

C Loop to read the data
      
      do m=1,12
       
       read (15,500) ((value(k,k,m),k=1,320),l=1,160)

      enddo

      close (15)

500   format (10f12.5)

      stop
      end
