- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In writing a new program which didn't work out of the box I found some really odd behavior. This is plain vanilla fortran code, but the code below is just not working properly under Win 10 x64 (Intel oneAPI 2023, v 2021.9.0 build 20230302 and also the latest 2025.1.1 release)
character inline*20
open(10,file='filein.txt')
do 10 i=1,2
read(10,20) inline
20 format(a20)
write(12,30) inline
10 continue
30 format('what is happening??? - ',a20)
close(10)
end
the file filein.txt, for example is
dog
cat
What I would expect the code to produce is two lines
what is happening??? - dog
what is happening??? - cat
Instead I am getting on fort.12 is
what is happening??? - ÿþd o g
what is happening??? - c awhat is happenin
Further, if I redirect the output to standard output, I get something different:
pening??? - ■d o g
what is happening??? - c awhat is happenin
So, like my code asks, what is happening? Note, if I replace read(10,20) with read(*,20) and type in the strings, I get the correct output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. I think notepad is messing things up - created the input file on my linux virtual machine and copied it over and it works perfectly. I also recreated the file in notepad and it comes up with a different file size than what I had originally, adding extra bytes - 22 bytes for the original file vs 10 for the newly created one (and 8 for the one created in linux).
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In my computer:
WINDOWS 11
Visial Studio 2022
Intel® Fortran Compiler 2025.1.1
The File BuildLog.htm is:
---------------------------------------------------------------------------------
Compiling with Intel® Fortran Compiler 2025.1.1 [Intel(R) 64]...
ifx /nologo /debug:full /Od /warn:interfaces /module:"x64\Debug\\" /object:"x64\Debug\\" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64" /Qm64 "B:\FORO_16_05_2025\P.F90"
Linking...
Link /OUT:"x64\Debug\FORO_16_05_2025.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"x64\Debug\FORO_16_05_2025.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"B:\FORO_16_05_2025\x64\Debug\FORO_16_05_2025.pdb" /SUBSYSTEM:CONSOLE /IMPLIB:"B:\FORO_16_05_2025\x64\Debug\FORO_16_05_2025.lib" -qnextgen -qm64 "x64\Debug\P.obj"
Embedding manifest...
mt.exe /nologo /outputresource:"B:\FORO_16_05_2025\x64\Debug\FORO_16_05_2025.exe;#1" /manifest "x64\Debug\FORO_16_05_2025.exe.intermediate.manifest"
FORO_16_05_2025 - 0 error(s), 0 warning(s)
----------------------------------------------------
it works perfectly
The file fot.12 contains:
what is happening??? - dog
what is happening??? - cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. I think notepad is messing things up - created the input file on my linux virtual machine and copied it over and it works perfectly. I also recreated the file in notepad and it comes up with a different file size than what I had originally, adding extra bytes - 22 bytes for the original file vs 10 for the newly created one (and 8 for the one created in linux).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Windows uses CR+LF for end of lines. 3 characters for the texts "dog" and "cat", plus 2 end of lines with 2 characters each = 10characters. Linux uses just 1 character, LF, for end of line, thus = 8 characters.
Notepad must've been using formatting characters for something like a Rich Text Format or something.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This sort of stuff comes up a lot when moving large CSV data files for input. It is annoying, but you just accept it.
At the moment I have a computer program that adds strange characters to the end of the file, inputting it later requires a special routine to strip character 26 as you cannot ever see it.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page