format_bibtex Subroutine

public subroutine format_bibtex(string, citation)

Format a citation as a BibTeX entry

Arguments

Type IntentOptional Attributes Name
character(len=:), intent(out), allocatable :: string

The formatted BibTeX entry

class(citation_type), intent(in) :: citation

The citation to format


Source Code

subroutine format_bibtex(string, citation)
   !> The formatted BibTeX entry
   character(len=:), allocatable, intent(out) :: string
   !> The citation to format
   class(citation_type), intent(in) :: citation
   integer :: idx

   if (.not.is_citation_present(citation)) return

   string = &
      & "@article{" // citation%doi // "," // nl // &
      & "  title = {{" // citation%title // "}}," // nl // &
      & "  author = {" // citation%author(1)%name
   do idx = 2, size(citation%author)
      string = string // nl // &
         & "    and " // citation%author(idx)%name
   end do
   string = string // "}," // nl
   if (allocated(citation%issue)) then
      string = string // &
         & "  issue = {" // citation%issue // "}," // nl
   end if
   string = string // &
      & "  volume = {" // citation%volume // "}," // nl // &
      & "  pages = {" // citation%pages // "}," // nl // &
      & "  doi = {" // citation%doi // "}," // nl // &
      & "  url = {https://doi.org/" // citation%doi // "}" // nl // &
      & "}"
end subroutine format_bibtex