[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: netcdf under win95



> Subject: netcdf under win95
>Subject: 2nd post of CR/LF of netcdf problem under win95
>Keywords: 199607061830.AA12318

Hi Yu-Long,

Sorry it has taken so long to reply to your posts of 4 July and 6 July, but
lots of people here took some vacation.

>      First of all, I would like to thank Russ to give me a hand while I try
> to install netcdf under win95 w/ bc++ 5.0 compiler. (to Russ, now there is
> no run-time error happen while I run nctst)
>      Now I got a question to run it.  Here is the output of nctst.cc. 
> 
> //---example.nc got from win95
> 0000000 4344 4601 0000 0002 0000 000d 0a00 0000   // with CR/LF 0d 0a
> 0000020 0400 0000 036c 6174 0000 0000 0400 0000
> 0000040 036c 6f6e 0000 0000 0300 0000 0666 7274
> 
> //---example.nc got from solaris 2.5
> 0000000 4344 4601 0000 0002 0000 000a 0000 0004   // with LF    0a only
> 0000020 0000 0003 6c61 7400 0000 0004 0000 0003
> 0000040 6c6f 6e00 0000 0003 0000 0006 6672 7469
> 
>  Under solaris, end of one line is only LF instead of CR/LF under pc, which
> will cause the problem while I use ncdump.  I got the error message
> 
> ncopen:NC_xtypden: Unknown type 13
> 
>  I believe that it is from 0d 0a under pc.  I add define key words such as
> MSDOS WINNT DOS_FS while I compile and link netcdf.dll but it still did not
> work well.  I even check whole functions call or possible words related to
> ouput process such as write,fwrite,fputc,NC_ENCODE,\n,endl.  I still could
> not find out where netcdf and xdr to put \n after magic number CDF.  I am
> wondering whether you success to get nc files under pc and run ncdump w/o
> problems.  Please help me out!  Thank you very much!  Happy holiday!

As far as I know, there is nothing in the netCDF or XDR libraries that is
writing \r\n instead of \n.  This must be happening in the Borland libraries
or at a lower level, or the extra carriage-return character (the \r byte)
is getting inserted by some other process (e.g. a copy or FTP not in binary
mode).  It is common for text files on MSDOS systems to always end each
line with \r\n instead of just \n as in Unix, but netcdf files are binary
files that should not use any such convention.  Perhaps you are using the
wrong "write" call;  you should be using a binary write that just writes
the bytes out to the file.  I'm pretty sure this is not a netCDF problem,
because the port with the Microsoft C++ compiler to Windows 95 encountered
no such problem, and a previous port of netCDF 2.3.2 to MSDOS using the
Borland compiler encountered no such problem.

We can't reproduce the problem here or provide much more help with it,
because we have no expertise in Windows95, no Borland compilers, and no
platforms on which to test the Borland/Win95 port.

All I can suggest is that you write a little test program, separately from
netcdf, that writes an array of bytes out to a file, make sure the array of
bytes has a newline ("\n", 0xa, 012) byte in the middle of it, and see if
you can use that to get a binary write to a file that doesn't insert a
carriage-return ("\r", 0xd, 015) after the newline.  If you can get the
options and write correct for that, you can probably discover the problem
for netCDF.

Good luck!

--Russ

______________________________________________________________________________

Russ Rew                                           UCAR Unidata Program
address@hidden                              http://www.unidata.ucar.edu


>      I posted a question about CR/LF under MS Win95 instead of LF under
> unix a couple days ago.  So far I havn't got any help yet.  Is there any
> one who could give me a hand please?  Here I address this question again.
> Under win95 it will use 0d 0a instead of 0a.  This probably cause that
> ncdump could not reconize the format because I use spyclass's slicer which
> cann't read example.nc generated under win95 either.
> 
> example.nc under unix 
> 4344 4601 0000 0002 0000 000a 0000 0004 ....
> 
> 
> example.nc under win95
> 4344 4601 0000 0002 0000 000d 0a00 0000 ....
> 
> Because I could not find the low-level io part related to this problem in
> netcdf, I could not change netcdf output into unix format (0a only).  I am
> waiting for the help so that I could go on installing .hdf lib under Win95.
> Thank you in advance Cheers Yu-Long