10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-14 10:03:47 +01:00
QuantumPackage/src/json/json.irp.f

46 lines
982 B
Fortran
Raw Normal View History

2023-04-21 15:11:50 +02:00
BEGIN_PROVIDER [ character*(128), json_filename ]
implicit none
BEGIN_DOC
! Fortran unit of the JSON file
END_DOC
integer, external :: getUnitAndOpen
integer :: counter
character*(128) :: prefix
logical :: exists
prefix = trim(ezfio_filename)//'/json/'
2023-04-21 18:06:37 +02:00
call lock_io
2023-04-21 15:11:50 +02:00
exists = .True.
counter = 0
do while (exists)
counter += 1
write(json_filename, '(A,I5.5,A)') trim(prefix), counter, '.json'
INQUIRE(FILE=trim(json_filename), EXIST=exists)
enddo
2023-04-21 18:06:37 +02:00
call unlock_io
2023-04-21 15:11:50 +02:00
END_PROVIDER
BEGIN_PROVIDER [ integer, json_unit]
implicit none
BEGIN_DOC
! Unit file for JSON output
END_DOC
integer, external :: getUnitAndOpen
call ezfio_set_json_empty(.False.)
2023-04-21 18:06:37 +02:00
call lock_io
2023-04-21 15:11:50 +02:00
json_unit = getUnitAndOpen(json_filename, 'w')
write(json_unit, '(A)') '{'
2023-04-21 18:06:37 +02:00
call unlock_io
2023-04-21 15:11:50 +02:00
END_PROVIDER
subroutine json_close
2023-04-21 18:06:37 +02:00
call lock_io
2023-04-21 15:11:50 +02:00
write(json_unit, '(A)') '}'
close(json_unit)
2023-04-21 18:06:37 +02:00
call unlock_io
2023-04-21 15:11:50 +02:00
FREE json_unit
end