[MITgcm-support] FORTRAN binary read help.

Jody Klymak jklymak at uvic.ca
Mon Nov 16 12:03:37 EST 2009


Hi Michael and Martin,

Thanks for the remedial FORTRAN lesson!  Much appreciated.

Cheers,  Jody


On Nov 15, 2009, at  15:56 PM, Michael Schaferkotter (Contractor) wrote:

> jody;
>
> after writing out the data on a powerpc Mac using the MATLAB program
>
> x=cos(1:100); ieee='l'; prec='real*8';
> fid = fopen('HorStruct.bin','w',ieee); fwrite(fid,x,prec);  
> fclose(fid);
>
>
> the following fortran program on a Intel MacBookPro, successfully  
> reads the data back in:
>
> program testprog
>
>       integer, parameter :: real8  = selected_real_kind(10)
>
>       real(kind=real8), dimension(100) :: horStructWest
>
>       open(unit=111,file="HorStruct.bin", status="old",  
> access="direct", recl=100*8 ,action="read")
>       read(unit=111,rec=1) horStructWest
>       CLOSE (unit=111)
>
>       print *, horStructWest
>
> endprogram testprog
>
> i/m sure it/s not the only way.
>
> michael schaferkotter
>
> ps.
>
> [PowerBookG5:/] schaferk% g95 -v
> Using built-in specs.
> Target:
> Configured with: ../configure --enable-languages=c
> Thread model: posix
> gcc version 4.0.3 (g95 0.92!) Apr 24 2009
>
>
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-support

--
Jody Klymak
http://web.uvic.ca/~jklymak/







More information about the MITgcm-support mailing list