  program main

    use vtype_module
    use ni3_module
    use netcdf

    implicit none

    integer(i4b)              :: tmax

    real(dp)    , allocatable :: a_time(:)

    integer(i4b)          :: fu
    character(len=extstr) :: ctlfn = "timelastval.ctl"

    character(len=extstr)            :: ncfn
    integer(i4b)                     :: ncid
    character(len=extstr)            :: mode
    character(len=extstr)            :: name

    namelist /timelastval_nml/ ncfn


    fu = 10
    open( fu, file = ctlfn, status = 'unknown' )
    rewind( fu )
    read( fu, nml = timelastval_nml )
    close( fu )

    !
    ! Input from a NetCDF file
    !
    mode = "read"
    call ni3_open( ncfn, mode, ncid )
    name = "time"
    call ni3_inq_dimlen( ncid, name, tmax  )
    allocate( a_time( tmax ) )
    call ni3_get_var( ncid, name, a_time )
    call ni3_close( ncid )

    write( 6, * ) a_time(tmax)


  end program main
