 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 301
|
Posted: Mon May 12, 2014 2:44 pm Post subject: formatted output file |
|
|
I have created a formatted output file using FTN95, and can read the file perfectly in Plato, Excel, and WordPad, but it looks completely garbled in NotePad. If I create the same file using a different compiler the problem does not occur.
I am perfectly happy to make the output file available if somebody could let me know how to do so. Unfortunately, providing some complete sample code for the output to reproduce the problem would be difficult, but it works something like the following:
Code: |
WRITE (UNIT=iout,FMT='(A)',ADVANCE='no') TRIM(c)
DO j=1,m
WRITE (cout,FMT=*) r(j)
WRITE (UNIT=iout,FMT='(2A)',ADVANCE='no') c,TRIM(ADJUSTL(cout))
END DO
WRITE (UNIT=iout,FMT='(A)',ADVANCE='yes')
ij=0
DO i=1,n
WRITE (cout,FMT=*) s(i)
WRITE (UNIT=iout,FMT='(A)',ADVANCE='no') TRIM(ADJUSTL(cout))
DO j=1,m
ij=ij+1
WRITE (cout,FMT=*) v(ij)
WRITE (UNIT=iout,FMT='(2A)',ADVANCE='no') cdelim,TRIM(ADJUSTL(cout))
END DO
WRITE (UNIT=iout,FMT='(A)',ADVANCE='yes')
END DO
|
The code above is part of a subroutine, and c is is passed as a CHARACTER(LEN=*) argument, m and n as INTEGER, and r,s and v as REAL arrays. The subroutine and is called more than once when generating the output file. The problem occurs only sometimes, apparently depending on the value of c. If I abort the program part way through printing the file the partial file looks ok until the second call to the routine when line 6 above is invoked. |
|
Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Mon May 12, 2014 6:21 pm Post subject: |
|
|
Notepad needs a CR+LF at the end of each line, whereas Wordpad and the editor in Plato can get by with LF.
One thing I note in your code, is that the WRITE you are doing to turn ADVANCE back on isn't correct as there isn't any data to match the A format descriptor.
I would have used:
Code: |
WRITE(UNIT=iout, FMT='()', ADVANCE='yes')
|
An empty format descriptor is valid Fortran. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
 |
simon
Joined: 05 Jul 2006 Posts: 301
|
Posted: Mon May 12, 2014 7:15 pm Post subject: |
|
|
Thanks David,
Usually if Notepad does not have the correct end-of-line character it just wraps everything into a single line. The file then becomes difficult to read, but not what I see now - Chinese and other special characters. It almost looks as if the file is binary, but there are no complaints from NotePad when the file is opened. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8254 Location: Salford, UK
|
Posted: Tue May 13, 2014 7:10 am Post subject: |
|
|
Plato can also read UNICODE/UTF8 files and maybe Notepad cannot do this.
This key in the end will be to look at the binary. You can do this from Plato provided that you use the Open on the File menu and not the toolbar button.
Then you get a check box to select in order to display the binary. |
|
Back to top |
|
 |
simon
Joined: 05 Jul 2006 Posts: 301
|
Posted: Tue May 13, 2014 7:32 am Post subject: |
|
|
Thanks for the suggestion, Paul. I see how to open the file in binary as you indicated. The first few lines look as follows:
Code: |
0: 31393731 2D30362F 30390932 38362E30 1971-06/09�286.0
10: 30303030 30303030 09323838 2E303030 00000000�288.000
20: 30303030 30300932 39302E30 30303030 000000�290.00000
30: 30303030 09323932 2E303030 30303030 0000�292.0000000
40: 30300932 39342E30 30303030 30303030 00�294.000000000
50: 200D0A32 342E3030 30303030 30303030 ��24.0000000000
|
Some of this is recognisable: the "1971-06/09", for example, is the first character string I printed in line 1, and the numbers 286, 288 ... do follow.
In Plato, Excel etc, the data look like this:
Code: |
1971-06/09 286.000000000 288.000000000 290.000000000 292.000000000 294.000000000
24.0000000000 28.3700000000 28.2825000000 28.2625000000 28.2200000000 28.1400000000
22.0000000000 28.4475000000 28.2850000000 28.1950000000 28.1450000000 28.0750000000
20.0000000000 28.4925000000 28.2775000000 28.1375000000 28.1100000000 28.0725000000
18.0000000000 28.3275000000 28.1950000000 28.0875000000 28.0950000000 28.1025000000
16.0000000000 27.9625000000 27.9375000000 27.9525000000 28.0350000000 28.0925000000
|
In NotePad, the data look like this:
Code: |
㤱ㄷ〭⼶㤰㈉㘸〮〰〰〰〰㈉㠸〮〰〰〰〰㈉〹〮〰〰〰〰㈉㈹〮〰〰〰〰㈉㐹〮〰 |
I did open the output file as a formatted file, and an INQUIRE on the file confirms that. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8254 Location: Salford, UK
|
Posted: Tue May 13, 2014 12:43 pm Post subject: |
|
|
The first line of the binary looks fine so there must be something else going on. Are you sure that you are opening the same file in Notepad? |
|
Back to top |
|
 |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Wed May 14, 2014 6:30 am Post subject: Re: |
