gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dcstringfprintf.f90
Go to the documentation of this file.
1! -*- mode: f90; coding: utf-8 -*-
2!-----------------------------------------------------------------------
3! Copyright (c) 2000-2026 Gtool Development Group. All rights reserved.
4!-----------------------------------------------------------------------
5!>
6!> @author Yasuhiro MORIKAWA, Eizi TOYODA
7!> @copyright Copyright (C) GFD Dennou Club, 2000-2026. All rights reserved. <br/>
8!> License is BSD-2-Clause. see [COPYRIGHT](@ref COPYRIGHT) in detail
9!> @en
10!> @brief Formatted output conversion to file unit
11!> @details
12!> Format a string like C sprintf(3) and output to a file unit.
13!> Note that the implementation is quite different from C sprintf(3).
14!> @enden
15!>
16!> @ja
17!> @brief 書式変換出力 (装置番号版)
18!> @details
19!> C の sprintf(3) のように文字列をフォーマットして装置番号に出力します。
20!> ただし、実装は C の sprintf(3) とは大分違うのでご注意ください。
21!> @endja
22!>
23
24!> @en
25!> @brief Format string and output to unit
26!> @details
27!> Return a formatted string according to format string `fmt` to unit `unit`.
28!> If `unit` is omitted, output to standard output.
29!> Use specifiers starting with '%' in `fmt`.
30!> Use '%%' to output a literal '%'.
31!> See dcstringsprintf.f90 for specifier details and examples.
32!>
33!> @param[in] unit Output unit number (default: standard output)
34!> @param[in] fmt Format string with specifiers
35!> @param[in] i Integer array data for %d, %o, %x
36!> @param[in] r Single precision real array data for %r
37!> @param[in] d Double precision real array data for %f
38!> @param[in] L Logical array data for %b, %y
39!> @param[in] n Repeat counts for %* specifier
40!> @param[in] c1 First character string for %c
41!> @param[in] c2 Second character string for %c
42!> @param[in] c3 Third character string for %c
43!> @param[in] ca Character array for %a
44!> @enden
45!>
46!> @ja
47!> @brief 書式変換して装置番号に出力
48!> @details
49!> フォーマット文字列 `fmt` に従って変換された文字列を
50!> 装置番号 `unit` に出力します。`unit` を省略する場合には標準出力に出力します。
51!> `fmt` には '%' で始まる指示子を含む文字列を与えます。
52!> '%' を出力したい場合は '%%' と記述します。
53!> 指示子および用例に関しての詳細は dcstringsprintf.f90 を参照ください。
54!>
55!> @param[in] unit 出力先の装置番号 (デフォルト: 標準出力)
56!> @param[in] fmt 指示子を含むフォーマット文字列
57!> @param[in] i %d, %o, %x 用の整数配列データ
58!> @param[in] r %r 用の単精度実数配列データ
59!> @param[in] d %f 用の倍精度実数配列データ
60!> @param[in] L %b, %y 用の論理配列データ
61!> @param[in] n %* 用の繰り返し回数
62!> @param[in] c1 %c 用の1番目の文字列
63!> @param[in] c2 %c 用の2番目の文字列
64!> @param[in] c3 %c 用の3番目の文字列
65!> @param[in] ca %a 用の文字配列
66!> @endja
67subroutine dcstringfprintf(unit, fmt, i, r, d, L, n, c1, c2, c3, ca)
68
69 use dc_types, only: string, dp,sp
70 use dc_string, only: printf
71 implicit none
72 integer, intent(in), optional:: unit
73 character(*), intent(in):: fmt
74 integer, intent(in), optional:: i(:), n(:)
75 real(SP), intent(in), optional:: r(:)
76 real(DP), intent(in), optional:: d(:)
77 logical, intent(in), optional:: L(:)
78 character(*), intent(in), optional:: c1, c2, c3
79 character(*), intent(in), optional:: ca(:)
80 character(STRING):: buf
81 continue
82 call printf(buf, fmt, i=i, r=r, d=d, l=l, n=n, &
83 & c1=c1, c2=c2, c3=c3, ca=ca)
84 if (present(unit)) then
85 write(unit, '(A)') trim(buf)
86 else
87 write(*, '(A)') trim(buf)
88 endif
89end subroutine dcstringfprintf
subroutine dcstringfprintf(unit, fmt, i, r, d, l, n, c1, c2, c3, ca)
Formatted output conversion to file unit.
Handling character types.
Definition dc_string.f90:83
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92
integer, parameter, public sp
Single Precision Real number.
Definition dc_types.f90:82