Different CHARACTER lengths (3/4) in array constructor, how to trim strings - fortran

前端 未结 1 1884
一个人的身影
一个人的身影 2021-01-05 13:06

According to an answer to a similar question, I have declared the characters as indicated here gfortran does not allow character arrays with varying component lengths . Howe

相关标签:
1条回答
  • 2021-01-05 13:54

    gfortran is preventing you from writing non-standard code; it's the language standard which forbids it, not the implementation.

    If you initialise a character array as you have done then all the entries must have the same length. In your case you would have to pad each shorter entry with enough spaces to make them all equally long.

    The alternative would be to insert the entries when program execution starts. If you write something like vars_ncep(1) = 'air' then the additional characters will be set to spaces, the compiler will take care of that for you. This however, would mean that your array could not be a parameter.

    0 讨论(0)
提交回复
热议问题