program rd_ascii c c program to create an ascii version of the gridded fields at upper levels c c Useage: c g77 read_ascii_grd.f -o read_ascii_grd.x c c the data is stored using the following convention c i - longitude, lon(i) = 80. + (i-1)*2. where i goes from 1, 26 c j - latitude, lat(j) = 0. + (j-1)*2. where j goes from 1, 21 c k - pressure level, from 1000 to 25mb c plev(k) = 1000. - (k-1)*25. where k goes from 1, 40 c integer i, j, k integer imax, jmax, kmax parameter (imax=26, jmax=21, kmax=40, gridsp=2.) parameter(rlat=0., rlon=80.) real wlon, elon, slat, nlat, gridsp, plev(kmax) real ps(imax,jmax), psl(imax,jmax) c upper air fields real t(imax,jmax,kmax), u(imax,jmax,kmax) real v(imax,jmax,kmax), q(imax,jmax,kmax) integer z(imax,jmax,kmax) real lat(jmax), lon(imax) character header*20, tmp*8 c define pressure levels for data dp = 25. do k=1,kmax plev(k) = 1000. - (k-1)*dp enddo c define lat/lon coordinates of the data c define latitude of all points do j=1,jmax lat(j) = rlat + gridsp*(j-1) enddo c define longitude of all points do i=1,imax lon(i) = rlon + gridsp*(i-1) enddo C print *, 'Specify date/time to read (e.g., 98050100) >' read(5,'(a8)') tmp 10 format(4x,a8) print *, ' reading grids for ', tmp open (20,file='gridded.'//tmp, status='unknown', form='formatted') c ********** read in upper level fields *********************************** open(21, file='u.'//tmp, status='old', form='formatted') open(22, file='v.'//tmp, status='old', form='formatted') open(23, file='q.'//tmp, status='old', form='formatted') open(24, file='t.'//tmp, status='old', form='formatted') open(25, file='z.'//tmp, status='old', form='formatted') c read in zonal wind component (m/s) do k=1,kmax read (21,'(a20)') header write(20,'(a20)') header write(20,45) (ifix(lat(j)),j=1,jmax) do i=1,imax read (21,50) (u(i,j,k),j=1,jmax) write (20,51) ifix(lon(i)), (u(i,j,k),j=1,jmax) enddo enddo c read in meridional wind component (m/s) do k=1,kmax read (22,'(a20)') header write(20,'(a20)') header write(20,45) (ifix(lat(j)),j=1,jmax) do i=1,imax read (22,50) (v(i,j,k),j=1,jmax) write(20,51) ifix(lon(i)), (v(i,j,k),j=1,jmax) enddo enddo c read in specific humidity (gr/kg) do k=1,kmax read (23,'(a20)') header write(20,'(a20)') header write(20,45) (ifix(lat(j)),j=1,jmax) do i=1,imax read (23,60) (q(i,j,k),j=1,jmax) write(20,61) ifix(lon(i)), (q(i,j,k),j=1,jmax) enddo enddo c read in temperature (C) do k=1,kmax read (24,'(a20)') header write(20,'(a20)') header write(20,45) (ifix(lat(j)),j=1,jmax) do i=1,imax read (24,50) (t(i,j,k),j=1,jmax) write(20,51) ifix(lon(i)), (t(i,j,k),j=1,jmax) enddo enddo c read in geopotential height (m) do k=1,kmax read (25,'(a20)') header write(20,'(a20)') header write(20,45) (ifix(lat(j)),j=1,jmax) do i=1,imax read (25,40) (z(i,j,k), j=1,jmax) write(20,41) ifix(lon(i)), (z(i,j,k), j=1,jmax) enddo enddo close(21) close(22) close(23) close(24) close(25) 40 format(21i6) 41 format(22i6) 45 format(6x,21i6) 50 format(21f6.1) 51 format(i6,21f6.1) 60 format(21f6.2) 61 format(i6,21f6.2) end