tostring_set(3f) - [M_display] set modes for TOSTRING(3f)
Description
Examples
Author
The subroutine TOSTRING_SET has five arguments, all of which are optional. Argument association will normally be realized using argument keywords, e.g. CALL TOSTRING_SET(SEP=; ). The examples in section 5.4 clarify how to use this subroutine. The five arguments are:
SEP Character string used to separate elements of displayed vectors. Original default value is RFMT Character string containing default edit descriptor to use to display real items. The original default value is 1PG12.5 IFMT Character string containing default edit descriptor to use to display integer items. The original default value is I0. TRIMB Controls whether leading and trailing blanks are trimmed from individual displayed elements. Possible values are YES (to trim blanks) and NO (for no trimming). Default is YES. TRIMZ Controls whether trailing zeros are trimmed from the fractional part of displayed items. Possible values are NONE (for no zero trimming), G (to trim fractional trailing zeros only when G editing is used), and ALL (to trim zeros with all types of editing). Trailing decimal points are also removed when zero-trimming is active. Default value is G.
When the original (factory) defaults are in effect, the result of invoking TOSTRING will usually be as follows.
Invocation Returned String ---------- --------------- tostring(atan(1.0)) 0.785398 tostring(exp([-3.,-1.,0.,1.])) 4.97871E-02, 0.36788, 1, 2.7183 tostring(real([(i,i=1,5)])**8) 1, 256, 6561, 65536, 3.90625E+05 tostring([1.23456,1.2300,1.23456e6]) 1.2346, 1.23, 1.23456E+06 tostring(real([(i,i=1,5)])**8,f0.1) 1.0, 256.0, 6561.0, 65536.0, 390625.0 tostring(real([(i,i=1,5)])**8,f6.1) 1.0, 256.0, 6561.0, ******, ****** tostring([1200000.,-1.2e-9]) 1.2E+06, -1.2E-09 ! tostring(1.200d103) 1.2+103 tostring([1.1d0,2.2d10,3.3d20]) 1.1E+00, 2.2E+10, 3.3E+20 ! tostring(-77) -77 tostring([(i,i=-3,3)]**11) -177147, -2048, -1, 0, 1, 2048, 177147 tostring([(i,i=-3,3)]**11, i7) -177147, -2048, -1, 0, 1, 2048, 177147 tostring([(i,i=-3,3)]**11, i4) ****, ****, -1, 0, 1, 2048, **** ! tostring((1,3)/(4,2)) 0.5 + 0.5i tostring(cmplx([-1,-2])**0.25) 0.70711 + 0.70711i, 0.8409 + 0.8409i ! tostring([.true., .false., .false.]) T, F, F tostring(.true., L2) TThe returned strings may be slightly different from the ones shown, because some compilers (at least some versions of g95) will produce one more decimal place in a few cases, and because the Fortran standard allows G editing to give exponent fields in the form 0dd instead of Edd. The examples make use of brackets to construct vector constants (a Fortran 2003 feature). If the compiler being used does not support this, [ and ] must be used instead. Notice that trimming is on by default so there is not much purpose in specifying the format for integers and logicals. Notice also that (usually) 5 significant digits are displayed when the default G editing results in F edited output, but 6 digits for the numbers of small or large magnitude, displayed with E editing. This discrepancy is present in the Fortran standard; the presence of the scale factor 1P in the edit descriptor increases the number of displayed significant digits.
Examples of using TOSTRING_SET follow (again the returned string may be slightly different).
Invocation Returned String ---------- --------------- call tostring_set(sep=;) tostring([1,2,30]) 1;2;30 ! call tostring_set(trimb=NO) tostring(real([(i,i=1,5)])**8,f6.1) 1.0; 256.0;6561.0;******;****** tostring([1,2,30],i3) 1; 2; 30 tostring([(i,i=-3,3)]**11, i4) ****;****; -1; 0; 1;2048;**** tostring([1,2,30],i0) 1;2;30 tostring(.true.,L3) T ! call tostring_set(trimz=NONE,sep=, ,trimb=YES) tostring(real([(i,i=1,4)])**8) 1.0000, 256.00, 6561.0, 65536. tostring([1.23456,1.2300,1.23456e6]) 1.2346, 1.2300, 1.23456E+06 tostring(1.200d103) 1.20000+103 ! call tostring_set(trimz=ALL) tostring(real([(i,i=1,5)])**8,f0.1) 1, 256, 6561, 65536, 390625 ! call tostring_set(rfmt=G12.4) tostring(real([(i,i=0,5)])**8) 1, 256, 6561, 0.6554E+05, 0.3906E+06 tostring([1200000.,-1.2e-9]) 0.12E+07, -0.12E-08 ! call tostring_set_factory()
Based on dispmodule(3f), "A Fortran 95 module for pretty-printing matrices". Version number 1.02 6-Sept-2008, Kristjan Jonasson, Dept. of Computer Science, University of Iceland (jonasson@hi.is).
Nemo Release 3.1 | tostring_set (3) | February 23, 2025 |