Thardy
Technical User
- Oct 29, 2011
- 13
Dear all,
Trying to read the climate binary program (then write to ascii) attached here but having an error at line 55. My Fortran program is below, thanks for the help:
implicit none
integer :: lon,lat,j,k,i
character*4 :: par !Psea
character*12 time !YYYYMMDDhhmm
integer*2 :: xpix,ypix !288,145
real*4 :: dxpix,dypix,d1,d2,d3,d4 !1.25,1.25,0.0,90.0,358.75,-90
character :: char*1,uni*3 !0,unit(Pa)
integer*4 :: size !size (byte)
integer*2 :: sea !pressure level at sea(1)
integer*2 :: rh !humidity levels(9)
integer*2 :: tem !alt, wind EW,Wind NS,temp levels(18)
integer*2 :: sea1(1:18) !levels(18*2=36)
character :: flag*1, zero*1 !flag,0
character :: fin*150,fout*150
real*4 :: t(288,145) !climate data
integer :: i_pix,j_pix
C integer, parameter:: irec=288*145*18
integer, parameter:: irec =288*145
fin='M2009.T'
fout='M2009.T.txt'
write(*,*)"start"
open(21,file=fin,form='unformatted',access='direct',
& recl=irec,status='old',convert='big_endian',err=999)
write(*,*) "step1"
read(21,rec=1)
& par,time,xpix,ypix,dxpix,dypix,d1,d2,d3,d4,
& char,uni,size,sea,(sea1(j),j=1,1)
& ,flag, zero
write(*,*) "step2"
write(*,*)
& par,time,xpix,ypix,dxpix,dypix,d1,d2,d3,d4,
& char,uni,size,sea,(sea1(j),j=1,18)
& ,flag,zero
write(*,*) "step3"
do j_pix=1,145
read(21,rec=j_pix)
& (t(i_pix,j_pix),i_pix=1,288)
write(*,*)
& par,time,xpix,ypix,dxpix,dypix,d1,d2,d3,d4,
& char,uni,size,sea,(sea1(j),j=1,18)
& ,flag, zero
write(*,*)
& (t(i_pix,j_pix),i_pix=1,288)
open(22,file=fout,form='formatted',status='old')
write(22,*)
& par,time,xpix,ypix,dxpix,dypix,d1,d2,d3,d4,
& char,uni,size,sea,(sea1(j),j=1,18),
& flag, zero,
& (t(i_pix,j_pix),i_pix=1,288)
end do
write(*,*) "zzzz"
close (21)
close (22)
999 continue
stop
End
Trying to read the climate binary program (then write to ascii) attached here but having an error at line 55. My Fortran program is below, thanks for the help:
implicit none
integer :: lon,lat,j,k,i
character*4 :: par !Psea
character*12 time !YYYYMMDDhhmm
integer*2 :: xpix,ypix !288,145
real*4 :: dxpix,dypix,d1,d2,d3,d4 !1.25,1.25,0.0,90.0,358.75,-90
character :: char*1,uni*3 !0,unit(Pa)
integer*4 :: size !size (byte)
integer*2 :: sea !pressure level at sea(1)
integer*2 :: rh !humidity levels(9)
integer*2 :: tem !alt, wind EW,Wind NS,temp levels(18)
integer*2 :: sea1(1:18) !levels(18*2=36)
character :: flag*1, zero*1 !flag,0
character :: fin*150,fout*150
real*4 :: t(288,145) !climate data
integer :: i_pix,j_pix
C integer, parameter:: irec=288*145*18
integer, parameter:: irec =288*145
fin='M2009.T'
fout='M2009.T.txt'
write(*,*)"start"
open(21,file=fin,form='unformatted',access='direct',
& recl=irec,status='old',convert='big_endian',err=999)
write(*,*) "step1"
read(21,rec=1)
& par,time,xpix,ypix,dxpix,dypix,d1,d2,d3,d4,
& char,uni,size,sea,(sea1(j),j=1,1)
& ,flag, zero
write(*,*) "step2"
write(*,*)
& par,time,xpix,ypix,dxpix,dypix,d1,d2,d3,d4,
& char,uni,size,sea,(sea1(j),j=1,18)
& ,flag,zero
write(*,*) "step3"
do j_pix=1,145
read(21,rec=j_pix)
& (t(i_pix,j_pix),i_pix=1,288)
write(*,*)
& par,time,xpix,ypix,dxpix,dypix,d1,d2,d3,d4,
& char,uni,size,sea,(sea1(j),j=1,18)
& ,flag, zero
write(*,*)
& (t(i_pix,j_pix),i_pix=1,288)
open(22,file=fout,form='formatted',status='old')
write(22,*)
& par,time,xpix,ypix,dxpix,dypix,d1,d2,d3,d4,
& char,uni,size,sea,(sea1(j),j=1,18),
& flag, zero,
& (t(i_pix,j_pix),i_pix=1,288)
end do
write(*,*) "zzzz"
close (21)
close (22)
999 continue
stop
End