NCEPLIBS-w3emc  2.11.0
w3miscan.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Reads 1 ssm/i scan line from bufr d-set
3 C> @author Dennis Keyser @date 1996-07-30
4 
5 C> Reads one ssm/i scan line (64 retrievals) from the NCEP
6 C> bufr ssm/i dump file. Each scan is time checked against the
7 C> user-requested time window and satellite id combinations. When a
8 C> valid scan is read the program returns to the calling program.
9 C> the user must pass in the type of the input ssm/i dump file,
10 C> either derived products (regardless of source) or brightness
11 C> temperatures (7-channels). If the latter is chosen, the user
12 C> has the further option of processing, in addition to the
13 C> brightness temperatures, in-line calculation of wind speed
14 C> product via the goodberlet algorithm, and/or in-line calculation
15 C> of both wind speed and total column precipitable water (tpw)
16 C> products using the neural net 3 algorithm. If the wind speed
17 C> or tpw is calculated here (either algorithm), this subroutine
18 C> will check for brightness temperatures outside of a preset range
19 C> and will return a missing wind speed/tpw if any b. temp is
20 C> unreasonable. Also, for calculated wind speeds and tpw, this
21 C> program will check to see if the b. temps are over land or ice,
22 C> and if they are it will also return missing values since these
23 C> data are valid only over ocean.
24 C>
25 C> ### Program History Log:
26 C> Date | Programmer | Comment
27 C> -----|------------|--------
28 C> 1996-07-30 | Dennis Keyser | Original author - subroutine is a modified version of w3lib w3fi86 which read one scan line from the 30-orbit shared processing data sets
29 C> 1997-05-22 | Dennis Keyser | Crisis fix to account for clon now returned from bufr as -180 to 0 (west) or 0 to 180 (east), used to return as 0 to 360 east which was not the bufr standard
30 C> 1998-01-28 | Dennis Keyser | Replaced neural net 2 algorithm which calculated only wind speed product with neural net 3 algorithm which calculates both wind speed and total precipitable water products (among others) but, unlike nn2, does not return a rain flag value (it does set all retrievals to missing that fail rain flag and ice contamination tests)
31 C> 1998-03-30 | Dennis Keyser | Modified to handle neural net 3 ssm/i products input in a products bufr data dump file; now prints out number of scans processed by satellite number in final summary
32 C> 1998-10-23 | Dennis Keyser | Subroutine now y2k and fortran 90 compliant
33 C> 1999-02-18 | Dennis Keyser | Modified to compile and run properly on ibm-sp
34 C> 2000-06-08 | Dennis Keyser | Corrected mnemonic for rain rate to "reqv" (was "prer" for some unknown reason)
35 C> 2001-01-03 | Dennis Keyser | Changed units of returned rain rate from whole mm/hr to 10**6 mm/sec, changed units of returned surface temp from whole kelvin to 10**2 kelvin (to incr. precision to that orig. in input bufr file)
36 C> 2004-09-12 | Dennis Keyser | Now decodes sea-surface temperature if valid into same location as surface temperature, quantity is surface temperature if surface tag is not 5, otherwise quantity is sea-surface temperature (ncep products data dump file now contains sst); checks to see if old or new version of mnemonic table bufrtab.012 is being used here (old version had "ph2o" instead of "tpwt", "sndp" instead of "tosd", "wsos" instead of "wspd" and "ch2o" instead of the sequence "metfet vilwc metfet"), and decodes using whichever mnemonics are found {note: a further requirement for "vilwc" is that the first "metfet" (meteorological feature) in the sequence must be 12 (=cloud), else cloud water set to missing, regardless of "vilwc" value}
37 C> 2011-08-04 | Dennis Keyser | Add ibdate (input bufr message date) to output argument list (now used by calling program prepobs_prepssmi)
38 C>
39 C> @param[in] INDTA Unit number of ncep bufr ssm/i dump data set
40 C> @param[in] INLSF Unit number of direct access nesdis land/sea file
41 C> (valid only if lbrit and either nnalg or gbalg true).
42 C> @param[in] INGBI Unit number of grib index file for grib file
43 C> Containing global 1-degree sea-surface temp field.
44 C> (valid only if lbrit and either nnalg or gbalg true).
45 C> @param[in] INGBD Unit number of grib file containing global 1-degree
46 C> Sea-surface temp field (valid only if lbrit and either.
47 C> Nnalg or gbalg true).
48 C> @param[in] LSAT 10-word logical array (240:249) indicating which
49 C> Satellite ids should be processed (see remarks)
50 C> @param[in] LPROD Logical indicating if the input bufr file contains
51 C> Products (regardless of source) - in this case one or.
52 C> More available products can be processed and returned.
53 C> @param[in] LBRIT Logical indicating if the input bufr file contains
54 C> Brightness temperatures - in this case b. temps are.
55 C> Processed and returned along with, if requested, in-.
56 C> Line generated products from one or both algorithms.
57 C> (see next two switches).
58 C> - The following two switches apply only if lbrit is true -----
59 C> @param[in] NNALG Indicating if the subroutine should
60 C> calculate and return ssm/i wind speed and tpw
61 C> via the neural net 3 algorithm (note: b o t h
62 C> wind speed and tpw are returned here)
63 C> @param[in] GBALG Indicating if the subroutine should
64 C> calculate and return ssm/i wind speed via the
65 C> goodberlet algorithm
66 C> @param[in] KDATE Requested earliest year(yyyy), month, day, hour,
67 C> Min for accepting scans.
68 C> @param[in] LDATE Requested latest year(yyyy), month, day, hour,
69 C> Min for accepting scans.
70 C> @param[in] IGNRTM Switch to indicate whether scans should be time-
71 C> Checked (= 0) or not time checked (=1) {if =1, all.
72 C> Scans read in are processed regardless of their time..
73 C> The input arguments "kdate" and "ldate" (earliest and.
74 C> Latest date for processing data) are ignored in the.
75 C> Time checking for scans. (note: the earliest and.
76 C> Latest dates should still be specified to the.
77 C> "expected" time range, but they will not be used for.
78 C> Time checking in this case)}.
79 C> @param[out] IBUFTN Output buffer holding data for a scan (1737 words -
80 C> See remarks for format. some words may be missing
81 C> Depending upon lprod, lbrit, nnalg and gbalg
82 C> @param[out] IBDATE Input bufr message section 1 date (yyyymmddhh)
83 C> @param[out] IER Error return code (see remarks)
84 C>
85 C> @remark
86 C> Return code ier can have the following values:
87 C> - IER = 0 Successful return of scan
88 C> - IER = 1 All scans have been read, all done
89 C> - IER = 2 Abnormal return - input bufr file in unit
90 C> 'indta' is either empty (null) or is not bufr
91 C> - IER = 3 Abnormal return - requested earliest and
92 C> latest dates are backwards
93 C> - IER = 4 Abnormal return - error opening random
94 C> access file holding land/sea tags
95 C> - IER = 5 Abnormal return - the number of decoded
96 C> "levels" is not what is expected
97 C> - IER = 6 Abnormal return - sea-surface temperature
98 C> not found in grib index file - error returned
99 C> from grib decoder getgb is 96
100 C> - IER = 7 Abnormal return - sea-surface temperature
101 C> grib message has a date that is either:
102 C> 1) more than 7-days prior to the earliest
103 C> requested date or 2) more than 7-days after
104 C> the latest requested date
105 C> - IER = 8 Abnormal return - byte-addressable read error
106 C> for grib file containing sea-surface
107 C> temperature field - error returned from grib
108 C> decoder getgb is 97-99
109 C> - IER = 9 Abnormal return - error returned from grib
110 C> decoder - getgb - for sea-surface
111 C> temperature field - > 0 but not 96-99
112 C>
113 C> Input argument lsat is set-up as follows:
114 C> - LSAT(X) = TRUE -- Process scans from satellite id x (where x is code figure from bufr code table 0-01-007)
115 C> - LSAT(X) = FALSE - Do not process scans from satellite id x
116 C> - X = 240 is f-7 dmsp satellite (this satellite is no longer available)
117 C> - X = 241 is f-8 dmsp satellite (this satellite is no longer available)
118 C> - X = 242 is f-9 dmsp satellite (this satellite is no longer available)
119 C> - X = 243 is f-10 dmsp satellite (this satellite is no longer available)
120 C> - X = 244 is f-11 dmsp satellite (this is available as of 8/96 but is not considered to be an operational dmsp ssm/i satellite)
121 C> - X = 245 is f-12 dmsp satellite (this satellite is no longer available)
122 C> - X = 246 is f-13 dmsp satellite (this is available and is considered to be an operational odd dmsp ssm/i satellite as of 8/1996)
123 C> - X = 247 is f-14 dmsp satellite (this is available as of 5/97 but is not considered to be an operational dmsp ssm/i satellite)
124 C> - X = 248 is f-15 dmsp satellite (this is available as of 2/2000 and is considered to be an operational odd dmsp ssm/i satellite as of 2/2000)
125 C> - X = 249 is reserved for a future dmsp satellite
126 C>
127 C> @note Here "even" means value in ibuftn(1) is an odd number while "odd" means value in ibuftn(1) is an even number
128 C> Contents of array 'ibuftn' holding one complete scan (64 individual retrievlas (1737 words)
129 C>
130 C> #### Always returned:
131 C> WORD | CONTENTS
132 C> ---- | --------
133 C> 1 | Satellite id (244 is f-11; 246 is f-13; 247 is f-14; 248 is f-15)
134 C> 2 | 4-digit year for scan
135 C> 3 | 2-digit month of year for scan
136 C> 4 | 2-digit day of month for scan
137 C> 5 | 2-digit hour of day for scan
138 C> 6 | 2-digit minute of hour for scan
139 C> 7 | 2-digit second of minute for scan
140 C> 8 | Scan number in orbit
141 C> 9 | Orbit number for scan
142 C> 10 | Retrieval #1 latitude (*100 degrees: + n, - s)
143 C> 11 | Retrieval #1 longitude (*100 degrees east)
144 C> 12 | Retrieval #1 position number
145 C> 13 | Retrieval #1 surface tag (code figure)
146 C>
147 C> #### For LPROD = TRUE {Input products file: note all products below except sea-surface temperature are available in the fnoc "operational" products data dump; most ncep products data dumps contain only wind speed, total precipitable water, cloud water and sea-surface temperature (all over ocean only)}:
148 C> WORD | CONTENTS
149 C> ---- | --------
150 C> 14 | Retrieval #1 cloud water (*100 kilogram/meter**2)
151 C> 15 | Retrieval #1 rain rate (*1000000 millimeters/second)
152 C> 16 | Retrieval #1 wind speed (*10 meters/second)
153 C> 17 | Retrieval #1 soil moisture (millimeters)
154 C> 18 | Retrieval #1 sea-ice concentration (per cent)
155 C> 19 | Retrieval #1 sea-ice age (code figure)
156 C> 20 | Retrieval #1 ice edge (code figure)
157 C> 21 | Retrieval #1 total precip. water (*10 millimeters)
158 C> 22 | Retrieval #1 surface temp (*100 k) if not over ocean -OR-
159 C> 22 | Retrieval #1 sea-surface temp (*100 k) if over ocean
160 C> 23 | Retrieval #1 snow depth (millimeters)
161 C> 24 | Retrieval #1 rain flag (code figure)
162 C> 25 | Retrieval #1 calculated surface type (code figure)
163 C>
164 C> #### For LBRIT = TRUE (Input brightness temperature file):
165 C> WORD | CONTENTS
166 C> ---- | --------
167 C> 26 | Retrieval #1 19 ghz v brightness temp (*100 deg. k)
168 C> 27 | Retrieval #1 19 ghz h brightness temp (*100 deg. k)
169 C> 28 | Retrieval #1 22 ghz v brightness temp (*100 deg. k)
170 C> 29 | Retrieval #1 37 ghz v brightness temp (*100 deg. k)
171 C> 30 | Retrieval #1 37 ghz h brightness temp (*100 deg. k)
172 C> 31 | Retrieval #1 85 ghz v brightness temp (*100 deg. k)
173 C> 32 | Retrieval #1 85 ghz h brightness temp (*100 deg. k)
174 C>
175 C> #### For LBRIT = TRUE and NNALG = TRUE (Input brightness temperature file):
176 C> WORD | CONTENTS
177 C> ---- | --------
178 C> 33 | Retrieval #1 Neural net 3 algorithm wind speed (generated in-line) (*10 meters/second)
179 C> 34 | Retrieval #1 Neural net 3 algorithm total precip. water (generated in-line) (*10 millimeters)
180 C>
181 C> #### For LBRIT = TRUE and GBALG = TRUE (Input brightness temperature file):
182 C> WORD | CONTENTS
183 C> ---- | --------
184 C> 35 | Retrieval #1 goodberlet algorithm wind speed (generated in-line) (*10 meters/second)
185 C> 36 | Retrieval #1 goodberlet algorithm rain flag (code figure)
186 C> 37-1737 | Repeat 10-36 for 63 more retrievals
187 C>
188 C> @note All missing data or data not selected by calling program are set to 99999
189 C>
190 C> @author Dennis Keyser @date 1996-07-30
191 
192  SUBROUTINE w3miscan(INDTA,INLSF,INGBI,INGBD,LSAT,LPROD,LBRIT,
193  $ NNALG,GBALG,KDATE,LDATE,IGNRTM,IBUFTN,IBDATE,IER)
194 
195  LOGICAL LPROD,LBRIT,NNALG,GBALG,LSAT(240:249)
196 
197  CHARACTER*1 CDUMMY
198  CHARACTER*2 ATXT(2)
199  CHARACTER*8 SUBSET
200  CHARACTER*20 RHDER,PROD2,BRITE
201  CHARACTER*46 SHDER,PROD1
202 
203  REAL SHDR(9),RHDR(4,64),PROD(13,64),BRIT(2,448),RINC(5),
204  $ metfet(64)
205 
206  REAL(8) SHDR_8(9),RHDR_8(4,64),PROD_8(13,64),BRIT_8(2,448),
207  $ ufbint_8(64)
208 
209  INTEGER IBUFTN(1737),KDATA(7),KDATE(5),LDATE(5),LBTER(7),
210  $ kspsat(239:249),kntsat(239:249),iflag(64),kdat(8),ldat(8),
211  $ mdat(8),icdate(5),iddate(5)
212 
213  common/misccc/sstdat(360,180)
214  common/miscee/lflag,licec
215 
216  SAVE
217 
218  DATA shder /'SAID YEAR MNTH DAYS HOUR MINU SECO SCNN ORBN '/
219  DATA rhder /'CLAT CLON POSN SFTG '/
220  DATA prod1 /'VILWC REQV WSPD SMOI ICON ICAG ICED TPWT TMSK '/
221  DATA prod2 /'TOSD RFLG SFTP SST1 '/
222  DATA brite /'CHNM TMBR '/
223  DATA atxt /'NN','GB'/
224  DATA imsg /99999/,kntscn/0/,knttim/0/,laerr/0/,
225  $ loerr/0/,lbter/7*0/,itimes/0/,nlr/0/,nir/0/,dmax/-99999./,
226  $ dmin/99999./,kspsat/11*0/,kntsat/11*0/,ilflg/0/,bmiss/10.0e10/
227 
228  IF(itimes.EQ.0) THEN
229 
230 C***********************************************************************
231 C FIRST CALL INTO SUBROUTINE DO A FEW THINGS .....
232  itimes = 1
233  lflag = 0
234  licec = 0
235  print 65, indta
236  65 FORMAT(//' ---> W3MISCAN: Y2K/F90 VERSION 08/04/2011: ',
237  $ 'PROCESSING SSM/I DATA FROM BUFR DATA SET READ FROM UNIT ',
238  $ i4/)
239  IF(lprod) print 66
240  66 FORMAT(//' ===> WILL READ FROM BUFR PRODUCTS DATA DUMP ',
241  $ 'FILE (EITHER FNOC OR NCEP) AND PROCESS ONE OR MORE SSM/I ',
242  $ 'PRODUCTS'//)
243  IF(lbrit) THEN
244  print 167
245  167 FORMAT(//' ===> WILL READ FROM BUFR BRIGHTNESS ',
246  $ 'TEMPERATURE DATA DUMP FILE AND PROCESS BRIGHTNESS ',
247  $ 'TEMPERATURES'//)
248  IF(nnalg) print 169
249  169 FORMAT(' ===> IN ADDITION, WILL PERFORM IN-LINE ',
250  $ 'CALCULATION OF NEURAL NETWORK 3 WIND SPEED AND TOTAL ',
251  $ 'PRECIPITABLE WATER AND PROCESS THESE'/)
252  IF(gbalg) print 170
253  170 FORMAT(' ===> IN ADDITION, WILL PERFORM IN-LINE ',
254  $ 'CALCULATION OF GOODBERLET WIND SPEED AND PROCESS THESE'/)
255  END IF
256  IF(ignrtm.EQ.1) print 704
257  704 FORMAT(' W3MISCAN: INPUT ARGUMENT "IGNRTM" IS SET TO 1 -- NO ',
258  $ 'TIME CHECKS WILL BE PERFORMED ON SCANS - ALL SCANS READ IN ',
259  $ 'ARE PROCESSED'/)
260 
261  print 104, kdate,ldate
262  104 FORMAT(' W3MISCAN: REQUESTED EARLIEST DATE:',i7,4i5/
263  $ ' REQUESTED LATEST DATE:',i7,4i5)
264 
265  kdat = 0
266  kdat(1:3) = kdate(1:3)
267  kdat(5:6) = kdate(4:5)
268  ldat = 0
269  ldat(1:3) = ldate(1:3)
270  ldat(5:6) = ldate(4:5)
271 
272 C DO REQUESTED EARLIEST AND LATEST DATES MAKE SENSE?
273 
274  CALL w3difdat(ldat,kdat,3,rinc)
275  IF(rinc(3).LT.0) THEN
276 C.......................................................................
277  print 103
278  103 FORMAT(' ##W3MISCAN: REQUESTED EARLIEST AND LATEST DATES ',
279  $ 'ARE BACKWARDS!! - IER = 3'/)
280  ier = 3
281  RETURN
282 C.......................................................................
283  END IF
284 
285 C DETERMINE MACHINE WORD LENGTH IN BYTES AND TYPE OF CHARACTER SET
286 C {ASCII(ICHTP=0) OR EBCDIC(ICHTP=1)}
287 
288  CALL w3fi04(iendn,ichtp,lw)
289  print 2213, lw, ichtp, iendn
290  2213 FORMAT(/' ---> W3MISCAN: CALL TO W3FI04 RETURNS: LW = ',i3,
291  $ ', ICHTP = ',i3,', IENDN = ',i3/)
292 
293  CALL datelen(10)
294 
295  CALL dumpbf(indta,icdate,iddate)
296 cppppp
297  print *,'CENTER DATE (ICDATE) = ',icdate
298  print *,'DUMP DATE (IDDATE) = ',iddate
299 cppppp
300 
301 C COME HERE IF CENTER DATE COULD NOT BE READ FROM FIRST DUMMY MESSAGE
302 C - RETURN WITH IRET = 2
303 
304  IF(icdate(1).LE.0) GO TO 998
305 
306 C COME HERE IF DUMP DATE COULD NOT BE READ FROM SECOND DUMMY MESSAGE
307 C - RETURN WITH IRET = 2
308 
309  IF(iddate(1).LE.0) GO TO 998
310  IF(icdate(1).LT.100) THEN
311 
312 C IF 2-DIGIT YEAR RETURNED IN ICDATE(1), MUST USE "WINDOWING" TECHNIQUE
313 C TO CREATE A 4-DIGIT YEAR
314 
315 C IMPORTANT: IF DATELEN(10) IS CALLED, THE DATE HERE SHOULD ALWAYS
316 C CONTAIN A 4-DIGIT YEAR, EVEN IF INPUT FILE IS NOT
317 C Y2K COMPLIANT (BUFRLIB DOES THE WINDOWING HERE)
318 
319  print *, '##W3MISCAN - THE FOLLOWING SHOULD NEVER ',
320  $ 'HAPPEN!!!!!'
321  print *, '##W3MISCAN - 2-DIGIT YEAR IN ICDATE(1) RETURNED ',
322  $ 'FROM DUMPBF (ICDATE IS: ',icdate,') - USE WINDOWING ',
323  $ 'TECHNIQUE TO OBTAIN 4-DIGIT YEAR'
324  IF(icdate(1).GT.20) THEN
325  icdate(1) = 1900 + icdate(1)
326  ELSE
327  icdate(1) = 2000 + icdate(1)
328  ENDIF
329  print *, '##W3MISCAN - CORRECTED ICDATE(1) WITH 4-DIGIT ',
330  $ 'YEAR, ICDATE NOW IS: ',icdate
331  ENDIF
332 
333  IF(iddate(1).LT.100) THEN
334 
335 C IF 2-DIGIT YEAR RETURNED IN IDDATE(1), MUST USE "WINDOWING" TECHNIQUE
336 C TO CREATE A 4-DIGIT YEAR
337 
338 C IMPORTANT: IF DATELEN(10) IS CALLED, THE DATE HERE SHOULD ALWAYS
339 C CONTAIN A 4-DIGIT YEAR, EVEN IF INPUT FILE IS NOT
340 C Y2K COMPLIANT (BUFRLIB DOES THE WINDOWING HERE)
341 
342  print *, '##W3MISCAN - THE FOLLOWING SHOULD NEVER ',
343  $ 'HAPPEN!!!!!'
344  print *, '##W3MISCAN - 2-DIGIT YEAR IN IDDATE(1) RETURNED ',
345  $ 'FROM DUMPBF (IDDATE IS: ',iddate,') - USE WINDOWING ',
346  $ 'TECHNIQUE TO OBTAIN 4-DIGIT YEAR'
347  IF(iddate(1).GT.20) THEN
348  iddate(1) = 1900 + iddate(1)
349  ELSE
350  iddate(1) = 2000 + iddate(1)
351  ENDIF
352  print *, '##W3MISCAN - CORRECTED IDDATE(1) WITH 4-DIGIT ',
353  $ 'YEAR, IDDATE NOW IS: ',iddate
354  END IF
355 
356 C OPEN BUFR FILE - READ IN DICTIONARY MESSAGES (TABLE A, B, D ENTRIES)
357 
358  CALL openbf(indta,'IN',indta)
359 
360  print *, ' '
361  print *, 'OPEN NCEP BUFR SSM/I DUMP FILE'
362  print *, ' '
363 
364 C Check to see if the old (pre 9/2004) version of the mnemonic
365 C table is being used here (had "PH2O" instead of "TPWT",
366 C "SNDP" instead of "TOSD", "WSOS" instead of "WSPD")
367 C ------------------------------------------------------------
368 
369  CALL status(indta,lun,idummy1,idummy2)
370  CALL nemtab(lun,'PH2O',idummy1,cdummy,iret_ph2o)
371  CALL nemtab(lun,'SNDP',idummy1,cdummy,iret_sndp)
372  CALL nemtab(lun,'WSOS',idummy1,cdummy,iret_wsos)
373  CALL nemtab(lun,'CH2O',idummy1,cdummy,iret_ch2o)
374 
375  IF(lbrit.AND.(nnalg.OR.gbalg)) THEN
376 
377 C-----------------------------------------------------------------------
378 C IF IN-LINE CALC. OF WIND SPEED FROM GOODBERLET ALG. OR
379 C IN-LINE CALCULATION OF WIND SPEED AND TPW FROM NEURAL NET 3 ALG.
380 C FIRST CALL TO THIS SUBROUTINE WILL READ IN SEA-SURFACE TEMPERATURE
381 C FIELD AS A CHECK FOR ICE LIMITS
382 C WILL ALSO OPEN DIRECT ACCESS NESDIS LAND SEA FILE
383 C-----------------------------------------------------------------------
384 
385  CALL misc06(ingbi,ingbd,kdate,ldate,*993,*994,*995,*996)
386  print 67, inlsf
387  67 FORMAT(//4x,'** W3MISCAN: OPEN R. ACCESS NESDIS LAND/SEA ',
388  $ 'FILE IN UNIT ',i2/)
389  OPEN(unit=inlsf,err=997,access='DIRECT',iostat=ierr,recl=10980)
390  END IF
391 
392 C READ THE FIRST BUFR MESSAGE IN THE BUFR FILE
393 
394  CALL readmg(indta,subset,ibdate,iret)
395 
396  print *, 'READ FIRST BUFR MESSAGE: SUBSET = ',subset,
397  $ '; IBDATE = ',ibdate,'; IRET = ',iret
398 
399  IF(iret.NE.0) GO TO 998
400 
401 C***********************************************************************
402 
403  END IF
404 
405  30 CONTINUE
406 
407 C TIME TO DECODE NEXT SUBSET (SCAN) OUT OF BUFR MESSAGE
408 
409  ibuftn = imsg
410  CALL readsb(indta,iret)
411  IF(iret.NE.0) THEN
412 
413 C ALL SUBSETS OUT OF THIS MESSAGE READ, TIME TO MOVE ON TO NEXT MESSAGE
414 
415  CALL readmg(indta,subset,ibdate,iret)
416 
417  print *, 'READ NEXT BUFR MESSAGE: SUBSET = ',subset,
418  $ '; IBDATE = ',ibdate,'; IRET = ',iret
419 
420  IF(iret.NE.0) THEN
421 c.......................................................................
422 
423 C NON-ZERO IRET IN READMG MEANS ALL BUFR MESSAGES IN FILE HAVE BEEN READ
424 C - ALL FINISHED, NO OTHER SCANS W/I DESIRED TIME RANGE -- SET IER TO 1
425 C AND RETURN TO CALLING PROGRAM
426 
427  print 124, kntscn
428  124 FORMAT(/' W3MISCAN: +++++ ALL VALID SCANS UNPACKED AND ',
429  $ 'RETURNED FROM THIS NCEP BUFR SSM/I DUMP FILE'//34x,
430  $ '** W3MISCAN: SUMMARY **'//35x,'TOTAL NUMBER OF SCANS ',
431  $ 'PROCESSED AND RETURNED',11x,i7)
432  DO jj = 239,249
433  IF(kntsat(jj).GT.0) THEN
434  print 294, jj,kntsat(jj)
435  294 FORMAT(35x,'......NO. OF SCANS PROCESSED AND ',
436  $ 'RETURNED FROM SAT',i4,':',i7)
437  END IF
438  END DO
439  DO jj = 239,249
440  IF(kspsat(jj).GT.0) THEN
441  ii = jj
442  IF(jj.EQ.239) ii = 1
443  print 224, ii,kspsat(jj)
444  224 FORMAT(35x,'NO. OF SCANS SKIPPED DUE TO BEING FROM ',
445  $ 'NON-REQ SAT',i4,':',i7)
446  END IF
447  END DO
448  print 194, knttim
449  194 FORMAT(35x,'NUMBER OF SCANS SKIPPED DUE TO BEING OUTSIDE ',
450  $ 'TIME INT.:',i7)
451  print 324, laerr,loerr
452  324 FORMAT(
453  $/35x,'NUMBER OF RETRIEVALS WITH LATITUDE OUT OF RANGE: ',i7/
454  $ 35x,'NUMBER OF RETRIEVALS WITH LONGITUDE OUT OF RANGE: ',i7)
455  IF(lbrit) THEN
456  IF(nnalg.OR.gbalg) print 780, lbter,nlr,nir
457  780 FORMAT(
458  $ 35x,'NUMBER OF RETRIEVALS W/ ERROR IN 19 GHZ V BRIGHT. TEMP:',i7/
459  $ 35x,'NUMBER OF RETRIEVALS W/ ERROR IN 19 GHZ H BRIGHT. TEMP:',i7/
460  $ 35x,'NUMBER OF RETRIEVALS W/ ERROR IN 22 GHZ V BRIGHT. TEMP:',i7/
461  $ 35x,'NUMBER OF RETRIEVALS W/ ERROR IN 37 GHZ V BRIGHT. TEMP:',i7/
462  $ 35x,'NUMBER OF RETRIEVALS W/ ERROR IN 37 GHZ H BRIGHT. TEMP:',i7/
463  $ 35x,'NUMBER OF RETRIEVALS W/ ERROR IN 85 GHZ V BRIGHT. TEMP:',i7/
464  $ 35x,'NUMBER OF RETRIEVALS W/ ERROR IN 85 GHZ H BRIGHT. TEMP:',i7/
465  $ 35x,'NUMBER OF RETRIEVALS REJECTED DUE TO BEING OVER LAND: ',i7/
466  $ 35x,'NUMBER OF RETRIEVALS REJECTED DUE TO BEING OVER ICE: ',i7)
467  IF(nnalg) print 781, lflag,licec
468  781 FORMAT(
469  $ 35x,'NUMBER OF NN3 RETR. REJECTED DUE TO FAILING RAIN FLAG: ',i7/
470  $ 35x,'NUMBER OF NN3 RETR. REJECTED DUE TO ICE CONTAMINATION: ',i7)
471  IF(nnalg.OR.gbalg) print 782, dmax,dmin
472  782 FORMAT(/' ** FOR SEA-SFC TEMP AT ALL RETRIEVAL LOCATIONS: FIELD',
473  $ ' MAX =',f8.3,' DEG K, FIELD MIN =',f8.3,' DEG K'/)
474  END IF
475  ier = 1
476  RETURN
477 C.......................................................................
478  END IF
479 
480  GO TO 30
481  END IF
482 
483 C***********************************************************************
484 C COME HERE FOR BOTH PRODUCTS AND BRIGHTNESS TEMPERATURES
485 C***********************************************************************
486  shdr = bmiss
487  CALL ufbint(indta,shdr_8,09,1,nlev,shder) ; shdr = shdr_8
488  ilflg = 1
489  IF(nlev.NE.1) GO TO 999
490 
491 C STORE THE SCAN'S SATELLITE ID IN WORD 1
492 C STORE SCAN'S YEAR (YYYY), MONTH, DAY, HOUR, MIN, SEC INTO WORDS 2-7
493 C STORE THE SCAN NUMBER IN WORD 8
494 C STORE THE SCAN'S ORBIT NUMBER IN WORD 9
495 
496  ibuftn(1:9) = min(imsg,nint(shdr(1:9)))
497 
498 C CHECK TO SEE IF SCAN IS FROM REQUESTED SATELLITE ID
499 
500  IF(ibuftn(1).LT.240.OR.ibuftn(1).GT.249) THEN
501  print 523, (ibuftn(ii),ii=1,9)
502  kspsat(239) = kspsat(239) + 1
503  GO TO 30
504  END IF
505  IF(.NOT.lsat(ibuftn(1))) THEN
506 CDAK PRINT 523, (IBUFTN(II),II=1,9)
507  523 FORMAT(' ##W3MISCAN: SCAN NOT FROM REQ. SAT. ID -SAT. ID',i4,
508  $ ', SCAN TIME:',6i4,', SCAN',i6,', ORBIT',i8,'-GO TO NEXT SCAN')
509  kspsat(ibuftn(1)) = kspsat(ibuftn(1)) + 1
510  GO TO 30
511  END IF
512 
513  IF(ignrtm.EQ.0) THEN
514 
515 C TIME CHECK THIS SCAN IF USER REQUESTS SUCH
516 
517  mdat = 0
518  mdat(1:3) = ibuftn(2:4)
519  mdat(5:7) = ibuftn(5:7)
520  CALL w3difdat(kdat,mdat,4,rinc)
521  ksec = rinc(4)
522  CALL w3difdat(ldat,mdat,4,rinc)
523  lsec = rinc(4)
524  IF(ksec.GT.0.OR.lsec.LT.0) THEN
525 
526 C TIME CHECK FOR SCAN FAILED: GO ON TO NEXT SCAN
527 
528 CDAK PRINT 123, (IBUFTN(II),II=2,9)
529  123 FORMAT(' ##W3MISCAN: SCAN NOT IN REQUESTED TIME WINDOW-',
530  $ 'SCAN TIME:',6i5,' SCAN',i6,', ORBIT',i8,' - GO TO NEXT SCAN')
531  knttim = knttim + 1
532  GO TO 30
533  END IF
534  END IF
535  rhdr = bmiss
536  CALL ufbint(indta,rhdr_8,04,64,nlev,rhder) ; rhdr = rhdr_8
537  ilflg = 2
538  IF(nlev.NE.64) GO TO 999
539  iflag = 0
540  DO irt = 1,64
541 
542 C THIS ROUTINE EXPECTS LONGITUDE TO BE 0-360 E; BUFR NOW RETURNS -180-0
543 C FOR WEST AND 0-180 FOR EAST
544 
545  IF(rhdr(2,irt).LT.0.0) rhdr(2,irt) = rhdr(2,irt) + 360.
546 C-----------------------------------------------------------------------
547 C LOOP THROUGH THE 64 RETRIEVALS IN A SCAN
548 C-----------------------------------------------------------------------
549 C STORE THE LATITUDE (*100 DEGREES; + : NORTH, - : SOUTH)
550  IF(nint(rhdr(1,irt)*100.).GE.-9000.AND.nint(rhdr(1,irt)*100.)
551  $ .LE.9000) THEN
552  ibuftn((27*irt)-17) = nint(rhdr(1,irt)*100.)
553  ELSE
554 
555 C.......................................................................
556 
557 C BAD LATITUDE
558 
559  laerr = laerr + 1
560  print 777, irt,ibuftn(8),ibuftn(9),nint(rhdr(1,irt)*100.)
561  777 FORMAT(' ##W3MISCAN: BAD LAT: RETR.',i3,', SCAN',i6,
562  $ ', ORBIT',i8,'; INPUT LAT=',i7,' - ALL DATA IN THIS ',
563  $ 'RETRIEVAL SET TO MISSING')
564  iflag(irt) = 1
565 C.......................................................................
566 
567  END IF
568 
569 C STORE THE LONGITUDE (*100 DEGREES EAST)
570 
571  IF(nint(rhdr(2,irt)*100.).GE.0.AND.nint(rhdr(2,irt)*100.).LE.
572  $ 36000) THEN
573  IF(iflag(irt).EQ.0)
574  $ ibuftn((27*irt)-16) = nint(rhdr(2,irt)*100.)
575  ELSE
576 
577 C.......................................................................
578 
579 C BAD LONGITUDE
580 
581  loerr = loerr + 1
582  print 778, irt,ibuftn(8),ibuftn(9),nint(rhdr(2,irt)*100.)
583  778 FORMAT(' ##W3MISCAN: BAD LON: RETR.',i3,', SCAN',i6,
584  $ ', ORBIT',i8,'; INPUT LON=',i7,' - ALL DATA IN THIS ',
585  $ 'RETRIEVAL SET TO MISSING')
586  iflag(irt) = 1
587 C.......................................................................
588 
589  END IF
590  IF(iflag(irt).NE.0) GO TO 110
591 
592 C STORE THE POSITION NUMBER
593 
594  ibuftn((27*irt)-15) = min(imsg,nint(rhdr(3,irt)))
595 
596 C STORE THE SURFACE TAG (0-6)
597 
598  ibuftn((27*irt)-14) = min(imsg,nint(rhdr(4,irt)))
599  110 CONTINUE
600 C-----------------------------------------------------------------------
601  END DO
602 
603  IF(lprod) THEN
604 C***********************************************************************
605 C COME HERE TO PROCESS PRODUCTS FROM INPUT SSM/I PRODUCTS FILE
606 C***********************************************************************
607 
608  prod = bmiss
609  CALL ufbint(indta,prod_8,13,64,nlev,prod1//prod2)
610  ufbint_8 = bmiss
611  IF(iret_ph2o.GT.0) THEN ! Prior to 9/2004
612  CALL ufbint(indta,ufbint_8,1,64,nlev,'PH2O')
613  prod_8(8,:) = ufbint_8(:)
614  END IF
615  ufbint_8 = bmiss
616  IF(iret_sndp.GT.0) THEN ! Prior to 9/2004
617  CALL ufbint(indta,ufbint_8,1,64,nlev,'SNDP')
618  prod_8(10,:) = ufbint_8(:)
619  END IF
620  ufbint_8 = bmiss
621  IF(iret_wsos.GT.0) THEN ! Prior to 9/2004
622  CALL ufbint(indta,ufbint_8,1,64,nlev,'WSOS')
623  prod_8(3,:) = ufbint_8(:)
624  END IF
625  ufbint_8 = bmiss
626  IF(iret_ch2o.GT.0) THEN ! Prior to 9/2004
627  CALL ufbint(indta,ufbint_8,1,64,nlev,'CH2O')
628  prod_8(1,:) = ufbint_8(:)
629  ELSE
630  CALL ufbint(indta,ufbint_8,1,64,nlev,'METFET')
631  metfet = ufbint_8
632  DO irt = 1,64
633  IF(nint(metfet(irt)).NE.12) prod_8(1,irt) = bmiss
634  END DO
635  END IF
636 
637  prod=prod_8
638  ilflg = 3
639  IF(nlev.EQ.0) THEN
640  print 797, ibuftn(8),ibuftn(9)
641  797 FORMAT(' ##W3MISCAN: PRODUCTS REQ. BUT SCAN',i6,', ORBIT',
642  $ i8,' DOES NOT CONTAIN PRODUCT DATA - CONTINUE PROCESSING ',
643  $ 'SCAN (B.TEMPS REQ.?)')
644  GO TO 900
645  ELSE IF(nlev.NE.64) THEN
646  GO TO 999
647  END IF
648  DO irt = 1,64
649 C-----------------------------------------------------------------------
650 C LOOP THROUGH THE 64 RETRIEVALS IN A SCAN
651 C-----------------------------------------------------------------------
652  IF(iflag(irt).NE.0) GO TO 111
653 
654 C STORE THE CLOUD WATER (*100 KG/M**2) IF AVAILABLE
655 
656  IF(nint(prod(01,irt)).LT.imsg)
657  $ ibuftn((27*irt)-13) = nint(prod(01,irt)*100.)
658 
659 C STORE THE RAIN RATE (*1000000 KG/((M**2)*SEC)) IF AVAILABLE
660 C (THIS IS ALSO RAIN RATE (*1000000 MM/SEC))
661 
662  IF(nint(prod(02,irt)).LT.imsg)
663  $ ibuftn((27*irt)-12) = nint(prod(02,irt)*1000000.)
664 
665 C STORE THE WIND SPEED (*10 M/SEC) IF AVAILABLE
666 
667  ibuftn((27*irt)-11) = min(imsg,nint(prod(03,irt)*10.))
668 
669 C STORE THE SOIL MOISTURE (MM) IF AVAILABLE
670 
671  IF(nint(prod(04,irt)).LT.imsg)
672  $ ibuftn((27*irt)-10) = nint(prod(04,irt)*1000.)
673 
674 C STORE THE SEA ICE CONCENTRATION (PERCENT) IF AVAILABLE
675 
676  ibuftn((27*irt)-09) = min(imsg,nint(prod(05,irt)))
677 
678 C STORE THE SEA ICE AGE (0,1) IF AVAILABLE
679 
680  ibuftn((27*irt)-08) = min(imsg,nint(prod(06,irt)))
681 
682 C STORE THE ICE EDGE (0,1) IF AVAILABLE
683 
684  ibuftn((27*irt)-07) = min(imsg,nint(prod(07,irt)))
685 
686 C STORE THE WATER VAPOR (*10 KG/M**2) IF AVAILABLE
687 C (THIS IS ALSO TOTAL PRECIPITABLE WATER SCALED AS *10 MM)
688 
689  ibuftn((27*irt)-06) = min(imsg,nint(prod(08,irt)*10.))
690 
691  IF(ibuftn((27*irt)-14).NE.5) THEN
692 
693 C STORE THE SURFACE TEMPERATURE (*100 DEGREES KELVIN) IF AVAILABLE
694 C (NOTE: SURFACE TAG MUST NOT BE 5)
695 
696  ibuftn((27*irt)-05) = min(imsg,nint(prod(09,irt)*100.))
697 
698  ELSE
699 
700 C STORE THE SEA-SURFACE TEMPERATURE (*100 DEGREES KELVIN) IF AVAILABLE
701 C (NOTE: SURFACE TAG MUST BE 5)
702 
703  ibuftn((27*irt)-05) = min(imsg,nint(prod(13,irt)*100.))
704 
705  END IF
706 
707 C STORE THE SNOW DEPTH (MM) IF AVAILABLE
708 
709  IF(nint(prod(10,irt)).LT.imsg)
710  $ ibuftn((27*irt)-04) = nint(prod(10,irt)*1000.)
711 
712 C STORE THE RAIN FLAG (0-3) IF AVAILABLE
713 
714  ibuftn((27*irt)-03) = min(imsg,nint(prod(11,irt)))
715 
716 C STORE THE CALCULATED SURFACE TYPE (1-20) IF AVAILABLE
717 
718  ibuftn((27*irt)-02) = min(imsg,nint(prod(12,irt)))
719  111 CONTINUE
720 C-----------------------------------------------------------------------
721  END DO
722  END IF
723  900 CONTINUE
724 
725  IF(lbrit) THEN
726 C***********************************************************************
727 C COME HERE TO PROCESS BRIGHTNESS TEMPERATURES FROM INPUT SSM/I
728 C BRIGHTNESS TEMPERATURE FILE
729 C AND POSSIBLY FOR IN-LINE CALC. OF WIND SPEED VIA GOODBERLET ALG.
730 C AND POSSIBLY FOR IN-LINE CALC. OF WIND SPEED AND TPW VIA N. NET 3 ALG.
731 C***********************************************************************
732 
733  brit = bmiss
734  CALL ufbrep(indta,brit_8,2,448,nlev,brite) ; brit = brit_8
735  ilflg = 4
736  IF(nlev.EQ.0) THEN
737  print 798, ibuftn(8),ibuftn(9)
738  798 FORMAT(' ##W3MISCAN: B. TEMPS REQ. BUT SCAN',i6,', ORBIT',
739  $ i8,' DOES NOT CONTAIN B. TEMP DATA - DONE PROCESSING THIS',
740  $ ' SCAN')
741  GO TO 901
742  ELSE IF(nlev.NE.448) THEN
743  GO TO 999
744  END IF
745  DO irt = 1,64
746 C-----------------------------------------------------------------------
747 C LOOP THROUGH THE 64 RETRIEVALS IN A SCAN
748 C-----------------------------------------------------------------------
749  IF(iflag(irt).NE.0) GO TO 112
750 
751 C STORE THE 7 BRIGHTNESS TEMPS (*100 DEGREES KELVIN)
752 C -- CHANNELS ARE IN THIS ORDER FOR A PARTICULAR RETRIEVAL:
753 C 19 GHZ V, 19 GHZ H, 22 GHZ V, 37 GHZ V, 37 GHZ H, 85 GHZ V, 85 GHZ H
754 
755  igood = 0
756  mindx = (irt * 7) - 6
757  DO lch = mindx,mindx+6
758  ichnn = nint(brit(1,lch))
759  IF(ichnn.GT.7) GO TO 79
760  IF(nint(brit(2,lch)).LT.imsg) THEN
761  ibuftn((27*irt)-02+ichnn) = nint(brit(2,lch)*100.)
762  igood = 1
763  END IF
764  79 CONTINUE
765  END DO
766 
767  IF(nnalg.OR.gbalg) THEN
768  kdata = imsg
769  IF(igood.EQ.1) THEN
770 C- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
771 C COME HERE FOR IN-LINE CALC. OF WIND SPEED VIA GOODBERLET ALG. AND/OR
772 C FOR IN-LINE CALC. OF WIND SPEED AND TPW VIA NEURAL NET 3 ALG.
773 C- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
774 
775 C GET LAND/SEA TAG AND CHECK FOR LAT/LON OVER LAND OR ICE
776 
777  balon=real(mod(ibuftn((27*irt)-16)+18000,36000)-18000)/100.
778  ialon = mod(36000-ibuftn((27*irt)-16),36000)
779  ix = 361. - real(ialon)/100.
780  jy = 91 - nint(real(ibuftn((27*irt)-17))/100. + 0.50)
781  dmin = min(dmin,sstdat(ix,jy))
782  dmax = max(dmax,sstdat(ix,jy))
783  CALL misc04(inlsf,real(ibuftn((27*irt)-17))/100.,balon,lstag)
784 
785 C ..... REJECT IF OVER LAND (USE LAND/SEA TAG HERE)
786 
787  IF(lstag.NE.0) THEN
788  nlr = nlr + 1
789  GO TO 112
790  END IF
791 
792 C ..... REJECT IF OVER ICE (USE SEA-SURFACE TEMPERATURE HERE)
793 
794  IF(sstdat(ix,jy).LE.272.96) THEN
795  nir = nir + 1
796  GO TO 112
797  END IF
798 
799  kdata = ibuftn((27*irt)-01:(27*irt)+05)
800  DO it = 1,7
801  IF((it.NE.2.AND.kdata(it).LT.10000).OR.
802  $ (it.EQ.2.AND.kdata(it).LT. 8000)) THEN
803  lbter(it) = lbter(it) + 1
804  print 779,it,ibuftn(8),ibuftn(9),kdata
805  779 FORMAT(' ##W3MISCAN: BT, CHN',i2,' BAD: SCAN',i6,', ORBIT',i8,
806  $ '; BT:',7i6,'-CANNOT CALC. PRODS VIA ALG.')
807  GO TO 112
808  END IF
809  END DO
810 
811 C CALL SUBR. MISC01 TO INITIATE IN-LINE PRODUCT CALCULATION
812 
813  CALL misc01(nnalg,gbalg,kdata,swnn,tpwnn,swgb,nrfgb)
814 
815  IF(nnalg) THEN
816 CDAK IF(MOD(KNTSCN,100).EQ.0) PRINT 6021, ATXT(1),SWNN,
817 CDAK $ TPWNN,REAL(KDATA(1))/100.,(REAL(KDATA(KKK))/100.,
818 CDAK $ KKK=3,5),(REAL(KDATA(4)-KDATA(5)))/100.
819  6021 FORMAT(' W3MISCAN: ',a2,' SPD',f6.1,' TPW',f6.1,' TB19V',f6.1,
820  $ ' TB22V',f6.1,' TB37V',f6.1,' TB37H',f6.1,' TD37',f5.1)
821 
822 C STORE THE CALCULATED NEURAL NET 3 WIND SPEED (*10 M/SEC)
823 
824  ibuftn((27*irt)+6) = min(imsg,nint(swnn*10.))
825 
826 C STORE THE CALCULATED NEURAL NET 3 TPW (*10 MILLIMETERS)
827 
828  ibuftn((27*irt)+7) = min(imsg,nint(tpwnn*10.))
829  END IF
830 
831  IF(gbalg) THEN
832 CDAK IF(MOD(KNTSCN,100).EQ.0) PRINT 602, ATXT(2),NRFGB,
833 CDAK $ SWGB,REAL(KDATA(1))/100.,(REAL(KDATA(KKK))/100.,
834 CDAK $ KKK=3,5),(REAL(KDATA(4)-KDATA(5)))/100.
835  602 FORMAT(' W3MISCAN: ',a2,' RF, SPD',i2,f6.1,' TB19V',f6.1,
836  $ ' TB22V',f6.1,' TB37V',f6.1,' TB37H',f6.1,' TD37',f5.1)
837 
838 C STORE THE CALCULATED GOODBERLET WIND SPEED (*10 M/SEC)
839 
840  ibuftn((27*irt)+8) = min(imsg,nint(swgb*10.))
841 
842 C STORE THE GOODBERLET RAIN FLAG (0-3)
843 
844  ibuftn((27*irt)+9) = min(imsg,nrfgb)
845  END IF
846 
847 C- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
848  ELSE
849 
850 C......................................................................
851 
852 C PROBLEM - CAN'T CALCULATE PRODUCTS VIA ANY ALG., ALL B.TEMPS MISSING
853 
854  print 879, ibuftn(8),ibuftn(9),kdata
855  879 FORMAT(' ##W3MISCAN: ALL B.TMPS MSSNG: SCAN',i6,', ',
856  $ 'ORBIT',i8,'; BT:',7i6,'-CANNOT CALC PRODS VIA ALG.')
857 C......................................................................
858 
859  END IF
860  END IF
861 
862  112 CONTINUE
863 C-----------------------------------------------------------------------
864  END DO
865  END IF
866 C***********************************************************************
867  901 CONTINUE
868 
869 C RETURN TO CALLING PROGRAM - IER = 0 SCAN SUCCESSFULLY READ
870 
871  kntscn = kntscn + 1
872  kntsat(ibuftn(1)) = kntsat(ibuftn(1)) + 1
873  ier = 0
874  RETURN
875 
876 C.......................................................................
877  993 CONTINUE
878 
879 C PROBLEM: SEA-SURFACE TEMPERATURE NOT FOUND IN GRIB INDEX FILE - ERROR
880 C RETURNED FROM GRIB DECODER GETGB IS 96 - SET IER = 6 & RETURN
881 
882  print 2008, ingbi
883  2008 FORMAT(/' ##W3MISCAN: SEA-SURFACE TEMPERATURE NOT FOUND IN GRIB ',
884  $ 'INDEX FILE IN UNIT ',i2,' - IER = 6'/)
885  ier = 6
886  RETURN
887 
888 C.......................................................................
889  994 CONTINUE
890 
891 C PROBLEM: SEA-SURFACE TEMPERATURE GRIB MESSAGE HAS A DATE THAT IS
892 C EITHER: 1) MORE THAN 7-DAYS PRIOR TO THE EARLIEST REQ. DATE
893 C (INPUT ARG. "KDATE") OR 2) MORE THAN 7-DAYS AFTER THE LATEST
894 C REQ. DATE (INPUT ARG. "LDATE") - SET IER = 7 AND RETURN
895 
896  print 2009
897  2009 FORMAT(' SST GRIB MSG HAS DATE WHICH IS EITHER 7-DAYS',
898  $ ' PRIOR TO EARLIEST REQ. DATE'/14x,'OR 7-DAYS LATER THAN LATEST',
899  $ ' REQ. DATE - IER = 7'/)
900  ier = 7
901  RETURN
902 
903 C.......................................................................
904  995 CONTINUE
905 
906 C PROBLEM: BYTE-ADDRESSABLE READ ERROR FOR GRIB FILE CONTAINING SEA-
907 C SURFACE TEMPERATURE FIELD - ERROR RETURNED FROM GRIB DECODER
908 C GETGB IS 97-99 - SET IER = 8 AND RETURN
909 
910  print 2010
911  2010 FORMAT(' BYTE-ADDRESSABLE READ ERROR FOR GRIB FILE ',
912  $ 'CONTAINING SEA-SURFACE TEMPERATURE FIELD - IER = 8'/)
913  ier = 8
914  RETURN
915 
916 C.......................................................................
917  996 CONTINUE
918 
919 C PROBLEM: ERROR RETURNED FROM GRIB DECODER - GETGB - FOR SEA-SURFACE
920 C TEMPERATURE FIELD - > 0 BUT NOT 96-99 - SET IER = 9 & RETURN
921 
922  print 2011
923  2011 FORMAT(' - IER = 9'/)
924  ier = 9
925  RETURN
926 
927 C.......................................................................
928  997 CONTINUE
929 
930 C PROBLEM: ERROR OPENING R. ACCESS FILE HOLDING LAND/SEA TAGS - SET IER
931 C = 4 AND RETURN
932 
933  print 2012, ierr,inlsf
934  2012 FORMAT(/' ##W3MISCAN: ERROR OPENING R. ACCESS LAND/SEA FILE IN ',
935  $ 'UNIT ',i2,' -- IOSTAT =',i5,' -- NO SCANS PROCESSED - IER = 4'/)
936  ier = 4
937  RETURN
938 
939 C.......................................................................
940  998 CONTINUE
941 
942 C PROBLEM: THE INPUT DATA SET IS EITHER EMPTY (NULL), NOT BUFR, OR
943 C CONTAINS NO DATA MESSAGES - SET IER = 2 AND RETURN
944 
945  print 14, indta
946  14 FORMAT(/' ##W3MISCAN: SSM-I DATA SET IN UNIT',i3,' IS EITHER ',
947  $'EMPTY (NULL), NOT BUFR, OR CONTAINS NO DATA MESSAGES - IER = 2'/)
948  ier = 2
949  RETURN
950 
951 C.......................................................................
952  999 CONTINUE
953 
954 C PROBLEM: THE NUMBER OF DECODED "LEVELS" IS NOT WHAT IS EXPECTED - SET
955 C IER = 5 AND RETURN
956 
957  print 217, nlev,ilflg
958  217 FORMAT(/' ##W3MISCAN: THE NUMBER OF DECODED "LEVELS" (=',i5,') ',
959  $ 'IS NOT WHAT IS EXPECTED (ILFLG=',i1,') - IER = 5'/)
960  ier = 5
961  RETURN
962 
963 C.......................................................................
964  END
965 C> @brief Prepares for in-line caluclation of prods.
966 C> @author Dennis Keyser @date 1995-01-04
967 
968 C> Based on input 7-channel ssm/i brightness temperatures,
969 C> determines the rain flag category for wind speed product for the
970 C> goodberlet algorithm. Then calls the appropriate function to
971 C> calculate either the wind speed product for the goodberlet
972 C> algorithm (if requested) or the wind speed and tpw products for
973 C> the neural net 3 algorithm (if requested).
974 C>
975 C> ### Program History Log:
976 C> Date | Programmer | Comment
977 C> -----|------------|--------
978 C> ????-??-?? | W. Gemmill | (w/nmc21) -- original author
979 C> 1995-01-04 | Dennis Keyser | -- incorporated into w3miscan and
980 C> streamlined code
981 C> 1996-05-07 | Dennis Keyser | (np22) -- in-line neural network 1 algoritm
982 C> replaced by neural network 2 algorithm
983 C> 1996-07-30 | Dennis Keyser | (np22) -- can now process wind speed from
984 C> both algorithms if desired
985 C> 1998-01-28 | Dennis Keyser | (np22) -- replaced neural net 2 algorithm
986 C> which calculated only wind speed product with neural net 3
987 C> algorithm which calculates both wind speed and total
988 C> precipitable water products (among others) but, unlike nn2,
989 C> does not return a rain flag value (it does set all retrievals
990 C> to missing that fail rain flag and ice contamination tests)
991 C>
992 C> @param[in] NNALG Process wind speed and tpw via neural net 3 algorithm if true
993 C> @param[in] GBALG Process wind speed via goodberlet algorithm if true
994 C> @param[in] KDATA 7-word array containing 7 channels of brightness temperature (kelvin x 100)
995 C> @param[out] SWNN alculated wind speed based on neural net 3 algorithm (meters/second)
996 C> @param[out] TPWNN Calculated total column precipitable water based on neural net 3 algorithm (millimeters)
997 C> @param[out] SWGB Calculated wind speed based on goodberlet algorith (meters/second)
998 C> @param[out] NRFGB Rain flag category for calculated wind speed from goodberlet algorithm
999 C>
1000 C> @remark If an algorithm is not chosen, the output products are set
1001 C> to values of 99999. for that algorithm and, for the goodberlet
1002 C> algorithm only, the rain flag is set to 99999. Called by
1003 C> subroutine w3miscan().
1004 C>
1005 C> @author Dennis Keyser @date 1995-01-04
1006  SUBROUTINE misc01(NNALG,GBALG,KDATA,SWNN,TPWNN,SWGB,NRFGB)
1007  LOGICAL NNALG,GBALG
1008  REAL BTA(4),BTAA(7)
1009  INTEGER KDATA(7)
1010 
1011  common/miscee/lflag,licec
1012 
1013  SAVE
1014 
1015  swnn = 99999.
1016  tpwnn = 99999.
1017  swgb = 99999.
1018  nrfgb = 99999
1019 
1020  tb19v = real(kdata(1))/100.
1021  tb19h = real(kdata(2))/100.
1022  tb22v = real(kdata(3))/100.
1023  tb37v = real(kdata(4))/100.
1024  tb37h = real(kdata(5))/100.
1025  tb85v = real(kdata(6))/100.
1026  tb85h = real(kdata(7))/100.
1027  td37 = tb37v - tb37h
1028 
1029  IF(nnalg) THEN
1030 C COMPUTE WIND SPEED FROM NEURAL NET 2 ALGORITHM (1995)
1031 C (no longer a possibility - subr. expects dim. of 5 on BTAA)
1032 cdak NRFNN = 1
1033 cdak IF(TB19H.LE.185.0.AND.TB37H.LE.210.0.AND.TB19V.LT.TB37V)
1034 cdak $ NRFNN = 0
1035 cdak BTAA(1) = TB19V
1036 cdak BTAA(2) = TB22V
1037 cdak BTAA(3) = TB37V
1038 cdak BTAA(4) = TB37H
1039 cdak BTAA(5) = TB85V
1040 cdak SWNN = RISC02xx(BTAA)
1041 
1042 C COMPUTE WIND SPEED AND TPW FROM NEURAL NET 3 ALGORITHM (1997)
1043  btaa(1) = tb19v
1044  btaa(2) = tb19h
1045  btaa(3) = tb22v
1046  btaa(4) = tb37v
1047  btaa(5) = tb37h
1048  btaa(6) = tb85v
1049  btaa(7) = tb85h
1050  swnn = risc02(btaa,tpwnn,lqwnn,sstnn,jerr)
1051  IF(jerr.EQ.1) lflag = lflag + 1
1052  IF(jerr.EQ.2) licec = licec + 1
1053  END IF
1054 
1055  IF(gbalg) THEN
1056 C COMPUTE WIND SPEED FROM GOODBERLET ALGORITHM
1057  nrfgb = 0
1058  IF(td37.LE.50.0.OR.tb19h.GE.165.0) THEN
1059  IF(td37.LE.50.0.OR.tb19h.GE.165.0) nrfgb = 1
1060  IF(td37.LE.37.0) nrfgb = 2
1061  IF(td37.LE.30.0) nrfgb = 3
1062  END IF
1063  bta(1) = tb19v
1064  bta(2) = tb22v
1065  bta(3) = tb37v
1066  bta(4) = tb37h
1067  swgb = risc03(bta)
1068  END IF
1069 
1070  RETURN
1071  END
1072 C> @brief Calc. ssm/i prods from neural net 3 alg.
1073 C> @author V. Krasnopolsky @date 1997-02-02
1074 
1075 C> This retrieval algorithm is a neural network implementation
1076 C> of the ssm/i transfer function. It retrieves the wind speed (w)
1077 C> at the height 20 meters, columnar water vapor (v), columnar liquid
1078 C> water (l) and sst. The nn was trained using back-propagation
1079 C> algorithm. Transfer function is described and compared with
1080 C> cal/val and other algorithms in omb technical note no. 137. See
1081 C> remarks for detailed info on this algorithm. This is an improved
1082 C> version of the earlier neural network 2 algorithm.
1083 C>
1084 C> ### Program History Log:
1085 C> Date | Programmer | Comment
1086 C> -----|------------|--------
1087 C> 1997-02-02 | V. Krasnopolsky | Initial.
1088 C>
1089 C> @param[in] XT 7-word array containing brightness temperature in the order:
1090 C> t19v (word 1), t19h (word 2), t22v (word 3), t37v (word 4), t37h (word 5),
1091 C> t85v (word 6), t85h (word 7) (all in kelvin)
1092 C> @param[in] V Columnar water vapor (total precip. water) (mm)
1093 C> @param[in] L Columnar liquid water (mm)
1094 C> @param[in] SST Sea surface temperature (deg. c)
1095 C> @param[in] JERR Error return code:
1096 C> - = 0 -- Good retrievals
1097 C> - = 1 -- Retrievals could not be made due to one or
1098 C> more brightness temperatures out of range
1099 C> (i.e, failed the rain flag test)
1100 C> - = 2 -- Retrievals could not be made due to ice
1101 C> contamination
1102 C> {for either 1 or 2 above, all retrievals set to
1103 C> 99999. (missing)}
1104 C>
1105 C> @remark Function, called by subroutine misc01.
1106 C> Description of training and test data set:
1107 C> ------------------------------------------
1108 C> The training set consists of 3460 matchups which were received
1109 C> from two sources:
1110 C> - 1. 3187 F11/SSMI/buoy matchups were filtered out from a
1111 C> preliminary version of the new NRL database which was
1112 C> kindly provided by G. Poe (NRL). Maximum available wind
1113 C> speed is 24 m/s.
1114 C> - 2. 273 F11/SSMI/OWS matchups were filtered out from two
1115 C> datasets collected by high latitude OWS LIMA and MIKE.
1116 C> These data sets were kindly provided by D. Kilham
1117 C> (University of Bristol). Maximum available wind speed
1118 C> is 26.4 m/s.
1119 C>
1120 C> Satellite data are collocated with both buoy and OWS data in
1121 C> space within 15 km and in time within 15 min.
1122 C>
1123 C> The test data set has the same structure, the same number of
1124 C> matchups and maximum buoy wind speed.
1125 C>
1126 C> Description of retrieval flags:
1127 C> -------------------------------
1128 C> Retrieval flags by Stogryn et al. are used. The algorithm
1129 C> produces retrievals under CLEAR + CLOUDY conditions, that is
1130 C> if:
1131 C> - T37V - T37H > 50. => CLEAR condition -or-
1132 C> - T37V - T37H =< 50.|
1133 C> - T19H =< 185. and |
1134 C> - T37H =< 210. and | => CLOUDY conditions
1135 C> - T19V < T37V |
1136 C>
1137 C> @author V. Krasnopolsky @date 1997-02-02
1138  FUNCTION risc02(XT,V,L,SST,JERR)
1139  parameter(iout =4)
1140  LOGICAL lq1,lq2,lq3,lq4
1141  REAL xt(7),y(iout),v,l,sst
1142  equivalence(y(1),spn)
1143 
1144  jerr = 0
1145 
1146 C -------- Retrieval flag (Stogryn) -------------------------
1147 
1148 C T19H =< 185
1149 
1150  lq1 = (xt(2).LE.185.)
1151 
1152 C T37H =< 210
1153 
1154  lq2 = (xt(5).LE.210.)
1155 
1156 C T19V < T37V
1157 
1158  lq3 = (xt(1).LT.xt(4))
1159 
1160 C T37V - T37H =< 50.
1161 
1162  lq4 = ((xt(4) - xt(5)).LE.50.)
1163  lq1 = (lq1.AND.lq2.AND.lq3)
1164  IF(.NOT.lq1.AND.lq4) THEN
1165  spn = 99999.
1166  v = 99999.
1167  l = 99999.
1168  sst = 99999.
1169  jerr = 1
1170  GO TO 111
1171  END IF
1172 
1173 C --------------- Call NN ----------------------
1174 
1175 C NN WIND SPEED
1176 
1177  CALL misc10(xt,y)
1178  v = y(2)
1179  l = y(3)
1180  sst = y(4)
1181 
1182 C --------- Remove negative values ----------------------------
1183 
1184  IF(spn.LT.0.0) spn = 0.0
1185  IF(sst.LT.0.0) sst = 0.0
1186  IF(v .LT.0.0) v = 0.0
1187 
1188 C ------ Remove ice contamination ------------------------------------
1189 
1190  ice = 0
1191  si85 = -174.4 + (0.715 * xt(1)) + (2.439 * xt(3)) - (0.00504 *
1192  $ xt(3) * xt(3)) - xt(6)
1193  tt = 44. + (0.85 * xt(1))
1194  IF(si85.GE.10.) THEN
1195  IF(xt(3).LE.tt) ice = 1
1196  IF((xt(3).GT.264.).AND.((xt(3)-xt(1)).LT.2.)) ice = 1
1197  END IF
1198  IF(ice.EQ.1) THEN
1199  spn = 99999.
1200  v = 99999.
1201  l = 99999.
1202  sst = 99999.
1203  jerr = 2
1204  END IF
1205 
1206  111 CONTINUE
1207 
1208  risc02 = spn
1209 
1210  RETURN
1211  END
1212 C> @brief Calc. ssm/i prods from neural net 3 alg.
1213 C> @author V. Krasnopolsky @date 1996-07-15
1214 
1215 C> This nn calculates w (in m/s), v (in mm), l (in mm), and
1216 C> sst (in deg c). This nn was trained on blended f11 data set
1217 C> (ssmi/buoy matchups plus ssmi/ows matchups 15 km x 15 min) under
1218 C> clear + cloudy conditions.
1219 C>
1220 C> ### Program History Log:
1221 C> Date | Programmer | Comment
1222 C> -----|------------|--------
1223 C> 1996-07-15 | V. Krasnopolsky | Initial.
1224 C>
1225 C> @param[in] X 5-word array containing brightness temperature in the
1226 C> order: t19v (word 1), t19h (word 2), t22v (word 3),
1227 C> t37v (word 4), t37h (word 5) (all in kelvin)
1228 C> @param[out] Y 4-word array containing calculated products in the
1229 C> order: wind speed (m/s) (word 1), columnar water
1230 C> vapor (total precip. water) (mm) (word 2), columnar
1231 C> liquid water (mm) (word 3), sea surface temperature
1232 C> (deg. c) (word 4)
1233 C>
1234 C> @remark Called by subroutine risc02().
1235 C>
1236 C> @author V. Krasnopolsky @date 1996-07-15
1237  SUBROUTINE misc10(X,Y)
1238  INTEGER HID,OUT
1239 
1240 C IN IS THE NUMBER OF NN INPUTS, HID IS THE NUMBER OF HIDDEN NODES,
1241 C OUT IS THE NUMBER OF OUTPUTS
1242 
1243  parameter(in =5, hid =12, out =4)
1244  dimension x(in),y(out),w1(in,hid),w2(hid,out),b1(hid),b2(out),
1245  $ o1(in),x2(hid),o2(hid),x3(out),o3(out),a(out),b(out)
1246 
1247 C W1 HOLDS INPUT WEIGHTS
1248 
1249  DATA ((w1(i,j),j = 1,hid),i = 1,in)/
1250  $-0.0435901, 0.0614709,-0.0453639,-0.0161106,-0.0271382, 0.0229015,
1251  $-0.0650678, 0.0704302, 0.0383939, 0.0773921, 0.0661954,-0.0643473,
1252  $-0.0108528,-0.0283174,-0.0308437,-0.0199316,-0.0131226, 0.0107767,
1253  $ 0.0234265,-0.0291637, 0.0140943, .00567931,-.00931768,
1254  $-.00860661, 0.0159747,-0.0749903,-0.0503523, 0.0524172, 0.0195771,
1255  $ 0.0302056, 0.0331725, 0.0326714,-0.0291429, 0.0180438, 0.0281923,
1256  $-0.0269554, 0.102836, 0.0591511, 0.134313, -0.0109854,-0.0786303,
1257  $ 0.0117111, 0.0231543,-0.0205603,-0.0382944,-0.0342049,
1258  $ 0.00052407,0.110301, -0.0404777, 0.0428816, 0.0878070, 0.0168326,
1259  $ 0.0196183, 0.0293995, 0.00954805,-.00716287,0.0269475,
1260  $-0.0418217,-0.0165812, 0.0291809/
1261 
1262 C W2 HOLDS HIDDEN WEIGHTS
1263 
1264  DATA ((w2(i,j),j = 1,out),i = 1,hid)/
1265  $-0.827004, -0.169961,-0.230296, -0.311201, -0.243296, 0.00454425,
1266  $ 0.950679, 1.09296, 0.0842604, 0.0140775, 1.80508, -0.198263,
1267  $-0.0678487, 0.428192, 0.827626, 0.253772, 0.112026, 0.00563793,
1268  $-1.28161, -0.169509, 0.0019085,-0.137136, -0.334738, 0.224899,
1269  $-0.189678, 0.626459,-0.204658, -0.885417, -0.148720, 0.122903,
1270  $ 0.650024, 0.715758, 0.735026, -0.123308, -0.387411,-0.140137,
1271  $ 0.229058, 0.244314,-1.08613, -0.294565, -0.192568, 0.608760,
1272  $-0.753586, 0.897605, 0.0322991,-0.178470, 0.0807701,
1273  $-0.781417/
1274 
1275 C B1 HOLDS HIDDEN BIASES
1276 
1277  DATA (b1(i), i=1,hid)/
1278  $ -9.92116,-10.3103,-17.2536, -5.26287, 17.7729,-20.4812,
1279  $ -4.80869,-11.5222, 0.592880,-4.89773,-17.3294, -7.74136/
1280 
1281 C B2 HOLDS OUTPUT BIAS
1282 
1283  DATA (b2(i), i=1,out)/-0.882873,-0.0120802,-3.19400,1.00314/
1284 
1285 C A(OUT), B(OUT) HOLD TRANSFORMATION COEFFICIENTS
1286 
1287  DATA (a(i), i=1,out)/18.1286,31.8210,0.198863,37.1250/
1288  DATA (b(i), i=1,out)/13.7100,32.0980,0.198863,-5.82500/
1289 
1290 C INITIALIZE
1291 
1292  o1 = x
1293 
1294 C START NEURAL NETWORK
1295 
1296 C - INITIALIZE X2
1297 
1298  DO i = 1,hid
1299  x2(i) = 0.
1300  DO j = 1,in
1301  x2(i) = x2(i) + (o1(j) * w1(j,i))
1302  END DO
1303  x2(i) = x2(i) + b1(i)
1304  o2(i) = tanh(x2(i))
1305  END DO
1306 
1307 C - INITIALIZE X3
1308 
1309  DO k = 1,out
1310  x3(k) = 0.
1311  DO j = 1,hid
1312  x3(k) = x3(k) + (w2(j,k) * o2(j))
1313  END DO
1314 
1315  x3(k) = x3(k) + b2(k)
1316 
1317 C --- CALCULATE O3
1318 
1319  o3(k) = tanh(x3(k))
1320  y(k) = (a(k) * o3(k)) + b(k)
1321  END DO
1322 
1323  RETURN
1324  END
1325 C> @brief Calc. wspd from neural net 2 algorithm
1326 C> @author V. Krasnopolsky @date 1996-05-07
1327 
1328 C> Calculates a single neural network output for wind speed.
1329 C> the network was trained on the whole data set without any
1330 C> separation into subsets. It gives rms = 1.64 m/s for training set
1331 C> and 1.65 m/s for testing set. This is an improved version of the
1332 C> earlier neural network 1 algorithm.
1333 C>
1334 C> ### Program History Log:
1335 C> Date | Programmer | Comment
1336 C> -----|------------|--------
1337 C> 1994-03-20 | V. Krasnopolsky | Initial.
1338 C> 1995-05-07 | V. Krasnopolsky | Replaced with neural net 2 algorithm.
1339 C>
1340 C> @param[in] X 5-Word array containing brightness temperature in the
1341 C> order: t19v (word 1), t22v (word 2), t37v (word 3),
1342 C> t37h (word 4), t85v (word 5) (all in kelvin)
1343 C> @return XX Wind speed (meters/second)
1344 C>
1345 C> @remark Function, no longer called by this program. It is here
1346 C> simply to save neural net 2 algorithm for possible later use
1347 C> (has been replaced by neural net 3 algorithm, see subr. risc02
1348 C> and misc10).
1349 C>
1350 C> @author V. Krasnopolsky @date 1996-05-07
1351  FUNCTION risc02xx(X)
1352  INTEGER hid
1353 C IN IS THE NUMBER OF B. TEMP. CHNLS, HID IS THE NUMBER OF HIDDEN NODES
1354  parameter(in =5, hid =2)
1355  dimension x(in),w1(in,hid),w2(hid),b1(hid),o1(in),x2(hid),o2(hid)
1356 
1357  SAVE
1358 
1359 C W1 HOLDS INPUT WEIGHTS
1360  DATA ((w1(i,j),j=1,hid),i=1,in)/
1361  $ 4.402388e-02, 2.648334e-02, 6.361322e-04,-1.766535e-02,
1362  $ 7.876555e-03,-7.387260e-02,-2.656543e-03, 2.957161e-02,
1363  $-1.181134e-02, 4.520317e-03/
1364 C W2 HOLDS HIDDEN WEIGHTS
1365  DATA (w2(i),i=1,hid)/8.705661e-01,1.430968/
1366 C B1 HOLDS HIDDEN BIASES
1367  DATA (b1(i),i=1,hid)/-6.436114,8.799655/
1368 C B2 HOLDS OUTPUT BIAS
1369 C AY AND BY HOLD OUTPUT TRANSFORMATION COEFFICIENTS
1370  DATA b2/-0.736255/,ay/16.7833/,by/11.08/
1371  o1 = x
1372 C INITIALIZE
1373  x3 = 0.
1374  DO i = 1, hid
1375  o2(i) = 0.
1376  x2(i) = 0.
1377  DO j = 1,in
1378  x2(i) = x2(i) + (o1(j) * w1(j,i))
1379  END DO
1380  x2(i) = x2(i) + b1(i)
1381  o2(i) = tanh(x2(i))
1382  x3 = x3 + (o2(i)* w2(i))
1383  END DO
1384  x3 = x3 + b2
1385  o3 = tanh(x3)
1386  risc02xx = (ay * o3) + by
1387  risc02xx = max(risc02xx,0.0)
1388 C BIAS CORRECTION
1389  bias = 0.5 + 0.004*((risc02xx-10.)**3)*(1.-exp(-0.5*risc02xx))
1390  risc02xx = risc02xx + bias
1391  RETURN
1392  END
1393 C> @brief Calc. w.spd from b temp.- goodberlet alg.
1394 C> @author W. Gemmill @date 1994-08-15
1395 
1396 C> Calculates a single goodberlet output for wind speed.
1397 C> This is a linear regression algorithm from 1989.
1398 C>
1399 C> ### Program History Log:
1400 C> Date | Programmer | Comment
1401 C> -----|------------|--------
1402 C> 1994-08-15 | W. Gemmill | Initial.
1403 C>
1404 C> @param[in] X 4-word array containing brightness temperature in the
1405 C> order: t19v (word 1), t22v (word 2), t37v (word 3),
1406 C> t37h (word 4) (all in kelvin)
1407 C> @return XX Wind speed (meters/second)
1408 C>
1409 C> @remark Function, called by subroutine misc01.
1410 C>
1411 C> @author W. Gemmill @date 1994-08-15
1412  FUNCTION risc03(X)
1413  dimension x(4)
1414 
1415  SAVE
1416 
1417  risc03 = 147.90 + (1.0969 * x(1)) - (0.4555 * x(2)) -
1418  $ (1.76 * x(3)) + (0.7860 * x(4))
1419  RETURN
1420  END
1421 C> @brief Returns land/sea tag for given lat/lon
1422 C> @author Dennis Keyser @date 1995-01-04
1423 
1424 C> Finds and returns the low resolution land/sea tag nearest
1425 C> to the requested latitude and longitude.
1426 C>
1427 C> ### Program History Log:
1428 C> Date | Programmer | Comment
1429 C> -----|------------|--------
1430 C> 1978-01-20 | J. K. Kalinowski (S11213) | Original author
1431 C> 1978-10-03 | J. K. Kalinowski (S1214) | Changes unknown
1432 C> 1985-03-01 | N. Digirolamo (SSAI) | Conversion to vs fortran
1433 C> 1995-01-04 | Dennis Keyser | Incorporated into w3miscan and streamlined code
1434 C>
1435 C> @param[in] INLSF Unit number of direct access nesdis land/sea file
1436 C> @param[in] BLAT Latitude (whole degrees: range is 0. to +90. north,
1437 C> 0. to -90. south)
1438 C> @param[in] BLNG Longitude (whole degrees: range is 0. to +179.99 east,
1439 C> 0. to -180. west)
1440 C> @param[out] LSTAG Land/sea tag {=0 - sea; =1 - land; =2 - coastal
1441 C> interface (higher resolution tags are available);
1442 C> =3 - coastal interface (no higher resolution tags
1443 C> exist)}
1444 C>
1445 C> @remark Called by subroutine w3miscan.
1446 C>
1447 C> @author Dennis Keyser @date 1995-01-04
1448  SUBROUTINE misc04(INLSF,BLAT,BLNG,LSTAG)
1449  CHARACTER*1 LPUT
1450  REAL RGS(3)
1451 C LPUT CONTAINS A REGION OF LAND/SEA TAGS (RETURNED FROM CALL TO MISC05)
1452  common/miscdd/lput(21960)
1453 
1454  SAVE
1455 
1456 C RGS IS ARRAY HOLDING SOUTHERN BOUNDARIES OF EACH LAND/SEA TAG REGION
1457  DATA rgs/-85.,-30.,25./,numrgl/0/,iflag/0/
1458 C INITIALIZE LAND/SEA TAG AS 1 (OVER LAND)
1459  lstag = 1
1460 C FIND NEAREST POINT OF A HALF-DEGREE (LAT,LONG) GRID
1461 C ..ALAT IS LATITUDE TO THE NEAREST HALF-DEGREE
1462  alat = int((blat+sign(.25,blat))/.5) * .5
1463 C ..ALNG IS LONGITUDE TO THE NEAREST HALF-DEGREE
1464  alng = int((blng+sign(.25,blng))/.5) * .5
1465  IF(nint(alng*10.).EQ.1800) alng = -180.
1466 C IDENTIFY DATABASE REGION IN WHICH TO FIND CORRECT TAG
1467  numrgn = 1
1468  IF(iabs(nint(alat*10)).GT.850) THEN
1469  RETURN
1470  ELSE IF(nint(alat*10).GT.275) THEN
1471  numrgn = 3
1472  ELSE IF(nint(alat*10.).GE.-275) THEN
1473  numrgn = 2
1474  END IF
1475  IF(numrgn.NE.numrgl.OR.iflag.EQ.1) THEN
1476  numrgl = numrgn
1477  CALL misc05(inlsf,numrgn,*99)
1478  END IF
1479 C FIND THE BYTE & BIT PAIR W/I DATA BASE REGION CONTAINING DESIRED TAG
1480  trm1 = ((alat - rgs(numrgn)) * 1440.) + 360.
1481  lstpt = trm1 + (2. * alng)
1482 C ..NBYTE IS THE BYTE IN LPUT CONTAINING THE TAG
1483  nbyte = (180 * 8) + (lstpt/4 * 8)
1484  nshft = (2 * (mod(lstpt,4) + 1)) - 2
1485 C PULL OUT THE TAG
1486  CALL gbyte(lput,lstag,nbyte+nshft,2)
1487  iflag = 0
1488  RETURN
1489 C-----------------------------------------------------------------------
1490  99 CONTINUE
1491 C COME HERE IF LAND/SEA TAG COULD NOT BE RETURNED FROM SUBR. W3MISCAN
1492 C (IN THIS CASE IT WILL REMAIN SET TO 1 INDICATING OVER LAND)
1493  iflag = 1
1494  RETURN
1495 C-----------------------------------------------------------------------
1496  END
1497 C> @brief Reads 2 records from land/sea tag database
1498 C> @author Dennis Keyser @date 195-01-04
1499 
1500 C> Reads two records from a low resolution land/sea database and stores into common.
1501 C>
1502 C> ### Program History Log:
1503 C> Date | Programmer | Comment
1504 C> -----|------------|--------
1505 C> 1978-01-20 | J. K. Kalinowski (S11213) | Original author
1506 C> 1995-01-04 | Dennis Keyser | Incorporated into w3miscan and
1507 C> streamlined code; modified to be machine independent thru
1508 C> use of standard fortran direct access read
1509 C>
1510 C> @param[in] INLSF Unit number of direct access nesdis land/sea file
1511 C> @param[in] NUMRGN The region (1,2 or 3) of the database to be accessed
1512 C> (dependent on latitude band)
1513 C>
1514 C> @remark Called by subroutne misc04.
1515 C>
1516 C> @author Dennis Keyser @date 195-01-04
1517  SUBROUTINE misc05(INLSF,NUMRGN,*)
1518  CHARACTER*1 LPUT
1519 
1520 C LPUT CONTAINS A REGION OF LAND/SEA TAGS (COMPRISED OF 2 RECORDS FROM
1521 C LAND/SEA FILE) -- 180 BYTES OF DOCUMENTATION FOLLOWED BY 21780 BYTES
1522 C OF LAND/SEA TAGS
1523 
1524  common/miscdd/lput(21960)
1525 
1526  SAVE
1527 
1528  nrec = (2 * numrgn) - 1
1529  READ(inlsf,rec=nrec,err=10) (lput(ii),ii=1,10980)
1530  nrec = nrec + 1
1531  READ(inlsf,rec=nrec,err=10) (lput(ii),ii=10981,21960)
1532  RETURN
1533 C-----------------------------------------------------------------------
1534  10 CONTINUE
1535 C ERROR READING IN A RECORD FROM LAND-SEA FILE -- RETURN (TAG WILL BE
1536 C SET TO 1 MEANING OVER LAND IN THIS CASE)
1537  print 1000, nrec,inlsf
1538  1000 FORMAT(' ##W3MISCAN/MISC05: ERROR READING IN LAND-SEA DATA ',
1539  $ 'RECORD',i7,' IN UNIT ',i2,' -- SET TAG TO LAND'/)
1540  RETURN 1
1541 C-----------------------------------------------------------------------
1542  END
1543 C> @brief Reads in nh and sh 1-deg. sea-sfc temps.
1544 C> @author Dennis Keyser @date 200-02-18
1545 
1546 C> Reads in global sea-surface temperature field on a one-degree grid from grib file.
1547 C>
1548 C> ### Program History Log:
1549 C> Date | Programmer | Comment
1550 C> -----|------------|--------
1551 C> ????-??-?? | W. Gemmill (NP21) | Original author
1552 C> 1995-01-04 | Dennis Keyser | Incorporated into w3miscan and
1553 C> streamlined code; converted sst input file from vsam/on84 to
1554 C> grib to allow code compile and run on the cray machines.
1555 C> 2000-02-18 | Dennis Keyser | Modified to call w3lib routine "getgb",
1556 C> this allows code to compile and run properly on ibm-sp
1557 C>
1558 C> @param[in] INGBI Unit number of grib index file for grib file
1559 C> containing global 1-degree sea-surface temp field
1560 C> @param[in] INGBD Unit number of grib file containing global 1-degree
1561 C> sea-surface temp field
1562 C> @param[in] IDAT1 Requested earliest year(yyyy), month, day, hour, min
1563 C> @param[in] IDAT2 Requested latest year(yyyy), month, day, hour, min
1564 C>
1565 C> @remark Called by subroutine w3miscan.
1566 C>
1567 C> @author Dennis Keyser @date 200-02-18
1568  SUBROUTINE misc06(INGBI,INGBD,IDAT1,IDAT2,*,*,*,*)
1569  parameter(maxpts=360*180)
1570  LOGICAL*1 LBMS(360,180)
1571  INTEGER KPDS(200),KGDS(200),LPDS(200),LGDS(200),IDAT1(5),
1572  $ idat2(5),jdat1(8),jdat2(8),kdat(8),ldat(8),mdate(8)
1573  REAL RINC(5)
1574  CHARACTER*11 ENVVAR
1575  CHARACTER*80 FILEB,FILEI
1576  common/misccc/sstdat(360,180)
1577 
1578  SAVE
1579 
1580  envvar='XLFUNIT_ '
1581  WRITE(envvar(9:10),fmt='(I2)') ingbd
1582  CALL getenv(envvar,fileb)
1583  envvar='XLFUNIT_ '
1584  WRITE(envvar(9:10),fmt='(I2)') ingbi
1585  CALL getenv(envvar,filei)
1586  CALL baopenr(ingbd,fileb,iret1)
1587 ccccc PRINT *,'SAGT: ',INGBD,FILEB,IRET1
1588  CALL baopenr(ingbi,filei,iret2)
1589 ccccc PRINT *,'SAGT: ',INGBI,FILEI,IRET2
1590 
1591  kpds = -1
1592  kgds = -1
1593  n = -1
1594  kpds(5) = 11
1595  kpds(6) = 1
1596  kpds(7) = 0
1597  kpds(8) = -1
1598  kpds(9) = -1
1599  kpds(10) = -1
1600  print 68, ingbd
1601  68 FORMAT(//4x,'** W3MISCAN/MISC06: READ IN "CURRENT" SEA-SURFACE ',
1602  $ 'TEMPERATURE DATA FROM GRIB MESSAGE IN UNIT',i3)
1603  CALL getgb(ingbd,ingbi,maxpts,0,kpds,kgds,kf,k,lpds,lgds,lbms,
1604  $ sstdat,iret)
1605 C.......................................................................
1606 C ABNORMAL RETURN IF PROBLEM WITH SST IN GRIB FILE
1607  IF(iret.NE.0) THEN
1608  WRITE(6,*)' ERROR READING SST USING GETGB. IRET = ',iret
1609  IF (iret.EQ.96) RETURN 1
1610  IF (iret.EQ.97) RETURN 3
1611  IF (iret.EQ.98) RETURN 3
1612  IF (iret.EQ.99) RETURN 3
1613  RETURN 4
1614  ENDIF
1615 C.......................................................................
1616 C READ SUCCESSFUL
1617  jdat1 = 0
1618  jdat2 = 0
1619  jdat1(1:3) = idat1(1:3)
1620  jdat1(5:6) = idat1(4:5)
1621  jdat2(1:3) = idat2(1:3)
1622  jdat2(5:6) = idat2(4:5)
1623  mdate = 0
1624  mdate(1) = ((lpds(21) - 1) * 100) + lpds(8)
1625  mdate(2:3) = lpds(9:10)
1626  mdate(5:6) = lpds(11:12)
1627  CALL w3movdat((/-7.,0.,0.,0.,0./),jdat1,kdat)
1628  CALL w3movdat((/ 7.,0.,0.,0.,0./),jdat2,ldat)
1629 cppppp
1630  print *, '** W3MISCAN/MISCO6: SST GRIB FILE MUST HAVE DATE ',
1631  $ 'BETWEEN ',(kdat(iii),iii=1,3),(kdat(iii),iii=5,6),' AND ',
1632  $ (ldat(iii),iii=1,3),(ldat(iii),iii=5,6)
1633  print *, ' RETURNED FROM GRIB FILE IS YEAR ',
1634  $ 'OF CENTURY = ',lpds(8),' AND CENTURY = ',lpds(21)
1635  print *, ' CALULATED 4-DIGIT YEAR IS = ',
1636  $ mdate(1)
1637 cppppp
1638  CALL w3difdat(kdat,mdate,3,rinc)
1639  kmin = rinc(3)
1640  CALL w3difdat(ldat,mdate,3,rinc)
1641  lmin = rinc(3)
1642  IF(kmin.GT.0.OR.lmin.LT.0) THEN
1643 C.......................................................................
1644 C COME HERE IF SST GRIB MSG HAS A DATE THAT IS EITHER: 1) MORE THAN 7-
1645 C DAYS PRIOR TO THE EARLIEST REQ. DATE (INPUT ARG. "IDAT1" TO W3MISCAN)
1646 C OR 2) MORE THAN 7-DAYS AFTER THE LATEST REQ. DATE (INPUT ARG.
1647 C "IDAT2" TO W3MISCAN)
1648  print 27, (mdate(iii),iii=1,3),(mdate(iii),iii=5,6)
1649  27 FORMAT(/' ##W3MISCAN/MISC06: SST GRIB MSG HAS DATE:',i5,4i3,
1650  $ ' - AS A RESULT......')
1651  RETURN 2
1652 C.......................................................................
1653  END IF
1654  print 60, (mdate(iii),iii=1,3),(mdate(iii),iii=5,6)
1655  60 FORMAT(/4x,'** W3MISCAN/MISC06: SEA-SFC TEMP SUCCESSFULLY READ ',
1656  $ 'IN FROM GRIB FILE, DATE IS: ',i5,4i3/)
1657  RETURN
1658 
1659  CALL baclose(ingbi,iret)
1660  CALL baclose(ingbd,iret)
1661 
1662  END
subroutine gbyte(IPACKD, IUNPKD, NOFF, NBITS)
This is the fortran version of gbyte.
Definition: gbyte.f:27
subroutine getgb(LUGB, LUGI, JF, J, JPDS, JGDS, KF, K, KPDS, KGDS, LB, F, IRET)
Find and unpack a grib message.
Definition: getgb.f:166
subroutine w3difdat(jdat, idat, it, rinc)
Returns the elapsed time interval from an NCEP absolute date and time given in the second argument un...
Definition: w3difdat.f:29
subroutine w3fi04(IENDN, ITYPEC, LW)
Subroutine computes word size, the type of character set, ASCII or EBCDIC, and if the computer is big...
Definition: w3fi04.f:30
function risc02xx(X)
Calc.
Definition: w3miscan.f:1352
function risc02(XT, V, L, SST, JERR)
Calc.
Definition: w3miscan.f:1139
subroutine misc05(INLSF, NUMRGN,)
Reads 2 records from land/sea tag database.
Definition: w3miscan.f:1518
function risc03(X)
Calc.
Definition: w3miscan.f:1413
subroutine misc04(INLSF, BLAT, BLNG, LSTAG)
Returns land/sea tag for given lat/lon.
Definition: w3miscan.f:1449
subroutine misc10(X, Y)
Calc.
Definition: w3miscan.f:1238
subroutine misc06(INGBI, INGBD, IDAT1, IDAT2,,,,)
Reads in nh and sh 1-deg.
Definition: w3miscan.f:1569
subroutine w3miscan(INDTA, INLSF, INGBI, INGBD, LSAT, LPROD, LBRIT, NNALG, GBALG, KDATE, LDATE, IGNRTM, IBUFTN, IBDATE, IER)
Reads one ssm/i scan line (64 retrievals) from the NCEP bufr ssm/i dump file.
Definition: w3miscan.f:194
subroutine misc01(NNALG, GBALG, KDATA, SWNN, TPWNN, SWGB, NRFGB)
Prepares for in-line caluclation of prods.
Definition: w3miscan.f:1007
subroutine w3movdat(rinc, idat, jdat)
This subprogram returns the date and time that is a given NCEP relative time interval from an NCEP ab...
Definition: w3movdat.f:24