!*************************************************************************************************** !* by_dbts * !* * !* This routine gets and stores the depth, temperature, salinity data. * !* * !* by_dbts( iubfma, iubfmn ) * !* * !* Input parameters: * !* iubfma integer Logical unit number of BUFR messages file. * !* iubfmn integer Logical unit number of BUFR output file. * !** * !* Log: * !* J. Ator/NCEP 07/23 * !*************************************************************************************************** subroutine by_dbts( iubfma, iubfmn ) use bycmn implicit none integer, intent(in) :: iubfma, iubfmn integer :: ibfms, ii, jj, kk, nlv, nlv2, iersb real*8 :: getvalnb real :: ut_bmri logical :: newdbss ! Get the depth, temperature, salinity data. call ufbrep( iubfma, r8wk, MXMN, MXLV, nlv2, 'DBSS SST1 SALN') if ( nlv2 > 0 ) then nlv = 0 do kk = 1, nlv2 ! Skip this level if DBSS is missing, or if both SST1 and SALN are missing. if ( ibfms( r8wk(1,kk) ) == 1 ) cycle if ( ( ibfms( r8wk(2,kk) ) == 1 ) .and. ( ibfms( r8wk(3,kk) ) == 1 ) ) cycle ! Merge any levels which have the same DBSS values. newdbss = .true. if ( ( kk > 1 ) .and. ( nlv > 0 ) ) then jj = 1 do while ( ( newdbss ) .and. ( jj <= nlv ) ) if ( int( ut_bmri( r8wk(1,kk) ) * 10 ) == int( ut_bmri( r8in(1,jj) ) * 10 ) ) then ! This is a duplicate DBSS value, so overwrite any missing data values from the earlier ! level with any corresponding non-missing data values from the new level, rather than ! creating a new level. newdbss = .false. if ( ( ibfms( r8in(2,jj) ) == 1 ) .and. ( ibfms( r8wk(2,kk) ) == 0 ) ) r8in(2,jj) = r8wk(2,kk) if ( ( ibfms( r8in(3,jj) ) == 1 ) .and. ( ibfms( r8wk(3,kk) ) == 0 ) ) r8in(3,jj) = r8wk(3,kk) else jj = jj + 1 end if end do end if if ( newdbss ) then ! Create a new level for output. nlv = nlv + 1 do ii = 1, 3 r8in(ii,nlv) = r8wk(ii,kk) end do end if end do if ( nlv > 0 ) then ! Store the depth, temperature, salinity data. call drfini( iubfmn, 1, 1, '' ) call drfini( iubfmn, nlv, 1, '{BBYSTSL}' ) call ufbseq( iubfmn, r8in, MXMN, nlv, nlv2, 'BBYSTSL' ) ! Get and store any preceding IDGT, PCAT, and MSDM values. r8wk (1,1) = getvalnb( iubfma, 'DBSS', 1, 'IDGT', -1 ) call setvalnb( iubfmn, 'DBSS', 1, 'IDGT', -1, r8wk (1,1), iersb ) r8wk (1,1) = getvalnb( iubfma, 'DBSS', 1, 'PCAT', -1 ) call setvalnb( iubfmn, 'DBSS', 1, 'PCAT', -1, r8wk (1,1), iersb ) r8wk (1,1) = getvalnb( iubfma, 'DBSS', 1, 'MSDM', -1 ) call setvalnb( iubfmn, 'DBSS', 1, 'MSDM', -1, r8wk (1,1), iersb ) end if end if end subroutine by_dbts