Writes a spectrum instance to a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(spectrum_type), | intent(in) | :: | self |
|
||
character(len=*), | intent(in) | :: | filename | JSON file name |
||
logical, | intent(in) | :: | minify | Logical switch to minify the JSON file |
subroutine writeJSON(self,filename,minify)
!! Writes a spectrum instance to a JSON file.
class(spectrum_type),intent(in) :: self !! `spectrum` instance
character(len=*),intent(in) :: filename !! JSON file name
logical,intent(in) :: minify !! Logical switch to minify the JSON file
type(json_core) :: json
type(json_value),pointer :: ptr
call json % initialize(no_whitespace=minify,real_format='ES')
call json % create_object(ptr,'')
call json % add(ptr,'frequency',self % getFrequency())
call json % add(ptr,'wavenumber',self % getWavenumber())
call json % add(ptr,'directions',self % getDirections())
call json % add(ptr,'spectrum',pack(self % getSpectrum(),.true.))
call json % add(ptr,'depth',self % getDepth())
call json % add(ptr,'elevation',self % getElevation())
call json % add(ptr,'gravity',self % getGravity())
call json % add(ptr,'air_density',self % getAirDensity())
call json % add(ptr,'water_density',self % getWaterDensity())
call json % add(ptr,'surface_tension',self % getSurfaceTension())
call json % add(ptr,'u-velocity',self % getCurrent_u())
call json % add(ptr,'v-velocity',self % getCurrent_v())
call json % add(ptr,'z',self % getDepthLevels())
call json % print(ptr,trim(filename))
call json % destroy(ptr)
endsubroutine writeJSON