NADCON5-ng  0.0.2
NADCON5 Next Generation Documentation
checkgrid.f
Go to the documentation of this file.
1 c> \ingroup doers
2 c> \if MANPAGE
3 c> \page checkgrid
4 c> \endif
5 c>
6 c> Part of the NADCON5 build process, generates `gmtbat04`
7 c>
8 c> Creates a batch file called
9 c>
10 c> gmtbat04.(olddtm).(newdtm).(region).(igridsec)
11 c>
12 c> This Program:
13 c>
14 c> 1) Compare grids of dlat, dlon and deht
15 c> to vectors of dlat, dlon and deht.
16 c> 2) Spit out interpolated (from grid) vectors
17 c> 3) Spit out differential (interpolated minus original) vectors.
18 c> 4) Create a GMT batch file to plot said vectors.
19 c>
20 c> The input vectors:
21 c>
22 c> Represent *all* (outlier removed)
23 c> vectors of dlat/dlon/deht for the
24 c> olddatum/newdatum/region combination
25 c>
26 c> However, for the sake of understanding, the
27 c> vectors will be read in from their "thinned"
28 c> and "dropped" files, so that we can generate
29 c> statistics of:
30 c>
31 c> thinned-versus-gridded
32 c> dropped-versus-gridded
33 c> all-versus-gridded
34 c>
35 c> This is important, since ONLY the thinned
36 c> vectors went into the grid and it seems
37 c> that their statistics should be better against
38 c> the grid than the dropped vectors. Additionally,
39 c> one might argue that the only independent check
40 c> on the grid is the dropped agreement. We'll see.
41 c>
42 c> The input grids:
43 c>
44 c> dlat/dlon/deht grids based on thinning
45 c> all of the vectors (see above) using
46 c> a median thinning at some block spacing
47 c> in arcseconds, and gridding to that same
48 c> block spacing.
49 c>
50 c> ### Program arguments
51 c> Arguments are newline terminated and read from standard input
52 c>
53 c> They are enumerated here
54 c> \param oldtm Source Datum
55 c> \param newdtm Target Datum,region
56 c> \param region Conversion Region
57 c> \param agridsec Grid Spacing in arcsec
58 c>
59 c> Example:
60 c>
61 c> olddatum = 'ussd'
62 c> newdatum = 'nad27'
63 c> region = 'conus'
64 c> agridsec = '900'
65 c>
66 c> ### Program Inputs:
67 c>
68 c> ## Changelog
69 c>
70 c> ### 2016 08 26:
71 c> Changed "getmapbounds" to bring in a better way
72 c> of computing the reference vector location and added a new
73 c> variable for its label
74 c>
75 c> Also changing the call to "getmapbounds" to give it "olddatum" and "newdatum"
76 c> to aide in filtering out things like the Saint regions in Alaska
77 c> for unsupported transformations.
78 c>
79 c> ### 2016 07 29:
80 c> Scrapped personal placement of vectors and just let them
81 c> sit outside/below the map
82 c>
83 c> ### 2016 07 21:
84 c> Added code to allow for optional placement of reference vectors, coming from
85 c> "map.parameters" as read in subroutine "getmapbounds"
86 c>
87 c> ### 2015 10 08:
88 c> Added HOR output in M and S for Lat/Lon to both "gi" and "dd" vector output.
89 c>
90 c> Combined: v(m/s)(a/t/d)(gi/dd)lat...
91 c> v(m/s)(a/t/d)(gi/dd)lon...
92 c> into : v(m/s)(a/t/d)(gi/dd)hor...
93 c>
94 c>
95 c> ### 2015 9 10:
96 c> Initial Release
97 c> For use in creating NADCON5
98 c> Built by Dru Smith
99 c>
100  program checkgrid
101  implicit real*8(a-h,o-z)
102  parameter(maxlat=5000,maxlon=5000,maxpts=300000)
103  parameter(maxplots=60)
104 
105  character*10 olddtm,newdtm,region
106 c - Grid spacing, converted to characters for file names
107 c - Presumes:
108 c - 1) igridsec is an integer
109 c - 2) 1 <= igridsec <= 99999
110  integer*4 igridsec
111  character*5 agridsec
112  character*1 mapflag
113  character*200 suffix1,suffix2,suffix3
114  character*200 suffix2t04
115  character*200 gmtfile
116  character*3 ele(7),el0(7)
117 
118 c - GMT stuff
119  real*8 bw(maxplots),be(maxplots),bs(maxplots),bn(maxplots)
120  real*4 jm(maxplots)
121  real*4 b1(maxplots),b2(maxplots)
122  character*10 fn(maxplots)
123  character*200 gfn
124  real*8 lorvopc
125  real*8 lorvog(7),lorvoggi(7)
126  real*8 scaledd(7),scalegi(7)
127  real*8 basedd(7),basegi(7)
128  real*8 lorvogprime,lorvogmeters
129  real*8 lorvogprimegi,lorvogmetersgi
130  real*8 lorvoghorgis,lorvoghorgim
131  real*8 lorvoghordds,lorvoghorddm
132 
133 c - 2016 07 21:
134  logical lrv(maxplots)
135  real*8 rv0x(maxplots),rv0y(maxplots),rl0y(maxplots)
136 
137 c - Input original THINNED vectors (outliers must be
138 c - removed)
139  character*200 gfnvmtcdlat,gfnvstcdlat
140  character*200 gfnvmtcdlon,gfnvstcdlon
141  character*200 gfnvmtcdeht
142  character*200 gfnvmtcdhor,gfnvstcdhor
143 c - Input original DROPPED vectors (outliers must be
144 c - removed)
145  character*200 gfnvmdcdlat,gfnvsdcdlat
146  character*200 gfnvmdcdlon,gfnvsdcdlon
147  character*200 gfnvmdcdeht
148  character*200 gfnvmdcdhor,gfnvsdcdhor
149 c - Input ".b" files created from the thinned vectors
150  character*200 bfnvmtcdlat,bfnvstcdlat
151  character*200 bfnvmtcdlon,bfnvstcdlon
152  character*200 bfnvmtcdeht
153 
154 c - Logical arguments to tell me if there are no values in files
155  logical*1 nothinlat,nothinlon,nothineht
156 
157 c - Output grid-interpolated coordinate difference vector files:
158 c - For the sake of completeness, we'll create grid-interpolated vectors
159 c - for all of these combinations in meters (thus 15 files):
160 c - thin, drop, all
161 c - by
162 c - lat(m),lat(s),lon(m),lon(s),eht(m)
163  character*200 gfnvmagilat,gfnvmtgilat,gfnvmdgilat
164  character*200 gfnvsagilat,gfnvstgilat,gfnvsdgilat
165  character*200 gfnvmagilon,gfnvmtgilon,gfnvmdgilon
166  character*200 gfnvsagilon,gfnvstgilon,gfnvsdgilon
167  character*200 gfnvmagieht,gfnvmtgieht,gfnvmdgieht
168 c - Added 2015 10 08
169  character*200 gfnvmagihor,gfnvmtgihor,gfnvmdgihor
170  character*200 gfnvsagihor,gfnvstgihor,gfnvsdgihor
171 
172 c - Output double differenced (differences of coordinate differences,
173 c - aka DDlat, DDlon or DDeht) GMT-ready files:
174 c
175 c - For the sake of completeness, we'll create differential vectors
176 c - for all of these combinations in meters (thus 15 files):
177 c - thin, drop, all
178 c - by
179 c - lat(m),lat(s),lon(m),lon(s),eht(m)
180 c -
181 
182 c - Stats will be generated for thin, drop or all.
183 c - We will create a batch file to plot thin, drop or all.
184 
185 c - Naming scheme is:
186 
187 c - 1-2: "vm" or "vs" for "vectors in meters" or "vectos in arcseconds"
188 c - 3: "a","t","d" or "r" for All, Thinned, Dropped or RMS'd
189 c - 4-5: "cd" or "gi" or "dd" for Coordinate Differences, Grid-Interpolated coordinate differences, or Double Differences
190 c - 6-8: "lat", "lon" or "eht"
191 
192 c - Thus, by way of example:
193 c - vmacdlat = Vectors in meters, All Coordinate Differences, Latitude
194 c - vmagilat = Vectors in meters, All Grid-Interpolated coordinate differences, Latitude
195 c - and their difference would be:
196 c - vmaddlat = Vectors in meters, Double Differences (Grid minus original), Latitude
197 c
198 c - Other examples, in general:
199 c - vstcdlon = Vectors in arcseconds, Thinned Coordinate Differences, Longitude
200 c - vmrddeht = Vectors in meters, RMS'd Double Differences, Ellipsoid Height (not used in this program)
201 c -
202 c - On the use of RMS: The RMS'd values only are applied to Double Differences
203 c - (that is, Differences of Coordinate Differences). As such, we should
204 c - not see an "r" in the 3rd position of the file name without "dd" in
205 c - positions 4-5. These Double Differenes represent the difference
206 c - between a Coordinate Difference interpolated off the GRID and a Coordinate
207 c - Difference directly computed from input data (aka "vectors").
208 c - The RMS'd data is compiled from ALL vectors compared against the
209 c - GRID, not just thinned vectors (which were used to MAKE the grid).
210 c - Doing it only on "thinned" causes overly optimistic statistics, while
211 c - doing it only on "dropped" ignores the fact that the thinned
212 c - and dropped vectors are both in the public domain and used by
213 c - the public.)
214 
215 c - Note, the "dropped" and "thinned" refer to those categories established
216 c - way back in "mymedian5.f", under doit3.bat.
217 
218 
219 c - Output double differenced vector files (all/thinned/dropped):
220  character*200 gfnvmaddlat,gfnvmtddlat,gfnvmdddlat
221  character*200 gfnvsaddlat,gfnvstddlat,gfnvsdddlat
222  character*200 gfnvmaddlon,gfnvmtddlon,gfnvmdddlon
223  character*200 gfnvsaddlon,gfnvstddlon,gfnvsdddlon
224  character*200 gfnvmaddeht,gfnvmtddeht,gfnvmdddeht
225 c - Added 2015 10 08
226  character*200 gfnvmaddhor,gfnvmtddhor,gfnvmdddhor
227  character*200 gfnvsaddhor,gfnvstddhor,gfnvsdddhor
228 
229 c - Stats file name
230  character*200 sfn
231 
232 c - The gridded data
233  real*8 glamn,glomn,dla,dlo
234  integer*4 nla,nlo,ikind
235  real*4 datlats(maxlat,maxlon)
236  real*4 datlons(maxlat,maxlon)
237  real*4 datehtm(maxlat,maxlon)
238 
239 c - The vector data
240  character*80 card
241 
242 c - All statistical data
243 c i,j,k,l:
244  real*8 stat(5,5,3,3)
245 c j,k:
246  integer*4 kstat(5,3)
247 c j:
248  character*20 units(5)
249 
250 c - stat(i,j,k,l) :
251 c - kstat(j,k) :
252 c
253 c i = 1 => Average
254 c i = 2 => RMS
255 c i = 3 => Min
256 c i = 4 => Max
257 c i = 5 => Standard Deviation
258 c
259 c j = 1 => LAT, arcseconds
260 c j = 2 => LON, arcseconds
261 c j = 3 => EHT, meters
262 c j = 4 => LAT, meters
263 c j = 4 => LON, meters
264 c
265 c k = 1 => Thinned vectors
266 c k = 2 => Dropped vectors
267 c k = 3 => All vectors
268 c
269 c l = 1 => Bilinear Interpolation
270 c l = 2 => Biquadratic Interpolation
271 c l = 3 => Not currently used
272 
273 c l:
274  real*8 vgrd(3),vgrdm(3),dd(3),ddm(3)
275 
276  character*4 type(3)
277 c - Note that "dd" means arcsec/arcsec/meters for lat/lon/eht
278 c - while "ddm" means meters/meters/meters for lat/lon/eht
279 
280  character*20 coord(3)
281 
282  real*8 fac(3,3)
283 
284 c - The output data
285  real*8 xla0(maxpts),xlo0(maxpts)
286  real*8 dd0(maxpts),ddm0(maxpts),gi0(maxpts),gim0(maxpts)
287  character*6 pid0(maxpts)
288 
289 c --------------------------------------
290 c --------------------------------------
291 c --------------------------------------
292 c -------BEGIN GUTS OF PROGRAM----------
293 c --------------------------------------
294 c --------------------------------------
295 c --------------------------------------
296  write(6,1001)
297  1001 format('BEGIN program checkgrid.f')
298 
299 c ------------------------------------------------------------------
300 c - Some required constants.
301 c ------------------------------------------------------------------
302 c - Length of Reference Vector on Paper, in CM (lorvopc). Depends
303 c - on having the "MEASURE_UNITS" in .gmtdefaults set to "cm"
304  lorvopc = 1.d0
305  pi = 2.d0*dasin(1.d0)
306  d2r = pi/180.d0
307  re = 6371000.d0
308  s2m = (1.d0/3600.d0)*d2r*re
309  multiplierlorvog = 2
310 
311  coord(1) = 'LATITUDE'
312  coord(2) = 'LONGITUDE'
313  coord(3) = 'ELLIPSOID HEIGHT'
314 
315  units(1) = 'arcseconds'
316  units(2) = 'arcseconds'
317  units(3) = 'meters'
318  units(4) = 'meters'
319  units(5) = 'meters'
320 
321 c ------------------------------------------------------------------
322 c - Read in arguments from batch file
323 c ------------------------------------------------------------------
324  read(5,'(a)')olddtm
325  read(5,'(a)')newdtm
326  read(5,'(a)')region
327  read(5,'(a)')agridsec
328  read(5,'(a)')mapflag
329 
330 c ------------------------------------------------------------------
331 c - Generate the suffixes used in all our files
332 c ------------------------------------------------------------------
333  read(agridsec,*)igridsec
334  suffix1=trim(olddtm)//'.'//trim(newdtm)//'.'//trim(region)
335  suffix2=trim(suffix1)//'.'//trim(agridsec)
336 
337  suffix2t04=trim(suffix2)//'.04'
338 
339  suffix3=trim(suffix2)//'.'//trim(mapflag)
340 
341 c ------------------------------------------------------------------
342 c - Open the input, thinned, GMT-ready files
343 c - "t" meaning "thinned". Briefly snoop the
344 c - first line of each file. If it is empty,
345 c - then skip using that particular component.
346 c ------------------------------------------------------------------
347 
348 c - Always maintain THIS order:
349 c - Lat/Seconds 1
350 c - Lon/Seconds 2
351 c - Eht/Meters 3
352 c - (Hor/Seconds 4)
353 c - (Hor/Meters 5)
354 c - Lat/Meters 6
355 c - Lon/Meters 7
356 
357  gfnvstcdlat = 'vstcdlat.'//trim(suffix2)
358  open(21,file=gfnvstcdlat,status='old',form='formatted')
359  write(6,1012)trim(gfnvstcdlat)
360 
361  gfnvstcdlon = 'vstcdlon.'//trim(suffix2)
362  open(22,file=gfnvstcdlon,status='old',form='formatted')
363  write(6,1012)trim(gfnvstcdlon)
364 
365  gfnvmtcdeht = 'vmtcdeht.'//trim(suffix2)
366  open(23,file=gfnvmtcdeht,status='old',form='formatted')
367  write(6,1012)trim(gfnvmtcdeht)
368 
369  gfnvmtcdlat = 'vmtcdlat.'//trim(suffix2)
370  open(26,file=gfnvmtcdlat,status='old',form='formatted')
371  write(6,1012)trim(gfnvmtcdlat)
372 
373  gfnvmtcdlon = 'vmtcdlon.'//trim(suffix2)
374  open(27,file=gfnvmtcdlon,status='old',form='formatted')
375  write(6,1012)trim(gfnvmtcdlon)
376 
377 
378 c - Note: "nothinlat" means there were no thinned lat vectors,
379 c - and thus no ".b" grid made from thinned vectors. As such,
380 c - anything having to do with latitude grids is skipped.
381 c - Same for lon or eht.
382  call nlines(21,nthinlat,nothinlat)
383  call nlines(22,nthinlon,nothinlon)
384  call nlines(23,nthineht,nothineht)
385 c - No need to do this for files 26/27 as the parallel 21 and 22
386 
387  1012 format(6x,'checkgrid.f: ',
388  *'Opening input thinned vector file ',a)
389 
390 c ------------------------------------------------------------------
391 c - Open the input, dropped, GMT-ready files
392 c - "d" meaning "dropped"
393 c ------------------------------------------------------------------
394  gfnvsdcdlat = 'vsdcdlat.'//trim(suffix2)
395  open(31,file=gfnvsdcdlat,status='old',form='formatted')
396  write(6,1013)trim(gfnvsdcdlat)
397 
398  gfnvsdcdlon = 'vsdcdlon.'//trim(suffix2)
399  open(32,file=gfnvsdcdlon,status='old',form='formatted')
400  write(6,1013)trim(gfnvsdcdlon)
401 
402  gfnvmdcdeht = 'vmdcdeht.'//trim(suffix2)
403  open(33,file=gfnvmdcdeht,status='old',form='formatted')
404  write(6,1013)trim(gfnvmdcdeht)
405 
406  gfnvmdcdlat = 'vmdcdlat.'//trim(suffix2)
407  open(36,file=gfnvmdcdlat,status='old',form='formatted')
408  write(6,1013)trim(gfnvmdcdlat)
409 
410  gfnvmdcdlon = 'vmdcdlon.'//trim(suffix2)
411  open(37,file=gfnvmdcdlon,status='old',form='formatted')
412  write(6,1013)trim(gfnvmdcdlon)
413 
414  1013 format(6x,'checkgrid.f: ',
415  *'Opening input dropped vector file ',a)
416 
417 c ------------------------------------------------------------------
418 c - Open the input, gridded-from-thinned .b files. If the
419 c - thinned vector file is empty, skip trying to open the
420 c - related ".b" file.
421 c ------------------------------------------------------------------
422  if(.not.nothinlat)then
423  bfnvstcdlat = 'vstcdlat.'//trim(suffix2t04)//'.b'
424  open(11,file=bfnvstcdlat,status='old',form='unformatted')
425  write(6,1015)trim(bfnvstcdlat)
426 
427  bfnvmtcdlat = 'vmtcdlat.'//trim(suffix2t04)//'.b'
428  open(16,file=bfnvmtcdlat,status='old',form='unformatted')
429  write(6,1015)trim(bfnvmtcdlat)
430  endif
431 
432  if(.not.nothinlon)then
433  bfnvstcdlon = 'vstcdlon.'//trim(suffix2t04)//'.b'
434  open(12,file=bfnvstcdlon,status='old',form='unformatted')
435  write(6,1015)trim(bfnvstcdlon)
436 
437  bfnvmtcdlon = 'vmtcdlon.'//trim(suffix2t04)//'.b'
438  open(17,file=bfnvmtcdlon,status='old',form='unformatted')
439  write(6,1015)trim(bfnvmtcdlon)
440  endif
441 
442  if(.not.nothineht)then
443  bfnvmtcdeht = 'vmtcdeht.'//trim(suffix2t04)//'.b'
444  open(13,file=bfnvmtcdeht,status='old',form='unformatted')
445  write(6,1015)trim(bfnvmtcdeht)
446  endif
447 
448  1015 format(6x,'checkgrid.f: ',
449  *'Opening input grid file ',a)
450 
451 c ------------------------------------------------------------------
452 c - Open the output, interpolated-from-grid coordinate difference
453 c - vector files, GMT-ready for plotting.
454 c - If the input thinned vector file is empty (aka there is
455 c - no grid), skip
456 c ------------------------------------------------------------------
457  if(.not.nothinlat)then
458  gfnvsagilat = 'vsagilat.'//trim(suffix2)
459  open(91,file=gfnvsagilat,status='new',form='formatted')
460  write(6,1017)'lat',trim(gfnvsagilat)
461 
462  gfnvmagilat = 'vmagilat.'//trim(suffix2)
463  open(96,file=gfnvmagilat,status='new',form='formatted')
464  write(6,1017)'lat',trim(gfnvmagilat)
465 
466  gfnvstgilat = 'vstgilat.'//trim(suffix2)
467  open(71,file=gfnvstgilat,status='new',form='formatted')
468  write(6,1017)'lat',trim(gfnvstgilat)
469 
470  gfnvmtgilat = 'vmtgilat.'//trim(suffix2)
471  open(76,file=gfnvmtgilat,status='new',form='formatted')
472  write(6,1017)'lat',trim(gfnvmtgilat)
473 
474  gfnvsdgilat = 'vsdgilat.'//trim(suffix2)
475  open(81,file=gfnvsdgilat,status='new',form='formatted')
476  write(6,1017)'lat',trim(gfnvsdgilat)
477 
478  gfnvmdgilat = 'vmdgilat.'//trim(suffix2)
479  open(86,file=gfnvmdgilat,status='new',form='formatted')
480  write(6,1017)'lat',trim(gfnvmdgilat)
481  endif
482 
483 
484 
485  if(.not.nothinlon)then
486  gfnvsagilon = 'vsagilon.'//trim(suffix2)
487  open(92,file=gfnvsagilon,status='new',form='formatted')
488  write(6,1017)'lon',trim(gfnvsagilon)
489 
490  gfnvmagilon = 'vmagilon.'//trim(suffix2)
491  open(97,file=gfnvmagilon,status='new',form='formatted')
492  write(6,1017)'lon',trim(gfnvmagilon)
493 
494  gfnvstgilon = 'vstgilon.'//trim(suffix2)
495  open(72,file=gfnvstgilon,status='new',form='formatted')
496  write(6,1017)'lon',trim(gfnvstgilon)
497 
498  gfnvmtgilon = 'vmtgilon.'//trim(suffix2)
499  open(77,file=gfnvmtgilon,status='new',form='formatted')
500  write(6,1017)'lon',trim(gfnvmtgilon)
501 
502  gfnvsdgilon = 'vsdgilon.'//trim(suffix2)
503  open(82,file=gfnvsdgilon,status='new',form='formatted')
504  write(6,1017)'lon',trim(gfnvsdgilon)
505 
506  gfnvmdgilon = 'vmdgilon.'//trim(suffix2)
507  open(87,file=gfnvmdgilon,status='new',form='formatted')
508  write(6,1017)'lon',trim(gfnvmdgilon)
509  endif
510 
511 
512 
513  if(.not.nothineht)then
514  gfnvmagieht = 'vmagieht.'//trim(suffix2)
515  open(93,file=gfnvmagieht,status='new',form='formatted')
516  write(6,1017)'eht',trim(gfnvmagieht)
517 
518  gfnvmtgieht = 'vmtgieht.'//trim(suffix2)
519  open(73,file=gfnvmtgieht,status='new',form='formatted')
520  write(6,1017)'eht',trim(gfnvmtgieht)
521 
522  gfnvmdgieht = 'vmdgieht.'//trim(suffix2)
523  open(83,file=gfnvmdgieht,status='new',form='formatted')
524  write(6,1017)'eht',trim(gfnvmdgieht)
525  endif
526 
527 c - Added 2015 10 08
528 
529  if(.not.nothinlat .and. .not.nothinlon)then
530  gfnvsagihor = 'vsagihor.'//trim(suffix2)
531  open(94,file=gfnvsagihor,status='new',form='formatted')
532  write(6,1017)'hor',trim(gfnvsagihor)
533 
534  gfnvmagihor = 'vmagihor.'//trim(suffix2)
535  open(95,file=gfnvmagihor,status='new',form='formatted')
536  write(6,1017)'hor',trim(gfnvmagihor)
537 
538  gfnvstgihor = 'vstgihor.'//trim(suffix2)
539  open(74,file=gfnvstgihor,status='new',form='formatted')
540  write(6,1017)'hor',trim(gfnvstgihor)
541 
542  gfnvmtgihor = 'vmtgihor.'//trim(suffix2)
543  open(75,file=gfnvmtgihor,status='new',form='formatted')
544  write(6,1017)'hor',trim(gfnvmtgihor)
545 
546  gfnvsdgihor = 'vsdgihor.'//trim(suffix2)
547  open(84,file=gfnvsdgihor,status='new',form='formatted')
548  write(6,1017)'hor',trim(gfnvsdgihor)
549 
550  gfnvmdgihor = 'vmdgihor.'//trim(suffix2)
551  open(85,file=gfnvmdgihor,status='new',form='formatted')
552  write(6,1017)'hor',trim(gfnvmdgihor)
553  endif
554 
555  1017 format(6x,'checkgrid.f: ',
556  *'Opening output grid-interpolated ',a,' vector file :',a)
557 
558 c ------------------------------------------------------------------
559 c - Open the output, differential, GMT-ready files for
560 c - plotting. THINNED. If the input thinned vector file
561 c - is empty, skip
562 c ------------------------------------------------------------------
563  if(.not.nothinlat)then
564  gfnvstddlat = 'vstddlat.'//trim(suffix2)
565  open(41,file=gfnvstddlat,status='new',form='formatted')
566  write(6,1014)'lat',trim(gfnvstddlat)
567 
568  gfnvmtddlat = 'vmtddlat.'//trim(suffix2)
569  open(46,file=gfnvmtddlat,status='new',form='formatted')
570  write(6,1014)'lat',trim(gfnvmtddlat)
571  endif
572 
573  if(.not.nothinlon)then
574  gfnvstddlon = 'vstddlon.'//trim(suffix2)
575  open(42,file=gfnvstddlon,status='new',form='formatted')
576  write(6,1014)'lon',trim(gfnvstddlon)
577 
578  gfnvmtddlon = 'vmtddlon.'//trim(suffix2)
579  open(47,file=gfnvmtddlon,status='new',form='formatted')
580  write(6,1014)'lon',trim(gfnvmtddlon)
581  endif
582 
583  if(.not.nothineht)then
584  gfnvmtddeht = 'vmtddeht.'//trim(suffix2)
585  open(43,file=gfnvmtddeht,status='new',form='formatted')
586  write(6,1014)'eht',trim(gfnvmtddeht)
587  endif
588 
589  if(.not.nothinlon .and. .not.nothinlat)then
590  gfnvstddhor = 'vstddhor.'//trim(suffix2)
591  open(44,file=gfnvstddhor,status='new',form='formatted')
592  write(6,1014)'hor',trim(gfnvstddhor)
593 
594  gfnvmtddhor = 'vmtddhor.'//trim(suffix2)
595  open(45,file=gfnvmtddhor,status='new',form='formatted')
596  write(6,1014)'hor',trim(gfnvmtddhor)
597  endif
598 
599 c ------------------------------------------------------------------
600 c - Open the output, differential, GMT-ready files for
601 c - plotting. DROPPED.
602 c ------------------------------------------------------------------
603  if(.not.nothinlat)then
604  gfnvsdddlat = 'vsdddlat.'//trim(suffix2)
605  open(51,file=gfnvsdddlat,status='new',form='formatted')
606  write(6,1014)'lat',trim(gfnvsdddlat)
607 
608  gfnvmdddlat = 'vmdddlat.'//trim(suffix2)
609  open(56,file=gfnvmdddlat,status='new',form='formatted')
610  write(6,1014)'lat',trim(gfnvmdddlat)
611  endif
612 
613  if(.not.nothinlon)then
614  gfnvsdddlon = 'vsdddlon.'//trim(suffix2)
615  open(52,file=gfnvsdddlon,status='new',form='formatted')
616  write(6,1014)'lon',trim(gfnvsdddlon)
617 
618  gfnvmdddlon = 'vmdddlon.'//trim(suffix2)
619  open(57,file=gfnvmdddlon,status='new',form='formatted')
620  write(6,1014)'lon',trim(gfnvmdddlon)
621  endif
622 
623  if(.not.nothineht)then
624  gfnvmdddeht = 'vmdddeht.'//trim(suffix2)
625  open(53,file=gfnvmdddeht,status='new',form='formatted')
626  write(6,1014)'eht',trim(gfnvmdddeht)
627  endif
628 
629  if(.not.nothinlat .and. .not.nothinlon)then
630  gfnvsdddhor = 'vsdddhor.'//trim(suffix2)
631  open(54,file=gfnvsdddhor,status='new',form='formatted')
632  write(6,1014)'hor',trim(gfnvsdddhor)
633 
634  gfnvmdddhor = 'vmdddhor.'//trim(suffix2)
635  open(55,file=gfnvmdddhor,status='new',form='formatted')
636  write(6,1014)'hor',trim(gfnvmdddhor)
637  endif
638 
639 c ------------------------------------------------------------------
640 c - Open the output, differential, GMT-ready files for
641 c - plotting. ALL.
642 c ------------------------------------------------------------------
643  if(.not.nothinlat)then
644  gfnvsaddlat = 'vsaddlat.'//trim(suffix2)
645  open(61,file=gfnvsaddlat,status='new',form='formatted')
646  write(6,1014)'lat',trim(gfnvsaddlat)
647 
648  gfnvmaddlat = 'vmaddlat.'//trim(suffix2)
649  open(66,file=gfnvmaddlat,status='new',form='formatted')
650  write(6,1014)'lat',trim(gfnvmaddlat)
651  endif
652 
653  if(.not.nothinlon)then
654  gfnvsaddlon = 'vsaddlon.'//trim(suffix2)
655  open(62,file=gfnvsaddlon,status='new',form='formatted')
656  write(6,1014)'lon',trim(gfnvsaddlon)
657 
658  gfnvmaddlon = 'vmaddlon.'//trim(suffix2)
659  open(67,file=gfnvmaddlon,status='new',form='formatted')
660  write(6,1014)'lon',trim(gfnvmaddlon)
661  endif
662 
663  if(.not.nothineht)then
664  gfnvmaddeht = 'vmaddeht.'//trim(suffix2)
665  open(63,file=gfnvmaddeht,status='new',form='formatted')
666  write(6,1014)'eht',trim(gfnvmaddeht)
667  endif
668 
669  if(.not.nothinlat .and. .not.nothinlon)then
670  gfnvsaddhor = 'vsaddhor.'//trim(suffix2)
671  open(64,file=gfnvsaddhor,status='new',form='formatted')
672  write(6,1014)'hor',trim(gfnvsaddhor)
673 
674  gfnvmaddhor = 'vmaddhor.'//trim(suffix2)
675  open(65,file=gfnvmaddhor,status='new',form='formatted')
676  write(6,1014)'hor',trim(gfnvmaddhor)
677  endif
678 
679  1014 format(6x,'checkgrid.f: ',
680  *'Opening output differential ',a,' vector file :',a)
681 
682 c ------------------------------------------------------------------
683 c - Each region has officially chosen boundaries (which may
684 c - or may not agree with the MAP boundaries). Get the
685 c - official grid boundaries here. See DRU-11, p. 126
686 c ------------------------------------------------------------------
687  call getgridbounds(region,glamx,glamn,glomn,glomx)
688 
689  write(6,1004)trim(region),glamn,glamx,glomn,glomx
690  1004 format(6x,'checkgrid.f: Region= ',a,/,
691  * 6x,'checkgrid.f: North = ',f12.6,/,
692  * 6x,'checkgrid.f: South = ',f12.6,/,
693  * 6x,'checkgrid.f: West = ',f12.6,/,
694  * 6x,'checkgrid.f: East = ',f12.6)
695 
696  write(6,8002)
697  8002 format(50('*'),/,
698  *6x,'checkgrid.f: BEGIN STATISTICAL REPORT ',
699  *'(grid minus true vector diffs)')
700 
701 c -------------------------------------------------------
702 c - Read the ".b" grids into RAM
703 c -
704 c - See DRU-11, p. 140 for the following philosophy:
705 c
706 c Because the final grids in lat/lon will ONLY be
707 c in arcseconds, all statistics should be about
708 c arcseconds, with CONVERSION to meters on the fly,
709 c and NOT about meter vectors compared to meter grids.
710 c -------------------------------------------------------
711  do 1 i=1,3
712 
713  if(i.eq.1 .and. nothinlat)goto 1
714  if(i.eq.2 .and. nothinlon)goto 1
715  if(i.eq.3 .and. nothineht)goto 1
716 
717  ifil = 10+i
718  read(ifil)glamn,glomn,dla,dlo,nla,nlo,ikind
719  do 2 j=1,nla
720  if(i.eq.1)read(ifil)(datlats(j,k),k=1,nlo)
721  if(i.eq.2)read(ifil)(datlons(j,k),k=1,nlo)
722  if(i.eq.3)read(ifil)(datehtm(j,k),k=1,nlo)
723 
724  2 continue
725  1 continue
726  glamx = glamn + (nla-1)*dla
727  glomx = glomn + (nlo-1)*dlo
728 
729 c -------------------------------------------------------
730 c - Go through the vectors. Do lat first, then lon,
731 c - then eht. Compute DDlat, DDlon and DDeht.
732 c - Compute region-wide statistics for:
733 c - thinned-versus-gridded
734 c - dropped-versus-gridded
735 c - all-versus-gridded
736 c - Spit out the grid interpolated lat/lon/eht values,
737 c - as well as the double differences:
738 c - Spit out the DDlat, DDlon and DDeht values to
739 c - output files, for either thinned, dropped or all.
740 c -------------------------------------------------------
741 
742 c - stat(i,j,k,l) :
743 c - kstat(j,k) :
744 c
745 c i = 1 => Average
746 c i = 2 => RMS
747 c i = 3 => Min
748 c i = 4 => Max
749 c i = 5 => Standard Deviation
750 c
751 c j = 1 => LAT, arcseconds
752 c j = 2 => LON, arcseconds
753 c j = 3 => EHT, meters
754 c j = 4 => LAT, meters <- Computed by converting from arcseconds
755 c j = 4 => LON, meters <- Computed by converting from arcseconds
756 c
757 c k = 1 => Thinned vectors
758 c k = 2 => Dropped vectors
759 c k = 3 => All vectors
760 c
761 c l = 1 => Bilinear Interpolation
762 c l = 2 => Biquadratic Interpolation
763 c l = 3 => Bicubic Spline Interpolation
764 
765 c - Zero stats
766  do 3002 i=1,5
767 c do 3003 j=1,3
768  do 3003 j=1,5
769  do 3004 k=1,3
770  kstat(j,k) = 0
771  do 3005 l=1,3
772  stat(i,j,k,l) = 0.d0
773  if(i.eq.3)stat(i,j,k,l) = 99999.d0
774  if(i.eq.4)stat(i,j,k,l) =-99999.d0
775  3005 continue
776  3004 continue
777  3003 continue
778  3002 continue
779 
780  type(1) = 'THIN'
781  type(2) = 'DROP'
782  type(3) = 'ALL '
783 
784 
785 c -------------------------------------------------------------
786 c -------------------------------------------------------------
787 c -------------------------------------------------------------
788 c - MAIN LOOP
789 c -------------------------------------------------------------
790 c -------------------------------------------------------------
791 c -------------------------------------------------------------
792 
793 c In the loops below, for j,k=
794 c 1,1 = Lat(s)/Thinned
795 c 1,2 = Lat(s)/Dropped
796 c 2,1 = Lon(s)/Thinned
797 c 2,2 = Lon(s)/Dropped
798 c 3,1 = Eht(s)/Thinned
799 c 1,2 = Eht(s)/Dropped
800 
801 c - j=4 and 5, being Lat(m) and Lon(m) will be converted ON THE FLY
802 c - from j=1 and 2 values.
803 c 4,1 = Lat(s)/Thinned
804 c 4,2 = Lat(s)/Dropped
805 c 5,1 = Lon(s)/Thinned
806 c 5,2 = Lon(s)/Dropped
807 
808  do 2001 j=1,3
809 
810  avegiprime = 0.d0
811  avegimeter = 0.d0
812 
813  if(j.eq.1 .and. nothinlat)goto 2001
814  if(j.eq.2 .and. nothinlon)goto 2001
815  if(j.eq.3 .and. nothineht)goto 2001
816 
817 c - Now spin over thinned, then dropped vectors
818  itot = 0
819 
820  do 2002 k=1,2
821  if(k.eq.1)ifile = 20+j ! Thinned Vectors
822  if(k.eq.2)ifile = 30+j ! Dropped Vectors
823 
824  iread = 0
825  igood = 0
826  101 read(ifile,'(a)',end=103)card
827  iread = iread + 1
828 
829 c - CRITICAL, pull true values of ARCSECONDS for lat/lon
830 c - but METERS for eht
831  if(j.eq.1 .or. j.eq.2)read(card, 102)xlo,xla,vvec
832  if(j.eq.3 )read(card,1102)xlo,xla,vvec
833 
834 c - This shouldn't happen, but in case a vector
835 c - is not inside the grid, skip it
836  if(xla.gt.glamx .or. xla.lt.glamn .or.
837  * xlo.gt.glomx .or. xlo.lt.glomn)then
838  goto 101
839  endif
840  igood = igood + 1
841  itot = itot + 1
842 
843 c - Hold the lat, lon and PID in RAM until its time to
844 c - spit them out.
845  xla0(itot) = xla
846  xlo0(itot) = xlo
847  pid0(itot) = card(74:79)
848 
849 c - Do the interpolations
850 c - "vgrd()" stores sec/sec/met for lat/lon/eht
851 c - "vgrdm()" stores meters for everything
852 
853 c - Bilinear to get vgrd(1)
854  if(j.eq.1)call bilin(datlats,glamn,glomn,dla,dlo,
855  * nla,nlo,maxlat,maxlon,xla,xlo,vgrd(1))
856  if(j.eq.2)call bilin(datlons,glamn,glomn,dla,dlo,
857  * nla,nlo,maxlat,maxlon,xla,xlo,vgrd(1))
858  if(j.eq.3)call bilin(datehtm,glamn,glomn,dla,dlo,
859  * nla,nlo,maxlat,maxlon,xla,xlo,vgrd(1))
860 
861 c - Biquadratic to get vgrd(2)
862  if(j.eq.1)call biquad(datlats,glamn,glomn,dla,dlo,
863  * nla,nlo,maxlat,maxlon,xla,xlo,vgrd(2))
864  if(j.eq.2)call biquad(datlons,glamn,glomn,dla,dlo,
865  * nla,nlo,maxlat,maxlon,xla,xlo,vgrd(2))
866  if(j.eq.3)call biquad(datehtm,glamn,glomn,dla,dlo,
867  * nla,nlo,maxlat,maxlon,xla,xlo,vgrd(2))
868 
869 c - Biquadratic to get vgrd(2)
870  if(j.eq.1)call bicubic(datlats,glamn,glomn,dla,dlo,
871  * nla,nlo,maxlat,maxlon,xla,xlo,vgrd(3))
872  if(j.eq.2)call bicubic(datlons,glamn,glomn,dla,dlo,
873  * nla,nlo,maxlat,maxlon,xla,xlo,vgrd(3))
874  if(j.eq.3)call bicubic(datehtm,glamn,glomn,dla,dlo,
875  * nla,nlo,maxlat,maxlon,xla,xlo,vgrd(3))
876 
877 c - Differences grd minus true (lat, lon in arcseconds; eht in meters)
878  do 808 l = 1,3
879  dd(l) = vgrd(l) - vvec
880 
881 c - Convert seconds to meters but don't lose the seconds either
882  if(j.eq.1)then
883  vgrdm(l) = vgrd(l) * s2m
884  ddm(l) = dd(l) * s2m
885  elseif(j.eq.2)then
886  coslat = dcos(xla*d2r)
887  vgrdm(l) = vgrd(l) * s2m * coslat
888  ddm(l) = dd(l) * s2m * coslat
889  else
890  vgrdm(l) = vgrd(l)
891  ddm(l) = dd(l)
892  endif
893 
894 c*********************************************************
895 c - ALL *STATISTICS* in their primary units
896 c - (arcsec for lat/lon, meters for eht), but then
897 c - converted to meters/meters for lat/lon after the
898 c - fact.
899 c - will be in arcseconds or meters appropriately.
900 c - These stats are all for DOUBLE DIFFERENCES
901 c
902 c - However, I do need to tally the average absolute
903 c - values of lat(sec), lat(m), lon(sec), lon(m) and eht(m) of
904 c - grid-interpolated vectors so I can scale their vector
905 c - plots correctly. We'll hack that into here...
906 c*********************************************************
907 
908 c - k=1,2 = thin/drop; k=3 = all
909 c - j=1,2,3 for lat-sec,lon-sec,eht-met
910 c - j=4,5 for lat-met, lon-met
911 
912 c - Tally average
913  stat(1,j,k,l) = stat(1,j,k,l) + dd(l)
914  stat(1,j,3,l) = stat(1,j,3,l) + dd(l)
915  if(j.lt.3)then
916  stat(1,j+3,k,l) = stat(1,j+3,k,l) + ddm(l)
917  stat(1,j+3,3,l) = stat(1,j+3,3,l) + ddm(l)
918  endif
919 
920 c - Tally RMS:
921  stat(2,j,k,l) = stat(2,j,k,l) + dd(l)**2
922  stat(2,j,3,l) = stat(2,j,3,l) + dd(l)**2
923  if(j.lt.3)then
924  stat(2,j+3,k,l) = stat(2,j+3,k,l) + ddm(l)**2
925  stat(2,j+3,3,l) = stat(2,j+3,3,l) + ddm(l)**2
926  endif
927 c - Tally Min:
928  if(dd(l).lt.stat(3,j,k,l))stat(3,j,k,l)=dd(l)
929  if(dd(l).lt.stat(3,j,3,l))stat(3,j,3,l)=dd(l)
930  if(j.lt.3)then
931  if(ddm(l).lt.stat(3,j+3,k,l))stat(3,j+3,k,l)=ddm(l)
932  if(ddm(l).lt.stat(3,j+3,3,l))stat(3,j+3,3,l)=ddm(l)
933  endif
934 
935 c - Tally Max:
936  if(dd(l).gt.stat(4,j,k,l))stat(4,j,k,l)=dd(l)
937  if(dd(l).gt.stat(4,j,3,l))stat(4,j,3,l)=dd(l)
938  if(j.lt.3)then
939  if(ddm(l).gt.stat(4,j+3,k,l))stat(4,j+3,k,l)=ddm(l)
940  if(ddm(l).gt.stat(4,j+3,3,l))stat(4,j+3,3,l)=ddm(l)
941  endif
942 
943  808 continue
944 
945 c - HACK / CHOICE: For now, use biquadratically interpolated
946 c - data as the official output. Note that
947 c - "dd0" stores ARCSECONDS for lat or lon and METERS for eht
948 c - but "ddm0" stores METERS for everything
949 c dd0(igood) = dd(2)
950 c ddm0(igood) = ddm(2)
951 
952 c - Double Differences:
953  dd0(itot) = dd(2)
954  ddm0(itot) = ddm(2)
955 c - Grid Interpolated:
956  gi0(itot) = vgrd(2)
957  gim0(itot) = vgrdm(2)
958 
959  avegiprime = avegiprime + dabs(gi0(itot))
960  avegimeter = avegimeter + dabs(gim0(itot))
961 
962 c - Tally counts
963 c - Either Thinned or Dropped:
964  kstat(j,k)=kstat(j,k) + 1
965  if(j.lt.3)then
966  kstat(j+3,k)=kstat(j+3,k) + 1
967  endif
968 c - All:
969  kstat(j,3)=kstat(j,3) + 1
970  if(j.lt.3)then
971  kstat(j+3,3)=kstat(j+3,3) + 1
972  endif
973 
974  goto 101
975  103 continue
976 
977  2002 continue
978 
979 c - Double check that the counts of thinned and dropped
980 c - add up to the count for all.
981  kthin = kstat(j,1)
982  kdrop = kstat(j,2)
983  kall = kstat(j,3)
984 c - Won't do this for j=4/5 as they should parallel j=1/2
985 
986  avegiprime = avegiprime / dble(kall)
987  avegimeter = avegimeter / dble(kall)
988 
989 c write(6,*) j,kthin
990 c write(6,*) j,kdrop
991 c write(6,*) j,kall
992  if(kall.ne.kthin+kdrop)then
993  write(6,*) ' Thin+Drop .DNE. All => STOP'
994  stop
995  endif
996  if(itot.ne.kall)then
997  write(6,*) ' itot .DNE. All => STOP'
998  stop
999  endif
1000 
1001 c - Finalize stats for k=1,3 (thin/drop/all)
1002  do 809 k=1,3
1003  fac(j,k) = dble(kstat(j,k))/dble(kstat(j,k)-1)
1004  if(j.lt.3)then
1005  fac(j+3,k) = dble(kstat(j+3,k))/dble(kstat(j+3,k)-1)
1006  endif
1007  do 810 l=1,3
1008  stat(1,j,k,l)=stat(1,j,k,l)/kstat(j,k)
1009  stat(2,j,k,l)=dsqrt(stat(2,j,k,l)/kstat(j,k))
1010  stat(5,j,k,l)=dsqrt(fac(j,k)*
1011  * (stat(2,j,k,l)**2 - stat(1,j,k,l)**2))
1012 
1013  if(j.lt.3)then
1014  stat(1,j+3,k,l)=stat(1,j+3,k,l)/kstat(j+3,k)
1015  stat(2,j+3,k,l)=dsqrt(stat(2,j+3,k,l)/kstat(j+3,k))
1016  stat(5,j+3,k,l)=dsqrt(fac(j+3,k)*
1017  * (stat(2,j+3,k,l)**2 - stat(1,j+3,k,l)**2))
1018  endif
1019 
1020  810 continue
1021  809 continue
1022 
1023 
1024 c -----------------------
1025 c - At this point we've finished collecting statistics for
1026 c - one type of coordinate (lat, lon or eht), and can spit
1027 c - out the data to files.
1028 c -
1029 c - OUTPUT the "vgrd" values to the appropriate VECTOR FILE
1030 c - OUTPUT the "vgrd-vvec" values to the appropriate VECTOR FILE
1031 c -
1032 c - Use the RMS value to compute scales needed for our output vector file.
1033 c - Why not AVE? Because the AVE is expected to be VERY close to zero
1034 c - but RMS better represents overall magnitude of disagreement.
1035 c -----------------------
1036 c
1037 c - 2,j,3,2 = rms , lat-sec/lon-sec/eht-met/lat-met/lon-met , all , biquad, double differenced
1038 c Convert the RMS to cm to go along with all over vector plots heretofore
1039  rms0prime = stat(2,j,3,2)
1040  lorvogprime = onzd2(multiplierlorvog*rms0prime)
1041 c iqprime = floor(log10(rms0prime))
1042 c qqprime = 10.d0**(iqprime )
1043 c lorvogprime = MultiplierLorvog*qqprime*nint(rms0prime/qqprime)
1044 
1045  gprime2pc = lorvopc / lorvogprime
1046  scaledd(j) = gprime2pc
1047  basedd(j) = rms0prime
1048  if(j.lt.3)then
1049  rms0meters = stat(2,j+3,3,2)
1050  lorvogmeters = onzd2(multiplierlorvog*rms0meters)
1051 c iqmeters = floor(log10(rms0meters))
1052 c qqmeters = 10.d0**(iqmeters )
1053 c lorvogmeters = MultiplierLorvog*
1054 c * qqmeters*nint(rms0meters/qqmeters)
1055  gmeters2pc = lorvopc / lorvogmeters
1056  scaledd(j+3) = gmeters2pc
1057  basedd(j+3) = rms0meters
1058  endif
1059  lorvog(j) = lorvogprime
1060  if(j.lt.3)lorvog(j+3) = lorvogmeters
1061 
1062 c - for the grid interpolated guys...
1063 c iqprimegi = floor(log10(avegiprime))
1064 c qqprimegi = 10.d0**(iqprimegi )
1065 c lorvogprimegi = MultiplierLorvog*
1066 c * qqprimegi*nint(avegiprime/qqprimegi)
1067  lorvogprimegi = onzd2(multiplierlorvog*avegiprime)
1068 c write(6,*)'MultiplierLorvog = ',MultiplierLorvog
1069 c write(6,*)'avegiprime = ',avegiprime
1070 c write(6,*)'lorvogprimegi = ',lorvogprimegi
1071  gprime2pcgi = lorvopc / lorvogprimegi
1072  scalegi(j) = gprime2pcgi
1073  basegi(j) = avegiprime
1074  if(j.lt.3)then
1075  lorvogmetersgi = onzd2(multiplierlorvog*avegimeter)
1076 c iqmetersgi = floor(log10(avegimeter))
1077 c qqmetersgi = 10.d0**(iqmetersgi )
1078 c lorvogmetersgi = MultiplierLorvog*
1079 c * qqmetersgi*nint(avegimeter/qqmetersgi)
1080  gmeters2pcgi = lorvopc / lorvogmetersgi
1081  scalegi(j+3) = gmeters2pcgi
1082  basegi(j+3) = avegimeter
1083  endif
1084  lorvoggi(j) = lorvogprimegi
1085  if(j.lt.3)lorvoggi(j+3) = lorvogmetersgi
1086 
1087 c ------------------------------------------------------------------
1088 c - pvlon and pvlat are the percentage of the total lon/lat
1089 c - span of the plot, from which the reference vector
1090 c - begins, starting with the Lower Left corner
1091 c ------------------------------------------------------------------
1092  pvlon = 10.d0
1093  pvlat = 10.d0
1094 
1095  pvlat = (pvlat / 100.d0)
1096  pvlon = (pvlon / 100.d0)
1097 
1098 c - Set the output file number
1099  ifthin = 40+j
1100  ifdrop = 50+j
1101  ifall = 60+j
1102 
1103 c - Spin over all "grid minus vector" values, and spit the differences
1104 c - into fresh vector files. Note that THIN data is first, then DROPPED
1105  do 813 ipt=1,kall
1106  if(ipt.le.kthin)then
1107  ifout1 = ifthin
1108  else
1109  ifout1 = ifdrop
1110  endif
1111  ifout2 = ifall
1112 
1113 c - Get the Azimuth for this point, double differenced version:
1114  if(j.eq.1 .or. j.eq.3)then
1115  if(dd0(ipt).lt.0)then
1116  az=180.d0
1117  else
1118  az=0.d0
1119  endif
1120  else
1121  if(dd0(ipt).lt.0)then
1122  az=270.d0
1123  else
1124  az=90.d0
1125  endif
1126  endif
1127 
1128 c - Get the Azimuth for this point, grid interpolated version:
1129  if(j.eq.1 .or. j.eq.3)then
1130  if(gi0(ipt).lt.0)then
1131  azgi=180.d0
1132  else
1133  azgi=0.d0
1134  endif
1135  else
1136  if(gi0(ipt).lt.0)then
1137  azgi=270.d0
1138  else
1139  azgi=90.d0
1140  endif
1141  endif
1142 
1143 c - Get the scaled value for this point
1144 c - Because we aren't looping over j through 4/5, we catch
1145 c - the j=4/5 values while hitting j=1/2:
1146  vcprime = dabs(dd0(ipt)*gprime2pc)
1147  if(j.lt.3)then
1148  vcmeters = dabs(ddm0(ipt) * gmeters2pc)
1149  endif
1150 
1151  giprime = dabs(gi0(ipt)*gprime2pcgi)
1152  if(j.lt.3)then
1153  gimeters = dabs(gim0(ipt) * gmeters2pcgi)
1154  endif
1155 
1156 c ------------------------
1157 c - Spit out fresh "grid interpolated" as well as "double difference" vectors
1158 c ------------------------
1159 
1160  if(j.eq.1 .or. j.eq.2)then
1161 c - Write out for j=1,2 to thinned/dropped in primary units, double differenced:
1162  write(ifout1 ,140)xlo0(ipt),xla0(ipt),az,vcprime,
1163  * dd0(ipt),ddm0(ipt),pid0(ipt)
1164 c - Write out for j=1,2 to thinned/dropped in primary units, grid-interpolated:
1165  write(ifout1+30,140)xlo0(ipt),xla0(ipt),azgi,giprime,
1166  * gi0(ipt),gim0(ipt),pid0(ipt)
1167 
1168 
1169 c - Write out for j=1,2 to all in primary units, double differenced:
1170  write(ifout2 ,140)xlo0(ipt),xla0(ipt),az,vcprime,
1171  * dd0(ipt),ddm0(ipt),pid0(ipt)
1172 c - Write out for j=1,2 to all in primary units, grid-interpolated:
1173  write(ifout2+30,140)xlo0(ipt),xla0(ipt),azgi,giprime,
1174  * gi0(ipt),gim0(ipt),pid0(ipt)
1175 
1176 
1177 c - Write out for j=4,5 to thinned/dropped in meters, double differenced:
1178  write(ifout1+5 ,140)xlo0(ipt),xla0(ipt),az,vcmeters,
1179  * dd0(ipt),ddm0(ipt),pid0(ipt)
1180 c - Write out for j=4,5 to thinned/dropped in meters, grid interpolated:
1181  write(ifout1+35,140)xlo0(ipt),xla0(ipt),azgi,gimeters,
1182  * gi0(ipt),gim0(ipt),pid0(ipt)
1183 
1184 
1185 c - Write out for j=4,5 to all in meters, double differenced:
1186  write(ifout2+5 ,140)xlo0(ipt),xla0(ipt),az,vcmeters,
1187  * dd0(ipt),ddm0(ipt),pid0(ipt)
1188 c - Write out for j=4,5 to all in meters, grid interpolated:
1189  write(ifout2+35,140)xlo0(ipt),xla0(ipt),azgi,gimeters,
1190  * gi0(ipt),gim0(ipt),pid0(ipt)
1191 
1192 
1193 
1194  endif
1195 
1196  if(j.eq.3)then
1197 c - Write out for j=3 to thinned/dropped in primary units, double differenced:
1198  write(ifout1 ,140)xlo0(ipt),xla0(ipt),az,vcprime,
1199  * 0.d0 ,ddm0(ipt),pid0(ipt)
1200 c - Write out for j=3 to thinned/dropped in primary units, grid interpolated:
1201  write(ifout1+30,140)xlo0(ipt),xla0(ipt),azgi,giprime,
1202  * 0.d0 ,gim0(ipt),pid0(ipt)
1203 
1204 
1205 c - Write out for j=3 to all in primary units, double differenced:
1206  write(ifout2 ,140)xlo0(ipt),xla0(ipt),az,vcprime,
1207  * 0.d0 ,ddm0(ipt),pid0(ipt)
1208 c - Write out for j=3 to all in primary units, grid interpolated:
1209  write(ifout2+30,140)xlo0(ipt),xla0(ipt),azgi,giprime,
1210  * 0.d0 ,gim0(ipt),pid0(ipt)
1211 
1212  endif
1213 
1214  813 continue
1215 
1216 c 140 format(f16.10,1x,f15.10,1x,f6.2,1x,f12.2,1x,f5.1,1x,f9.5,1x,a6)
1217  140 format(f16.10,1x,f15.10,1x,f6.2,1x,f12.2,1x,f9.5,1x,f9.3,1x,a6)
1218 
1219 
1220 c ------------------------------------------------------------------
1221 c - Write out a clear report.
1222 c ------------------------------------------------------------------
1223  write(6,8000)trim(coord(j)),units(j)
1224  do 2003 k=1,3
1225  write(6,8001)type(k),
1226  * (kstat(j,k),l=1,3),
1227  * (stat(1,j,k,l),l=1,3),
1228  * (stat(2,j,k,l),l=1,3),
1229  * (stat(5,j,k,l),l=1,3),
1230  * (stat(3,j,k,l),l=1,3),
1231  * (stat(4,j,k,l),l=1,3)
1232  2003 continue
1233 
1234  if(j.lt.3)then
1235  write(6,8000)trim(coord(j)),units(j+3)
1236  do 2004 k=1,3
1237  write(6,8001)type(k),
1238  * (kstat(j+3,k),l=1,3),
1239  * (stat(1,j+3,k,l),l=1,3),
1240  * (stat(2,j+3,k,l),l=1,3),
1241  * (stat(5,j+3,k,l),l=1,3),
1242  * (stat(3,j+3,k,l),l=1,3),
1243  * (stat(4,j+3,k,l),l=1,3)
1244  2004 continue
1245  endif
1246 
1247  2001 continue
1248 
1249 c 102 format(f16.10,1x,f15.10,1x, 6x,1x, 12x,1x, 5x,1x,f9.5,1x,6x)
1250 
1251 c - To pull arcseconds:
1252  102 format(f16.10,1x,f15.10,1x, 6x,1x, 12x,1x,f9.5,1x, 9x,1x,a6)
1253 c - To pull meters:
1254  1102 format(f16.10,1x,f15.10,1x, 6x,1x, 12x,1x, 9x,1x,f9.3,1x,a6)
1255 
1256 
1257  8000 format(
1258  *//,25x,a,' in ',a,/,
1259  *'Type',1x,'Stat',
1260  *7x,'Bilinear',5x,'Biquadratic',
1261  *9x,'Bicubic ')
1262  8001 format(a4,1x,
1263  *'Num:',3(i15 ,1x),/,
1264  *5x,'Ave:',3(f15.6,1x),/,
1265  *5x,'RMS:',3(f15.6,1x),/,
1266  *5x,'STD:',3(f15.6,1x),/,
1267  *5x,'MIN:',3(f15.6,1x),/,
1268  *5x,'MAX:',3(f15.6,1x),/,
1269  *50('-'))
1270 
1271  write(6,8003)
1272  8003 format(
1273  *6x,'checkgrid.f: END STATISTICAL REPORT ',
1274  *'(grid minus true vector diffs)',/,
1275  *50('*'))
1276 
1277 
1278 c -----------------------------------------------
1279 c - CREATE THE HORIZONTAL VECTOR FILES
1280 c - 2015 10 08
1281 c -----------------------------------------------
1282  write(6,8004)
1283  8004 format(
1284  *6x,'checkgrid.f: Generating HORIZONTAL vector files',
1285  *' from lat/lon vector files')
1286  5072 format('FATAL in checkgrid: Mismatched PID for hor')
1287  5073 format('FATAL in checkgrid: Mismatched LON for hor')
1288  5074 format('FATAL in checkgrid: Mismatched LAT for hor')
1289 
1290  do 5080 i=1,5
1291  if(i.eq.3)goto 5080
1292 c write(6,*)i,'basedd() = ',basedd(i)
1293  5080 continue
1294  do 5081 i=1,5
1295  if(i.eq.3)goto 5081
1296 c write(6,*)i,'basegi() = ',basegi(i)
1297  5081 continue
1298 
1299  baseddhors = sqrt(basedd(1)**2+basedd(2)**2)
1300  baseddhorm = sqrt(basedd(4)**2+basedd(5)**2)
1301  basegihors = sqrt(basegi(1)**2+basegi(2)**2)
1302  basegihorm = sqrt(basegi(4)**2+basegi(5)**2)
1303 
1304 c lorvog(6) = baseddhors
1305 c lorvog(7) = baseddhorm
1306 
1307 c lorvoggi(6) = basegihors
1308 c lorvoggi(7) = basegihorm
1309 
1310 c write(6,*) ' baseddhors = ',baseddhors
1311 c write(6,*) ' baseddhorm = ',baseddhorm
1312 c write(6,*) ' basegihors = ',basegihors
1313 c write(6,*) ' basegihorm = ',basegihorm
1314 
1315  lorvoghorddm = onzd2(multiplierlorvog*baseddhorm)
1316 c iqhorddm = floor(log10(baseddhorm))
1317 c qqhorddm = 10.d0**(iqhorddm )
1318 c lorvoghorddm = MultiplierLorvog*qqhorddm*nint(baseddhorm/qqhorddm)
1319  gm2pchordd = lorvopc / lorvoghorddm
1320 
1321  lorvoghordds = onzd2(multiplierlorvog*baseddhors)
1322 c iqhordds = floor(log10(baseddhors))
1323 c qqhordds = 10.d0**(iqhordds )
1324 c lorvoghordds = MultiplierLorvog*qqhordds*nint(baseddhors/qqhordds)
1325  gs2pchordd = lorvopc / lorvoghordds
1326 
1327  lorvoghorgim = onzd2(multiplierlorvog*basegihorm)
1328 c iqhorgim = floor(log10(basegihorm))
1329 c qqhorgim = 10.d0**(iqhorgim )
1330 c lorvoghorgim = MultiplierLorvog*qqhorgim*nint(basegihorm/qqhorgim)
1331  gm2pchorgi = lorvopc / lorvoghorgim
1332 
1333  lorvoghorgis = onzd2(multiplierlorvog*basegihors)
1334 c iqhorgis = floor(log10(basegihors))
1335 c qqhorgis = 10.d0**(iqhorgis )
1336 c lorvoghorgis = MultiplierLorvog*qqhorgis*nint(basegihors/qqhorgis)
1337  gs2pchorgi = lorvopc / lorvoghorgis
1338 
1339  lorvog(6) = lorvoghordds
1340  lorvog(7) = lorvoghorddm
1341 
1342  lorvoggi(6) = lorvoghorgis
1343  lorvoggi(7) = lorvoghorgim
1344 
1345  convgs2pcddlat = lorvopc / lorvog(1)
1346  convgs2pcddlon = lorvopc / lorvog(2)
1347 
1348  convgm2pcddlat = lorvopc / lorvog(4)
1349  convgm2pcddlon = lorvopc / lorvog(5)
1350 
1351  convgs2pcgilat = lorvopc / lorvoggi(1)
1352  convgs2pcgilon = lorvopc / lorvoggi(2)
1353 
1354  convgm2pcgilat = lorvopc / lorvoggi(4)
1355  convgm2pcgilon = lorvopc / lorvoggi(5)
1356 
1357 c goto 8070
1358 c write(6,*) ' Way #1 : '
1359 c write(6,*) ' convgs2pcddlat = ',convgs2pcddlat
1360 c write(6,*) ' convgs2pcddlon = ',convgs2pcddlon
1361 c write(6,*) ' convgm2pcddlat = ',convgm2pcddlat
1362 c write(6,*) ' convgm2pcddlon = ',convgm2pcddlon
1363 c write(6,*) ' convgs2pcgilat = ',convgs2pcgilat
1364 c write(6,*) ' convgs2pcgilon = ',convgs2pcgilon
1365 c write(6,*) ' convgm2pcgilat = ',convgm2pcgilat
1366 c write(6,*) ' convgm2pcgilon = ',convgm2pcgilon
1367 c8070 continue
1368 
1369  convgs2pcddlat = scaledd(1)
1370  convgs2pcddlon = scaledd(2)
1371  convgm2pcddlat = scaledd(4)
1372  convgm2pcddlon = scaledd(5)
1373  convgs2pcgilat = scalegi(1)
1374  convgs2pcgilon = scalegi(2)
1375  convgm2pcgilat = scalegi(4)
1376  convgm2pcgilon = scalegi(5)
1377 
1378 c goto 8071
1379 c write(6,*) ' Way #2 : '
1380 c write(6,*) ' convgs2pcddlat = ',convgs2pcddlat
1381 c write(6,*) ' convgs2pcddlon = ',convgs2pcddlon
1382 c write(6,*) ' convgm2pcddlat = ',convgm2pcddlat
1383 c write(6,*) ' convgm2pcddlon = ',convgm2pcddlon
1384 c write(6,*) ' convgs2pcgilat = ',convgs2pcgilat
1385 c write(6,*) ' convgs2pcgilon = ',convgs2pcgilon
1386 c write(6,*) ' convgm2pcgilat = ',convgm2pcgilat
1387 c write(6,*) ' convgm2pcgilon = ',convgm2pcgilon
1388 c8071 continue
1389 
1390  convgs2pcddhor = dsqrt(convgs2pcddlat**2 + convgs2pcddlon**2)
1391  convgm2pcddhor = dsqrt(convgm2pcddlat**2 + convgm2pcddlon**2)
1392  convgs2pcgihor = dsqrt(convgs2pcgilat**2 + convgs2pcgilon**2)
1393  convgm2pcgihor = dsqrt(convgm2pcgilat**2 + convgm2pcgilon**2)
1394 
1395 c goto 8072
1396 c write(6,*) ' Ways #1 or 2 : '
1397 c write(6,*) ' convgs2pcddhor = ',convgs2pcddhor
1398 c write(6,*) ' convgm2pcddhor = ',convgm2pcddhor
1399 c write(6,*) ' convgs2pcgihor = ',convgs2pcgihor
1400 c write(6,*) ' convgm2pcgihor = ',convgm2pcgihor
1401 c8072 continue
1402 
1403  convgs2pcddhor = gs2pchordd
1404  convgm2pcddhor = gm2pchordd
1405  convgs2pcgihor = gs2pchorgi
1406  convgm2pcgihor = gm2pchorgi
1407 
1408 c goto 8073
1409 c write(6,*) ' Way #3:'
1410 c write(6,*) ' convgs2pcddhor = ',convgs2pcddhor
1411 c write(6,*) ' convgm2pcddhor = ',convgm2pcddhor
1412 c write(6,*) ' convgs2pcgihor = ',convgs2pcgihor
1413 c write(6,*) ' convgm2pcgihor = ',convgm2pcgihor
1414 c8073 continue
1415 
1416  do 5070 i=40,90,10
1417  do 5071 j=1,2
1418  if(i.le.60 .and. j.eq.1)conv = convgs2pcddhor
1419  if(i.le.60 .and. j.eq.2)conv = convgm2pcddhor
1420  if(i.ge.70 .and. j.eq.1)conv = convgs2pcgihor
1421  if(i.ge.70 .and. j.eq.2)conv = convgm2pcgihor
1422 
1423  ilat = i+1 + (j-1)*5
1424  ilon = i+2 + (j-1)*5
1425  ihor = i+4 + (j-1)*1
1426 c write(6,*) ilat,ilon,ihor
1427  rewind(ilat)
1428  rewind(ilon)
1429 
1430  5078 read(ilat,140,end=5071)ylo1,yla1,az1,vc1,sec1,xmet1,pid1
1431  read(ilon,140)ylo2,yla2,az2,vc2,sec2,xmet2,pid2
1432  if(pid1.ne.pid2)then
1433  write(6,5072)
1434  stop
1435  endif
1436  if(ylo1.ne.ylo2)then
1437  write(6,5073)
1438  stop
1439  endif
1440  if(yla1.ne.yla2)then
1441  write(6,5074)
1442  stop
1443  endif
1444  azhor = datan2(xmet2,xmet1)/d2r
1445  if(azhor.lt.0.d0)azhor=azhor+360.d0
1446  dhors = dsqrt(sec1**2 + sec2**2)
1447  dhorm = dsqrt(xmet1**2 + xmet2**2)
1448 
1449  if(j.eq.1)vchor = conv * dhors
1450  if(j.eq.2)vchor = conv * dhorm
1451 
1452  write(ihor,140)ylo1,yla1,azhor,vchor,dhors,dhorm,pid1
1453  goto 5078
1454 
1455  5071 continue
1456  5070 continue
1457 
1458 
1459 c ------------------------------------------------------------------
1460 c - Write out statistics that I'll pick up later when
1461 c - I run "makeplotfiles03.f" -- just the "rmslatm", "rmslonm"
1462 c - and "rmsehtm" values, used to scale vector plots.
1463 c ------------------------------------------------------------------
1464  sfn = 'dvstats.'//trim(suffix2)
1465  open(2,file=sfn,status='new',form='formatted')
1466 
1467 c 2,j,3,2 = RMS/j/All/Biquad,
1468 c - where j=1/2/3 => lat-sec/lon-sec/eht-met
1469 c - j=4/5 => lat-met/lon-met
1470  write(2,777)kstat(1,3),stat(2,1,3,2)
1471  write(2,777)kstat(2,3),stat(2,2,3,2)
1472  write(2,777)kstat(3,3),stat(2,3,3,2)
1473  write(2,777)kstat(1,3),stat(2,4,3,2)
1474  write(2,777)kstat(2,3),stat(2,5,3,2)
1475 c - 2015 10 09:
1476  rhors = sqrt(stat(2,1,3,2)**2 + stat(2,2,3,2)**2)
1477  rhorm = sqrt(stat(2,4,3,2)**2 + stat(2,5,3,2)**2)
1478  write(2,777)kstat(1,3),rhors
1479  write(2,777)kstat(2,3),rhorm
1480 
1481  close(2)
1482  777 format(i10,1x,f20.10)
1483 
1484 c ----------------------------------------------------------
1485 c ----------------------------------------------------------
1486 c ----------------------------------------------------------
1487 c - Create GMT file "gmtbat04..." and fill it full of
1488 c - calls to make vector plots of thinned/dropped/all
1489 c - "grid interpolated" vectors as well as
1490 c - "double differenced" vectors.
1491 c ----------------------------------------------------------
1492 c ----------------------------------------------------------
1493 c ----------------------------------------------------------
1494 
1495 c ------------------------------------------------------------------
1496 c - GMT Batch file: Open the file. The output batch file full
1497 c - of all the GMT commands needed to create
1498 c - the plots of interest
1499 c ------------------------------------------------------------------
1500  gmtfile = 'gmtbat04.'//trim(suffix3)
1501  open(99,file=gmtfile,status='new',form='formatted')
1502  write(6,1011)trim(gmtfile)
1503  1011 format(6x,'checkgrid.f: Creating GMT batch file ',a)
1504  write(99,1030)trim(gmtfile)
1505  1030 format('echo BEGIN batch file ',a)
1506 
1507 c --------------------------------------------------------------
1508 c - GMT Batch file: Determine Number of areas to plot (=nplots)
1509 c - and Boundaries of plots and other stuff.
1510 c - Report the information out.
1511 c --------------------------------------------------------------
1512 c - 2016 08 29
1513  call getmapbounds(mapflag,maxplots,region,nplots,
1514  *olddtm,newdtm,
1515  *bw,be,bs,bn,jm,b1,b2,fn,lrv,rv0x,rv0y,rl0y)
1516 
1517 c - 2016 08 26, See DRU-12, p. 56-57:
1518 c call getmapbounds(mapflag,maxplots,region,nplots,
1519 c *bw,be,bs,bn,jm,b1,b2,fn,lrv,rv0x,rv0y,rl0y)
1520 
1521 c - See DRU-11, p. 126 for choices on grid boundaries for NADCON v5.0
1522 c - 2016 07 21:
1523 c call getmapbounds(mapflag,maxplots,region,nplots,
1524 c *bw,be,bs,bn,jm,b1,b2,fn,lrv,rv0x,rv0y)
1525 c call getmapbounds(mapflag,maxplots,region,nplots,
1526 c *bw,be,bs,bn,jm,b1,b2,fn)
1527  write(6,1006)trim(region)
1528  1006 format(6x,'checkgrid.f: Calling getmapbounds for region ',a)
1529 
1530 c --------------------------------------------------------------
1531 c - GMT Batch file: Like "makeplotfiles02.f", I will
1532 c - spin over "nplots" as my main loop, inside of that though,
1533 c - I will spin over j,k (as above, but letting k go from 1 to 3)
1534 c - Remember: j=1,2,3 => lat,lon,eht
1535 c - k=1,2,3 => Thinned, Dropped, All
1536 c --------------------------------------------------------------
1537  ele(1) = 'lat'
1538  ele(2) = 'lon'
1539  ele(3) = 'eht'
1540  ele(4) = 'lat'
1541  ele(5) = 'lon'
1542  ele(6) = 'hor'
1543  ele(7) = 'hor'
1544 
1545  el0(1) = 'LAT'
1546  el0(2) = 'LON'
1547  el0(3) = 'EHT'
1548  el0(4) = 'LAT'
1549  el0(5) = 'LON'
1550  el0(6) = 'HOR'
1551  el0(7) = 'HOR'
1552 
1553  991 format(
1554  *'# ------------------------------',/,
1555  *'# Double Difference Vector Plots',/,
1556  *'# ------------------------------',/,
1557  *'echo Double Difference Vector Plots')
1558 
1559  992 format(
1560  *'# ------------------------------',/,
1561  *'# Grid Interpolated Vector Plots',/,
1562  *'# ------------------------------',/,
1563  *'echo Grid Interpolated Vector Plots')
1564 
1565  990 format(
1566  *'# ------------------------------',/,
1567  *'# Plots for region: ',a,', sub-region: ',a,/,
1568  *'# ------------------------------',/,
1569  *'echo Creating plots for region: ',a,', sub-region: ',a)
1570 
1571 
1572 c----------------------------------
1573 c - Grid-Interpolated Vector Plots
1574 c----------------------------------
1575 
1576  write(99,992)
1577  do 4011 ij=1,nplots
1578  write(99,990)trim(region),trim(fn(ij)),
1579  * trim(region),trim(fn(ij))
1580 
1581 c - 2016 08 26:
1582  xvlon = rv0x(ij)
1583  xvlat = rv0y(ij)
1584 
1585  xllat = rl0y(ij)
1586  xllon = xvlon
1587 
1588 c - Where is the start of the reference vector:
1589 c - 2016 07 29: Decided to scrap personalized locations
1590 c - and just put all reference vectors outside/below
1591 c - the plots
1592 c - 2016 07 21:
1593 c if(lrv(ij))then
1594 c xvlon = rv0x(ij)
1595 c xvlat = rv0y(ij)
1596 c else
1597 c - 2016 08 26
1598 cccc xvlon = bw(ij) + (pvlon*(be(ij)-bw(ij)))
1599 c xvlat = bs(ij) + (pvlat*(bn(ij)-bs(ij)))
1600 cccc xvlat = bs(ij) - (pvlat*(bn(ij)-bs(ij)))
1601 c endif
1602 c - Where is the start of the label for the ref vector:
1603 c xllon = xvlon
1604 c - To prevent the label from going off the page on
1605 c - plots that have very little N/S span, put in a
1606 c - failsafe
1607 c - 2016 07 21: This may take some tweaking...
1608 c if(lrv(ij))then
1609 ccccc xllat = xvlat - 0.1d0
1610 c else
1611 cccc if(bn(ij)-bs(ij).lt.2.0)then
1612 c xllat = bs(ij) + ((pvlat*0.75d0)*(bn(ij)-bs(ij)))
1613 cccc xllat = bs(ij) - ((pvlat*1.25d0)*(bn(ij)-bs(ij)))
1614 cccc else
1615 c xllat = bs(ij) + (pvlat*(bn(ij)-bs(ij))) - 0.1d0
1616 cccc xllat = bs(ij) - (pvlat*(bn(ij)-bs(ij))) - 0.1d0
1617 cccc endif
1618 c endif
1619 
1620 
1621 c do 4012 j = 1,5
1622  do 4012 j = 1,7
1623  do 4013 k = 1,3
1624  if(j.eq.1.and.k.eq.1)gfn = gfnvstgilat
1625  if(j.eq.1.and.k.eq.2)gfn = gfnvsdgilat
1626  if(j.eq.1.and.k.eq.3)gfn = gfnvsagilat
1627 
1628  if(j.eq.2.and.k.eq.1)gfn = gfnvstgilon
1629  if(j.eq.2.and.k.eq.2)gfn = gfnvsdgilon
1630  if(j.eq.2.and.k.eq.3)gfn = gfnvsagilon
1631 
1632  if(j.eq.3.and.k.eq.1)gfn = gfnvmtgieht
1633  if(j.eq.3.and.k.eq.2)gfn = gfnvmdgieht
1634  if(j.eq.3.and.k.eq.3)gfn = gfnvmagieht
1635 
1636  if(j.eq.4.and.k.eq.1)gfn = gfnvmtgilat
1637  if(j.eq.4.and.k.eq.2)gfn = gfnvmdgilat
1638  if(j.eq.4.and.k.eq.3)gfn = gfnvmagilat
1639 
1640  if(j.eq.5.and.k.eq.1)gfn = gfnvmtgilon
1641  if(j.eq.5.and.k.eq.2)gfn = gfnvmdgilon
1642  if(j.eq.5.and.k.eq.3)gfn = gfnvmagilon
1643 
1644  if(j.eq.6.and.k.eq.1)gfn = gfnvstgihor
1645  if(j.eq.6.and.k.eq.2)gfn = gfnvsdgihor
1646  if(j.eq.6.and.k.eq.3)gfn = gfnvsagihor
1647 
1648  if(j.eq.7.and.k.eq.1)gfn = gfnvmtgihor
1649  if(j.eq.7.and.k.eq.2)gfn = gfnvmdgihor
1650  if(j.eq.7.and.k.eq.3)gfn = gfnvmagihor
1651 
1652  if(j.le.5)then
1653  if(kstat(j,k).ne.0)
1654  * call bwplotvc(ele(j),gfn,bw,be,bs,bn,jm,b1,b2,
1655  * maxplots,olddtm,newdtm,region,el0(j),ij,xvlon,
1656  * xvlat,xllon,xllat,lorvoggi(j),lorvopc,igridsec,fn)
1657  else
1658  if(kstat(1,k).ne.0 .and. kstat(2,k).ne.0)
1659  * call bwplotvc(ele(j),gfn,bw,be,bs,bn,jm,b1,b2,
1660  * maxplots,olddtm,newdtm,region,el0(j),ij,xvlon,
1661  * xvlat,xllon,xllat,lorvoggi(j),lorvopc,igridsec,fn)
1662  endif
1663 
1664 
1665  4013 continue
1666  4012 continue
1667  4011 continue
1668 
1669 c----------------------------------
1670 c - Double-Difference Vector Plots
1671 c----------------------------------
1672 
1673 
1674  write(99,991)
1675  do 3011 ij=1,nplots
1676  write(99,990)trim(region),trim(fn(ij)),
1677  * trim(region),trim(fn(ij))
1678 
1679 c - Where is the start of the reference vector:
1680 c - 2016 07 29: Decided to scrap personalized locations
1681 c - and just put all reference vectors outside/below
1682 c - the plots
1683 
1684 c - 2016 08 26
1685  xvlon = rv0x(ij)
1686  xvlat = rv0y(ij)
1687 
1688  xllon = xvlon
1689  xllat = rl0y(ij)
1690 
1691 c - 2016 07 21:
1692 c if(lrv(ij))then
1693 c xvlon = rv0x(ij)
1694 c xvlat = rv0y(ij)
1695 c else
1696 cccc xvlon = bw(ij) + (pvlon*(be(ij)-bw(ij)))
1697 c xvlat = bs(ij) + (pvlat*(bn(ij)-bs(ij)))
1698 cccc xvlat = bs(ij) - (pvlat*(bn(ij)-bs(ij)))
1699 c endif
1700 c - Where is the start of the label for the ref vector:
1701 cccc xllon = xvlon
1702 c - To prevent the label from going off the page on
1703 c - plots that have very little N/S span, put in a
1704 c - failsafe
1705 c - 2016 07 21:
1706 c if(lrv(ij))then
1707 c xllat = xvlat - 0.1d0
1708 c else
1709 cccc if(bn(ij)-bs(ij).lt.2.0)then
1710 c xllat = bs(ij) + ((pvlat*0.75d0)*(bn(ij)-bs(ij)))
1711 cccc xllat = bs(ij) - ((pvlat*1.25d0)*(bn(ij)-bs(ij)))
1712 cccc else
1713 c xllat = bs(ij) + (pvlat*(bn(ij)-bs(ij))) - 0.1d0
1714 cccc xllat = bs(ij) - (pvlat*(bn(ij)-bs(ij))) - 0.1d0
1715 cccc endif
1716 c endif
1717 
1718 
1719 c do 3012 j = 1,3
1720 c do 3012 j = 1,5
1721  do 3012 j = 1,7
1722  do 3013 k = 1,3
1723  if(j.eq.1.and.k.eq.1)gfn = gfnvstddlat
1724  if(j.eq.1.and.k.eq.2)gfn = gfnvsdddlat
1725  if(j.eq.1.and.k.eq.3)gfn = gfnvsaddlat
1726 
1727  if(j.eq.2.and.k.eq.1)gfn = gfnvstddlon
1728  if(j.eq.2.and.k.eq.2)gfn = gfnvsdddlon
1729  if(j.eq.2.and.k.eq.3)gfn = gfnvsaddlon
1730 
1731  if(j.eq.3.and.k.eq.1)gfn = gfnvmtddeht
1732  if(j.eq.3.and.k.eq.2)gfn = gfnvmdddeht
1733  if(j.eq.3.and.k.eq.3)gfn = gfnvmaddeht
1734 
1735  if(j.eq.4.and.k.eq.1)gfn = gfnvmtddlat
1736  if(j.eq.4.and.k.eq.2)gfn = gfnvmdddlat
1737  if(j.eq.4.and.k.eq.3)gfn = gfnvmaddlat
1738 
1739  if(j.eq.5.and.k.eq.1)gfn = gfnvmtddlon
1740  if(j.eq.5.and.k.eq.2)gfn = gfnvmdddlon
1741  if(j.eq.5.and.k.eq.3)gfn = gfnvmaddlon
1742 
1743  if(j.eq.6.and.k.eq.1)gfn = gfnvstddhor
1744  if(j.eq.6.and.k.eq.2)gfn = gfnvsdddhor
1745  if(j.eq.6.and.k.eq.3)gfn = gfnvsaddhor
1746 
1747  if(j.eq.7.and.k.eq.1)gfn = gfnvmtddhor
1748  if(j.eq.7.and.k.eq.2)gfn = gfnvmdddhor
1749  if(j.eq.7.and.k.eq.3)gfn = gfnvmaddhor
1750 
1751  if(j.le.5)then
1752  if(kstat(j,k).ne.0)
1753  * call bwplotvc(ele(j),gfn,bw,be,bs,bn,jm,b1,b2,
1754  * maxplots,olddtm,newdtm,region,el0(j),ij,xvlon,
1755  * xvlat,xllon,xllat,lorvog(j),lorvopc,igridsec,fn)
1756  else
1757  if(kstat(1,k).ne.0 .and. kstat(2,k).ne.0)
1758  * call bwplotvc(ele(j),gfn,bw,be,bs,bn,jm,b1,b2,
1759  * maxplots,olddtm,newdtm,region,el0(j),ij,xvlon,
1760  * xvlat,xllon,xllat,lorvog(j),lorvopc,igridsec,fn)
1761  endif
1762 
1763  3013 continue
1764  3012 continue
1765  3011 continue
1766 
1767 
1768 
1769 
1770 
1771 
1772  write(99,1031)trim(gmtfile)
1773  1031 format('echo END batch file ',a)
1774  close(99)
1775 
1776  write(6,9999)
1777  9999 format('END program checkgrid.f')
1778 
1779  end
1780 c
1781 c --------------------------------------------------------------
1782 c
1783  subroutine nlines(ifile,num,ilogic)
1784  integer*4 ifile,num
1785  logical*1 ilogic
1786  character*1 dummy
1787 
1788  ilogic = .false.
1789  num = 0
1790  1 read(ifile,'(a)',end=2)dummy
1791  num = num + 1
1792  goto 1
1793  2 if(num.eq.0)ilogic = .true.
1794  rewind(ifile)
1795  return
1796  end
1797 c
1798 c --------------------------------------------------------------
1799 c
1800  include 'Subs/getmapbounds.f'
1801  include 'Subs/getgridbounds.f'
1802  include 'Subs/bwplotvc.f'
1803  include 'Subs/plotcoast.f'
1804 c
1805  include 'Subs/bilin.f'
1806  include 'Subs/biquad.f'
1807  include 'Subs/bicubic.f'
1808  include 'Subs/onzd2.f'
1809 
subroutine bwplotvc(ele, fname, bw, be, bs, bn, jm, b1, b2, maxplots, olddtm, newdtm, region, elecap, ij, xvlon, xvlat, xllon, xllat, lorvog, lorvopc, igridsec, fn)
Subroutine to make GMT calls to do a B/W vector plot.
Definition: bwplotvc.f:37
subroutine nlines(ifile, num, ilogic)
Definition: checkgrid.f:1784
subroutine bilin(data, glamn, glomn, dla, dlo, nla, nlo, maxla, maxlo, xla, xlo, val)
Subroutine to perform bilinear interpolation.
Definition: bilin.f:27
real *8 function onzd2(x)
Function to round a digit to one significant figure (one non zero digit), double precision.
Definition: onzd2.f:36
subroutine getmapbounds(mapflag, maxplots, region, nplots, olddtm, newdtm, bw, be, bs, bn, jm, b1, b2, fn, lrv, rv0x, rv0y, rl0y)
Subroutine to collect up the MAP boundaries for use in creating NADCON 5.
Definition: getmapbounds.f:77
subroutine bicubic(z, glamn, glomn, dla, dlo, nla, nlo, maxla, maxlo, xla, xlo, val)
Subroutine to perform a 2-D cubic ("bicubic") interpolation.
Definition: bicubic.f:41
subroutine getgridbounds(region, xn, xs, xw, xe)
Subroutine to collect up the GRID boundaries for use in creating NADCON 5.
Definition: getgridbounds.f:30
program checkgrid
Part of the NADCON5 build process, generates gmtbat04
Definition: checkgrid.f:100
subroutine biquad(z, glamn, glomn, dla, dlo, nla, nlo, maxla, maxlo, xla, xlo, val)
Subroutine to perform a 2-D quadratic ("biquadratic") interpolation.
Definition: biquad.f:33