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