Writes a spectrum instance to a JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(domain_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(domain_type),intent(in) :: self !! `domain` 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,'lb',self % grid % getLowerBounds())
call json % add(ptr,'ub',self % grid % getUpperBounds())
call json % add(ptr,'x',pack(self % grid % getAxisX(),.true.))
call json % add(ptr,'y',pack(self % grid % getAxisY(),.true.))
!call json % add(ptr,'lon',pack(self % grid % getLongitude(),.true.))
!call json % add(ptr,'lat',pack(self % grid % getLatitude(),.true.))
call json % add(ptr,'u',pack(self % u,.true.))
call json % add(ptr,'v',pack(self % v,.true.))
call json % add(ptr,'eta',pack(self % eta,.true.))
call json % add(ptr,'depth',pack(self % depth,.true.))
call json % add(ptr,'frequency',self % getFrequency())
call json % add(ptr,'directions',self % getDirections())
call json % add(ptr,'spectrum',&
pack(self % getSpectrumArray([0,0],.false.),.true.))
call json % print(ptr,trim(filename))
call json % destroy(ptr)
endsubroutine writeJSON