kipp_save Subroutine

public subroutine kipp_save(name)

Render once to named PNG, or PDF for .pdf name.

Leaves current device as it was; PDF page PDF_WIDTH wide, text at PDF_CHS.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Output file name; .png appended unless it ends in .png or .pdf.


Source Code

   subroutine kipp_save(name)
      !! Render once to named PNG, or PDF for `.pdf` name.
      !!
      !! Leaves current device as it was; PDF page `PDF_WIDTH` wide, text at `PDF_CHS`.
      ! Arguments
      character(len=*), intent(in) :: name
         !! Output file name; `.png` appended unless it ends in `.png` or `.pdf`.
      character(len=256) :: pfx
      character(len=4) :: ext
      integer :: id, n
      pfx = name
      ext = '.png'
      n = len_trim(pfx)
      if (n > 4) then
         if (pfx(n - 3:n) == '.png' .or. pfx(n - 3:n) == '.pdf') then
            ext = pfx(n - 3:n)
            pfx = pfx(1:n - 4)
         end if
      end if
      if (ext == '.pdf') then
         id = giza_open_device_size('/pdf', trim(pfx), real(PDF_WIDTH), &
                                    real(PDF_WIDTH*2.d0/(1.d0 + sqrt(5.d0))), giza_units_inches)
         chs = PDF_CHS
      else
         id = giza_open_device('/png', trim(pfx))
      end if
      if (id <= 0) then
         print *, '[kipp] cannot open /'//ext(2:)//' for ', trim(pfx)
         chs = 1.d0
         return
      end if
      call draw_scene()
      call giza_close_device()
      chs = 1.d0
      print '(a)', '[kipp] saved '//trim(pfx)//ext
      ! re-select the interactive device if one is open
      if (st%interactive .and. st%devid > 0) call giza_select_device(st%devid)
   end subroutine kipp_save