c c reformat UNR hcat (hypo71) summary files into CNSS unified format c implicit none integer azgap character*2 auxrmk character*8 date real depth real dmin real errh real errz integer id(3) integer iday integer ihour integer imin integer imonth integer iunit integer iyear real latdeg real latd real latmin character*2 loctyp real londeg real lond real lonmin integer nps_sol integer nsec integer ounit real pmag character*1 qual1 character*1 qual2 real rms real sec character*3 src integer iline integer ios character*45 file c parameter (iunit = 15, ounit = 16) c call idate(id) write (date, '(i4, 2i2.2)'), id(3), id(2), id(1) loctyp = 'H ' src = 'NN' auxrmk = 'L ' c call askc ('enter input file name', file) open (2, file=file, status='old') file = 'j.out' call askc ('enter output file name', file) open (ounit, file=file, status='unknown') write (ounit, '(a)') '$fmt cnss-catalog-ver-1.0' c iline =0 10 iline = iline + 1 read (2, 100, iostat = ios, end = 1000) 1 iyear, imonth, iday, ihour, imin, sec, latdeg, 2 latmin, londeg, lonmin, depth, pmag, nps_sol, 3 azgap, dmin, rms, errh, errz, qual1, qual2 100 format (3i2, 1x, 2i2, f6.2, 1x, f2.0, 1 1x, f5.2, f4.0, 1x, f5.2, f7.2, 3x, f4.2, i3, 2 1x, i3, f4.0, 2x, 3(f4.2, 1x), 2a1) c c error handling c if (ios .ne. 0) then print *, 'error on line ', iline goto 10 elseif (iyear .eq. 0 .and. imonth .eq. 0 .and. iday .eq. 0 1 .and. ihour .eq. 0 .and. imin .eq. 0) then print *, 'skipping zero origin time on line ', iline goto 10 end if londeg = -londeg lond = sign(abs(londeg) + abs(lonmin)/60., londeg) latd = sign(abs(latdeg) + abs(latmin)/60., latdeg) iyear = iyear + 1900 c c map UNR qualities to errh, errz if no explicit values c if (errh .eq. 0. .and. errz .eq. 0.) then if (qual1 .eq. 'a') then errh = 1.0 errz = 2.0 elseif (qual1 .eq. 'b') then errh = 2.5 errz = 5.0 elseif (qual1 .eq. 'c') then errh = 5.0 errz = 99.0 else errh = 99.0 errz = 99.0 endif endif c c rectify origin time problem. This is a half-assed effort for this c task. Warn when day jumps month boundary for manual intervention. c if (sec .ge. 60.) then nsec = int(sec/60.) imin = imin + nsec sec = sec - nsec*60. if (imin .ge. 60) then ihour = ihour + 1 imin = imin - 60 if (ihour .ge. 24) then iday = iday + 1 ihour = ihour - 24 print *, 'Day incremented for event at',iyear,imonth,iday print *, ' check if month is correct' endif endif endif if (sec .lt. 0.) then imin = imin - 1 sec = 60. + sec if (imin .lt. 0) then ihour = ihour - 1 imin = imin + 60 if (ihour .lt. 0) then iday = iday - 1 ihour = ihour + 24 print *, 'Day decremented for event at',iyear,imonth,iday print *, ' check if month is correct' endif endif endif c c write out $beg line c write (ounit, '(a4)') '$beg' c c write out $loc line c write (ounit, 200) iyear, imonth, iday, ihour, imin, sec, 1 latd, lond, depth, loctyp, src, nps_sol, azgap, dmin, rms, 2 errh, errz, auxrmk, date 200 format ('$loc ', i4, 4i2.2, f7.4, 1 f9.5, f10.5, f8.4, a2, a3, i4, i3, f10.4, f7.4, 2 t88, 2f7.4, a2, a8) c c No information for $add line; nothing output c c output $mag line. c write (ounit, 400) pmag, src, date 400 format ('$mag', 'P', f5.2, 'c ', a3, 13x, a8) c c write out $end line c write (ounit, '(a)') '$end' goto 10 1000 continue close (2) close (ounit) end