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