From aea7f4d426130d8e55031f564a81902df30709cc Mon Sep 17 00:00:00 2001 From: Jeff Ator Date: Thu, 2 Nov 2023 18:23:58 +0000 Subject: [PATCH] Jack Woollen's fix to optimize upb8.f routine --- src/upb8.f | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/upb8.f b/src/upb8.f index 61f4e65f..2ba76fdc 100644 --- a/src/upb8.f +++ b/src/upb8.f @@ -36,16 +36,19 @@ subroutine upb8(nval,nbits,ibit,ibay) !---------------------------------------------------------------------- !---------------------------------------------------------------------- - if(nbits<0 ) call bort('BUFRLIB: UPB8 - nbits < zero !!!!!') - if(nbits>64) then + if(nbits<0) then + call bort('BUFRLIB: UPB8 - nbits < zero !!!!!') + elseif(nbits<=32) then + jbit=ibit; ival=0 + call upb(ival,nbits,ibay,jbit) + nval=ival + elseif(nbits<=64) then + jbit=ibit; nvals=0 + call upb(nvals(2),max(nbits-nbitw,0),ibay,jbit) + call upb(nvals(1),min(nbitw,nbits ),ibay,jbit) + nval=nval8 + else nval=0 - return endif - jbit=ibit - nvals=0 - call upb(nvals(2),max(nbits-nbitw,0),ibay,jbit) - call upb(nvals(1),min(nbitw,nbits ),ibay,jbit) - nval=nval8 - end subroutine