NADCON5-ng  0.0.2
NADCON5 Next Generation Documentation
decimate.f
Go to the documentation of this file.
1 c> \ingroup core
2 c> \if MANPAGE
3 c> \page decimate
4 c> \endif
5 c>
6 c> Part of the NADCON5 \ref core , Extract a reduced (1 of n) dataset
7 c>
8 c> Decimate - Extract `1` of every `n` points
9 c>
10 c> ### Program arguments
11 c> Arguments are newline terminated and read from standard input
12 c>
13 c> When run from the command line, the program prints a prompt for each argument
14 c>
15 c> They are enumerated here
16 c> \param infile Input File Name
17 c> \param outfile Output File Name
18 c> \param ny Latitude Decimation Ratio `1:ny`
19 c> \param nx Longitude Decimation Ratio `1:nx`
20 c>
21 c> ### Program Inputs:
22 c>
23 c> - `lin` Input File A
24 c>
25 c> ### Program Outputs:
26 c>
27 c> - `lout` Output File to Write Decimated File
28 c>
29  program decimate
30 
31 *** extract every 1 of "n" points
32 
33  implicit double precision(a-h,o-z)
34  character*80 fname
35  integer hrec(1000000)
36  real*4 zrec(1000000)
37  equivalence(hrec(1),zrec(1))
38 
39  lin=1
40  lout=2
41 
42  write(6,*) 'program decimate'
43 
44  write(6,2)
45  2 format('Enter input file: ',$)
46  read(5,1) fname
47  1 format(a)
48  open(lin,file=fname,status='old',form='unformatted')
49 
50  write(6,3)
51  3 format('Enter output file: ',$)
52  read(5,1) fname
53  open(lout,file=fname,status='new',form='unformatted')
54 
55  14 write(6,4)
56  4 format('Extract every 1 of "n" points in lat: ',$)
57  read(5,'(i4)') ny
58  if(ny.le.0) go to 14
59 
60  15 write(6,5)
61  5 format('Extract every 1 of "n" points in lon: ',$)
62  read(5,'(i4)') nx
63  if(nx.le.0) go to 15
64 
65  read(lin) glamn,glomn,dgla,dglo,nla,nlo,ikind
66  dgla2=ny*dgla
67  dglo2=nx*dglo
68  nla2=(nla-1)/ny+1
69  nlo2=(nlo-1)/nx+1
70  write(6,*)
71  write(6,*) dgla,' --> ',dgla2
72  write(6,*) dglo,' --> ',dglo2
73  write(6,*) nla, ' --> ', nla2
74  write(6,*) nlo, ' --> ', nlo2
75  write(6,*)
76  write(lout) glamn,glomn,dgla2,dglo2,nla2,nlo2,ikind
77 
78 *** always process first record (bottom row)
79 
80  if(ikind.eq.0) then
81  call inouti(lin,lout,nlo,nlo2,nx,hrec)
82  else
83  call inoutr(lin,lout,nlo,nlo2,nx,zrec)
84  endif
85  ila=1
86 
87  100 if(ila.lt.nla2) then
88  if(ikind.eq.0) then
89  do 10 iloop=2,ny
90  10 read(lin) (hrec(j),j=1,nlo)
91  call inouti(lin,lout,nlo,nlo2,nx,hrec)
92  else
93  do 20 iloop=2,ny
94  20 read(lin) (zrec(j),j=1,nlo)
95  call inoutr(lin,lout,nlo,nlo2,nx,zrec)
96  endif
97  ila=ila+1
98  go to 100
99  endif
100 
101  stop
102  end
103  subroutine inouti(lin,lout,nlo,nlo2,nx,hrec)
105 *** extract 1 of "nx" points in a record
106 
107  implicit double precision(a-h,o-z)
108  integer hrec(*)
109 
110  read(lin) (hrec(i),i=1,nlo)
111  write(lout) (hrec(nx*i+1),i=0,nlo2-1)
112 
113  return
114  end
115  subroutine inoutr(lin,lout,nlo,nlo2,nx,zrec)
117 *** extract 1 of "nx" points in a record
118 
119  implicit double precision(a-h,o-z)
120  real*4 zrec(*)
121 
122  read(lin) (zrec(i),i=1,nlo)
123  write(lout) (zrec(nx*i+1),i=0,nlo2-1)
124 
125  return
126  end
subroutine inoutr(lin, lout, nlo, nlo2, nx, zrec)
Definition: decimate.f:116
subroutine inouti(lin, lout, nlo, nlo2, nx, hrec)
Definition: decimate.f:104
program decimate
Part of the NADCON5 NADCON5 Core Library , Extract a reduced (1 of n) dataset.
Definition: decimate.f:29