- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
I used a standard WRITE to write some numerical coefficients in an outputfile: see attached description, @ Line 341.
However, I have a compilation error: “”this character is not valid for a format list” ??
Note that I declared the output file name OUTFILE as a character in line 279.
Note also that the list coefficients I want to store are a 2 dimensionnal array (3 x 3) as show attached.
Also, when I write the coefficient GammaB (line 341), I am in a do loop on ‘ger’ varying from 1 to 3 (the start of that loop is in an upper line not shown below), the end of that loop in @ line 355 as shown attached.
Do you see the problem ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your:
WRITE(OUTFILE,'ger,",")') GammaB(ger,:)
is not a proper format statement for what you want to do.
I assuming you want the output to look something like:
1, nnn.mmm, nnn.mmm, nnn.mmm
2, nnn.mmm, nnn.mmm, nnn.mmm
3, nnn.mmm, nnn.mmm, nnn.mmm
For this you could consider:
WRITE(OUTFILE, '(I1, 3(", ",F12.3)') ger, GammaB(ger,:)
Jim Dempsey
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your:
WRITE(OUTFILE,'ger,",")') GammaB(ger,:)
is not a proper format statement for what you want to do.
I assuming you want the output to look something like:
1, nnn.mmm, nnn.mmm, nnn.mmm
2, nnn.mmm, nnn.mmm, nnn.mmm
3, nnn.mmm, nnn.mmm, nnn.mmm
For this you could consider:
WRITE(OUTFILE, '(I1, 3(", ",F12.3)') ger, GammaB(ger,:)
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot , it helps !
There was a small error of synthax (missing parenthesis) in the WRITE command that I corrected: see below with the correct parenthesis number.
WRITE(OUTFILE, '(I1, 3(", ",F12.3))') ger, GammaB(ger,:)
However, I have several other problems now:
First, the WRITE command writes correctly in the OUTFILE the actual ger and GammaB(ger,:) for one ger, but it does not accumulate the values along the loop on ger (see attached). how to accumulate values in along the loop ?
Second, OUTFILE is not created in my folder, probably because I have not declared correctly OUTFILE in my global program, I just declared OUTFILE as a character at the beginning of the routine, any guidelines to check?
Third, I want to write in OUTFILE as follows:
1, nnn.mmm, nnn.mmm, nnn.mmm, 2, nnn.mmm, nnn.mmm, nnn.mmm, 3, nnn.mmm, nnn.mmm, nnn.mmm
instead of:
1, nnn.mmm, nnn.mmm, nnn.mmm
2, nnn.mmm, nnn.mmm, nnn.mmm
3, nnn.mmm, nnn.mmm, nnn.mmm
How can I do that ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>OUTFILE is not created in my folder
Where is "my folder"?
Note, specifying a file name without path creates (locates) the file in whatever the Current Drive and Current Directory is at the time of execution of the OPEN command.
When you execute the program from within VS IDE, the Current Drive and Current Directory is that of the Solution unless specified otherwise in the executable property page: Configuration Properties | Debugging | Working Directory
Note, this will not set the working directory when your program is run from: command line, Windows Explorer, shortcut, ...
You should specify the "working directory" prior to program run .OR. obtain the directory for use via some other means:
Explicitly on command line via CD (and optionally driveLetter:)
Environment variable
Command line argument
Or other means
And then prepend the specified location to the file name of interest.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On the WRITE, inside the 3x loop, add '," ",$' to suppress trailing CRLF.
See this.
WRITE(OUTFILE, '(I1, 3(", ",F12.3))," ",$') ger, GammaB(ger,:)
Then after the DO loop, you will have to add a WRITE to output a CRLF
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page