fortran - Converting integer to character in Fortran90 -


i trying convert integer character in program in fortran 90. here code:

write(array(i,j),'(i5)') myarray(i,j) 

array integer array , myarray character array, , '(i5)', don't know is, worked me before!

error is:

"unit has neither been opened not preconnected"

and

"format/data mismatch"!

alexander vogt explains meaning of (i5) part. answer points out other issues , fixes main problem. doesn't quite explicitly state solution, i'll write here.

you have 2 errors, both have same cause. i'll re-state write statement explicitly stating implicit.

write(unit=array(i,j),'(i5)') myarray(i,j) 

that implicit thing unit=. are, then, asking write character variable myarray(i,j) file connected unit given integer variable array(i,j).

for values of unit integer file not pre-connected. may want read that. when isn't first error:

unit has neither been opened not preconnected

for values of array(i,j), 5, 6 or other value depending on compiler, unit pre-connected. first error doesn't come , to

format/data mismatch

because trying write out character variable integer edit descriptor.

this answer, then, long way of saying want do

write(myarray(i,j),'(i5)') array(i,j) 

you want write integer value character variable.

finally, note if made same mistake real variable array instead of integer, have got a different error message. in 1 way got unlucky syntax correct intention wrong.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -