NADCON5-ng  0.0.1
NADCON5 Next Generation
b2xyz.f
Go to the documentation of this file.
1 c> \ingroup core
2 c> Part of the NADCON5 \ref core , converts `*.b` grid to `xyz`
3 c>
4 c> Program to convert standard "*.b" grid
5 c> formatted data to a binary xyz (lon, lat, value)
6 c> list, which can then be used by GMT for
7 c> various things (like running the GMT
8 c> routine "xyz2grd", to get a "*.grd"
9 c> file, which is useful for plotting, etc)
10 c>
11 c> ### Program arguments
12 c> Arguments are newline terminated and read from standard input
13 c>
14 c> When run from the command line, the program prints a prompt for each argument
15 c>
16 c> They are enumerated here
17 c> \param infile Input File Name
18 c>
19 c> ### Program Inputs:
20 c>
21 c> - Input File defined by `infile`
22 c>
23 c> ### Program Outputs:
24 c>
25 c> - `temp.xyz`
26 c>
27  program b2xyz
28  implicit real*8(a-h,o-z)
29  character*200 fnamein,fnameout,prefix
30  real*4 data(100000)
31  integer*4 idata(100000)
32  real*4 xlo,xla,val
33  equivalence(data(1),idata(1))
34 
35 c ------------------------------------------------
36 c - User-supplied file name
37 c ------------------------------------------------
38  read(5,'(a)')fnamein
39  open(1,file=fnamein,status='old',form='unformatted')
40  read(1)glamn,glomn,dla,dlo,nla,nlo,ikind
41 c ll = len(trim(fnamein))
42 c prefix = fnamein(1:ll-2)
43 c fnameout = prefix//'.xyz'
44  fnameout = 'temp.xyz'
45  open(2,file=fnameout,status='new',form='binary')
46 
47 c - Read, compute location, and write
48  do 1 i=1,nla
49  if(ikind.eq.1)read(1)( data(j),j=1,nlo)
50  if(ikind.eq.0)read(1)(idata(j),j=1,nlo)
51  xla = glamn + (i-1)*dla
52  do 2 j=1,nlo
53  xlo = glomn + (j-1)*dlo
54  if(ikind.eq.1)val = data(j)
55  if(ikind.eq.0)val = dble(idata(j))
56  write(2)xlo,xla,val
57  2 continue
58  1 continue
59  end
program b2xyz
Part of the NADCON5 NADCON5 Core Library , converts *.b grid to xyz
Definition: b2xyz.f:27