subroutine nbi_log2int(loga,inta,inum)
  !  convert logical to integer for netcdf call

  implicit none

  integer, intent(in) :: inum   ! number of elements to convert
  logical, intent(in) :: loga(inum)
  integer, intent(out) :: inta(inum)

  integer i

  do i=1,inum
     if(loga(i)) then
        inta(i)=1
     else
        inta(i)=0
     endif
  enddo

end subroutine nbi_log2int

subroutine nbi_int2log(inta,loga,inum)
  !  convert integer to logical from netcdf call

  implicit none

  integer, intent(in) :: inum   ! number of elements to convert
  logical, intent(out) :: loga(inum)
  integer, intent(in) :: inta(inum)

  integer i

  do i=1,inum
     if(inta(i).eq.1) then
        loga(i)=.true.
     else
        loga(i)=.false.
     endif
  enddo
 
  return
end subroutine nbi_int2log
