I have a string, eg 7f30.3 and I want to store things in the following way
npos = 7
decform = true
width = 30
ndp = 3
I need to read each character one by one. I am coding in fortran but I can try to code it should answer be given in C in the above way.
how do you get 'true' from that?
I meant set decform = .true. if 'f' is encountered
I got something to work as follows:
isChar = .false.
tag = "17f30.2"
n = LEN_TRIM(tag)
print '(A,A,A,I1)', 'tag = ', tag(:n), ', n = ', n
j = 0
do i = 1, n
if ( index('0123456789',tag(i:i)) > 0 ) then
j = j + 1
else
exit
endif
enddo
print *, 'j = ', j
npl = 0
itmp = 0
k = j
do i = 1, j
read(tag(i:i),*) itmp
print *, tag(i:i)
npl = npl + (itmp * (10 ** (k-1)) )
k = k - 1
enddo
print *, 'npl = ', npl
print *, ' '
k = 0
do i = j+2, n
if ( index('0123456789',tag(i:i)) > 0 ) then
k = k + 1
else
exit
endif
enddo
print *, 'k = ', k
iwid = 0
itmp = 0
l = k
print *, j+2, j+2+k-1
do i = j+2, j+2+k-1
read(tag(i:i),*) itmp
print *, tag(i:i)
iwid = iwid + (itmp * (10 ** (l-1)) )
l = l - 1
enddo
print *, 'iwid = ', iwid