TABLE OF CONTENTS


ABINIT/chkint_prt [ Functions ]

[ Top ] [ Functions ]

NAME

 chkint_prt

FUNCTION

 During the checking of the value of a variable,
 write a sophisticated error message when it is erroneous.
 A few conditions might have been checked before calling chkval,
 and these are mentioned in the error message.

 See the examples in the NOTES

COPYRIGHT

 Copyright (C) 1998-2017 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

 advice_change_cond= if 1, and if an error is detected, will
  advice to change the value of the conditions.
 cond_number= number of conditions checked before calling chkint.
 cond_string(cond_number)= name of the variables associated to the conditions.
 cond_values(cond_number)= value of the variables associated to the conditions.
 input_name=name of the input variable to be checked
 input_value=value of the input variable to be checked
 list_number=number of allowed values (maximum 40).
 list_values=list of allowed values
 minmax_flag=if 0, only values in the list are allowed
              if 1, admit values larger or equal to minmax_value
              if -1, admit values smaller or equal to minmax_value
              if 2, values in the list are not allowed
 minmax_value=see the description of minmax_flag
 unit=unit number for clean output file

OUTPUT

  (only side effect)

 SIDE EFFECT
 ierr= switch it to 1 if an error was detected. No action otherwise.

NOTES

 cond_values(cond_number) or list_values(list_number)
 must be between -99 and 999 to be printed correctly.

 for the time being, at most 3 conditions are allowed.

 in order to ask only for a minimal value, set list_number
 as well as minmax_flag to 1, and put the minimal value in both
 list_values and minmax_value.

 Examples :
  List of values - ionmov must be equal to 0, 1, 3, 8, or 9
   call chkint_prt(0,0,cond_string,cond_values,ierr,&
  & 'ionmov',ionmov,5,(/0,1,3,8,9/),0,0,iout)

  Larger or equal to a given value - nberry >= limit
   call chkint_prt(0,0,cond_string,cond_values,ierr,&
  & 'nberry',nberry,1,(/limit/),1,limit,iout)

  Smaller or equal to a given value - nberry <= limit
   call chkint_prt(0,0,cond_string,cond_values,ierr,&
  & 'nberry',nberry,1,(/limit/),-1,limit,iout)

  Conditional cases (examples to be provided - see chkinp.f for the
  time being)

PARENTS

      chkint,chkint_eq,chkint_ge,chkint_le,chkint_ne

CHILDREN

      wrtout

SOURCE

 78 #if defined HAVE_CONFIG_H
 79 #include "config.h"
 80 #endif
 81 
 82 #include "abi_common.h"
 83 
 84 
 85 subroutine chkint_prt(advice_change_cond,cond_number,cond_string,cond_values,&
 86 &  ierr,input_name,input_value,&
 87 &  list_number,list_values,minmax_flag,minmax_value,unit)
 88 
 89  use defs_basis
 90  use m_errors
 91  use m_profiling_abi
 92 
 93 !This section has been created automatically by the script Abilint (TD).
 94 !Do not modify the following lines by hand.
 95 #undef ABI_FUNC
 96 #define ABI_FUNC 'chkint_prt'
 97  use interfaces_14_hidewrite
 98 !End of the abilint section
 99 
