problems read binary grads file with a fortran file
Isilda da Cunha Menezes
isilda at UEVORA.PT
Fri Aug 1 04:34:26 EDT 2008
Thank you very much, Eric!
Yesterday I remember to write the ACCESS and the RECL in my fortran
program and I got read the grads file.
Best regards,
Isilda
> Hi Isilda,
>
> The problem may be that your fortran program opens unit 11 for sequential
> access but grads writes the fwrite file as flat binary (no control words)
> which would have to be read in the fortran program by direct access.
> Opening unit 11 for direct access is one way to solve the problem, but it
> is easier to tell grads to write the fwrite file sequentially by adding
> the -sq flag to 'set fwrite':
>
> 'set fwrite -sq -le mocambique.gra'
>
> Also, you have specified the dimensions of the array 'a' as (42,42). Be
> sure that the X-Y dimensions in the grads dimension environment are also
> (42,42) when the fwrite file is written. It's not possible to tell from
> your 'set lon' and 'set lat' commands how many grid points are in the
> lat-lon region you have specified.
>
> Best regards,
>
> Eric L. Altshuler
> Assistant Research Scientist
> Center for Ocean-Land-Atmosphere Studies
> 4041 Powder Mill Road, Suite 302
> Calverton, MD 20705-3106
> USA
>
> E-mail: ela at cola.iges.org
> Phone: (301) 902-1257
> Fax: (301) 595-9793
>
> ----- Original Message -----
> From: "Isilda da Cunha Menezes" <isilda at UEVORA.PT>
> To: GRADSUSR at LIST.CINECA.IT
> Sent: Thursday, July 31, 2008 6:27:14 AM GMT -05:00 US/Canada Eastern
> Subject: problems read binary grads file with a fortran file
>
> Hello!
> I have a problem when I try to read with a fortran program the binary
> data generated by the grads that extracts with the fwrite.
>
>
> I extracts the data as follows:
>
> 'open prec-temp-mocamb_g3.ctl'
> 'set gxout fwrite'
> 'set fwrite -le mocambique.gra'
> 'set lon -8.967 -7.077'
> 'set lat 36.999 38.511'
>
> ************precipitacao******
> t=2
> while(t<746)
> 'set t 't
> 'set z 1'
>
> 'd (totpcp-totpcp(t-1))+(acccon-acccon(t-1))'
>
> ************temperature********
> 'set z 1'
>
> 'd tempc'
>
> * Fim do loop no tempo
> t=t+1
> endwhile
>
> *'disable fwrite'
> 'quit'
>
>
>
>
> And I read the data created in a fortran program as follows:
>
>
> program ler
>
> real a(42,42),x(42,42,2,24,31)
> integer var,dia,hora,lat,long,soma,j,id,imi,imf,hour
>
> open(11,file='mocambique.gra',status='old',form='unformatted')
> open(12,file='dados-mocamb.dat',status='new',form='formatted')
>
> do hour=1,744
> do var=1,2
> read(11) ((a(long,lat),long=1,42),lat=1,42)
> enddo
> enddo
> write(*,*)'estou aqui'
>
> But get an error of core dump. I tried reading the matrix of different
> ways, but always get the same error. This file .gra is read directly with
> a fortran program or will have to use another method? If not needed,
> someone could indicate me where I have the error?
>
> Best regards,
> Isilda
>
More information about the gradsusr
mailing list