TABLE OF CONTENTS


ABINIT/appdig [ Functions ]

[ Top ] [ Functions ]

NAME

 appdig

FUNCTION

 Using input string "string" and integer "integ", make a string
 named 'strinn' by concatenating digits of "integ" with characters
 of "string"; return final string in "strinn".
 Can also treat initial empty string, then simply returns the integer in the form of a string

COPYRIGHT

 Copyright (C) 1998-2018 ABINIT group (DCA, XG, GMR)
 This file is distributed under the terms of the
 GNU General Public License, see ~abinit/COPYING
 or http://www.gnu.org/copyleft/gpl.txt .
 For the initials of contributors, see ~abinit/doc/developers/contributors.txt .

INPUTS

 integ=nonnegative integer whose digits will be appended to string
 string=string to which digits will be appended

OUTPUT

 strinn=string//nn

PARENTS

      berryphase_new,d2frnl,dfpt_looppert,dfpt_nstdy,dfpt_nstpaw,dfpt_scfcv
      dfptnl_loop,dtfil_init,intagm,m_gkk,m_ifc,m_io_redirect,mkfilename
      prtocc,prttagm,prttagm_images,uderiv

CHILDREN

SOURCE

 35 #if defined HAVE_CONFIG_H
 36 #include "config.h"
 37 #endif
 38 
 39 #include "abi_common.h"
 40 
 41 
 42 subroutine appdig(integ,string,strinn)
 43 
 44  use defs_basis
 45  use m_errors
 46 
 47 !This section has been created automatically by the script Abilint (TD).
 48 !Do not modify the following lines by hand.
 49 #undef ABI_FUNC
 50 #define ABI_FUNC 'appdig'
 51 !End of the abilint section
 52 
 53  implicit none
 54 
 55 !Arguments ------------------------------------
 56 !scalars
 57  integer,intent(in) :: integ
 58  character(len=*),intent(in) :: string
 59  character(len=*),intent(out) :: strinn
 60 
 61 !Local variables-------------------------------
 62 !scalars
 63  integer :: i,length,ndig
 64  character(len=2) :: ncha
 65  character(len=8) :: form
 66  character(len=500) :: msg
 67 
 68 ! *************************************************************************
 69 !
 70 !Check that integer is nonnegative
 71  if (integ<0) then
 72    write(msg,'(a,i0,a)') &
 73 &   'Input integer =',integ,' must not be <0. Argument integ was input as negative.'
 74    MSG_BUG(msg)
 75  end if
 76 !
 77 !Fill output string initially with blanks to end of dimensioned length
 78  length=len(strinn)
 79  do i=1,length
 80    strinn(i:i)=' '
 81  end do
 82 
 83 !Find nonwhitespace length of string
 84  length=len_trim(string)
 85 !Copy input character string into first part of output string
 86  if(length>0)then
 87    strinn(1:length)=string(1:length)
 88  end if
 89 
 90 !Find how many digits "integ" has
 91  ndig=int(log10(real(integ)+0.50))+1
 92 
 93 !Create a format for exact number of digits using internal write
 94  write(unit=ncha,fmt='(i2)') ndig
 95  form='(i'//ncha//')'
 96 !Do internal write to get digits of integer into character string,
 97 !placing digits into appropriate end of string.
 98  write(unit=strinn(1+length:length+ndig),fmt=form) integ
 99 !(Note that present version writes "1" or "2" for single digit,
100 !not "01" or "02".  Latter may be preferable.  Can be amended.)
101 !
102 end subroutine appdig