- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am in the process of upgrading some legacy Fortran code to be more compliant with the 2003 requirements based on using the /stand:f03 setting, and have a simple question. I am encountering many data initializations such as :
CHARACTER(6) CFORCE(6)/3*' FORCE',3*'MOMENT'/
and receive warning message #6915 concerning data values on a type statement.
I tried the following and received error #6952 concerning storing numeric data in type character:
CHARACTER(6) :: CFORCE(6) = [3*' FORCE',3*'MOMENT']
I assume that the "[]" brackets may be used to replace the "//";is there a way to replace the "3*" to maintainthe samefunctionality as the old statement? Is there a good book available that might show examples for these types of questions? Thanks for any help.
CHARACTER(6) CFORCE(6)/3*' FORCE',3*'MOMENT'/
and receive warning message #6915 concerning data values on a type statement.
I tried the following and received error #6952 concerning storing numeric data in type character:
CHARACTER(6) :: CFORCE(6) = [3*' FORCE',3*'MOMENT']
I assume that the "[]" brackets may be used to replace the "//";is there a way to replace the "3*" to maintainthe samefunctionality as the old statement? Is there a good book available that might show examples for these types of questions? Thanks for any help.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are almost there. Try implied loops, as in
CHARACTER(6) :: CFORCE(6) = [('FORCE',i=1,3),('MOMENT',i=1,3)]
where the counter i has been declared as integer earlier.
If you prefer the old style, split the declaration and the initialization into separate statements.
CHARACTER(len=6) :: CFORCE(6)
data CFORCE/3*'FORCE',3*'MOMENT'/
CHARACTER(6) :: CFORCE(6) = [('FORCE',i=1,3),('MOMENT',i=1,3)]
where the counter i has been declared as integer earlier.
If you prefer the old style, split the declaration and the initialization into separate statements.
CHARACTER(len=6) :: CFORCE(6)
data CFORCE/3*'FORCE',3*'MOMENT'/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When F2003 support is complete you could use the SPREAD intrinsic too.
[fortran]CHARACTER(6) :: var(6) = [SPREAD('FORCE ', 1, 3), SPREAD('MOMENT', 1, 3)][/fortran](Currently the intel compiler complains about it being in the initializer for a variable, which is a bit disappointing. The error message conflates terminology from different standards too.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both for these suggestions!
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page