loadconv_record Function

public function loadconv_record(iunit) result(cnv)

Decode next record w/ its version's decoder.

10600 to 10699: ladv after rncoord, no toffset. 10700 and later: toffset after dt, ladv in early header between ncoord and idx_kind_len. Both hold aw, angltv as 3-vectors. Below 10600 (no test files) stops w/ error; end of file gives nvers = 0.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: iunit

Unit of open .cnv file, positioned at a record.

Return Value type(convtype)


Source Code

  function loadconv_record(iunit) result(cnv)
    !! Decode next record w/ its version's decoder.
    !!
    !! 10600 to 10699: `ladv` after `rncoord`, no `toffset`. 10700 and later: `toffset` after `dt`,
    !! `ladv` in early header between `ncoord` and `idx_kind_len`. Both hold `aw`, `angltv` as
    !! 3-vectors. Below 10600 (no test files) stops w/ error; end of file gives `nvers = 0`.

    use typedef, only: &
         int32

    use convdata, only: &
         convtype

    ! Arguments
    integer(kind=int32), intent(IN) :: &
         iunit
         !! Unit of open `.cnv` file, positioned at a record.

    type(convtype) :: &
         cnv

    integer(kind=int32) :: &
         nvers, ncyc, iostat

    read(iunit, IOSTAT=iostat) nvers, ncyc
    if (IS_IOSTAT_END(iostat)) then
       cnv%nvers = 0
       return
    endif
    if (iostat /= 0) &
         error stop '[loadconv_record] Error reading record header'
    backspace(iunit)

    if (nvers >= 10700) then
       cnv = loadconv_10700(iunit)
    else if (nvers >= 10600) then
       cnv = loadconv_10600(iunit)
    else
       print*, '[loadconv_record] unsupported record version', nvers
       error stop '[loadconv_record] record version < 10600 not supported'
    endif

  end function loadconv_record