fbinrecread' and f77 'write'

From: Richard Neale <rneale_at_nyahnyahspammersnyahnyah>
Date: Tue, 23 Jan 2007 13:06:49 -0700

I am having trouble getting the expected behavior between
a f77 write and an ncl fbinrecread.

For example the two following snippets of code (a WRAPIT'ed
f77 routine writing unformatted output and an ncl routine reading it)
gives the output at the bottom. Basically fbinrecread seems to insert a
spurious zero at the start of the record and is not even able to read
any of
the two successive records??

The problems have broken diagnostic code that was fine probably 2
ncl versions ago.

Any help/ideas?

Thanks
Rich

**f77 code**

C NCLFORTSTART
     SUBROUTINE EX_RBN (DIMS1)
     CHARACTER*256 filename
     INTEGER DIMS1(3)
   
C NCLEND
     filename = "dims.bin"
     open (11,file=filename,form="unformatted")
         print*,'dims fortran ',DIMS1
     write (11) DIMS1 ! dimensions
     write (11) DIMS1 ! dimensions
     write (11) DIMS1 ! dimensions

   
     RETURN
     END

** NCL code **

external EX_RBN "./ex_rbn.so"

begin
 dims = (/100,144,192/)
 print("before dims = "+ dims)
 EX_RBN:: ex_rbn(dims)
 dims_out = fbinrecread("dims.bin",0,3,"integer")
 print("after dims = " + dims_out)
 dims_out = fbinrecread("dims.bin",1,3,"integer")
 print("after dims = " + dims_out)
 dims_out = fbinrecread("dims.bin",2,3,"integer")
 print("after dims = " + dims_out)

end

*Output

mineral:diag/var_code/fortran>ncl < ex_rbn.ncl
Copyright (C) 1995-2006 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 4.2.0.a034
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
(0) before dims = 100
(1) before dims = 144
(2) before dims = 192
dims fortran 100 144 192
(0) after dims = 0
(1) after dims = 100
(2) after dims = 144
fatal:fbinrecread: an error occurred reading the record control words.
Something is wrong with the FORTRAN binary file.
fatal:Execute: Error occurred at or near line 9

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Richard Neale - Rm 304 - rneale_at_ucar.edu
 http://www.cgd.ucar.edu/cms/rneale 
 Climate Modelling Section,  CGD,  NCAR
 P.O. Box 3000, Boulder,  CO   80307-3000
 Tel (303) 497-1380    Fax (303) 497-1324
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jan 23 2007 - 13:06:49 MST

This archive was generated by hypermail 2.2.0 : Mon Feb 05 2007 - 16:31:09 MST