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