SUBROUTINE UA_PSLV ( report, lenr, irptr, iret ) C************************************************************************ C* UA_PSLV * C* * C* This subroutine decodes all significant level wind data of the form * C* ATUUU DDFFF DDFFF DDFFF from pilot BB and pilot DD reports. * C* * C* UA_PSLV ( REPORT, LENR, IRPTR, IRET ) * C* * C* Input parameters: * C* REPORT CHAR* Report * C* LENR INTEGER Length of REPORT * C* * C* Input and output parameters: * C* IRPTR INTEGER Pointer within REPORT * C* * C* Output parameters: * C* IRET INTEGER Return code: * C* 0 = normal return * C* -1 = critical error in REPORT * C* or reached end of REPORT * C** * C* Log: * C* J. Ator/NCEP 03/96 * C* J. Ator/NCEP 10/96 ERRGRP -> UA_EGRP, removed ERRRPT * C* J. Ator/NCEP 01/97 Multiply HGTM by 1.016 for block 70, * C* 71, 72, and 74 stations * C* J. Ator/NCEP 12/97 New interface format, style changes * C* J. Ator/NCEP 03/98 Delete levels which fail MXPBHT or * C* MNPDHT check, add iskpct * C* J. Ator/NCEP 10/98 REGPID -> UA_RPID, NATPID -> UA_NPID * C* J. Ator/NCEP 10/99 Clean up function declarations * C************************************************************************ INCLUDE 'GEMPRM.PRM' INCLUDE 'uacmn.cmn' C* CHARACTER*(*) report C* CHARACTER field*(MXLENF) C* LOGICAL UA_EGRP, UA_RPID, UA_NPID, + ENDSLV, lost C* REAL hgtdat ( 3 ) C* INCLUDE 'ERMISS.FNC' C* C* Function to check for end of pilot significant level data. C* ENDSLV ( field ) = + ( ( UA_RPID ( field ) ) .or. + ( UA_NPID ( field ) ) ) C------------------------------------------------------------------------ C C* Initialize variables. C iret = 0 iskpct = 0 lost = .false. prevht = RMISSD C C* Retrieve (for later use) the station elevation from the C* interface arrays. C selv = rivals ( irselv ) C C* Fixed-land stations within WMO blocks 70, 71, 72, and 74 are C* known to take their height observations at 1000ft intervals C* (rather than the proper 300m intervals), so decoded heights C* from these stations need to be multiplied by a correction C* factor to account for this discrepancy. C htcorf = 1.0 IF ( stntyp .eq. LAND ) THEN stnm = rivals ( irstnm ) IF ( .not. ERMISS ( stnm ) ) THEN iwmob = INT ( stnm ) / 1000 IF ( ( iwmob .eq. 70 ) .or. ( iwmob .eq. 71 ) .or. + ( iwmob .eq. 72 ) .or. ( iwmob .eq. 74 ) ) THEN htcorf = 1.016 END IF END IF END IF C C* Loop through the pilot significant level data. C DO WHILE ( .true. ) C C* Get the next group in the report. C ipt1 = irptr CALL UA_GFLD ( report, lenr, irptr, field, lenf, ier ) IF ( ier .ne. 0 ) THEN iret = -1 RETURN ELSE IF ( ENDSLV ( field ) ) THEN irptr = ipt1 RETURN ELSE IF ( UA_EGRP ( field, lenf ) ) THEN lost = .true. ELSE IF ( ( lost ) .and. ( field (1:1) .eq. '1' ) ) THEN C C* When in error recovery mode, do not decode a group that C* begins with '1' as a pilot significant level height C* group because it might actually be a wind group. C ELSE C C* This group should be a pilot significant level height C* group. Attempt to decode it as such. C CALL UA_PSHT ( field, hgtdat, nhgt, ierhgt ) IF ( ( ierhgt .eq. 0 ) .and. ( nhgt .gt. 0 ) ) THEN lost = .false. C C* Get and decode the wind group corresponding to C* each decoded height. C DO ii = 1, nhgt drct = RMISSD sped = RMISSD ipt1 = irptr CALL UA_GFLD ( report, lenr, irptr, field, + lenf, ier ) IF ( ier .ne. 0 ) THEN iret = -1 RETURN ELSE IF ( ENDSLV ( field ) ) THEN irptr = ipt1 RETURN ELSE IF ( .not. UA_EGRP ( field, lenf ) ) THEN CALL UA_WIND ( field, drct, sped, ier ) END IF C C* Compute the height at this significant level. C IF ( INT ( hgtdat ( ii ) ) .eq. 0 ) THEN vsig = 64.0 hgtm = selv ELSE vsig = 2.0 hgtm = ( hgtdat ( ii ) ) * htcorf END IF C IF ( ( ( hgtm .gt. MXPBHT ) .and. + ( prttyp .eq. BB ) ) + .or. + ( ( hgtm .lt. MNPDHT ) .and. + ( prttyp .eq. DD ) ) ) THEN C C* The height at this significant level is C* not within the allowable range for this C* type of report. C IF ( prttyp .eq. BB ) THEN CALL UA_RDCS ( 117, ierrdc ) ELSE CALL UA_RDCS ( 118, ierrdc ) END IF WRITE ( UNIT = logmsg, FMT = '( A, F7.1 )' ) + 'pilot siglev HGTM = ', hgtm CALL DC_WLOG ( 2, 'UA', 2, logmsg, ierwlg ) ELSE IF ( hgtm .gt. prevht ) THEN C C* The height at this significant level is C* greater than the height at the previous C* valid significant level, so store all C* output values for this significant level C* into the interface arrays. C CALL UA_STLV ( vsig, RMISSD, hgtm, RMISSD, + RMISSD, drct, sped, RMISSD, RMISSD, + ierstv ) IF ( ierstv .lt. 0 ) THEN iret = -1 RETURN END IF prevht = hgtm END IF END DO ELSE lost = .true. logmsg = 'pilot siglev height group ' // + field (1:lenf) CALL DC_WLOG ( 2, 'UA', 2, logmsg, ierwlg ) CALL UA_RDCS ( 114, ierrdc ) C iskpct = iskpct + 1 C C* How many groups have we skipped over so far?? C IF ( iskpct .gt. MXSKIP ) THEN WRITE ( UNIT = logmsg, FMT = '( A, I3, A )' ) + 'skipped ', iskpct, ' groups during recovery' CALL DC_WLOG ( 2, 'UA', -1, logmsg, ierwlg ) CALL UA_RDCS ( 116, ierrdc ) iret = -1 RETURN END IF END IF END IF END DO C* RETURN END