1
0
mirror of https://github.com/TREX-CoE/fparser.git synced 2024-12-23 04:44:04 +01:00

lists int and floats working within limits

This commit is contained in:
Ravindra Shinde 2021-02-19 02:05:50 +01:00
parent 44f8276ff6
commit 3c64728501
2 changed files with 43 additions and 77 deletions

View File

@ -16,6 +16,7 @@ PROGRAM iochamp
character(len=30) :: keyword(5), argument(5)
integer(sp) :: i, j, ia, na, external_entry, number_of_atoms
integer(sp) :: isa(maxa)
real(dp) :: coeff(maxa)
real(sp) :: wmix
real(dp) :: cutoff, phonon_energy, factor
real(dp) :: xa(3, maxa)
@ -276,93 +277,47 @@ PROGRAM iochamp
enddo
endif
write(6,'(A)')
write(6,*) '------------------------------------------------------'
! if ( fdf_block('ListBlock',bfdf) ) then
! i = 0
! do while ( fdf_bline(bfdf,pline) )
! i = i + 1
! na = fdf_bnlists(pline)
! write(*,'(2(a,i0),a)') 'Listblock line: ',i,' has ',na,' lists'
! do ia = 1 , na
! j = -1
! call fdf_bilists(pline,ia,j,isa)
! write(*,'(tr5,2(a,i0),a)') 'list ',ia,' has ',j,' entries'
! call fdf_bilists(pline,ia,j,isa)
! write(*,'(tr5,a,1000(tr1,i0))') 'list: ',isa(1:j)
! end do
! end do
! end if
if ( fdf_block('ListBlock',bfdf) ) then
i = 0
do while ( fdf_bline(bfdf,pline) )
i = i + 1
na = fdf_bnlists(pline)
write(*,'(2(a,i0),a)') 'Listblock line: ',i,' has ',na,' lists'
do ia = 1 , na
j = -1
! Check lists
if ( fdf_islinteger('MyList') .and. fdf_islist('MyList') &
.and. (.not. fdf_islreal('MyList')) ) then
na = -1
call fdf_list('MyList',na,isa)
if ( na < 2 ) stop 1
write(*,'(tr1,a,i0,a)') 'MyList has ',na,' entries'
call fdf_list('MyList',na,isa)
write(*,'(tr5,a,1000(tr1,i0))') 'MyList: ',isa(1:na)
else
write(*,*)'MyList was not recognized'
stop 1
end if
call fdf_bilists(pline,ia,j,isa)
write(*,'(tr5,2(a,i0),a)') 'list ',ia,' has ',j,' entries'
call fdf_bilists(pline,ia,j,isa)
write(*,'(tr5,a,1000(tr1,i0))') 'list: ',isa(1:j)
if ( fdf_islinteger('MyListOne') .and. fdf_islist('MyListOne') &
.and. (.not. fdf_islreal('MyListOne')) ) then
na = -1
call fdf_list('MyListOne',na,isa)
if ( na /= 1 ) stop 1
write(*,'(tr1,a,i0,a)') 'MyListOne has ',na,' entries'
call fdf_list('MyListOne',na,isa)
write(*,'(tr5,a,1000(tr1,i0))') 'MyListOne: ',isa(1:na)
else
write(*,*)'MyListOne was not recognized'
stop 1
end do
end do
end if
if ( fdf_islreal('MyListR') .and. fdf_islist('MyListR') &
.and. (.not. fdf_islinteger('MyListR')) ) then
if ( fdf_islreal('list_floats') .and. fdf_islist('list_floats') &
.and. (.not. fdf_islinteger('list_floats')) ) then
na = -1
call fdf_list('MyListR',na,listr)
write(*,'(tr1,a,i0,a)') 'MyListR has ',na,' entries'
call fdf_list('list_floats',na,listr)
write(*,'(tr1,a,i0,a)') 'list_floats has ',na,' entries'
if ( na < 2 ) stop 1
call fdf_list('MyListR',na,listr)
write(*,'(tr5,a,1000(tr1,f4.1))') 'MyListR: ',listr(1:na)
call fdf_list('list_floats',na,listr)
write(*,'(tr5,a,1000(tr1,f12.8))') 'list_floats: ',listr(1:na)
else
write(*,*)'MyListR was not recognized'
write(*,*)'list_floats was not recognized'
stop 1
end if
if ( fdf_islreal('MyListROne') .and. fdf_islist('MyListROne') &
.and. (.not. fdf_islinteger('MyListROne')) ) then
na = -1
call fdf_list('MyListROne',na,listr)
if ( na /= 1 ) stop 1
write(*,'(tr1,a,i0,a)') 'MyListROne has ',na,' entries'
call fdf_list('MyListROne',na,listr)
write(*,'(tr5,a,1000(tr1,f4.1))') 'MyListROne: ',listr(1:na)
else
write(*,*)'MyListROne was not recognized'
stop 1
end if
if ( fdf_islist('externalentry') ) then
write(*,*) 'externalentry is a list'
else
write(*,*) 'externalentry is not a list'
end if
external_entry = fdf_integer('externalentry', 60)
write(6,*) 'ExternalEntry:', external_entry
axis = fdf_string('AxisXY', 'Cartesian')
status = fdf_string('StatusXY', 'Enabled')
write(6,*) 'Axis: ', TRIM(axis), ' | ', TRIM(status)
! Shutdown and deallocates fdf structure
call fdf_shutdown()
!----------------------------------------------------------------------------END

View File

@ -58,10 +58,10 @@ energy_tol 0.004
%block inline_xyz
3
hypothetical molecule
Nh 1.50 1.108000 -3
Ox 0.333000 0 45
Pd -1.431000 -1.108000 20
O 4.013 0.831 -9.083
H 4.941 0.844 -8.837
H 3.750 -0.068 -9.293
%endblock inline_xyz
@ -80,4 +80,15 @@ hypothetical molecule
## To include another file having fdf syntax
%include temp.fdf
%include temp.fdf
## Lists
%block ListBlock
list_integers [1 to 6 7 9 10 ] [ 1 to 7 8 9 11 12 ]
%endblock ListBlock
list_floats [ 0.94725807 -0.09274559 -0.05238276 -0.05238264 -0.04867531 -0.04162750 -0.04054186 -0.04017050 -0.04017045 -0.02963522 -0.02749165 -0.02351945 0.02056895 0.02056894 -0.01996166 0.01987062 0.01987060]