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