program read_int_sonde c c This program reads interpolated soundings for SURFRAD stations c c Filenames are of the form dd-mmm-yyyy_hh.int, e.g., 02-jun-1998_12.int c for 1200 UTC, June 2, 1998. c c There is one header record for the file, which contains the number c of soundings to follow (ng), the number of lines per sounding c (num_levels), c the date and time in the format dd-mmm-yyyy_hh:mm:ss.dd, the number c of passes carried out in the weighted sum interpolation (npass), and c the scale length in kilometers (xl) used in the interpolation. The scale c length is defined as the distance from the observation that its weight c falls to 1/e. A Gaussian weighting function is used. In the interpolated c sounding files before 1997, npass and xl may be missing from the initial c header record. In those cases, as in all, four passes and a scale length of c 400 km were used. c c The file header is followed by the soundings. Each sounding has a c header of its own that contains the station name, latitude, c longitude, and elevation above sea level in meters. The c The convention used for the earth coordinate system is North lat. c and East Long. are positive, and South Lat. and West Long. are c negative. c c All interpolated soundings have 38 levels, so num_levels should always c be 38. The first level is always the surface, and it is followed by c 37 upper levels at 25 mb increments to 100 mb. These upper levels c always begin with 1000 mb, then 975 mb, 950 mb ... 100 mb. Whenever c a level is below the surface, they are filled with missing values c (-999.0). c c There are usually 7 soundings per file, 6 corresponding to the c six surfrad stations and one to the Central Facility of the ARM c SGP site c c This fortran code may be used to read the interpolated sounding files. c Units are given in subroutine readsond. c parameter (nc=50) c common/unit/lun_in c real*4 pres(nc),dwpt(nc),temp(nc) real*4 height(nc),u(nc),v(nc) c character stat*20, datetime*20 character*80 filename character*24 atime c data badval /-999.0/ c c Define unit numbers lun_in = 15 c c open the interpolated sounding file c c inquire about the name of the interpolated soundings file write(6,5) 5 format(1x,/) write(6,7) 7 format(1x,'enter the name of the interpolated sounding file') read(5,10)ina,filename ! ina is the length of the character string just read in 10 format(q,a) write(6,12) filename(1:ina) 12 format(/,1x,'filename requested is ',a) c open(lun_in,file=filename(1:ina),status='old',err=120) c c read file header record read(lun_in,15) ng,num_levels,atime,npass,xl 15 format(1x,i4,1x,i3,1x,a24,1x,i2,1x,f8.2) c c set the dat label for the plot datetime = atime(1:17) c c read one sounding c 20 call readsond(num_levels,pres,temp,dwpt,u,v,height, 1 datetime,stat,badval) write(6,25) stat 25 format(/,1x,'Sounding for ',a,' read') c do i=1,num_levels write(6,30)pres(i),height(i),temp(i),dwpt(i),u(i),v(i) 30 format(6(1x,f8.2)) enddo c go to 20 ! read the next sounding c c ERROR- could not open the requested file c 120 write(6,40) filename(1:ina) 40 format(1x,/,'Sounding file ',a,' could not be opened') c end c------------------------------------------------------------------------- subroutine readsond(num_levels,pres,temp,dwpt,u,v, 1 height,datetime,stat,badval) c common/unit/lun_in ! logical unit number for input file c c the input file is assumed to be open and assigned to lun "lun_in" c c output arrays: real*4 pres(num_levels) ! pressure in (mb) real*4 height(num_levels) ! geopotential height (m) real*4 temp(num_levels) ! temperature (C) real*4 dwpt(num_levels) ! dew point temperature (C) real*4 u (num_levels) ! u component (m/s) real*4 v (num_levels) ! v component (m/s) c character stat*20, datetime*20 character*16 surfname c c read the sounding header read(lun_in,10,end=30) surfname,g_lat,g_lon,ielev 10 format(1x,a16,1x,f6.3,1x,f8.3,1x,i4) c c load the station name into variable stat stat(1:16) = surfname c do i = 1,num_levels read(lun_in,20) xpres,xheight,xtemp,xdewpt,xu,xv 20 format(6(1x,f8.2)) if(xpres.ne.badval)then pres(i) = xpres else pres(i) = badval endif if(xheight.ne.badval)then height(i) = xheight else height(i) = badval endif if(xtemp.ne.badval)then temp(i) = xtemp else temp(i) = badval endif if(xdewpt.ne.badval)then dwpt(i) = xdewpt else dwpt(i) = badval endif if((xu.ne.badval).and.(xv.ne.badval)) then u(i) = xu v(i) = xv else u(i) = badval v(i) = badval endif enddo return c 30 write(6,40) 40 format(/,1x,'no more soundings in this file, stop') c call exit(0) !stop c end c------------------------------------------------------------------------