- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I want to write a matrix to a file. Therefore I want to use a formated WRITE to determine the numbers of columns and rows the matrix should appear within the file.
I have the integer variable: maxCol which holds the value for the number of columns.
My initial idea was it to write this value in a character variable strMaxCol:
write(strMaxCol,'(I4)')maxCol
to create a format list like:
write(2, 'strMaxCol//F7.3') MATRIX
Unfortunatly, without success.
Does anybody know how to implement this correctly?
Kindly, Rico.
I want to write a matrix to a file. Therefore I want to use a formated WRITE to determine the numbers of columns and rows the matrix should appear within the file.
I have the integer variable: maxCol which holds the value for the number of columns.
My initial idea was it to write this value in a character variable strMaxCol:
write(strMaxCol,'(I4)')maxCol
to create a format list like:
write(2, 'strMaxCol//F7.3') MATRIX
Unfortunatly, without success.
Does anybody know how to implement this correctly?
Kindly, Rico.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
write(strMaxCol,'("(7F",I4.0,".3)")')maxCol
write(*,*)strMaxCol
write(2, strMaxCol) MATRIX
Didn't the results give you a clue about the error in the last line? You've gone a bit out of your way to hide your intentions; you might have meant something somewhat different.
There have been known to exist systems where unit 2 is pre-assigned to some special meaning. You would then require an OPEN to take it over for normal usage, with no ability to recover the original system usage. Hence the standard expert advice not to use units 0 through 9 for your own purposes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - tim18
Close. Maybe you should build the entire format string and display it, so as to see and fix the bug. How about
write(strMaxCol,'("7F",I4.0,".3")')maxCol
write(*,*)strMaxCol
write(2, strMaxCol) MATRIX
Didn't the results give you a clue about the error in the last line? You've gone a bit out of your way to hide your intentions; you might have meant something somewhat different.
There have been known to exist systems where unit 2 is pre-assigned to some special meaning. You would then require an OPEN to take it over for normal usage, with no ability to recover the original system usage. Hence the standard expert advice not to use units 0 through 9 for your own purposes.
write(strMaxCol,'("7F",I4.0,".3")')maxCol
write(*,*)strMaxCol
write(2, strMaxCol) MATRIX
Didn't the results give you a clue about the error in the last line? You've gone a bit out of your way to hide your intentions; you might have meant something somewhat different.
There have been known to exist systems where unit 2 is pre-assigned to some special meaning. You would then require an OPEN to take it over for normal usage, with no ability to recover the original system usage. Hence the standard expert advice not to use units 0 through 9 for your own purposes.
Hello Tim,
thanx for replying immediatly. The way you described to build format list works! No problem to compile, BUT:
The program crashed at the statement:
write(2, strMaxCol) MATRIX
with the error:
1377F7.3
forrtl: info (58): format syntax error at or near 1377F7.3
forrtl: severe (62): syntax error in format, unit 2, file D:bjava1.txt
Image PC Routine Line Source
rreadwrite.exe 004AE08A Unknown Unknown Unknown
rreadwrite.exe 004AA669 Unknown Unknown Unknown
rreadwrite.exe 0041F68B Unknown Unknown Unknown
rreadwrite.exe 0041E84B Unknown Unknown Unknown
rreadwrite.exe 00414360 Unknown Unknown Unknown
rreadwrite.exe 00403E27 _MAIN__ 86 ReadInZwei2.F90
rreadwrite.exe 004B4A73 Unknown Unknown Unknown
rreadwrite.exe 00457A67 Unknown Unknown Unknown
rreadwrite.exe 0045793F Unknown Unknown Unknown
kernel32.dll 7C817067 Unknown Unknown Unknown
strMaxCol is '1377F7.3'
Any ideas why? I#m clueless. I tried a lot of tests in a small testprogram with oher and more simple formats. It is always compilable, so the syntax should be allright. But it crashes during runtime when attempting to WRITE.
Gradeful for ideas,
Rico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You forgot the parentheses. They are a required part of the format string. Tim had them in his example.

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