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