c Copyright (C) 2008-2014 Vincent Eymet c c KDISTRIBUTION is free software; you can redistribute it and/or modify c it under the terms of the GNU General Public License as published by c the Free Software Foundation; either version 3, or (at your option) c any later version. c KDISTRIBUTION is distributed in the hope that it will be useful, c but WITHOUT ANY WARRANTY; without even the implied warranty of c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the c GNU General Public License for more details. c You should have received a copy of the GNU General Public License c along with KDISTRIBUTION; if not, see c subroutine idx2str(idx,idx_str) implicit none include 'max.inc' c c Purpose: to convert the provided integer into a character string c c Inputs: c + idx: value of the integer that has to be converted; allowed values c are 0-999 c c Outputs: c + idx_str: value of "idx" that has been converted into a character string c (size of 3) c integer idx character*1 zero_ch,idx_str1 character*2 idx_str2 character*3 idx_str c label integer strlen character*(Nchar_mx) label label='subroutine idx2str' 11 format(I1) 12 format(I2) 13 format(I3) write(zero_ch,11) 0 if (idx.lt.10) then write(idx_str1,11) idx idx_str=zero_ch(1:strlen(zero_ch))// & zero_ch(1:strlen(zero_ch))// & idx_str1(1:strlen(idx_str1)) else if (idx.lt.100) then write(idx_str2,12) idx idx_str=zero_ch(1:strlen(zero_ch))// & idx_str2(1:strlen(idx_str2)) else if (idx.lt.1000) then write(idx_str,13) idx else write(*,*) 'Error from routine ',label(1:strlen(label)),' :' write(*,*) 'idx=',idx stop endif return end