jacobwilliams / json-fortran

A Modern Fortran JSON API
https://jacobwilliams.github.io/json-fortran/
Other
332 stars 83 forks source link

how to pass non_normals_to_null=.true. #482

Closed jvo203 closed 3 years ago

jvo203 commented 3 years ago

json-fortran apparently supports null output for NaN real values. But I am unable to force it to do so. The ifort compiler outputs an error:

! initialize the class
call json%initialize(non_normals_to_null=.true.)
error #6627: This is an actual argument keyword name, and not a dummy argument name.   [NON_NORMALS_TO_NULL]
        call json%initialize(non_normals_to_null=.true.)

Incidentally, call json%initialize(use_quiet_nan=.true.) compiles fine. Am using the up-to-date json-fortran source code from github.

jvo203 commented 3 years ago

Solved: call json%initialize(non_normal_mode=2)

jacobwilliams commented 3 years ago

Yes, the options are:

integer(IK),intent(in),optional :: non_normal_mode
  !! How to serialize NaN, Infinity, and
  !! -Infinity real values:
  !!
  !! * 1 : as strings (e.g., "NaN",
  !!   "Infinity", "-Infinity") [default]
  !! * 2 : as JSON `null` values

See also null_to_real_mode and use_quiet_nan.