@@ -1573,19 +1573,45 @@ end subroutine wrap_json_file_get_string_vec
1573
1573
! # Modified
1574
1574
! * Izaak Beekman : 02/24/2015
1575
1575
1576
- subroutine json_initialize (verbose ,compact_reals )
1576
+ subroutine json_initialize (verbose ,compact_reals , print_signs , real_format )
1577
1577
1578
1578
implicit none
1579
1579
1580
1580
logical (LK),intent (in ),optional :: verbose ! ! mainly useful for debugging (default is false)
1581
1581
logical (LK),intent (in ),optional :: compact_reals ! ! to compact the real number strings for output
1582
+ logical (LK),intent (in ),optional :: print_signs ! ! always print numeric sign (default is false)
1583
+ character (len=* ,kind= CDK),intent (in ),optional :: real_format
1584
+ ! ! exponential (default), scientific, engineering or general
1582
1585
1583
1586
character (kind= CDK,len= 10 ) :: w,d,e
1587
+ character (kind= CDK,len= 2 ) :: sgn, rl_edit_desc
1584
1588
integer (IK) :: istat
1589
+ logical (LK) :: sgn_prnt
1590
+
1585
1591
1586
1592
! clear any errors from previous runs:
1587
1593
call json_clear_exceptions()
1588
1594
1595
+ ! set defaults
1596
+ sgn_prnt = .false.
1597
+ if ( present ( print_signs) ) sgn_prnt = print_signs
1598
+ if ( sgn_prnt ) then
1599
+ sgn = ' sp'
1600
+ else
1601
+ sgn = ' ss'
1602
+ end if
1603
+
1604
+ rl_edit_desc = ' E'
1605
+ if ( present ( real_format ) ) then
1606
+ select case ( real_format )
1607
+ case (' g' ,' G' ,' e' ,' E' ,' en' ,' EN' ,' es' ,' ES' )
1608
+ rl_edit_desc = real_format
1609
+ case default
1610
+ call throw_exception(' Invalid real format, "' // trim (real_format) // ' ", passed to json_initialize.' // &
1611
+ new_line(' a' ) // ' Acceptable formats are: "G", "E", "EN", and "ES".' )
1612
+ end select
1613
+ end if
1614
+
1589
1615
# ifdef USE_UCS4
1590
1616
! reopen stdout and stderr with utf-8 encoding
1591
1617
open (output_unit,encoding= ' utf-8' )
@@ -1608,9 +1634,9 @@ subroutine json_initialize(verbose,compact_reals)
1608
1634
if (istat== 0 ) write (d,' (ss,I0)' ,iostat= istat) real_precision
1609
1635
if (istat== 0 ) write (e,' (ss,I0)' ,iostat= istat) real_exponent_digits
1610
1636
if (istat== 0 ) then
1611
- real_fmt = ' (ss,E ' // trim (w) // ' .' // trim (d) // ' E' // trim (e) // ' )'
1637
+ real_fmt = ' (' // sgn // ' , ' // trim (rl_edit_desc) // trim (w) // ' .' // trim (d) // ' E' // trim (e) // ' )'
1612
1638
else
1613
- real_fmt = ' (ss,E30 .16E3)' ! just use this one (should never happen)
1639
+ real_fmt = ' (' // sgn // ' , ' // trim (rl_edit_desc) // ' 30 .16E3)' ! just use this one (should never happen)
1614
1640
end if
1615
1641
end if
1616
1642
0 commit comments