!== Formatted output conversion
!
! Authors::   Yasuhiro MORIKAWA, Eizi TOYODA
! Version::   $Id: dcstringfprintf.f90,v 1.2 2009-03-20 09:50:19 morikawa Exp $
! Tag Name::  $Name:  $
! Copyright:: Copyright (C) GFD Dennou Club, 2000-2005. All rights reserved.
! License::   See COPYRIGHT[link:../../COPYRIGHT]
!
!== Overview
!
! C 縺ｮ sprintf(3) 縺ｮ繧医≧縺ｫ譁�ｭ怜�繧偵ヵ繧ｩ繝ｼ繝槭ャ繝医＠縺ｦ霑斐＠縺ｾ縺吶�
! 縺溘□縺励∝ｮ溯｣�� C 縺ｮ sprintf(3) 縺ｨ縺ｯ螟ｧ蛻�＆縺��縺ｧ縺疲ｳｨ諢上￥縺�縺輔＞縲�
!

subroutine DCStringFPrintf(unit, fmt, i, r, d, L, n, c1, c2, c3, ca)
  !
  ! 繝輔か繝ｼ繝槭ャ繝域枚蟄怜� fmt 縺ｫ蠕薙▲縺ｦ螟画鋤縺輔ｌ縺滓枚蟄怜�繧�
  ! 陬�ｽｮ逡ｪ蜿ｷ unit 縺ｫ霑斐＠縺ｾ縺吶Ｖnit 繧堤怐逡･縺吶ｋ蝣ｴ蜷医↓縺ｯ讓呎ｺ門�蜉帙↓霑斐＠縺ｾ縺吶�
  ! 隨ｬ2蠑墓焚 fmt 縺ｫ縺ｯ謖�､ｺ蟄舌ｒ蜷ｫ繧譁�ｭ怜�繧剃ｸ弱∴縺ｾ縺吶�
  ! 謖�､ｺ蟄舌↓縺ｯ縲�<tt>%</tt>縲阪ｒ逕ｨ縺�∪縺吶�
  ! <tt>%</tt> 繧堤畑縺�◆縺��ｴ蜷医� 縲�<tt>%%</tt>縲阪→險倩ｿｰ縺励∪縺吶�
  ! 謖�､ｺ蟄舌♀繧医�逕ｨ萓九↓髢｢縺励※縺ｮ隧ｳ邏ｰ縺ｯ dc_utils/dcstringsprintf.f90 繧貞盾辣ｧ縺上□縺輔＞縲�
  !
  use dc_types, only: STRING, DP
  use dc_string, only: Printf
  implicit none
  integer, intent(in), optional:: unit
  character(*), intent(in):: fmt
  integer, intent(in), optional:: i(:), n(:)
  real, intent(in), optional:: r(:)
  real(DP), intent(in), optional:: d(:)
  logical, intent(in), optional:: L(:)
  character(*), intent(in), optional:: c1, c2, c3
  character(*), intent(in), optional:: ca(:)
  character(STRING):: buf
continue
  call printf(buf, fmt, i=i, r=r, d=d, L=L, n=n, &
    & c1=c1, c2=c2, c3=c3, ca=ca)
  if (present(unit)) then
    write(unit, '(A)') trim(buf)
  else
    write(*, '(A)') trim(buf)
  endif
end subroutine