SUBROUTINE AER_UNIT_CONV &
 &( KIDIA , KFDIA  , KLON, KLEV, KACTAERO, KCONV, &
 &  PRHO  , PFLDIN, &
 &  PFLDOUT )

!*** * AER_UNIT_CONV* - CONVERT UNITS FOR AEROSOL QUANTITIES

!**   INTERFACE.
!     ----------
!          *AER_UNIT_CONV* IS CALLED FROM *CALLPAR*.

!             from xx kg-1 to xx cm-3 if KCONV = 0
!             from xx cm-3 to xx kg-1 if KCONV = 1

!     AUTHOR.
!     -------
!        JEAN-JACQUES MORCRETTE  *ECMWF*
!        FROM O.BOUCHER's kg_to_cm3 and cm3_to_kg


!        OB's KG_TO_CM3 if KCONV = 0
!        CM3_TO_KG if KCONV = 1

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 2005-07-14


!-----------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

IMPLICIT NONE

!-----------------------------------------------------------------------

!---input fields
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KACTAERO
INTEGER(KIND=JPIM),INTENT(IN)    :: KCONV

REAL(KIND=JPRB)   ,INTENT(IN)    :: PRHO(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PFLDIN(KLON,KLEV,KACTAERO)

REAL(KIND=JPRB)   ,INTENT(INOUT) :: PFLDOUT(KLON,KLEV,KACTAERO)

INTEGER(KIND=JPIM) :: JAER, JK, JL

REAL(KIND=JPRB) :: ZHOOK_HANDLE
!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('AER_UNIT_CONV',0,ZHOOK_HANDLE)

IF (KCONV == 0) THEN
!-- converts kg kg-1 to kg cm-3 
  DO JAER=1,KACTAERO
    DO JK=1,KLEV
      DO JL=KIDIA,KFDIA
        PFLDOUT(JL,JK,JAER)=PFLDIN(JL,JK,JAER)*PRHO(JL,JK) / 1.E+06_JPRB
      ENDDO
    ENDDO
  ENDDO

ELSE
!-- converts kg cm-3 to kg kg-1
  DO JAER=1,KACTAERO
    DO JK=1,KLEV
      DO JL=KIDIA,KFDIA
        PFLDOUT(JL,JK,JAER)=PFLDIN(JL,JK,JAER)*1.E+06_JPRB / PRHO(JL,JK)
      ENDDO
    ENDDO
  ENDDO

ENDIF

!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('AER_UNIT_CONV',1,ZHOOK_HANDLE)
END SUBROUTINE AER_UNIT_CONV

