subroutine get_prev_sums(debug, csrb_stats_file, sum_obsclr, * sum_calclr, n, ssq_raddiff, * csrb_stats_file_open) c---------------------------------------------------------------------- c Description: Check for existence of CSRB output file for the current c calendar day. If file exists, read partial sums and c return to calling routine. If not, create new file. c c!Input parameters: c debug Debug write flag c csrb_stats_file Output file containing statistics for c current calendar day c c Output parameters: c sum_obsclr Sum of observed clear-sky radiances for c lat/lon bin, scene type c sum_calclr Sum of calculated clear-sky radiances for c lat/lon bin, scene type c n Number of radiance pairs for lat/lon bin, c scene type c ssq_raddiff Sum of squares of radiance differences for c lat/lon bin, scene type c csrb_stats_file_open Logical variable indicating whether or c not output file has been successfully c opened. Initialized to .false. in c process_csrb_ncep1.f. c c Revision history: c 01/11 R. Frey Original version c 03/11 R. Frey Added 'csrb_stats_file_open' c 04/11 R. Frey Added 4th dimension to output c arrays (scene type), changed c value of 'reclen' c c Calls: c c----------------------------------------------------------------------- implicit none save c----------------------------------------------------------------------- c Parameters. integer ntbct parameter (ntbct = 8) integer nlat_bins parameter (nlat_bins = 180) integer nlon_bins parameter (nlon_bins = 360) integer nscns parameter (nscns = 3) integer nstats parameter (nstats = 4) integer reclen parameter (reclen = nlon_bins*nlat_bins*ntbct*nstats*nscns*8) c----------------------------------------------------------------------- c Calling argument variables. character*120 csrb_stats_file integer debug real*8 sum_obsclr(nlon_bins, nlat_bins, ntbct, nscns) real*8 sum_calclr(nlon_bins, nlat_bins, ntbct, nscns) real*8 n(nlon_bins, nlat_bins, ntbct, nscns) real*8 ssq_raddiff(nlon_bins, nlat_bins, ntbct, nscns) logical csrb_stats_file_open c----------------------------------------------------------------------- c Local variables. integer ios, iosr c----------------------------------------------------------------------- c Attempt to open output file. write(*,'(''Attempting to open file '',a120)') csrb_stats_file open(30, file=csrb_stats_file, form='unformatted',status='old', * access='direct', recl=reclen, iostat=ios) c----------------------------------------------------------------------- c If file does not exist, create one, otherwise read contents. if(ios .gt. 0) then open(30, file=csrb_stats_file, form='unformatted',status='new', * access='direct', recl=reclen, iostat=ios) write(*,'(''Creating new CSRB statistics file: '',i10)') ios if(ios .eq. 0) csrb_stats_file_open = .true. c----------------------------------------------------------------------- else if (ios .eq. 0) then csrb_stats_file_open = .true. write(*,'(''Attempting to read file '',a120)') csrb_stats_file read(30, rec=1, err=100) n, sum_obsclr, sum_calclr, * ssq_raddiff go to 300 100 write(*,'(''Error reading CSRB statistics file: '')') call exit(1) 300 write(*,'(''Successfully read CSRB statistics file '' ,a120)') * csrb_stats_file c----------------------------------------------------------------------- else c Error occurred on file open. write(*,'(''Error on CSRB statistics file open '',i5)') ios c----------------------------------------------------------------------- end if c----------------------------------------------------------------------- return end