PROGRAM Read_d C C (Big-endian machine version, e.g. SGI. It calls subroutine Swap4 C to swap bytes in 4-byte words.) C C This is an example Fortran program to read the GCIP/SRB archive C of daily mean fluxes for a particular month. It reads the data C for a day by looping over the 51 latitude bands one at a time, C and in each pass through the loop, reading data for the 111 C longitude bands, and then proceeding to the next day. C C The program also assigns latitude and longitude coordinates to C the cell-centers. C C The program also prints a sample output of fluxes for a few C cells, and few days. C C NOTE: Northern latitudes are positive, western longitudes are C negative. C C VARIABLES: C Day : day of month (1-31) C Fluxd(Lon,Lat,Day) : Lon=1 to Nlon, Lat=1 to Nlat; Day=1 to C Maxday; daily mean flux (W/m**2) C Glat(Lat) : Lat=1 to Nlat; latitude of cell center C Glon(Lon) : Lon=1 to Nlon; longitude of cell center C Lat1 : latitude of center of first cell (degrees) C Lon1 : Longitude of center of first cell (degrees) C Lrec : record length C Maxday : max no. of days in a month C Ndays : no. of days in month C Nlat : max no. of latitudes C Nlon : max no. of longitudes C Month : month (1-12) C Reslat : resolution in latitude (degrees) C Reslon : resolution in longitude (degrees) C Year : year (0-99) C .. Parameters .. INTEGER Maxday, Nlat, Nlon PARAMETER ( Maxday=31, Nlat=51, Nlon=111 ) C .. C .. Local Scalars .. CHARACTER Fname * 9 INTEGER Day, Irec, Lat, Lon, Lrec, Month, Ndays, Year REAL Lat1, Lon1, Reslat, Reslon C .. C .. Local Arrays .. REAL Fluxd( Nlon, Nlat, Maxday ), Glat( Nlat ), Glon( Nlon ) C .. C .. External Subroutines .. EXTERNAL Swap4 C .. C .. Data statements .. DATA Reslat / 0.5 / , Reslon / 0.5 / , Lat1 / 25.0 / , & Lon1 / -125.0 / C .. C (record length in bytes) C Lrec = 4 * Nlon C (record length in 4-byte words) Lrec = Nlon C ** Set year, month and number of days to read data for C ** June 1996 C Year = 96 Month = 6 Ndays = 30 C ** Set up name of GCIP/SRB monthly file to be read C WRITE ( Fname, FMT='( 2I2.2, A )' ) Year, Month, 'sda.d' C ** Open and read GCIP/SRB file C OPEN ( Unit=1, File=Fname, Status='OLD', Form='UNFORMATTED', & Access='DIRECT', Recl=Lrec, ERR=90 ) Irec = 0 DO 30 Day = 1, Ndays DO 20 Lat = 1, Nlat Irec = Irec + 1 READ ( 1, Rec=Irec, ERR=100 ) ( Fluxd(Lon,Lat,Day), Lon=1, & Nlon ) C ** Swap bytes in little-endian data DO 10 Lon = 1, Nlon CALL Swap4( Fluxd(Lon,Lat,Day) ) 10 CONTINUE 20 CONTINUE 30 CONTINUE C ** Calculate latitude and longitude coordinates of C ** cell centers DO 40 Lat = 1, Nlat Glat( Lat ) = ( Lat-1 ) * Reslat + Lat1 40 CONTINUE DO 50 Lon = 1, Nlon Glon( Lon ) = ( Lon-1 ) * Reslon + Lon1 50 CONTINUE C ** Print latitude, longitude coordinates and flux C ** for a few days, and cells C PRINT 9000, 'File name= ', Fname PRINT 9010, 'Day Lat Lon Flux' PRINT 9010, ' (deg) (deg) (W/m^2)' DO 80 Day = 4, 5 DO 70 Lat = 10, 11 DO 60 Lon = 20, 22 PRINT 9020, Day, Glat( Lat ), Glon( Lon ), & Fluxd( Lon, Lat, Day ) 60 CONTINUE 70 CONTINUE 80 CONTINUE STOP 90 PRINT * , 'Error opening file ', Fname STOP 100 PRINT * , 'Error reading file ', Fname 9000 FORMAT ( 1X, 2A ) 9010 FORMAT ( 1X, A ) 9020 FORMAT ( 1X, I3, 3F8.1 ) END SUBROUTINE Swap4( A ) C C REVERSE ORDER OF BYTES IN INTEGER*4 WORD, or REAL*4 C C C .. Scalar Arguments .. INTEGER * 4 A C .. C .. Local Scalars .. CHARACTER Ktemp * 1 INTEGER Itemp C .. C .. Local Arrays .. CHARACTER Jtemp( 4 ) * 1 C .. C .. Equivalences .. EQUIVALENCE ( Jtemp(1), Itemp ) C .. Itemp = A Ktemp = Jtemp( 4 ) Jtemp( 4 ) = Jtemp( 1 ) Jtemp( 1 ) = Ktemp Ktemp = Jtemp( 3 ) Jtemp( 3 ) = Jtemp( 2 ) Jtemp( 2 ) = Ktemp A = Itemp RETURN END