Line data Source code
1 : !!****m* ABINIT/m_abicore
2 : !! NAME
3 : !! m_abicore
4 : !!
5 : !! FUNCTION
6 : !!
7 : !! COPYRIGHT
8 : !! Copyright (C) 2008-2026 ABINIT group
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_abicore
22 :
23 : !use defs_basis
24 : !use m_build_info
25 : use m_profiling_abi
26 : use m_specialmsg !, only : herald, specialmsg_setcount, specialmsg_getcount, specialmsg_mpisum, wrtout
27 : !use m_errors
28 :
29 :
30 : implicit none
31 :
32 : public
33 :
34 : contains !=====================================================
35 : !!***
36 :
37 : ! TODO: Replace with F90 i0
38 :
39 : !!****f* ABINIT/appdig
40 : !! NAME
41 : !! appdig
42 : !!
43 : !! FUNCTION
44 : !! Using input string "string" and integer "integ", make a string
45 : !! named 'strinn' by concatenating digits of "integ" with characters
46 : !! of "string"; return final string in "strinn".
47 : !! Can also treat initial empty string, then simply returns the integer in the form of a string
48 : !!
49 : !! INPUTS
50 : !! integ=nonnegative integer whose digits will be appended to string
51 : !! string=string to which digits will be appended
52 : !!
53 : !! OUTPUT
54 : !! strinn=string//nn
55 : !!
56 : !! SOURCE
57 :
58 6431812 : subroutine appdig(integ,string,strinn)
59 :
60 : !Arguments ------------------------------------
61 : !scalars
62 : integer,intent(in) :: integ
63 : character(len=*),intent(in) :: string
64 : character(len=*),intent(out) :: strinn
65 :
66 : !Local variables-------------------------------
67 : !scalars
68 : integer :: i,length,ndig
69 : character(len=2) :: ncha
70 : character(len=8) :: form
71 : !character(len=500) :: msg
72 : ! *************************************************************************
73 :
74 : ! Check that integer is nonnegative
75 : !if (integ<0) then
76 : ! write(msg,'(a,i0,a)') &
77 : ! 'Input integer =',integ,' must not be <0. Argument integ was input as negative.'
78 : ! ABI_BUG(msg)
79 : !end if
80 :
81 : ! Fill output string initially with blanks to end of dimensioned length
82 6431812 : length=len(strinn)
83 41081444 : do i=1,length
84 41081444 : strinn(i:i)=' '
85 : end do
86 :
87 : !Find nonwhitespace length of string
88 6431812 : length=len_trim(string)
89 : !Copy input character string into first part of output string
90 6431812 : if(length>0)then
91 22327 : strinn(1:length)=string(1:length)
92 : end if
93 :
94 : !Find how many digits "integ" has
95 6431812 : ndig=int(log10(real(integ)+0.50))+1
96 :
97 : !Create a format for exact number of digits using internal write
98 6431812 : write(unit=ncha,fmt='(i2)') ndig
99 6431812 : form='(i'//ncha//')'
100 : !Do internal write to get digits of integer into character string,
101 : !placing digits into appropriate end of string.
102 6431812 : write(unit=strinn(1+length:length+ndig),fmt=form) integ
103 : !(Note that present version writes "1" or "2" for single digit,
104 : !not "01" or "02". Latter may be preferable. Can be amended.)
105 : !
106 :
107 6431812 : end subroutine appdig
108 : !!***
109 :
110 : end module m_abicore
111 : !!***
|