9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-06-21 20:12:10 +02:00

Add metadata to TREXIO

This commit is contained in:
Anthony Scemama 2024-04-05 14:25:45 +02:00
parent 6848470850
commit 8e0a9be9ad

View File

@ -59,7 +59,59 @@ subroutine export_trexio(update,full_path)
enddo
call ezfio_set_trexio_trexio_file(trexio_filename)
! ------------------------------------------------------------------------------
! Metadata
! --------
integer :: code_num, author_num
character*(64) :: code(100), author(100), user
character*(64), parameter :: qp2_code = "QuantumPackage"
call getenv("USER",user)
do k=1,N_states
rc = trexio_read_metadata_code_num(f(k), code_num)
if (rc == TREXIO_ATTR_MISSING) then
i = 1
code(:) = ""
else
rc = trexio_read_metadata_code(f(k), code, 64)
do i=1, code_num
if (trim(code(i)) == trim(qp2_code)) then
exit
endif
enddo
endif
if (i == code_num+1) then
code(i) = qp2_code
rc = trexio_write_metadata_code_num(f(k), i)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_metadata_code(f(k), code, 64)
call trexio_assert(rc, TREXIO_SUCCESS)
endif
rc = trexio_read_metadata_author_num(f(k), author_num)
if (rc == TREXIO_ATTR_MISSING) then
i = 1
author(:) = ""
else
rc = trexio_read_metadata_author(f(k), author, 64)
do i=1, author_num
if (trim(author(i)) == trim(user)) then
exit
endif
enddo
endif
if (i == author_num+1) then
author(i) = user
rc = trexio_write_metadata_author_num(f(k), i)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_metadata_author(f(k), author, 64)
call trexio_assert(rc, TREXIO_SUCCESS)
endif
enddo
! ------------------------------------------------------------------------------