Array declaration in FORTRAN for beginners

前端 未结 2 1736
没有蜡笔的小新
没有蜡笔的小新 2021-01-20 18:56

This is a beginners question but I haven\'t found a comprehensive answer.

What are the differences (if any) of the following declarations?

CHARACTER(         


        
2条回答
  •  青春惊慌失措
    2021-01-20 19:18

    Regardless of the type, ,dimension(5) :: b and :: b(5) are identical and denote an array of length 5. can be e.g. character, integer, real, logical, etc.

    character(5) is a short-hand of character(len=5) and declares a string of length 5. If the length is omitted, it is assumed to be on. character :: d(5) is an array of five length-1 strings.

    character :: e*5 is an older variant to specify the string length.

    len is intrinsic to strings (and makes no sence for e.g. floats). You can specify your own derived types to have an length len, though ("Parameterized derived types"). For integers and floats (and some others) you can specify the kind of the variable in a similar way.

    For details consult the Fortran 2008 Standard, Ch. 4.4.3.2 "Character type specifier".

提交回复
热议问题