
module read_1d_profile

  use vtype_module
  use ni3_module

  implicit none

  private



  public :: Read1DProfile
  public :: Read1DProfileInqDimLen


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

contains

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

  subroutine Read1DProfileInqDimLen(      &
    & InFileName, DimName, &
    & NLev &
    & )

    character(*), intent(in ) :: InFileName
    character(*), intent(in ) :: DimName

    integer     , intent(out) :: NLev


    !
    ! local variables
    !
    character(stdstr) :: Mode
    integer           :: NcID


    Mode = "read"
    call ni3_open( InFileName, Mode, NcID )

    call ni3_inq_dimlen( NcID, DimName, NLev )

    call ni3_close( NcID )


  end subroutine Read1DProfileInqDimLen

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

  subroutine Read1DProfile(      &
    & InFileName, PressName, MolNumName, TempName, VMRName, &
    & NLev, NMolNum, &
    & z_Press, m_MolNum, z_Temp, zm_VMR     &
    & )

    character(*), intent(in) :: InFileName
    character(*), intent(in) :: PressName
    character(*), intent(in) :: MolNumName
    character(*), intent(in) :: TempName
    character(*), intent(in) :: VMRName
    integer     , intent(in ) :: NLev
    integer     , intent(in ) :: NMolNum
    real(DP)    , intent(out) :: z_Press  (1:NLev)
    integer     , intent(out) :: m_MolNum (1:NMolNum)
    real(DP)    , intent(out) :: z_Temp   (1:NLev)
    real(DP)    , intent(out) :: zm_VMR   (1:NLev,1:NMolNum)


    !
    ! local variables
    !
    character(stdstr) :: Mode
    integer           :: NcID


    Mode = "read"
    call ni3_open( InFileName, Mode, NcID )

    call ni3_get_var( NcID, PressName , z_Press  )
    call ni3_get_var( NcID, MolNumName, m_MolNum )
    call ni3_get_var( NcID, TempName  , z_Temp   )
    call ni3_get_var( NcID, VMRName   , zm_VMR   )

    call ni3_close( NcID )


  end subroutine Read1DProfile

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

end module read_1d_profile
