cat > p.f <<\EOR C=============================================================================C C International Comprehensive Ocean-Atmosphere Data Set (I-COADS) 24 Jul 2002 C C Filename:level: rdnrt:01A Fortran 77 program+shell C C Function: Read NCEP Real-time Obs (NRT) Author: S. Woodruff C C=============================================================================C C Software documentation for the (modifiable) example program {rdnrt} and C for the (invariant) user-interface routines {nrtrd,nrbrd,nrthd,nrbhd} C (adapted, with modifications, from {invent.f:01G} 11 February 1999). C C Functionality: The example program {rdnrt} illustrates how {nrtrd} or C {nrbrd} are called to read (and optionally print) NRT data. The two C different routines are needed because the NRT format changed effective C March 1997. Data prior to March 1997 were derived from the ON124 format C and should be read with {rdnrt}; data starting in March 1997 were derived C from the BUFR format and should be read with {rdnrb} (some overlapping C ON124-based data are also available until 19 April 1997 as detailed in C the format README: ftp://ftp.cdc.noaa.gov/Public/coads/ncep_obs/README). C C Similarly, {nrthd} and {nrbhd} can be used to print headers for ON124- C and BUFR-based data, respectively. C C An overview of the NRT format (adapted from the README), output arguments, C and returned missing values (if applicable): Arguments Missing C --------- ------- C 1 2 I2 Year (last two digits) year2 N/A C [alternative representation: + 1900, or + 2000 if year2<91: year N/A ] C 3 4 I2 Month month N/A C 5 6 I2 Day day N/A C 7 10 F4.2 Hour fhour N/A C 11 15 F5.2 Latitude (degrees) -- negative = southern hemis. flat N/A C 16 20 F5.2 Longitude (degrees) -- 0 to 360 West flonw N/A C [alternative representation: 0 to 360 E longitude: flon N/A ] C 21 22 I2 Report type (ON124), or tr N/A C 2I1 BUFR file type and wind speed ind. bf,wi N/A C 23 28 A6 Station ID/ship call sign id N/A C [alternative representation: 8 characters instead of 6: id8 N/A ] C 29 32 F4.1 Sea level press minus 900.0 (mb) missing=9999 fslp 999.9 C 33 35 I3 Wind direction (degs) missing=999 wd 999 C 36 38 I3 Wind speed (knots) missing=999 w 999 C 39 42 F4.1 Air temp (deg c) missing=9999 fat 999.9 C 43 45 F3.1 Dew point depression (deg c) missing=999 fdp 99.9 C 46 46 A1 Cloud cover missing=9 n '9' C 47 49 F3.1 Sea surface temp (deg c) missing=999 fsst 99.9 C C Machine dependencies: None known. C For more information: See (electronic document). c-----------------------------------------------------------------------3456789 program rdnrt c-----read and print ncep real-time marine observations IMPLICIT INTEGER(A-E,G-Z) logical bufr,eof character file*80,id*6,id8*8,n*1,rpt*49 data bufr/.true./,unit/1/,mrpts/100/ read(*,'(a)')file print '(a)',' rdnrt.01a , '//file c-----print headers if(bufr) then call nrbhd else call nrthd endif c-----for the 1st mrpts reports do 500 j=1,mrpts if(bufr) then c-----read and decode call nrbrd(unit,eof,rpt,year,year2,month,day,fhour,flat + ,flon,flonw,bf,wi,id8,id,fslp,wd,w,fat,fdp,n,fsst) if(eof) then print *,'rdnrt. eof encountered by nrbrd.' stop endif c-----print write(*,'(a)') rpt else c-----read and decode call nrtrd(unit,eof,rpt,year,year2,month,day,fhour,flat + ,flon,flonw,tr,id8,id,fslp,wd,w,fat,fdp,n,fsst) if(eof) then print *,'rdnrt. eof encountered by nrtrd.' stop endif c-----print write(*,'(a)') rpt endif 500 continue end C=============================================================================C C WARNING: Code beyond this point should not require any modification. C C=============================================================================C c-----------------------------------------------------------------------3456789 subroutine nrtrd(unit,eof,rpt,year,year2,month,day,fhour,flat + ,flon,flonw,tr,id8,id,fslp,wd,w,fat,fdp,n,fsst) c-----Read NCEP real-time obs (NRT) from unit into rpt, and return eof c true if end-of-file. Otherwise: Return the decoded fields following c the format summary given above, including alternative representations c in year, flon, and id8. Due to the absence of decimal points in the c input format, floating-point arguments (fslp, fat, fdp, and fsst) c have missing values transformed to the indicated floating-point c values. Also, extant fslp is transformed by +900 (returned as mb). c-----NOTE: Applicable only to ON124-based data (1991-97). IMPLICIT INTEGER(A-E,G-Z) logical eof character id*6,id8*8,n*1,rpt*49 eof = .false. read(unit,'(a)',end=500) rpt c-----and then decode into individual fields read(rpt,101) year2,month,day,fhour,flat,flonw,tr,id,fslp + ,wd,w,fat,fdp,n,fsst 101 format(3i2,f4.2,2f5.2,i2,a6,f4.1,2i3,f4.1,f3.1,a1,f3.1) c-----transform year2 (xx) to 20th century year (19xx) c " flonw (longitude W) to flon (longitude E) c " extant fslp by +900 c " id into 8-character id8 c-----check validity of year2 (ON124-based data cover 1991-97) c NOTE: therefore no Y2K fix necessary. if(year2.lt.91.or.year2.gt.97) then print *,'nrtrd error. year2=',year2,' outside ON124 period.' stop endif year = year2 + 1900 flon = 360. - flonw if(fslp.ne.999.9) fslp = fslp + 900. id8 = id return c-----in the event of an end-of-file 500 continue eof = .true. return end c-----------------------------------------------------------------------3456789 subroutine nrbrd(unit,eof,rpt,year,year2,month,day,fhour,flat + ,flon,flonw,bf,wi,id8,id,fslp,wd,w,fat,fdp,n,fsst) c-----As for {nrtrd}, except applicable to BUFR-based data: tr replaced c by bf and wi. c-----NOTE: Applicable only to BUFR-based data (1997-). IMPLICIT INTEGER(A-E,G-Z) logical eof character id*6,id8*8,n*1,rpt*49 eof = .false. read(unit,'(a)',end=500) rpt c-----and then decode into individual fields read(rpt,101) year2,month,day,fhour,flat,flonw,bf,wi,id,fslp + ,wd,w,fat,fdp,n,fsst 101 format(3i2,f4.2,2f5.2,2i1,a6,f4.1,2i3,f4.1,f3.1,a1,f3.1) c-----transform year2 (xx) to 20th or 21st century year (19xx or 20xx) c " flonw (longitude W) to flon (longitude E) c " extant fslp by +900 c " id into 8-character id8 c-----check validity of year2 (BUFR-based data cover 1997-) if(year2.ge.91.and.year2.lt.97) then print *,'nrbrd error. year2=',year2,' outside BUFR period.' stop endif if(year2.lt.97) then year = year2 + 2000 else year = year2 + 1900 endif flon = 360. - flonw if(fslp.ne.999.9) fslp = fslp + 900. id8 = id return c-----in the event of an end-of-file 500 continue eof = .true. return end c-----------------------------------------------------------------------3456789 subroutine nrthd c-----------Write header for NCEP real-time obs (NRT). c-----NOTE: Applicable only to ON124-based data (1991-97). IMPLICIT INTEGER(A-E,G-Z) write(*,100) 100 format( + '(ON124:) NorthWest -900deg kt degC o ', + /,'YrMoDyHourLat::Lon::TrID::::SLP:WD:W::AT::DP:NSST', + /,'==++==++++=====+++++==++++++====+++===++++===+===') return end c-----------------------------------------------------------------------3456789 subroutine nrbhd c-----As for {nrthd}, except applicable to BUFR-based data: Tr replaced c by Bf and WI. c-----NOTE: Applicable only to BUFR-based data (1997-). IMPLICIT INTEGER(A-E,G-Z) write(*,100) 100 format( + '(BUFR:) NorthWest BW -900deg kt degC o ', + /,'YrMoDyHourLat::Lon::fIID::::SLP:WD:W::AT::DP:NSST', + /,'==++==++++=====+++++==++++++====+++===++++===+===') return end EOR rm fort.1 a.out ln -s $1 fort.1 f77 p.f echo $1 `date` | ./a.out