NADCON5-ng  0.0.2
NADCON5 Next Generation Documentation
convlv.f
Go to the documentation of this file.
1 c> \ingroup core
2 c> \if MANPAGE
3 c> \page convlv
4 c> \endif
5 c>
6 c> Part of the NADCON5 \ref core , Convolves two grids
7 c>
8 c> Convolves one grid against another
9 c> \f[
10 c> c(i,j) = a(i,j) * b(i,j)
11 c> \f]
12 c>
13 c> ### Program arguments
14 c> Arguments are newline terminated and read from standard input
15 c>
16 c> When run from the command line, the program prints a prompt for each argument
17 c>
18 c> They are enumerated here
19 c> \param infileA First Input File Name
20 c> \param infileB Second Input File Name
21 c> \param outfile Output File Name of A*B
22 c>
23 c> ### Program Inputs:
24 c>
25 c> - `lin1` Input File A
26 c> - `lin2` Input File B
27 c> - `lout` Output File to Write A+B
28 c>
29  program convlv
30 
31 *** convolve one grid against another:
32 c c(i,j) = a(i,j) * b(i,j)
33 
34  implicit double precision(a-h,o-z)
35  character*88 fname
36  integer hrec1(200049),hrec2(200049)
37  real*4 zrec1(200049),zrec2(200049)
38  equivalence(hrec1(1),zrec1(1))
39  equivalence(hrec2(1),zrec2(1))
40 
41  lin1=1
42  lin2=2
43  lout=3
44 
45  write(6,*) 'program convlv'
46 
47  write(6,3)
48  3 format('Enter "first" input file: ',$)
49  read(5,1) fname
50  1 format(a)
51  open(lin1,file=fname,status='old',form='unformatted')
52 
53  write(6,4)
54  4 format('Enter "second" input file: ',$)
55  read(5,1) fname
56  open(lin2,file=fname,status='old',form='unformatted')
57 
58  write(6,2)
59  2 format('Enter "a*b" output file: ',$)
60  read(5,1) fname
61  open(lout,file=fname,status='new',form='unformatted')
62 
63  read(lin1) glamn1,glomn1,dgla1,dglo1,nla1,nlo1,ikind1
64  read(lin2) glamn2,glomn2,dgla2,dglo2,nla2,nlo2,ikind2
65 
66 *** check compatability
67 
68  if(dabs(glomn1-glomn2).gt.1.d-7) stop 1
69  if(dabs(glamn1-glamn2).gt.1.d-7) stop 6
70  if(dabs(dgla1 -dgla2 ).gt.1.d-7) stop 2
71  if(dabs(dglo1 -dglo2 ).gt.1.d-7) stop 3
72  if(nlo1 .ne.nlo2 ) stop 4
73  if(nla1 .ne.nla2 ) stop 7
74  if(ikind1.ne.ikind2) stop 5
75 
76  write(lout) glamn1,glomn1,dgla1,dglo1,nla1,nlo1,ikind1
77  if(ikind1.eq.0) then
78  do 10 irow=1,nla1
79  read (lin1) (hrec1(i),i=1,nlo1)
80  read (lin2) (hrec2(i),i=1,nlo1)
81  do 11 i=1,nlo1
82  11 hrec1(i)=hrec1(i)+hrec2(i)
83  10 write(lout) (hrec1(i),i=1,nlo1)
84  else
85  do 20 irow=1,nla1
86  read (lin1) (zrec1(i),i=1,nlo1)
87  read (lin2) (zrec2(i),i=1,nlo1)
88  do 21 i=1,nlo1
89  21 zrec1(i)=zrec1(i)*zrec2(i)
90  20 write(lout) (zrec1(i),i=1,nlo1)
91  endif
92 
93  stop
94  end
program convlv
Part of the NADCON5 NADCON5 Core Library , Convolves two grids.
Definition: convlv.f:29