Unexpected behaviour with file I/O handling adding extra cha

I am using PGI fortran 16.0 v on intel i7 processor. Using intel compiler my codes runs fine without any error on runtime and produces the desired output, But compilation using PGI compiler produces writes a new file with the extra char ^M.
insted of writing file “Mod_Basin_01_DEM.out” it is writing “Mod_Basin_01_DEM.out ?”
2nd issue is std out is not printing the same output
For example if following lines is to be executed


write(,) ‘Computation of the contributing area
.completed’
write(,)


It is producing


completedof the contributing area


my command line flags are


pgfortran -g -mp -m64 -fPIC -Kieee -Mnobackslash -mcmodel=medium -Mlarge_arrays -c filename.for


Also this piece of code inside the code tree


character* 30NameFl

open(11,FILE=‘xyz.in’,IOSTAT=ios,STATUS=‘OLD’)
//some if else condition**


*****************************************//
read(11,
) NameFl ! file of the distribution of roughness classes for the hillslope
print *,NameFl


Produces
.txt
and if i change declaration as

character* 15NameFl
it produces
basin_01_sc.txt


Can you help me on this. I am new to fortran programming and the file type is having .for extension …

Hello,

Without a complete program to run, we can only guess at some things. Fortran is different from C/C++ in its syntax.

Especially with execution problems like file/string creation,

ASCII files on Linux are different from ones created on Windows.
^M at the end of the line is what windows does.

% dos2unix foo.txt ! removes ^M if there
% unix2dos foo.txt ! adds ^M if not there.

Fortran statements end at each line end, if you do not
provide a continuation character ‘&’. This goes for strings.

If things are still failing, send a complete program that demonstrates
so we can determine what is wrong.

dave