Re: fbinrecread' and f77 'write'

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 5 Feb 2007 16:17:49 -0700 (MST)

FYI to all: we are looking into this problem. It involves in the way
the "g77" compiler behaves on a 64-bit Linux system when it comes to
reading and writing Fortran binary files. This behavior is different
than how other compilers and g77 on other systems behaves.

The work-around is to read the file from the same system it was
written on. Meanwhile, we will probably add an option to the
"setfileoption" procedure to account for this difference.

I may post back here once this is finished.

--Mary

On Tue, 23 Jan 2007, Richard Neale wrote:

> 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
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Feb 05 2007 - 16:17:49 MST

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