[Thread Prev][Thread Next][Index]

Binary 2 netCDF



Dear ferreters,

I wrote a script a couple of years ago to read binary NODC data
and write a netCDF file containing salinity and temperature. I
wanted to reuse it today and it's giving me a nasty error message.
Being unsavvy to the internals of ferret's I/O I'm not sure how
to fix this. Below is the relevant info to the case.

Thanks in advance for any suggestions/fixes.

David.

Here's my ferret script and the error it produces:

! nodc2cdf.jnl
!
! Regrid binary NODC (T,S) data into global 33-level arrays and
! write as a netCDF file.
!
! Oxilia * 18/2/97

! Set state
set mode verify
can/all data
can/all var
 
! Define depths grid
def axis/x=1:33:1/unit="levels" dax
def grid/x=dax dg

! Read depths data
file/grid=dg/var=depths depths.dat
set var/tit="Standard Depths"/unit=m depths

! Define axes
def axis/x=0.5E:0.5W/npoints=360/unit=deg xax
def axis/y=89.5S:89.5N/npoints=180/unit=deg yax
alias daxis def axis/depth/from_data/z/npoints=33/name=zax
daxis/unit=meters depths[d=1,i=1:33]

! Read temperature data
def grid/x=xax/y=yax/z=zax tg
alias tread file/form=unf/order=xyz/grid=tg/var=temp
tread/tit="NODC Annual Climatology" temp_u.bin
set var/tit="Temperature"/unit="deg C" temp

! Read salinity data
def grid/x=xax/y=yax/z=zax sg
alias sread file/form=unf/order=xyz/grid=sg/var=salt
sread/tit="NODC Annual Climatology" salt_u.bin
set var/tit="Salinity"/unit="psu" salt

! clean up
can data 1

! Plot meridional sections to check successful read
set r/x=180/j=1:180/k=1:33/l=1
set wind/siz=.4/clear 1
fill/line/key temp[d=2]
set wind/siz=.4/clear 2 
fill/line/key salt[d=3]

! Set state for netCDF file writing
can memory
set memory/size=5.0				! MegaWords

! Write netCDF file
set r/i=1:360/j=1:180/k=1:33/l=1:1
save/file=NODC.cdf temp[d=2],salt[d=3]
spawn mv NODC.cdf "/home/server/scratch/oxilia/data/netcdf"

! Restore state
set memory/size=3.2
can/a data

! End code
quit

-----------------------------------------------------------------

yes? go nodc2cdf

forrtl: severe (257): formatted I/O to unit open for unformatted
transfers, unit 63, file
/home/server/scratch/oxdata/data/nodc/./temp_u.bin

The binary files are unformatted but this message seems to think
otherwise!

-----------------------------------------------------------------

Here's the fortan code I wrote to create temp_u.bin and salt_u.bin:

* ------------------------------------------------------------
*     Convertion program to read in binary NODC data and write
*     out uniform length binary files for convertion to netCDF
*     by ferret.
*
*     Oxilia * 17/2/98
* ------------------------------------------------------------

      program convert

      parameter (nx=360,ny=180,nz=33)

      real*4 amiss
      real*4 temp(nx,ny,nz)
      real*4 salt(nx,ny,nz)
      integer nlon, nlat, nlev

      amiss = -99.9999
*
* Read binary temperature data
*     
      write(*,*)
      write(*,*) 'Reading binary temperature file'
      write(*,*)

      open(10,file='temp00.bin',form='unformatted',status='unknown')
      read(10) nlon, nlat, nlev, temp
      close(10)
      print*,nlon,nlat,nlev
*
* Write uniform length temperature binary data
*     
      write(*,*)
      write(*,*) 'Writing uniform length binary temperature file'
      write(*,*)

      open(20,file='temp_u.bin',form='unformatted',status='unknown')
      do k = 1,nz
         do j = 1,ny
            do i = 1,nx
               if (temp(i,j,k) .eq. amiss) then
                  temp(i,j,k) = -1.0e34
               end if
               write(20) temp(i,j,k)
            end do
         end do
      end do
      close(20)
*
* Read binary salinity data
*     
      write(*,*)
      write(*,*) 'Reading binary salinity file'
      write(*,*)

      open(10,file='salt00.bin',form='unformatted',status='unknown')
      read(10) nlon, nlat, nlev, salt
      close(10)
      print*,nlon,nlat,nlev
*
* Write uniform length binary salinity data
*     
      write(*,*)
      write(*,*) 'Writing uniform length binary salinity file'
      write(*,*)

      open(20,file='salt_u.bin',form='unformatted',status='unknown')
      do k = 1,nz
         do j = 1,ny
            do i = 1,nx
               if (salt(i,j,k) .eq. amiss) then
                  salt(i,j,k) = -1.0e34
               end if
               write(20) salt(i,j,k)
            end do
         end do
      end do
      close(20)
      
      stop
      end

*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
David Oxilia			Tel: (541) 737-2368
COAS:Oregon State University	Fax: (541) 737-2064
Ocean Admin. Bldg. 104		Email: oxilia@oce.orst.edu
Corvallis, OR 97331-5503	WWW: http://www.oce.orst.edu/po
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement