LCOV - code coverage report
Current view: top level - src/77_ddb - m_band2eps_dataset.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 70.2 % 114 80
Test Date: 2026-09-21 13:49:52 Functions: 40.0 % 5 2

            Line data    Source code
       1              : !!****m* ABINIT/m_band2eps_dataset
       2              : !! NAME
       3              : !!  m_band2eps_dataset
       4              : !!
       5              : !! FUNCTION
       6              : !!
       7              : !! COPYRIGHT
       8              : !!  Copyright (C) 2014-2026 ABINIT group (XG,JCC,CL,MVeithen,XW,MJV)
       9              : !!  This file is distributed under the terms of the
      10              : !!  GNU General Public License, see ~abinit/COPYING
      11              : !!  or http://www.gnu.org/copyleft/gpl.txt .
      12              : !!
      13              : !! SOURCE
      14              : 
      15              : #if defined HAVE_CONFIG_H
      16              : #include "config.h"
      17              : #endif
      18              : 
      19              : #include "abi_common.h"
      20              : 
      21              : module m_band2eps_dataset
      22              : 
      23              :  use defs_basis
      24              :  use m_abicore
      25              :  use m_errors
      26              : 
      27              :  use m_parser,    only : intagm
      28              : 
      29              :  implicit none
      30              : 
      31              :  private
      32              : 
      33              :  public :: band2eps_dataset_type
      34              :  public :: band2eps_dtset_free
      35              :  public :: outvars_band2eps
      36              :  public :: invars11
      37              : !!***
      38              : 
      39              : !----------------------------------------------------------------------
      40              : 
      41              : !!****t* m_band2eps_dataset/band2eps_dataset_type
      42              : !! NAME
      43              : !! band2eps_dataset_type
      44              : !!
      45              : !! FUNCTION
      46              : !! The band2eps_dataset_type structured datatype
      47              : !! gather all the input variables for the band2eps code.
      48              : !!
      49              : !! SOURCE
      50              : 
      51              :  type band2eps_dataset_type
      52              : 
      53              : ! Variables should be declared on separated lines in order to reduce the occurence of git conflicts.
      54              : ! Since all these input variables are described in the band2eps_help.html
      55              : ! file, they are not described in length here ...
      56              : ! Integer
      57              :   integer :: natom
      58              :   integer :: cunit
      59              :   integer :: nlines
      60              :   integer :: ngrad
      61              :   integer :: prtout
      62              :   real(dp) :: min
      63              :   real(dp) :: max
      64              : 
      65              : 
      66              :   integer,allocatable :: nqline(:)
      67              : ! nqline(nlines)
      68              : 
      69              :   real(dp),allocatable :: scale(:)
      70              : ! scale(nlines)
      71              : 
      72              :   integer,allocatable :: red(:)
      73              : ! red(natom)
      74              : 
      75              :   integer,allocatable :: blue(:)
      76              : ! blue(natom)
      77              : 
      78              :   integer,allocatable :: green(:)
      79              : ! green(natom)
      80              : 
      81              :   character(len=6),allocatable :: qpoint_name(:)
      82              : ! qpoint_name(nlines+1)
      83              : 
      84              : 
      85              :  end type band2eps_dataset_type
      86              : !!***
      87              : 
      88              : contains
      89              : !!***
      90              : 
      91              : !!****f* m_band2eps_dataset/band2eps_dtset_free
      92              : !!
      93              : !! NAME
      94              : !!   band2eps_dtset_free
      95              : !!
      96              : !! FUNCTION
      97              : !!   deallocate remaining arrays in the band2eps_dtset datastructure
      98              : !!
      99              : !! INPUTS
     100              : !!  band2eps_dtset = band2eps datastructure
     101              : !!
     102              : !! NOTES
     103              : !!
     104              : !! SOURCE
     105              : 
     106            2 : subroutine band2eps_dtset_free(band2eps_dtset)
     107              : 
     108              : !Arguments ------------------------------------
     109              : !scalars
     110              :  type(band2eps_dataset_type), intent(inout) :: band2eps_dtset
     111              : 
     112              : ! *************************************************************************
     113              : 
     114            2 :  ABI_SFREE(band2eps_dtset%nqline)
     115            2 :  ABI_SFREE(band2eps_dtset%scale)
     116            2 :  ABI_SFREE(band2eps_dtset%red)
     117            2 :  ABI_SFREE(band2eps_dtset%blue)
     118            2 :  ABI_SFREE(band2eps_dtset%green)
     119            2 :  ABI_SFREE(band2eps_dtset%qpoint_name)
     120              : 
     121            2 : end subroutine band2eps_dtset_free
     122              : !!***
     123              : 
     124              : !----------------------------------------------------------------------
     125              : 
     126              : !!****f* m_band2eps_dataset/invars11
     127              : !!
     128              : !! NAME
     129              : !! invars11
     130              : !!
     131              : !! FUNCTION
     132              : !! Open input file for the band2eps code, then reads or echoes the input information.
     133              : !!
     134              : !! INPUTS
     135              : !! lenstr=actual length of string
     136              : !! natom=number of atoms, needed for atifc
     137              : !! string*(*)=string of characters containing all input variables and data
     138              : !!
     139              : !! OUTPUT
     140              : !! band2eps_dtset= (derived datatype) contains all the input variables
     141              : !!
     142              : !! NOTES
     143              : !! Should be executed by one processor only.
     144              : !!
     145              : !!
     146              : !! SOURCE
     147              : 
     148            2 : subroutine invars11 (band2eps_dtset,lenstr,string)
     149              : 
     150              : !Arguments -------------------------------
     151              : !scalars
     152              :  integer,intent(in) :: lenstr
     153              :  character(len=strlen),intent(in) :: string
     154              :  type(band2eps_dataset_type),intent(inout) :: band2eps_dtset
     155              : 
     156              : !Local variables -------------------------
     157              : !Dummy arguments for subroutine 'intagm' to parse input file
     158              : !Set routine version number here:
     159              : !scalars
     160              :  integer :: ii,position,jdtset,marr,tread
     161              :  character(len=500) :: message
     162              :  character(len=fnlen) :: name_qpoint
     163              : !arrays
     164            2 :  integer,allocatable :: intarr(:)
     165            2 :  real(dp),allocatable :: dprarr(:)
     166              : 
     167              : !*********************************************************************
     168            2 :  marr=3
     169            2 :  ABI_MALLOC(intarr,(marr))
     170            2 :  ABI_MALLOC(dprarr,(marr))
     171              : 
     172            2 :  jdtset=1
     173              : 
     174              : ! Need to get the number of atom
     175            2 :  band2eps_dtset%natom = 0
     176            2 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'natom',tread,'INT')
     177            2 :  if(tread==1) band2eps_dtset%natom=intarr(1)
     178            2 :  if (band2eps_dtset%natom <= tol10) then
     179              :    write(message,'(a,I5,3a)' )&
     180            0 : &   'natom ',band2eps_dtset%natom,', is not allowed ',ch10,&
     181            0 : &   'Action: correct natom in your input file.'
     182            0 :    ABI_ERROR(message)
     183              :  end if
     184              : 
     185              : ! Need to get the number of lines
     186            2 :  band2eps_dtset%nlines = 0
     187            2 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'nlines',tread,'INT')
     188            2 :  if(tread==1) band2eps_dtset%nlines=intarr(1)
     189            2 :  if (band2eps_dtset%nlines <= tol10) then
     190              :    write(message,'(a,I5,3a)' )&
     191            0 : &   'nlines ',band2eps_dtset%nlines,', is not allowed ',ch10,&
     192            0 : &   'Action: correct nlines in your input file.'
     193            0 :    ABI_ERROR(message)
     194              :  end if
     195              : 
     196              : ! Need to get the number of lines
     197            2 :  band2eps_dtset%cunit = 0
     198            2 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'cunit',tread,'INT')
     199            2 :  if(tread==1) band2eps_dtset%cunit=intarr(1)
     200            2 :  if (band2eps_dtset%cunit < 1 .or. band2eps_dtset%cunit > 2) then
     201              :    write(message,'(a,I5,3a)' )&
     202            0 : &   'cunit ',band2eps_dtset%cunit,', is not allowed ',ch10,&
     203            0 : &   'Action: correct cunit in your input file (1 or 2).'
     204            0 :    ABI_ERROR(message)
     205              :  end if
     206              : 
     207              : ! Need to get the number of lines
     208            2 :  band2eps_dtset%ngrad = 0
     209            2 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'ngrad',tread,'INT')
     210            2 :  if(tread==1) band2eps_dtset%ngrad=intarr(1)
     211            2 :  if (band2eps_dtset%ngrad < 0) then
     212              :    write(message,'(a,I5,3a)' )&
     213            0 : &   'ngrad ',band2eps_dtset%ngrad,', is not allowed ',ch10,&
     214            0 : &   'Action: correct ngrad in your input file (positive value).'
     215            0 :    ABI_ERROR(message)
     216              :  end if
     217              : 
     218              : ! Need to get the number of lines
     219            2 :  band2eps_dtset%min = zero
     220            2 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'min',tread,'DPR')
     221            2 :  if(tread==1) band2eps_dtset%min=dprarr(1)
     222              : 
     223              : ! Need to get the number of lines
     224            2 :  band2eps_dtset%max = zero
     225            2 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'max',tread,'DPR')
     226            2 :  if(tread==1) band2eps_dtset%max=dprarr(1)
     227              : 
     228            6 :  ABI_MALLOC(band2eps_dtset%red,(band2eps_dtset%natom))
     229            4 :  ABI_MALLOC(band2eps_dtset%blue,(band2eps_dtset%natom))
     230            4 :  ABI_MALLOC(band2eps_dtset%green,(band2eps_dtset%natom))
     231            9 :  band2eps_dtset%red(:) = 0
     232            9 :  band2eps_dtset%blue(:) = 0
     233            9 :  band2eps_dtset%green(:) = 0
     234              : 
     235              : ! Read prtout
     236            2 :  band2eps_dtset%prtout = 0
     237            2 :  call intagm(dprarr,intarr,jdtset,marr,1,string(1:lenstr),'prtout',tread,'INT')
     238            2 :  if(tread==1) band2eps_dtset%prtout=intarr(1)
     239            2 :  if (band2eps_dtset%prtout < 0 .or. band2eps_dtset%prtout > 1) then
     240              :    write(message,'(a,I5,3a)' )&
     241            0 : &   'prtout ',band2eps_dtset%prtout,', is not allowed ',ch10,&
     242            0 : &   'Action: correct prtout in your input file (0 or 1).'
     243            0 :    ABI_ERROR(message)
     244              :  end if
     245              : 
     246              : !natom dimension
     247            2 :  if(band2eps_dtset%natom > marr)then
     248            1 :    marr = band2eps_dtset%natom
     249            1 :    ABI_FREE(intarr)
     250            1 :    ABI_FREE(dprarr)
     251            3 :    ABI_MALLOC(intarr,(marr))
     252            3 :    ABI_MALLOC(dprarr,(marr))
     253              :  end if
     254            2 :  call intagm(dprarr,intarr,jdtset,marr,band2eps_dtset%natom,string(1:lenstr),'red',tread,'INT')
     255            9 :  if(tread==1) band2eps_dtset%red(1:band2eps_dtset%natom) = intarr(1:band2eps_dtset%natom)
     256              : 
     257            2 :  call intagm(dprarr,intarr,jdtset,marr,band2eps_dtset%natom,string(1:lenstr),'blue',tread,'INT')
     258            9 :  if(tread==1) band2eps_dtset%blue(1:band2eps_dtset%natom) = intarr(1:band2eps_dtset%natom)
     259              : 
     260            2 :  call intagm(dprarr,intarr,jdtset,marr,band2eps_dtset%natom,string(1:lenstr),'green',tread,'INT')
     261            9 :  if(tread==1) band2eps_dtset%green(1:band2eps_dtset%natom) = intarr(1:band2eps_dtset%natom)
     262              : 
     263              : !nlines dimenstion
     264            6 :  ABI_MALLOC(band2eps_dtset%nqline,(band2eps_dtset%nlines))
     265            6 :  ABI_MALLOC(band2eps_dtset%scale,(band2eps_dtset%nlines))
     266           13 :  band2eps_dtset%nqline(:) = 0
     267           13 :  band2eps_dtset%scale(:) = zero
     268              : 
     269            2 :  if(band2eps_dtset%nlines > marr)then
     270            1 :    marr = band2eps_dtset%nlines
     271            1 :    ABI_FREE(intarr)
     272            1 :    ABI_FREE(dprarr)
     273            2 :    ABI_MALLOC(intarr,(marr))
     274            2 :    ABI_MALLOC(dprarr,(marr))
     275              :  end if
     276              : 
     277            2 :  call intagm(dprarr,intarr,jdtset,marr,band2eps_dtset%nlines,string(1:lenstr),'nqline',tread,'INT')
     278           13 :  if(tread==1) band2eps_dtset%nqline(1:band2eps_dtset%nlines) = intarr(1:band2eps_dtset%nlines)
     279              : !REMOVE THE LAST LINE OF NQLINE
     280            2 :   band2eps_dtset%nqline(band2eps_dtset%nlines) = band2eps_dtset%nqline(band2eps_dtset%nlines) - 1
     281              : 
     282            2 :  call intagm(dprarr,intarr,jdtset,marr,band2eps_dtset%nlines,string(1:lenstr),'scale',tread,'DPR')
     283           13 :  if(tread==1) band2eps_dtset%scale(1:band2eps_dtset%nlines) = dprarr(1:band2eps_dtset%nlines)
     284              : 
     285              : !nline+1 dimension
     286            6 :  ABI_MALLOC(band2eps_dtset%qpoint_name,(band2eps_dtset%nlines+1))
     287           15 :  band2eps_dtset%qpoint_name(:) = ""
     288            2 :  position = index(string(1:lenstr),trim("QPOINT_NAME")) + 11
     289              :  name_qpoint = trim(string(position:(position + &
     290            2 : &          len(band2eps_dtset%qpoint_name(1))*band2eps_dtset%nlines+1)))
     291           15 :  read(name_qpoint,*) (band2eps_dtset%qpoint_name(ii),ii=1,band2eps_dtset%nlines+1)
     292              : 
     293            2 : end subroutine invars11
     294              : !!***
     295              : 
     296              : !----------------------------------------------------------------------
     297              : 
     298              : !!****f* m_band2eps_dataset/outvars_band2eps
     299              : !!
     300              : !! NAME
     301              : !! outvars_band2eps
     302              : !!
     303              : !! FUNCTION
     304              : !! Open input file for the band2eps code, then
     305              : !! echoes the input information.
     306              : !!
     307              : !! INPUTS
     308              : !! band2eps_dtset= (derived datatype) contains all the input variables
     309              : !! nunit=unit number for input or output
     310              : !!
     311              : !! OUTPUT
     312              : !!  (only writing)
     313              : !!
     314              : !! NOTES
     315              : !! Should be executed by one processor only.
     316              : !!
     317              : !! SOURCE
     318              : 
     319            0 : subroutine outvars_band2eps (band2eps_dtset,nunit)
     320              : 
     321              : !Arguments -------------------------------
     322              : !scalars
     323              :  integer,intent(in) :: nunit
     324              :  type(band2eps_dataset_type),intent(in) :: band2eps_dtset
     325              : 
     326              : !Local variables -------------------------
     327              : !Set routine version number here:
     328              : !scalars
     329              :  integer :: ii
     330              : 
     331              : !*********************************************************************
     332              : 
     333              : !Write the heading
     334            0 :  write(nunit,'(80a,a)') ('=',ii=1,80),ch10
     335              :  write(nunit, '(a,a)' )&
     336            0 : & ' -outvars_band2eps: echo values of input variables ----------------------',ch10
     337              : 
     338              : !The flags
     339            0 :  if(band2eps_dtset%natom/=0 )then
     340            0 :    write(nunit,'(a)')' Informations :'
     341            0 :    if(band2eps_dtset%natom/=0)write(nunit,'(3x,a9,3i10)')'  natom',band2eps_dtset%natom
     342            0 :    if(band2eps_dtset%cunit/=0)write(nunit,'(3x,a9,3i10)')'  cunit',band2eps_dtset%cunit
     343            0 :    if(band2eps_dtset%nlines/=0)write(nunit,'(3x,a9,3i10)')' nlines',band2eps_dtset%nlines
     344            0 :    if(band2eps_dtset%min/=0)write(nunit,'(3x,a9,3f12.4)')'    Min',band2eps_dtset%min
     345            0 :    if(band2eps_dtset%max/=0)write(nunit,'(3x,a9,3f12.4)')'    Max',band2eps_dtset%max
     346            0 :    if(band2eps_dtset%ngrad/=0)write(nunit,'(3x,a9,3i10)')'  ngrad',band2eps_dtset%ngrad
     347            0 :    write(nunit,'(3x,a9,6i10)')'    red',(band2eps_dtset%red(ii),ii=1,band2eps_dtset%natom)
     348            0 :    write(nunit,'(3x,a9,6i10)')'   blue',(band2eps_dtset%blue(ii),ii=1,band2eps_dtset%natom)
     349            0 :    write(nunit,'(3x,a9,6i10)')'  green',(band2eps_dtset%green(ii),ii=1,band2eps_dtset%natom)
     350            0 :    write(nunit,'(3x,a9,8i10)')' nqline',(band2eps_dtset%nqline(ii),ii=1,band2eps_dtset%nlines)
     351            0 :    write(nunit,'(3x,a9,8a)')'    point',(band2eps_dtset%qpoint_name(ii),ii=1,band2eps_dtset%nlines+1)
     352              :  end if
     353              : 
     354            0 :  write(nunit,'(a,80a,a)') ch10,('=',ii=1,80),ch10
     355              : 
     356            0 : end subroutine outvars_band2eps
     357              : !!***
     358              : 
     359              : !----------------------------------------------------------------------
     360              : 
     361            0 : end module m_band2eps_dataset
     362              : !!***
        

Generated by: LCOV version 2.3-1