|
|
simon wrote: |
In NotePad, the data look like this:
Code: |
㤱ㄷ〭⼶㤰㈉㘸〮〰〰〰〰㈉㠸〮〰〰〰〰㈉〹〮〰〰〰〰㈉㈹〮〰〰〰〰㈉㐹〮〰 |
|
To me, it looks like the Notepad assumes your text file as Unicode text. Notepad uses IsTextUnicode() winapi function to determine if buffer is likely to contain a form of Unicode text.
I wrote you a small program to test, if this is the case.
Paul,
Would it be better to separate bytes in binary view with one blank and groups of four bytes with two blanks? I think it would make it easier to visualize data.
I currently use this output style with my hexdump utility:
Code: |
00000000: 6D 6F 64 75 6C 65 20 65 69 6E 67 61 62 65 6E 5F | module eingaben_
00000010: 6D 6F 64 75 6C 20 0D 0A 20 69 6E 74 65 67 65 72 | modul .. integer
00000020: 2A 34 20 73 65 6C 31 2C 69 63 6F 6C 20 0D 0A 20 | *4 sel1,icol ..
00000030: 63 68 61 72 61 63 74 65 72 20 63 62 65 7A 31 28 | character cbez1(
00000040: 33 29 2C 63 69 6E 70 75 74 31 2A 31 30 2C 63 69 | 3),cinput1*10,ci
00000050: 6E 70 75 74 32 2A 31 30 20 0D 0A 20 69 6E 74 65 | nput2*10 .. inte |
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8254 Location: Salford, UK
|
Posted: Wed May 14, 2014 7:06 am Post subject: |
|
|
Thanks for the suggestion. |
|
Back to top |
|
 |
simon
Joined: 05 Jul 2006 Posts: 301
|
Posted: Wed May 14, 2014 8:13 am Post subject: |
|
|
Thank you all for the assistance.
I have double-checked and am 100% certain that I am looking at the same file. But I did only copy a small portion of what is viewed in NotePad because everything is on a single line. Here is a bit more, if that helps:
Code: |
㤱ㄷ〭⼶㤰㈉㘸〮〰〰〰〰㈉㠸〮〰〰〰〰㈉〹〮〰〰〰〰㈉㈹〮〰〰〰〰㈉㐹〮〰〰〰〰ഠ㈊⸴〰〰〰〰〰㈉⸸㜳〰〰〰〰㈉⸸㠲㔲〰〰〰㈉⸸㘲㔲〰〰〰㈉⸸㈲〰〰〰〰㈉⸸㐱〰〰〰〰ഠ㈊⸲〰〰〰〰〰㈉⸸㐴㔷〰〰〰㈉⸸㠲〵〰〰〰㈉⸸㤱〵〰〰〰㈉⸸㐱〵〰〰〰㈉⸸㜰〵〰〰〰ഠ㈊⸰〰〰〰〰〰㈉⸸㤴㔲〰〰〰㈉⸸㜲㔷〰〰〰㈉⸸㌱㔷〰〰〰㈉⸸ㄱ〰〰〰〰㈉⸸㜰㔲〰〰〰ഠㄊ⸸〰〰〰〰〰㈉⸸㈳㔷〰〰〰㈉⸸㤱〵 |
When I run Jalih's program it says:
"Text file is probably Unicode." |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8254 Location: Salford, UK
|
|
Back to top |
|
 |
simon
Joined: 05 Jul 2006 Posts: 301
|
Posted: Wed May 14, 2014 10:32 am Post subject: |
|
|
Thanks Paul.
If I read the file into WordPad, it reads ok. If I then save it as:
Text Document - Notepad does NOT display the data properly
MS-DOS Format - Notepad does NOT display the data properly
Unicode Text Document - Notepad does display the data properly
I think I can justifiably treat this as a Notepad problem then. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|