TABLE OF CONTENTS
ABINIT/mkfilename [ Functions ]
NAME
mkfilename
FUNCTION
From the root (input or output) file names, produce a real file name.
COPYRIGHT
Copyright (C) 2002-2018 ABINIT group (XG) 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
character(len=fnlen):: filnam(5)=the root file names (only filnam(3) and filnam(4) are really needed) get=input 'get variable', if 1, must get the file from another dataset idtset=number of the dataset ird=input 'iread variable', if 1, must get the file from the input root jdtset_(0:ndtset)=actual index of the dataset ndtset=number of datasets stringfil character(len=*)=the string of characters to be appended e.g. '_WFK' or '_DEN' stringvar tcharacter(len=*)=the string of characters to be appended that defines the 'get' or 'ird' variables, e.g. 'wfk' or 'ddk'
OUTPUT
character(len=fnlen):: filnam_out=the new file name will_read=1 if the file must be read ; 0 otherwise (ird and get were zero)
PARENTS
dtfil_init,finddistrproc
CHILDREN
appdig,wrtout
SOURCE
41 #if defined HAVE_CONFIG_H 42 #include "config.h" 43 #endif 44 45 #include "abi_common.h" 46 47 48 subroutine mkfilename(filnam,filnam_out,get,idtset,ird,jdtset_,ndtset,stringfil,stringvar,will_read) 49 50 use defs_basis 51 use m_profiling_abi 52 use m_errors 53 54 !This section has been created automatically by the script Abilint (TD). 55 !Do not modify the following lines by hand. 56 #undef ABI_FUNC 57 #define ABI_FUNC 'mkfilename' 58 use interfaces_14_hidewrite 59 use interfaces_32_util 60 !End of the abilint section 61 62 implicit none 63 64 !Arguments ------------------------------------ 65 !scalars 66 integer,intent(in) :: get,idtset,ird,ndtset 67 integer,intent(out) :: will_read 68 character(len=*),intent(in) :: stringfil 69 character(len=*),intent(in) :: stringvar 70 character(len=fnlen),intent(out) :: filnam_out 71 !arrays 72 integer,intent(in) :: jdtset_(0:ndtset) 73 character(len=fnlen),intent(in) :: filnam(5) 74 75 !Local variables------------------------------- 76 !scalars 77 integer :: jdtset,jget 78 character(len=4) :: appen 79 character(len=500) :: message 80 character(len=fnlen) :: filnam_appen 81 82 ! ************************************************************************* 83 84 !Here, defaults if no get variable 85 will_read=ird 86 87 filnam_appen=trim(filnam(3)) 88 if(ndtset>0)then 89 jdtset=jdtset_(idtset) 90 call appdig(jdtset,'',appen) 91 filnam_appen=trim(filnam_appen)//'_DS'//appen 92 end if 93 filnam_out=trim(filnam_appen)//trim(stringfil) 94 95 !Treatment of the multi-dataset case (get is not relevant otherwise) 96 if(ndtset/=0)then 97 98 if(ndtset==1.and.get<0.and.(jdtset_(1)+get>0))then 99 write(message, '(7a,i3,a,i3,5a)' )& 100 & 'You cannot use a negative value of get',trim(stringvar),' with only 1 dataset!',ch10, & 101 & ' If you want to refer to a previously computed dataset,',ch10, & 102 & ' you should give the absolute index of it (i.e. ', & 103 & jdtset_(idtset)+get,' instead of ',get,').',ch10, & 104 & 'Action: correct get',trim(stringvar),' in your input file.' 105 MSG_ERROR(message) 106 end if 107 108 if(idtset+get<0)then 109 write(message, '(a,a,a,a,a,i3,a,a,a,i3,a,a,a,a)' )& 110 & 'The sum of idtset and get',trim(stringvar),' cannot be negative,',ch10,& 111 & 'while they are idtset=',idtset,', and get',trim(stringvar),'=',get,ch10,& 112 & 'Action: correct get',trim(stringvar),' in your input file.' 113 MSG_ERROR(message) 114 end if 115 116 if(get>0 .or. (get<0 .and. idtset+get>0) )then 117 118 if(ird/=0 .and. get/=0)then 119 write(message, '(a,a,a,a,a,a,a,a,a,a,a,i3,a,i3,a,a,a,a,a,a,a)' )& 120 & 'The input variables ird',trim(stringvar),' and get',trim(stringvar),' cannot be',ch10,& 121 & 'simultaneously non-zero, while for idtset=',idtset,',',ch10,& 122 & 'they are ',ird,', and ',get,'.',ch10,& 123 & 'Action: correct ird',trim(stringvar),' or get',trim(stringvar),' in your input file.' 124 MSG_ERROR(message) 125 end if 126 127 will_read=1 128 129 ! Compute the dataset from which to take the file, and the corresponding index 130 if(get<0 .and. idtset+get>0) jget=jdtset_(idtset+get) 131 if(get>0) jget=get 132 call appdig(jget,'',appen) 133 134 ! Note use of output filename (filnam(4)) 135 filnam_out=trim(filnam(4))//'_DS'//trim(appen)//trim(stringfil) 136 137 if(jdtset>=100)then 138 write(message, '(a,a,a,a,a,i5,a,a)' )& 139 & ' mkfilename : get',trim(stringvar) ,'/=0, take file ',trim(stringfil),& 140 & ' from output of DATASET ',jget,'.',ch10 141 else 142 write(message, '(a,a,a,a,a,i3,a,a)' )& 143 & ' mkfilename : get',trim(stringvar) ,'/=0, take file ',trim(stringfil),& 144 & ' from output of DATASET ',jget,'.',ch10 145 end if 146 call wrtout(ab_out,message,'COLL') 147 call wrtout(std_out,message,'COLL') 148 end if ! conditions on get and idtset 149 150 end if ! ndtset/=0 151 152 end subroutine mkfilename