NADCON5-ng  0.0.1
NADCON5 Next Generation
gsqr.f
Go to the documentation of this file.
1 c> \ingroup core
2 c> Part of the NADCON5 \ref core , Squares values in a `*.b` grid
3 c>
4 c> Belongs to the suite of ".b" file manipulators
5 c>
6 c> This program will convert every value in a ".b" grid
7 c> to its squared value.
8 c>
9 c> ### Program arguments
10 c> Arguments are newline terminated and read from standard input
11 c>
12 c> When run from the command line, the program prints a prompt for each argument
13 c>
14 c> They are enumerated here
15 c> \param infile Input File Name
16 c> \param outfile Output File Name
17 c>
18 c> ### Program Inputs:
19 c>
20 c> - `lin` Input File (`*.b` grid)
21 c>
22 c> ### Program Outputs:
23 c>
24 c> - `lout` Output File (`*.b` grid)
25 c>
26  program gsqr
27 
28 c - Belongs to the suite of ".b" file manipulators.
29 
30 c - This program will convert every value in a ".b" grid
31 c - to its squared value.
32 
33  implicit real*8(a-h,o-z)
34  character*200 fnamei,fnameo
35  integer hrec(100000)
36  real*4 zrec(100000),nw,ne,sw,se,zmin,zmax
37  integer*2 srec(100000)
38  equivalence(hrec(1),zrec(1),srec(1))
39 
40  lin = 1
41  lout = 99
42 
43  write(6,1)
44  1 format('Program gsqr - converts grid points ',
45  *'to their squared values')
46 
47  write(6,2)
48  2 format('Enter the input grid file name: ',$)
49  read(5,'(a)') fnamei
50  open(lin,file=fnamei,status='old',form='unformatted')
51 
52  write(6,3)
53  3 format('Enter the output grid file name: ',$)
54  read(5,'(a)') fnameo
55  open(lout,file=fnameo,status='new',form='unformatted')
56 
57 
58 *** display header contents
59 
60  read(lin) glamn,glomn,dgla,dglo,nla,nlo,ikind
61  write(lout) glamn,glomn,dgla,dglo,nla,nlo,ikind
62 
63 *** read records south to north (elements are west to east)
64 
65  if(ikind.eq.0) then
66  do 9 irow=1,nla
67  read(lin)(hrec(i),i=1,nlo)
68  do 8 i=1,nlo
69  hrec(i) = hrec(i)**2
70  8 continue
71  write(lout)(hrec(i),i=1,nlo)
72  9 continue
73 
74  elseif(ikind.eq.1)then
75  do 7 irow=1,nla
76  read(lin) (zrec(i),i=1,nlo)
77  do 6 i=1,nlo
78  zrec(i) = zrec(i)**2
79  6 continue
80  write(lout)(zrec(i),i=1,nlo)
81  7 continue
82 
83  elseif(ikind.eq.-1)then
84  do 10 irow=1,nla
85  read(lin) (srec(i),i=1,nlo)
86  do 11 i=1,nlo
87  srec(i) = srec(i)**2
88  11 continue
89  write(lout)(srec(i),i=1,nlo)
90  10 continue
91 
92  elseif(ikind.eq.2)then
93  do 90 irow=1,nla
94  read(lin) (srec(i),i=1,nlo)
95  do 91 i=1,nlo
96  srec(i) = srec(i)**2
97  91 continue
98  write(lout)(srec(i),i=1,nlo)
99  90 continue
100 
101  else
102  stop 'Bad ikind'
103  endif
104 
105  stop
106  end
program gsqr
Part of the NADCON5 NADCON5 Core Library , Squares values in a *.b grid.
Definition: gsqr.f:26