From 3c64728501717ea5dd3e296d0ddec4e0a8417b99 Mon Sep 17 00:00:00 2001 From: Ravindra Shinde Date: Fri, 19 Feb 2021 02:05:50 +0100 Subject: [PATCH] lists int and floats working within limits --- src/iochamp.f90 | 99 +++++++++++++--------------------------------- src/test-champ.inp | 21 +++++++--- 2 files changed, 43 insertions(+), 77 deletions(-) diff --git a/src/iochamp.f90 b/src/iochamp.f90 index ac58a9b..80e3821 100644 --- a/src/iochamp.f90 +++ b/src/iochamp.f90 @@ -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 diff --git a/src/test-champ.inp b/src/test-champ.inp index d898558..323f776 100644 --- a/src/test-champ.inp +++ b/src/test-champ.inp @@ -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 \ No newline at end of file +%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] \ No newline at end of file