NADCON5-ng  0.0.2
NADCON5 Next Generation Documentation
coplotwcv.f
Go to the documentation of this file.
1 c> \ingroup core
2 c> \if MANPAGE
3 c> \page coplotwcv
4 c> \endif
5 c>
6 c> Subroutine to make GMT calls to do a color raster rendering
7 c> of gridded data, with coverage overlaid.
8 c>
9 c> ## Changelog
10 c>
11 c> ### 2016 09 08:
12 c> Had to up the D_FORMAT default to %.3G because tight scalebar ranges
13 c> with the newly allowed "more free" average values were showing
14 c> repeating values when only 2 digits could be shown.
15 c>
16 c> ### 2016 09 07:
17 c> Had to add lines pre/post "makecpt" to change the D_FORMAT. This is because
18 c> I *had* been forcing the "scave" in cpt.f to be ONZD. But that yielded
19 c> bad values sometimes, so I switched it. With that switch, the scave could
20 c> have lots of digits. Well, that means the newly adopted "D_FORMAT" of %.2G
21 c> was insufficient for the CPT table. Who knew that D_FORMAT affected that!
22 c> Anyway, so change "D_FORMAT" pre/post all makecpt calls.
23 c>
24 c> ### 2016 08 30:
25 c> See item #39 in Google ToDo list
26 c> Changed "grdcontour" to have a blank "-R" call so it'll mimic whatever
27 c> decimal places are in the "grdimage" call that came before it.
28 c>
29 c> ### 2016 08 29:
30 c> Updated the initial -R and -B calls to 6 decimal places
31 c>
32 c> ### 2016 08 25:
33 c> - .gmtdefaults4 has been changed so X_ORIGIN is equal to 0.0
34 c> - Center the plot with "-Xc" at grdimage
35 c> - Center the scalebar by setting its Xcoordinate, which runs in "plot frame"
36 c> coordinates (0/0 at lower left) , to be equal to "jm/2"
37 c> - Force the scale bar to be exactly 4 inches wide, always
38 c> - Change the format for "makecpt" from 0.6 to 0.10
39 c>
40 c> ### 2016 07 29:
41 c> - Update to put more data into comment/echo
42 c> - Forced grdcontour with -Ctemp.cpt to align contours with color palette
43 c>
44 c> ### 2016 07 28:
45 c> - For d3 plots, to drop all contours
46 c> - For d3 plots to only use "coverage" part *only* if "ij" is not "1"
47 c> - Same for "09" and "ete" grids
48 c>
49 c> ### 2016 07 21:
50 c> - Set the "JM" code in "grdcontour" to just be "-JM" and let it therefore
51 c> run with whatever JM size is used in "grdimage"
52 c> - Set the "A" code in "grdcontour" to be "-A-" which should turn off
53 c> the labels on all contours
54 c> - Fixed the size of the scale bar
55 c>
56 c> ### 2016 03 01:
57 c> 1. Changed to a continuous color plot
58 c> - Get rid of "-Z" in "makecpt"
59 c> 2. Changed to an 8 color, from 6 color, plot (without changing the RANGE yet...see DRU-12, p. 19)
60 c> - Change varible that comes in from "cptin" to "cptin6"
61 c> - Compute cptin = cptin6 * 0.75d0 immediately
62 c>
63 c> ### 2016 02 29:
64 c> 1. Removed all shading from color plots
65 c> - Get rid of "grdgradient" call
66 c> - Remove from "grdimage" the "-Itempi.grd" part
67 c> - Remove the "rm -f tempi.grd" line
68 c>
69  subroutine coplotwcv(ele,fname,bw,be,bs,bn,jm,b1,b2,maxplots,
70  *olddtm,newdtm,region,elecap,ij,cptlo,cpthi,cptin6,suffixused,
71  *igridsec,fn,cvfname)
72 
73 c - 2016 09 08
74 c Had to up the D_FORMAT default to %.3G because tight scalebar ranges
75 c with the newly allowed "more free" average values were showing
76 c repeating values when only 2 digits could be shown.
77 
78 c - 2016 09 07
79 c Had to add lines pre/post "makecpt" to change the D_FORMAT. This is because
80 c I *had* been forcing the "scave" in cpt.f to be ONZD. But that yielded
81 c bad values sometimes, so I switched it. With that switch, the scave could
82 c have lots of digits. Well, that means the newly adopted "D_FORMAT" of %.2G
83 c was insufficient for the CPT table. Who knew that D_FORMAT affected that!
84 c Anyway, so change "D_FORMAT" pre/post all makecpt calls.
85 
86 c - 2016 08 30: See item #39 in Google ToDo list
87 c Changed "grdcontour" to have a blank "-R" call so it'll mimic whatever
88 c decimal places are in the "grdimage" call that came before it.
89 
90 c - 2016 08 29:
91 c Updated the initial -R and -B calls to 6 decimal places
92 
93 c - 2016 08 25:
94 c .gmtdefaults4 has been changed so X_ORIGIN is equal to 0.0
95 c Center the plot with "-Xc" at grdimage
96 c Center the scalebar by setting its Xcoordinate, which runs in "plot frame"
97 c coordinates (0/0 at lower left) , to be equal to "jm/2"
98 c Force the scale bar to be exactly 4 inches wide, always
99 c Change the format for "makecpt" from 0.6 to 0.10
100 
101 
102 c - 2016 07 29:
103 c Update to put more data into comment/echo
104 c - Forced grdcontour with -Ctemp.cpt to align contours with color palette
105 
106 c - Update 2016 07 28 to:
107 c For d3 plots, to drop all contours
108 c For d3 plots to only use "coverage" part *only* if "ij" is not "1"
109 c Same for "09" and "ete" grids
110 
111 c subroutine coplotwcv(ele,fname,bw,be,bs,bn,jm,b1,b2,maxplots,
112 c *olddtm,newdtm,region,elecap,ij,cptlo,cpthi,cptin,suffixused,
113 c *igridsec,fn,cvfname)
114 
115 c - Update 2016 07 21:
116 c - Set the "JM" code in "grdcontour" to just be "-JM" and let it therefore
117 c run with whatever JM size is used in "grdimage"
118 c - Set the "A" code in "grdcontour" to be "-A-" which should turn off
119 c the labels on all contours
120 c - Fixed the size of the scale bar
121 
122 
123 c - Update 2016 03 01:
124 c - 1) Changed to a continuous color plot
125 c * Get rid of "-Z" in "makecpt"
126 c 2) Changed to an 8 color, from 6 color, plot (without changing the RANGE yet...see DRU-12, p. 19)
127 c * Change varible that comes in from "cptin" to "cptin6"
128 c * Compute cptin = cptin6 * 0.75d0 immediately
129 
130 
131 c - Update 2016 02 29:
132 c - 1) Removed all shading from color plots
133 c * Get rid of "grdgradient" call
134 c * Remove from "grdimage" the "-Itempi.grd" part
135 c * Remove the "rm -f tempi.grd" line
136 c
137 
138  implicit real*8(a-h,o-z)
139 
140 c - Subroutine to make GMT calls to do a color raster rendering
141 c - of gridded data, with coverage overlaid.
142 
143  integer*4 maxplots
144  character*3 ele,elecap
145  character*200 fname,cvfname
146  character*10 olddtm,newdtm,region
147  real*8 bw(maxplots),be(maxplots),bs(maxplots),bn(maxplots)
148  real*4 jm(maxplots)
149  real*4 b1(maxplots),b2(maxplots)
150  character*10 fn(maxplots)
151  real*8 ave,std
152  character*200 suffixused
153  character*20 units
154  character*20 gridnote
155  character*20 gridnote2
156 
157 c ----------------------------------------------------
158 c - FAILSAFES: BEGIN
159 c ----------------------------------------------------
160  if(.not.(fname(1:3).eq.'vmt'.or.fname(1:3).eq.'vst' .or.
161  * fname(1:3).eq.'vmr'.or.fname(1:3).eq.'vsr'))then
162  write(6,2)trim(fname)
163  stop
164  endif
165  2 format('FATAL in coplotwcv. Bad character in spots 1-3: ',a)
166 
167  if(.not.(fname(4:5).eq.'cd' .or. fname(4:5).eq.'dd'))then
168  write(6,3)trim(fname)
169  stop
170  endif
171  3 format('FATAL in coplotwcv. Bad character in spots 4-5: ',a)
172 
173  if(fname(6:8).ne.ele)then
174  write(6,4)trim(fname),ele
175  stop
176  endif
177  4 format('FATAL in coplotwcv. Bad match of fname / ele: ',a,1x,a)
178 
179  if(fname(2:2).eq.'m')then
180  units='meters'
181  elseif(fname(2:2).eq.'s')then
182  units='arcseconds'
183  else
184  write(6,5)trim(fname)
185  stop
186  endif
187  5 format('FATAL in coplotwcv. Bad units in name: ',a)
188 
189  if(igridsec.le.0)then
190  write(6,6)igridsec
191  else
192  write(gridnote,10)igridsec
193  write(gridnote2,11)igridsec
194  endif
195  6 format('FATAL in coplotwcv. Bad igridsec: ',i0)
196  10 format('(',i0,' sec)')
197  11 format(i0,'.')
198 
199 c ----------------------------------------------------
200 c - FAILSAFES: END
201 c ----------------------------------------------------
202 
203 c ------------------------------------------------------------------
204 c - Contour interval and labeling
205 c ------------------------------------------------------------------
206 c - 2016 07 28: Scrapped the whole thing about scaling cptin.
207 c - Just bring in the interval for an 8 color spread, period.
208  cptin = cptin6
209 
210 c - 2016 03 01:
211 c cptin = cptin6 * 0.75d0
212 c - End 2016 03 01
213 
214  conin = cptin
215  conlb = conin / 2.d0
216 
217 c ----------------------------------------------
218 c - GMT COMMANDS: BEGIN
219 c ----------------------------------------------
220 
221 
222 c - Header of commands/echoes:
223 c - 2016 07 29:
224  write(99,991)ele,trim(units),trim(region),trim(fn(ij)),
225  *trim(suffixused),
226  *ele,trim(units),trim(region),trim(fn(ij)),
227  *trim(suffixused)
228 c write(99,991)ele,trim(units),trim(region),trim(fn(ij)),
229 c *ele,trim(units),trim(region),trim(fn(ij))
230 
231 
232 c - GMT call to create the color palette:
233 c - Store the palette as file "temp.cpt", to be
234 c - deleted later.
235  write(99,901)cptlo,cpthi,cptin
236 
237 c - Begin 2016 03 01:
238 c 901 format(
239 c *'makecpt -Crainbow -T',f0.6,'/',f0.6,'/',f0.6,
240 c *' -Z > temp.cpt')
241 c 901 format(
242 c *'makecpt -Crainbow -T',f0.6,'/',f0.6,'/',f0.6,
243 c *' > temp.cpt')
244 c - 2016 08 25
245 c 901 format(
246 c *'makecpt -Crainbow -T',f0.10,'/',f0.10,'/',f0.10,
247 c *' > temp.cpt')
248 c - 2016 09 07
249 c 901 format(
250 c *'gmtset D_FORMAT %.12G',/,
251 c *'makecpt -Crainbow -T',f0.10,'/',f0.10,'/',f0.10,
252 c *' > temp.cpt',/,
253 c *'gmtset D_FORMAT %.2G')
254 c - 2016 09 07
255  901 format(
256  *'gmtset D_FORMAT %.12G',/,
257  *'makecpt -Crainbow -T',f0.10,'/',f0.10,'/',f0.10,
258  *' > temp.cpt',/,
259  *'gmtset D_FORMAT %.3G')
260 
261 
262 c - GMT call to create the gradient file from
263 c - the "grd" formatted version of our input grid.
264 c - Store the gradients as file "tempi.grd" to be
265 c - deleted later.
266 
267 c - Updated 2016 02 29:
268 c write(99,902)fname(1:8),trim(suffixused)
269  902 format(
270  *'grdgradient ',a,'.',a,
271  *'.grd -N4.8 -A90 -M -Gtempi.grd')
272 c - Until here 2016 02 29
273 
274 c - GMT call to create the color render of the
275 c - gridded data. Store as file "plot.ps"
276 c - to be deleted later.
277 
278  write(99,903)fname(1:8),trim(suffixused),
279  *bw(ij),be(ij),bs(ij),bn(ij),
280  *jm(ij),b1(ij),b2(ij),
281  *trim(newdtm),trim(olddtm),elecap,igridsec,
282  *trim(region),trim(fn(ij)),'method noise'
283 
284 
285 c - Commented out for 2016 02 29:
286 c 903 format(
287 c *'grdimage ',a,'.',a,'.grd',
288 c *' -Ei -Itempi.grd',
289 c *' -R',f0.2,'/',f0.2,'/',f0.2,'/',f0.2,
290 c *' -JM',f3.1,'i -B',f0.2,'/',f0.2,
291 c *':."NADCON v5.0 ',a,' minus ',a,' ',a3,
292 c *'(',i0,' sec)',
293 c *1x,a,'-',a,1x,a,
294 c *':" -Ctemp.cpt -K > plot.ps')
295 c - Commented out for 2016 03 01:
296 c 903 format(
297 c *'grdimage ',a,'.',a,'.grd',
298 c *' -Ei ',
299 c *' -R',f0.2,'/',f0.2,'/',f0.2,'/',f0.2,
300 c *' -JM',f3.1,'i -B',f0.2,'/',f0.2,
301 c *':."NADCON v5.0 ',a,' minus ',a,' ',a3,
302 c *'(',i0,' sec)',
303 c *1x,a,'-',a,1x,a,
304 c *':" -Ctemp.cpt -K > plot.ps')
305 c - Below for 2016 08 25:
306 c 903 format(
307 c *'grdimage ',a,'.',a,'.grd',
308 c *' -Ei -Xc',
309 c *' -R',f0.2,'/',f0.2,'/',f0.2,'/',f0.2,
310 c *' -JM',f3.1,'i -B',f0.2,'/',f0.2,
311 c *':."NADCON v5.0 ',a,' minus ',a,' ',a3,
312 c *'(',i0,' sec)',
313 c *1x,a,'-',a,1x,a,
314 c *':" -Ctemp.cpt -K > plot.ps')
315 c - 2016 08 29:
316  903 format(
317  *'grdimage ',a,'.',a,'.grd',
318  *' -Ei -Xc',
319  *' -R',f0.6,'/',f0.6,'/',f0.6,'/',f0.6,
320  *' -JM',f3.1,'i -B',f0.6,'/',f0.6,
321  *':."NADCON v5.0 ',a,' minus ',a,' ',a3,
322  *'(',i0,' sec)',
323  *1x,a,'-',a,1x,a,
324  *':" -Ctemp.cpt -K > plot.ps')
325 
326 c - GMT call to put a color scale on the map. Add it
327 c - to file "plot.ps".
328 
329 c - 2016 07 21:
330 c qqa = jm(ij) - 1.d0
331 c qqb = qqa / 2.d0
332 c write(99,904)qqb,qqa,trim(units)
333 c - 2016 08 25
334  qqa = jm(ij)/2
335  write(99,904)qqa,trim(units)
336 
337  904 format(
338  *'psscale -D',f3.1,'i/-0.4i/4.0i/0.2ih',
339  *' -Ctemp.cpt -I0.4 -B/:',a,
340  *': -O -K >> plot.ps')
341 
342 c write(99,904)trim(units)
343 c 904 format(
344 c *'psscale -D4i/-0.4i/8i/0.2ih -Ctemp.cpt -I0.4 -B/:',a,
345 c *': -O -K >> plot.ps')
346 
347 c - GMT call to put contours on the map.
348 
349 c - 2016 07 28...skip contours if this is a d3, 09 or "ete" plot
350  ll = len(trim(suffixused))
351  if(suffixused(ll-1:ll).eq.'d3')goto 807
352  if(suffixused(ll-1:ll).eq.'09')goto 807
353  if(fname(3:5).eq.'ete')goto 807
354 
355 c - 2016 08 30:
356  write(99,908)fname(1:8),trim(suffixused)
357 c - 2016 07 29:
358 c write(99,908)fname(1:8),trim(suffixused),
359 c *bw(ij),be(ij),bs(ij),bn(ij)
360 c - 2016 07 21:
361 c write(99,908)fname(1:8),trim(suffixused),conin,
362 c *bw(ij),be(ij),bs(ij),bn(ij)
363 c write(99,908)fname(1:8),trim(suffixused),conin,
364 c *bw(ij),be(ij),bs(ij),bn(ij),
365 c *jm(ij),conlb
366 
367 c - 2016 08 30
368  908 format(
369  *'grdcontour ',a,'.',a,'.grd',
370  *' -Ctemp.cpt',
371  *' -R',
372  *' -JM -Wthin',
373  *' -A- -O -K >> plot.ps')
374 c - 2016 07 29:
375 c 908 format(
376 c *'grdcontour ',a,'.',a,'.grd',
377 c *' -Ctemp.cpt',
378 c *' -R',f0.2,'/',f0.2,'/',f0.2,'/',f0.2,
379 c *' -JM -Wthin',
380 c *' -A- -O -K >> plot.ps')
381 c - 2016 07 21:
382 c 908 format(
383 c *'grdcontour ',a,'.',a,'.grd',
384 c *' -C',f0.5,
385 c *' -R',f0.2,'/',f0.2,'/',f0.2,'/',f0.2,
386 c *' -JM -Wthin',
387 c *' -A- -O -K >> plot.ps')
388 c 908 format(
389 c *'grdcontour ',a,'.',a,'.grd',
390 c *' -C',f0.5,
391 c *' -R',f0.2,'/',f0.2,'/',f0.2,'/',f0.2,
392 c *' -JM',f3.1,'i -Wthin',
393 c *' -A',f0.5,' -O -K >> plot.ps')
394 
395 c - 2016 07 28 - Skip to here (skipping contours) for d3, 09 or "ete" plots
396  807 continue
397 
398 c - 2016 07 28 - Skip the coverage if this is a "d3" plot, 09 plot or "ete" plot *and*
399 c - we are at the overall map level of 1 ("entire")
400  if(suffixused(ll-1:ll).eq.'d3' .and. ij.eq.1)goto 808
401  if(suffixused(ll-1:ll).eq.'09' .and. ij.eq.1)goto 808
402  if(fname(3:5).eq.'ete' .and. ij.eq.1)goto 808
403 
404 c - GMT call to overlay the coverage
405  write(99,909)trim(cvfname)
406 
407  909 format(
408  *'psxy ',a,' -R -J -Sc0.02i -Gblack -O -K >> plot.ps')
409 
410  808 continue
411 
412 c - GMT call to create the shoreline. Add it to
413 c - file "plot.ps".
414 c - ALWAYS plot the coast last, as it closes the PS file
415  call plotcoast(region,99)
416 
417 c - GMT call to convert the plot.ps file to plot.jpg.
418  write(99,905)
419  905 format(
420  *'ps2raster plot.ps -Tj -P -A')
421 
422 c - Change name of JPG to its final name:
423  write(99,906)fname(2:8),trim(suffixused),trim(fn(ij))
424  906 format('mv plot.jpg c',a,'.',a,'.',a,'.jpg')
425 
426 c - Remove all the temporary files
427  write(99,907)
428 
429 c - Updated 2016 02 29:
430 c 907 format(
431 c *'rm -f temp.cpt',/,
432 c *'rm -f tempi.grd',/,
433 c *'rm -f plot.ps')
434  907 format(
435  *'rm -f temp.cpt',/,
436  *'rm -f plot.ps')
437 c - Until here 2016 02 29
438 
439 
440  991 format(
441  *'# -----------------------------------------------------',/,
442  *'# color plots with coverage in ',a,1x,a,1x,a,1x,a,
443  * 1x,' Grid:',a/,
444  *'# -----------------------------------------------------',/,
445  *'echo ...color plots with coverage in ',a,1x,a,1x,a,1x,a,
446  * 1x,' Grid:',a)
447 c 991 format(
448 c *'# -----------------------------------------------------',/,
449 c *'# color plots with coverage in ',a,1x,a,1x,a,1x,a,/,
450 c *'# -----------------------------------------------------',/,
451 c *'echo ...color plots with coverage in ',a,1x,a,1x,a,1x,a)
452 
453  return
454  end
subroutine coplotwcv(ele, fname, bw, be, bs, bn, jm, b1, b2, maxplots, olddtm, newdtm, region, elecap, ij, cptlo, cpthi, cptin6, suffixused, igridsec, fn, cvfname)
Subroutine to make GMT calls to do a color raster rendering of gridded data, with coverage overlaid...
Definition: coplotwcv.f:72
subroutine plotcoast(region, ifnum)
Subroutine to write GMT-based commands to create a shoreline Write GMT-based commands to create a sho...
Definition: plotcoast.f:44