100  implicit none
101 
102 !Arguments ------------------------------------
103 !scalars
104  integer,intent(in) :: advice_change_cond,cond_number,input_value,list_number
105  integer,intent(in) :: minmax_flag,minmax_value,unit
106  integer,intent(inout) :: ierr
107  character(len=*),intent(in) :: input_name
108 !arrays
109  integer,intent(in) :: cond_values(4),list_values(list_number)
110  character(len=*),intent(in) :: cond_string(4)
111 
112 !Local variables-------------------------------
113 !scalars
114  integer :: icond
115  character(len=500) :: message
116 
117 !******************************************************************
118 
119  if(cond_number<0 .or. cond_number>4)then
120    write(message,'(a,i0,a)' )&
121 &   'The value of cond_number is ',cond_number,' but it should be positive and < 5.'
122    MSG_BUG(message)
123  end if
124 
125  if(list_number<0 .or. list_number>40)then
126    write(message,'(a,i0,a)' )&
127 &   'The value of list_number is',list_number,' but it should be between 0 and 40.'
128    MSG_BUG(messagE)
129  end if
130 
131 !Compose the message, and print it
132  ierr=1
133  write(message, '(2a)' ) ch10,' chkint_prt: ERROR -'
134  if(cond_number/=0)then
135    do icond=1,cond_number
136 !    The following format restricts cond_values(icond) to be between -99 and 999
137      write(message, '(5a,i0,a)' ) trim(message),ch10,&
138 &     ' Context: the value of the variable ',trim(cond_string(icond)),' is ',cond_values(icond),'.'
139    end do
140  end if
141  write(message, '(5a,i0,a)' ) trim(message),ch10,&
142 & '  The value of the input variable ',trim(input_name),' is ',input_value,', while it must be'
143  if(minmax_flag==2)then
144    write(message, '(3a,20(i0,1x))' ) trim(message),ch10,&
145    '  different from one of the following:',list_values(1:list_number)
146  else if(list_number>1 .or. &
147 &   minmax_flag==0 .or. list_values(1)/=minmax_value )then
148 !  The following format restricts list_values to be between -99 and 999
149    if(list_number/=1)then
150      write(message, '(3a,40(i0,1x))' ) trim(message),ch10,&
151      '  equal to one of the following: ',list_values(1:list_number)
152    else
153      write(message, '(3a,40(i0,1x))' ) trim(message),ch10,&
154      '  equal to ',list_values(1)
155    end if
156    if(minmax_flag==1)then
157 !    The following format restricts minmax_value to be between -99 and 999
158      write(message, '(3a,i0,a)' ) trim(message),ch10,&
159 &     '  or it must be larger or equal to ',minmax_value,'.'
160    else if(minmax_flag==-1)then
161      write(message, '(3a,i0,a)' ) trim(message),ch10,&
162 &     '  or it must be smaller or equal to ',minmax_value,'.'
163    end if
164  else if(minmax_flag==1)then
165 !  The following format restricts minmax_value to be between -99 and 999
166    write(message, '(3a,i0,a)' ) trim(message),ch10,&
167 &   '  larger or equal to ',minmax_value,'.'
168  else if(minmax_flag==-1)then
169 !  The following format restricts minmax_value to be between -99 and 999
170    write(message, '(3a,i0,a)' ) trim(message),ch10,&
171 &   '  smaller or equal to ',minmax_value,'.'
172  end if
173  if(cond_number==0 .or. advice_change_cond==0)then
174    write(message, '(5a)' ) trim(message),ch10,&
175 &   '  Action: you should change the input variable ',trim(input_name),'.'
176  else if(cond_number==1)then
177    write(message, '(7a)' ) trim(message),ch10,&
178 &   '  Action: you should change the input variables ',trim(input_name),' or ',trim(cond_string(1)),'.'
179  else if(cond_number==2)then
180    write(message, '(11a)' ) trim(message),ch10,&
181 &   '  Action: you should change one of the input variables ',trim(input_name),',',ch10,&
182 &   '   ',trim(cond_string(1)),' or ',trim(cond_string(2)),'.'
183  else if(cond_number==3)then
184    write(message, '(13a)' ) trim(message),ch10,&
185 &   '  Action: you should change one of the input variables ',trim(input_name),',',ch10,&
186 &   '   ',trim(cond_string(1)),', ',trim(cond_string(2)),' or ',trim(cond_string(3)),'.'
187  end if
188  call wrtout(unit   ,message,'COLL')
189  call wrtout(std_out,message,'COLL')
190 
191 end subroutine chkint_prt