<div dir="ltr"><div>Your use of fbindirread is not correct. The functions reads values on a file.<br>The binary file contains fortran *character variables*. <br>The fortran code you attached reads *AND* 'decodes' the characters into a floating point values. <br></div><div>fbindirread reads only ... it does not decode.<br></div><div><br></div><div><br><div>Also **NOTE** you specified fortran dimension ordering (column major).<br></div>NCL is row major .... the opposite!<br><br>---<br><br> swdir = "./"<br> sfilename = "amsre_20070601v7"<br> dim = (/2, 7, 720, 1440/)<br> amsre_char = fbindirread(swdir + sfilename, 0, dim, "character")<br> printVarSummary(amsre_char) ; works fine<br><br>---<br></div><br><div>Lilely, you can do the decoding steps in NCL.<br><br></div><div>or ... create a fortran shared object and call the fortran code. <br>You must make it a subroutine to call from fortran.<br><br><br></div><div><br></div><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 10, 2015 at 10:38 AM, Zhifeng Yang <span dir="ltr"><<a href="mailto:yangzf01@gmail.com" target="_blank">yangzf01@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Hi <br><br></div>I am trying to read a binary file using the following statements<br><br>dim = (/1440, 720, 7, 2/)<br>amsre_data = fbindirread(swdir + sfilename, 0, dim, "float")<br><br></div>However, I got the errors as below.<br>fatal:fbindirread: The size implied by the dimension array and record number is greater that the size of the file, can't continue<br><br></div>This is how FORTRAN read this file.<br> CHARACTER(1) abuf(1440,720,7)<br> real, dimension(1440,720,7,2) ::amsr_data<br><br> OPEN(3,FILE=FILENAME,STATUS='OLD',RECL=7257600,<br> 1 ACCESS='DIRECT',FORM='UNFORMATTED')<br> do ia=1,2<br> READ(3,rec=ia) abuf<br> do iv=1,7<br> amsr_data(:,:,iv,ia)=real(ICHAR(abuf(:,:,iv)))<br> where(amsr_data(:,:,iv,ia)<=250)<br> amsr_data(:,:,iv,ia)=amsr_data(:,:,iv,ia)*xscale(iv)+xoffset(iv)<br> endwhere<br> enddo<br> enddo<br> close(3)<br><br></div>I am not sure why the error happens. Here is the link to download data.<br><a href="ftp://ftp.remss.com/amsre/bmaps_v07/y2007/m06/" target="_blank">ftp://ftp.remss.com/amsre/bmaps_v07/y2007/m06/</a><br></div>The file name is like <a href="ftp://ftp.remss.com/amsre/bmaps_v07/y2007/m06/amsre_20070601v7.gz" target="_blank">amsre_20070601v7.gz</a><br><br><br></div>Thank you<br></div>Bruce<br></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>