SUBROUTINE MT_BFCL ( vals, nreps, ndesc, skycnd, iret ) C*********************************************************************** C* MT_BFCL * C* * C* This subroutine converts GEMPAK sky cover numbers to BUFR values * C* * C* MT_BFCL ( vals, nreps, ndesc, skycnd, iret ) * C* * C* Input parameters: * C* vals REAL Array of GEMPAK sky cover nos. * C* nreps INTEGER Number of replications * C* ndesc INTEGER Number of descriptors * C* * C* Output parameters: * C* skycnd REAL Array of BUFR sky cover values * C* iret INTEGER Return code * C* 0 = normal return * C** * C* Log: * C* Kidwell/NCEP 06/96 * C* Kidwell/NCEP 09/96 Added documentation * C* Kidwell/NCEP 11/96 Changed mappings to correspond to new * C* function MT_CMTN - to get partial obsc * C* R. Hollern/NCEP 6/98 Changed mappings to correspond to new * C* GEMPAK interface values * C* R. Hollern/NCEP 5/99 Added check to set cloud height to * C* missing if coded incorrectly in report * C*********************************************************************** INCLUDE 'GEMPRM.PRM' C* REAL vals ( * ) REAL skycnd ( ndesc, * ), work ( 6 ) C* INTEGER iclam ( 9 ), icltp ( 3 ), ipri ( 8 ) C* DATA iclam / 0, 11, 12, 8, 9, 13, 8, 9, 10 / DATA icltp / 0, 32, 39 / DATA ipri / 13, 12, 8, 11, 11, 12, 12, 11 / C* INCLUDE 'ERMISS.FNC' C----------------------------------------------------------------------- iret = 0 layer = 0 C DO i = 1, nreps C IF ( .not. ERMISS ( vals ( i ) ) ) THEN C C* Unpack the GEMPAK cloud number C C* Remove interface GEMPAK flag which denotes C* a height of 0, which will occur if FEW000 reported C isky = ABS( vals ( i ) ) + .5 C iamt = MOD ( isky, 10 ) iht = ( isky - iamt ) / 10 C IF ( iht .eq. 0 .and. vals(i) .gt. 0.0 ) THEN iht = -9999 icnvc = -9999 ELSE icnvc = iht / 1000 END IF C IF ( nreps .le. 3 ) THEN C C* Store significant layer C layer = layer + 1 skycnd ( 1, i ) = layer C END IF C C* Store cloud amount, convective cloud type, and height C skycnd ( 2, i ) = iclam ( iamt ) IF ( icnvc .gt. 0 ) THEN iht = iht - icnvc * 1000 IF ( icltp( icnvc ) .ne. 0 ) THEN skycnd ( 3, i ) = icltp ( icnvc ) ELSE C C* SAO reporting partial obscuration C skycnd( 2, i ) = 10. END IF C C* Cumulonimbus Layer C IF ( icnvc .eq. 3 ) skycnd ( 1, i ) = 4 END IF C IF ( ( iamt .lt. 7 ) .and. ( iamt .ne. 1 ) .and. + iht .ne. -9999 ) THEN skycnd ( 4, i ) = iht * 30.48 END IF END IF END DO C C* If more than 3 layers, determine the 3 significant layers C* using priority values from FMH-1 table. C IF ( nreps .gt. 3 ) THEN DO i = 1, nreps work ( i ) = skycnd ( 2, i ) END DO ip = 1 C DO WHILE ( layer .lt. 3 ) i = 1 DO WHILE ( i .le. nreps ) IF ( work ( i ) .eq. ipri ( ip ) ) THEN C C* Found a significant layer C IF ( ERMISS ( skycnd ( 1, i ) ) ) THEN layer = layer + 1 skycnd ( 1, i ) = 0 END IF work ( i ) = 0 i = nreps + 1 ELSE i = i + 1 END IF END DO ip = ip + 1 IF ( ip .eq. 9 ) layer = 3 END DO C layer = 1 DO i = 1, nreps IF ( skycnd ( 1, i ) .eq. 0 ) THEN skycnd ( 1, i ) = layer layer = layer + 1 END IF END DO END IF C C* Finally, force a table value of "10" (partial obscuration) C* if cloud amount is FEW, SCT or BKN and height is zero. C DO i = 1, nreps IF ( skycnd ( 4, i ) .eq. 0. ) THEN IF ( ( skycnd ( 2, i ) .ge. 11. ) .and. + ( skycnd ( 2, i ) .le. 13. ) ) + skycnd ( 2, i ) = 10. END IF END DO C RETURN END