source: palm/trunk/SCRIPTS/NCL/spectra.ncl @ 957

Last change on this file since 957 was 957, checked in by heinze, 12 years ago

png output adjusted for NCL versions higher than 5.2.1

File size: 23.8 KB
Line 
1load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
2load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
3load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
4
5;***************************************************
6; load .ncl.config or .ncl.config.default
7;***************************************************
8
9function which_script()
10local script
11begin
12   script="spectra"
13   return(script)
14end
15   
16if (isfilepresent("$PALM_BIN/../../.ncl.config")) then
17   loadscript("$PALM_BIN/../../.ncl.config")
18else
19  if (isfilepresent("$PALM_BIN/NCL/.ncl.config.default")) then
20     loadscript( "$PALM_BIN/NCL/.ncl.config.default")
21  else
22      palm_bin_path = getenv("PALM_BIN")
23      print(" ")
24      print("Neither the personal configuration file '.ncl.config' exists in")
25      print("~/palm/current_version")
26      print("nor the default configuration file '.ncl.config.default' "+\
27            "exists in")
28      print(palm_bin_path + "/NCL")
29      print(" ")
30      exit
31   end if
32end if   
33
34begin
35
36   ;***************************************************
37   ; Retrieving the NCL version used
38   ;***************************************************
39   
40   ncl_version_ch = systemfunc("ncl -V")
41   ncl_version    = stringtofloat(ncl_version_ch)
42
43   ;***************************************************
44   ; Retrieving the double quote character
45   ;***************************************************
46   
47   dq=str_get_dq()
48
49   ;***************************************************
50   ; set up default parameter values and strings
51   ;***************************************************
52 
53   if (file_1 .EQ. "File in") then
54      print(" ")
55      print("Declare input file 'file_1=' in '.ncl.config' or prompt")
56      print(" ")
57      exit
58   else
59      file_in = file_1   
60   end if
61
62   if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND.   \
63       format_out .NE. "eps" .AND. format_out .NE. "ps" .AND.    \
64       format_out .NE. "epsi" .AND. format_out .NE. "ncgm" .AND. \
65       format_out .NE. "png")then
66      print(" ")
67      print("'format_out = "+format_out+"' is invalid and set to'x11'")
68      print(" ")
69      format_out="x11"
70   end if
71
72   if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then
73      print(" ")
74      print("Output of png files not available")
75      print("png output is avaiable with NCL version 5.2.0 and higher ")
76      print("NCL version used: " + ncl_version_ch)
77      print(" ")
78      exit
79   end if
80   
81   if (log_x .NE. 0 .AND. log_x .NE. 1)then
82      print(" ")
83      print("'log_x'= "+log_x+" is invalid and set to 1")
84      print(" ")
85      log_x = 1
86   end if 
87   
88   if (log_y .NE. 0 .AND. log_y .NE. 1)then
89      print(" ")
90      print("'log_y'= "+log_y+" is invalid and set to 1")
91      print(" ")
92      log_y = 1
93   end if   
94 
95   if (norm_y .EQ. 0.) then
96      print(" ")
97      print("Normalising with 0 is not allowed, 'norm_y' is set to 1.0")
98      print(" ")
99      norm_y = 1.0
100   end if
101   if (norm_x .EQ. 0.) then
102      print(" ")
103      print("Normalising with 0 is not allowed, 'norm_x' is set to 1.0")
104      print(" ")
105      norm_x= 1.0
106   end if
107   
108   if (sort .NE. "height" .AND. sort .NE. "time") then 
109      print(" ")
110      print("'sort'= "+sort+" is invalid and set to 'height'")
111      print(" ")
112      sort = "height" 
113   end if
114   
115   if (black .NE. 0 .AND. black .NE. 1)then
116      print(" ")
117      print("'black'= "+black+" is invalid and set to 0")
118      print(" ")
119      black = 0
120   end if
121 
122   if (dash .NE. 0 .AND. dash .NE. 1)then
123      print(" ")
124      print("'dash'= "+dash+" is invalid and set to 0")
125      print(" ")
126      dash = 0
127   end if
128
129   ;***************************************************
130   ; open input file
131   ;***************************************************
132   
133   file_in_1 = False
134   if (isStrSubset(file_in, ".nc"))then
135      start_f = -2
136      end_f = -2
137      file_in_1 = True     
138   end if
139
140   if (start_f .EQ. -1)then
141      print(" ")
142      print("'start_f' must be one of the cyclic numbers (at least 0) of "+\
143            "your input file(s)")
144      print(" ") 
145      exit
146   end if
147   if (end_f .EQ. -1)then
148      print(" ")
149      print("'end_f' must be one of the cyclic numbers (at least 0) of "+\
150            "your input file(s)")
151      print(" ") 
152      exit
153   end if
154
155   files=new(end_f-start_f+1,string)
156   
157   if (file_in_1)then
158      if (isfilepresent(file_in))then
159         files(0)=file_in
160      else
161         print(" ")
162         print("1st input file: '"+file_in+"' does not exist")
163         print(" ")
164         exit
165      end if
166   else   
167      if (start_f .EQ. 0)then
168         if (isfilepresent(file_in+".nc"))then
169            files(0)=file_in+".nc"
170            do i=1,end_f
171               if (isfilepresent(file_in+"."+i+".nc"))then   
172                  files(i)=file_in+"."+i+".nc"
173               else
174                  print(" ")
175                  print("Input file: '"+file_in+"."+i+".nc' does not exist")
176                  print(" ")
177                  exit 
178               end if       
179            end do         
180         else
181            print(" ")
182            print("Input file: '"+file_in+".nc' does not exist")
183            print(" ")
184            exit
185         end if
186      else
187         do i=start_f,end_f
188            if (isfilepresent(file_in+"."+i+".nc"))then   
189               files(i-start_f)=file_in+"."+i+".nc"
190            else
191               print(" ")
192               print("Input file: '"+file_in+"."+i+".nc' does not exist")
193               print(" ")
194               exit 
195            end if
196         end do
197      end if
198   end if
199
200   f=addfiles(files,"r")
201   f_att=addfile(files(0),"r")
202   ListSetType(f,"cat")
203   
204   vNam = getfilevarnames(f_att)
205   vType = getfilevartypes(f_att,vNam)
206
207   if ((all(vType .eq. "double"))) then ;distinction if data is double or float
208      check_vType = True
209   else
210      check_vType = False
211   end if
212
213   print(" ")
214   print("Variables in input file:")
215   print("- "+ vNam)
216   print(" ")
217   dim = dimsizes(vNam)
218   vDim = getfiledimsizes(f_att)
219 
220   t_all = f[:]->time
221   nt    = dimsizes(t_all)
222
223   if (nt .EQ. 1)then
224      delta_t=t_all(nt-1)/nt
225   else
226      delta_t_array = new(nt-1,double)
227
228      do i=0,nt-2
229         delta_t_array(i) = t_all(i+1)-t_all(i)
230      end do
231
232      delta_t = min(delta_t_array)
233      delete(delta_t_array)
234   end if
235   
236   k_x=f_att->k_x
237   dimx=dimsizes(k_x)
238   k_y=f_att->k_y
239   dimy=dimsizes(k_y)
240   
241   
242   dim_level=dimsizes(height_level)
243
244   do i=0,dim-1
245      if (vNam(i) .EQ. "zu_sp")then
246         zu=f_att->zu_sp         
247         if (height_level(0) .EQ. -1)then
248            dimz=dimsizes(zu)
249         else
250            if (dim_level .GT. dimsizes(zu))then
251               print(" ")
252               print("'height_level' has more elements than available "+\
253                     "height levels in input file (= "+dimsizes(zu)+")")
254               print(" ")
255               exit
256            else
257               zuh=new(dim_level,double)
258               do le=0,dim_level-1
259                  if (height_level(le) .GE. dimsizes(zu)) then
260                     no_levels=dimsizes(zu)-1
261                     print(" ")
262                     print("Element "+le+" of 'height_level' is greater "  +\
263                          "than the maximum available index in input file "+\
264                          "which is "+no_levels+". Note that the first "   +\
265                          "element has the index 0.")
266                     print(" ")
267                     exit
268                  end if
269                  zuh(le)=zu(height_level(le))
270               end do
271               dimz=dim_level
272            end if   
273         end if 
274      else
275         if (vNam(i) .EQ. "zw_sp")then
276            zw=f_att->zw_sp
277            if (height_level(0) .EQ. -1)then             
278               dimz=dimsizes(zw)
279            else
280               if (dim_level .GT. dimsizes(zw))then
281                  print(" ")
282                  print("'height_level' has more elements than available "+\
283                        "height levels in input file (= "+dimsizes(zw)+")")
284                  print(" ")
285                  exit
286               else
287                  zwh=new(dim_level,double)
288                  do le=0,dim_level-1
289                     if (height_level(le) .GE. dimsizes(zw)) then
290                        no_levels=dimsizes(zw)-1
291                        print(" ")
292                        print("Element "+le+" of 'height_level' is greater "+\
293                              "than the maximum available index in input "  +\
294                              "file which is "+no_levels+". Note that the " +\
295                              "first element has the index 0.")
296                        print(" ")
297                        exit
298                     end if
299                     zwh(le)=zw(height_level(le))
300                  end do
301                  dimz=dim_level
302               end if   
303            end if
304         end if
305      end if
306   end do
307
308   ;****************************************************       
309   ; start of time step and different types of mistakes that could be done
310   ;****************************************************
311   
312   if (start_time_step .EQ. -1.d) then         
313      start_time_step=t_all(0)/3600
314   else
315      if (start_time_step .GT. t_all(nt-1)/3600)then
316         print(" ")
317         print("'start_time_step' = "+ start_time_step +"h is greater than "+\
318               "last time step = "+ t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h")
319         print(" ")
320         print("Select another 'start_time_step'")
321         print(" ")
322         exit
323      end if
324      if (start_time_step .LT. t_all(0)/3600)then
325         print(" ")
326         print("'start_time_step' = "+ start_time_step +"h is lower than "+\
327               "first time step = "+ t_all(0)+"s = "+t_all(0)/3600+"h")       
328         exit
329      end if
330   end if
331
332   do i=0,nt-1     
333      if (start_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \
334          start_time_step .LT. (t_all(i)+delta_t/2)/3600)then
335         st=i
336         break
337      else
338         st=0
339      end if
340   end do
341   
342   ;****************************************************
343   ; end of time step and different types of mistakes that could be done
344   ;****************************************************
345
346   if (end_time_step .EQ. -1.d) then           
347      end_time_step = t_all(nt-1)/3600
348   else
349      if (end_time_step .GT. t_all(nt-1)/3600)then
350         print(" ")
351         print("'end_time_step' = "+ end_time_step +"h is greater than "+\
352               "last time step = " + t_all(nt-1)+"s = "+t_all(nt-1)/3600+"h")
353         print(" ")
354         print("Select another 'end_time_step'") 
355         print(" ")
356         exit
357      end if
358      if (end_time_step .LT. start_time_step/3600)then
359         print(" ")
360         print("'end_time_step' = "+ end_time_step +"h is lower than "+\
361               "'start_time_step' = "+start_time_step+"h")
362         print(" ")
363         print("Select another 'start_time_step' or 'end_time_step'")
364         print(" ")
365         exit
366      end if
367   end if
368
369   do i=0,nt-1     
370      if (end_time_step .GE. (t_all(i)-delta_t/2)/3600 .AND. \
371          end_time_step .LT. (t_all(i)+delta_t/2)/3600)then
372         et=i
373         break
374       else
375         et=0
376      end if
377   end do
378
379   delete(start_time_step)
380   start_time_step=round(st,3)
381   delete(end_time_step)
382   end_time_step=round(et,3)
383
384   print(" ")
385   print("Output of time steps from "+t_all(start_time_step)/3600+" h = "+\
386         t_all(start_time_step)+" s => index = "+start_time_step)
387   print("                     till "+t_all(end_time_step)/3600+" h = "+\
388         t_all(end_time_step)+" s => index = "+end_time_step)
389   print(" ")
390
391   dimt = end_time_step-start_time_step+1
392 
393   ;***************************************************
394   ; set up recourses
395   ;***************************************************
396     
397   res = True
398   res@gsnDraw                 = False
399   res@gsnFrame                = False
400   res@txFont                  = "helvetica"
401   res@tiMainFont              = "helvetica"
402   res@tiXAxisFont             = "helvetica"
403   res@tiYAxisFont             = "helvetica"
404   res@tmXBLabelFont           = "helvetica"
405   res@tmYLLabelFont           = "helvetica"
406   res@lgLabelFont             = "helvetica"
407   res@tmLabelAutoStride       = True
408   
409   res@lgLabelFontHeightF     = font_size_legend
410   res@lgTitleFontHeightF     = font_size
411   res@txFontHeightF      = font_size
412   res@tiXAxisFontHeightF = font_size
413   res@tiYAxisFontHeightF = font_size
414   res@tmXBLabelFontHeightF = font_size
415   res@tmYLLabelFontHeightF = font_size
416   
417   res@tmXBMinorPerMajor = 4
418   res@tmYLMinorPerMajor = 4
419   
420   if (log_x .EQ. 1) then
421      res@trXLog = True
422   else
423      res@trXLog = False
424   end if
425   if (log_y .EQ. 1)then
426      res@trYLog = True
427   else 
428      res@trYLog = False
429   end if
430
431   legend_label=new(dimt,string)
432   legend_label_zu=new(dimz,double)
433   legend_label_zw=new(dimz,double)
434   legend_label_z=new(dimz,double)
435   do p=start_time_step,end_time_step
436      legend_label(p-start_time_step)=sprintf("%6.2f", t_all(p)/3600)
437   end do 
438   if (sort .EQ. "time")
439      plot  = new(dim*dimz,graphic)
440      np=dimt
441      res@lgTitleString = "Time (h)"
442   else
443      plot  = new(dim*dimt,graphic)
444      np=dimz
445     
446      do p=0,dimz-1
447         if (height_level(0) .EQ. -1)then
448            legend_label_zu(p)=round(zu(p),3)
449            legend_label_zw(p)=round(zw(p),3)
450         else
451            legend_label_zu(p)=round(zuh(p),3)
452            legend_label_zw(p)=round(zwh(p),3)
453         end if
454      end do
455   end if
456
457   if (black .eq. 0 ) then
458      if (np .EQ. 1)then
459         color = 237
460      else   
461         step=round(235/(np-1),3)
462         color = ispan(2,237,step)
463      end if
464   else
465      color = 2
466   end if
467   if ( dash .eq. 0 ) then
468      res@xyMonoDashPattern = True
469   end if
470
471   if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then
472      format_out@wkPaperSize = "A4"
473   end if
474   if ( format_out .EQ. "png" ) then
475      format_out@wkWidth  = 1000
476      format_out@wkHeight = 1000
477   end if
478
479   wks=gsn_open_wks(format_out,file_out)
480   gsn_define_colormap(wks,"rainbow+white")
481
482   n=0
483   do varn =dim-1,0,1
484     
485      check = True
486
487      if ( isStrSubset( vNam(varn), "time") .OR.  \
488           isStrSubset( vNam(varn), "zu_sp") .OR. \
489           isStrSubset( vNam(varn), "zw_sp") .OR. \
490           isStrSubset( vNam(varn), "k_x") .OR.   \
491           isStrSubset( vNam(varn), "k_y")) then
492            check = False
493      end if
494
495      if (var .NE. "all") then
496         check = isStrSubset( var,","+vNam(varn)+"," )
497      end if
498
499      if(check) then
500
501         temp = f[:]->$vNam(varn)$
502         data = temp(start_time_step:end_time_step,0:dimz-1,:)
503
504         temp_att = f_att->$vNam(varn)$
505         a=getvardims(temp_att)
506         b=dimsizes(a)
507         delete(temp_att)
508
509         if (height_level(0) .NE. -1)then
510            do te=0,dimz-1
511               data(:,te,:) = temp(start_time_step:end_time_step,\
512                                                    height_level(te),:)       
513            end do
514         end if
515
516         data=data/(norm_y*norm_x)
517           
518         do i=0,b-1           
519            if (isStrSubset( a(i),"zu_sp" ))then
520               legend_label_z=legend_label_zu
521               if (height_level(0) .NE. -1)then
522                  z=zuh
523               else
524                  z=zu
525               end if
526            else
527               if (isStrSubset( a(i),"zw_sp" ))then
528                  legend_label_z=legend_label_zw
529                  if (height_level(0) .NE. -1)then
530                     z=zwh
531                  else
532                     z=zw
533                  end if   
534               end if
535            end if
536         end do 
537         
538         if (check_vType) then
539            min_y=new(dimz,double)
540            max_y=new(dimz,double)
541         else
542            min_y=new(dimz,float)
543            max_y=new(dimz,float)
544         end if
545         min_x=new(dimz,double)
546         max_x=new(dimz,double)
547         
548         plot_h  = new(dimz,graphic)
549         
550         if (isStrSubset(vNam(varn),"x"))then
551            x_axis = new((/dimz,dimx/),double)
552            do q=0,dimz-1
553               x_axis(q,:) = f_att->k_x
554               x_axis = x_axis/norm_x
555            end do
556            if (norm_x .NE. 1.)then
557               res@tiXAxisString = "k~B~x~N~ ("+unit_x+")"
558            else
559               if (norm_height .EQ. 1)then
560                  res@tiXAxisString = "k~B~x~N~ x z (1"
561               else
562                  res@tiXAxisString = "k~B~x~N~ (1/m)"
563               end if
564            end if
565            dim_r=dimx
566         else
567            x_axis=new((/dimz,dimy/),double)
568            do q=0,dimz-1
569               x_axis(q,:) = f_att->k_y
570               x_axis = x_axis/norm_x
571            end do
572            if (norm_x .NE. 1.)then
573               res@tiXAxisString = "k~B~x~N~ ("+unit_x+")"
574            else
575               if (norm_height .EQ. 1)then
576                  res@tiXAxisString = "k~B~x~N~ x z (1)"
577               else
578                  res@tiXAxisString = "k~B~x~N~ (1/m)"
579               end if
580            end if
581            dim_r=dimy
582         end if
583       
584         if (sort .EQ. "time")
585            res@xyLineColors = color
586            res@pmLegendDisplayMode     = "Always"
587            res@pmLegendSide            = "Top"
588            res@pmLegendParallelPosF    = 1.2
589            res@pmLegendOrthogonalPosF  = -1.0
590            res@pmLegendWidthF          = 0.12
591            res@pmLegendHeightF         = 0.04*\
592                                          (end_time_step-start_time_step+1)
593            do p=dimz-1,0,1
594               if (log_y .EQ. 1)then 
595                  do q=0,dimt-1
596                     do r=0,dim_r-1
597                        if (data(q,p,r) .EQ. 0)then
598                           st=p+start_time_step
599                           print(" ")
600                           print("'"+vNam(varn)+"("+st+","+q+","+r+")' is "+\
601                                 "equal 0. Logarithmic scale for y-axis "+\
602                                 "and height "+z(p)+" cannot be used")
603                           print(" ")
604                           res@trYLog = False
605                        end if
606                     end do
607                  end do
608               end if
609               res@gsnLeftString      = vNam(varn)
610               res@gsnRightString     = "Height = "+z(p)+"m"               
611               res@tiYAxisString      = "("+unit_y+")"           
612               res@xyExplicitLegendLabels  = legend_label             
613               if (norm_height .EQ. 1)then
614                  data(:,p,:)=data(:,p,:)*doubletofloat(z(p))
615                  x_axis(p,:) = x_axis(p,:)*z(p)
616               end if
617               res@trXMinF = min(x_axis(p,:))
618               res@trXMaxF = max(x_axis(p,:))
619               plot(n)  = gsn_csm_xy(wks,x_axis(p,:),data(:,p,:),res)
620               n=n+1
621            end do
622         else
623            if (sort .EQ. "height")
624               do p=0,dimt-1           
625                  do q=0,dimz-1
626                     do r=0,dim_r-1
627                        if (data(p,q,r) .EQ. 0)then
628                           st=p+start_time_step
629                           print(" ")
630                           print("'"+vNam(varn)+"("+st+","+q+","+r+")' "+\
631                                 "is equal 0. Logarithmic scale for y-axis "+\
632                                 "and time "+legend_label(p)+" h cannot be used")
633                           print(" ")
634                           res@trYLog = False
635                        end if
636                     end do
637                     if (norm_height .EQ. 1 .AND. p .EQ. 0)then
638                        data(p,q,:) = data(p,q,:)*\
639                                           doubletofloat(legend_label_z(q))
640                        x_axis(q,:) = x_axis(q,:)*\
641                                           doubletofloat(legend_label_z(q))
642                     end if
643                     max_y(q)=max(data(p,q,:))
644                     min_y(q)=min(data(p,q,:))
645                     min_x(q)=min(x_axis(q,:))
646                     max_x(q)=max(x_axis(q,:))
647                  end do
648                  do q=0,dimz-1
649                     res@xyLineColor = color(q)
650                     if (dash .EQ. 1)then
651                        res@xyDashPattern = q
652                     end if
653                     if (q .EQ. 0)then
654                        res@tiYAxisString      = "("+unit_y+")"
655                        res@gsnLeftString      = vNam(varn)
656                        res@gsnRightString     = "Time = "+legend_label(p)+"h"
657                        res@trXMinF = min(min_x)
658                        res@trXMaxF = max(max_x)
659                        res@trYMinF = min(min_y)
660                        res@trYMaxF = max(max_y)
661                       
662                        plot_h(q)  = gsn_csm_xy(wks,x_axis(q,:),\
663                                                         data(p,q,:),res)
664                       
665                        lgres = True
666                        if (dash .EQ. 0)then
667                           lgres@lgMonoDashIndex = True
668                        else
669                           lgres@lgDashIndexes   = ispan(0,dimz-1,1)
670                        end if
671                        if (black .EQ. 1)then
672                           lgres@lgMonoLineColors = True
673                        else
674                           lgres@lgLineColors = color
675                        end if
676                        lgres@lgTitleString      = "Height (m)" 
677                        lgres@lgLabelFont        = "helvetica"
678                        lgres@lgLabelFontHeightF = font_size_legend*6
679                        lgres@lgTitleFontHeightF = font_size     
680                        lgres@vpWidthF           = 0.12           
681                        lgres@vpHeightF          = font_size_legend*(dimz+3)
682 
683                        lbid = gsn_create_legend(wks,dimz,legend_label_z,lgres)
684
685                        amres = True
686                        amres@amParallelPosF   = 0.75               
687                        amres@amOrthogonalPosF = 0.15           
688                        annoid1 = gsn_add_annotation(plot_h(q),lbid,amres)
689                     else
690                        plot_h(q)  = gsn_csm_xy(wks,x_axis(q,:),\
691                                                        data(p,q,:),res)
692                        overlay(plot_h(0),plot_h(q))
693                     end if
694                  end do             
695                  plot(n)=plot_h(0)
696                  n=n+1
697               end do
698            end if
699         end if
700         delete(data)
701         delete(temp)
702         delete(x_axis)
703         delete(min_x)
704         delete(max_x)
705         delete(min_y)
706         delete(max_y)
707         delete(plot_h)
708      end if
709   end do
710
711   if (n .EQ. 0) then
712      print(" ")
713      print("The variables 'var="+var+"' do not exist on your input file;")
714      print("be sure to have one comma berfore and after each variable")
715      print(" ")
716      exit
717   end if
718 
719   ; ***************************************************
720   ; merge plots onto one page
721   ; ***************************************************
722
723   resP                        = True
724   resP@txFont                 = "helvetica"
725   resP@txString               = f_att@title
726   resP@txFuncCode             = "~"
727   resP@txFontHeightF          = 0.015
728
729   no_frames = 0
730
731   if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. \
732                                          n .gt. no_rows*no_columns) then
733      gsn_panel(wks,plot,(/n,1/),resP)
734      print(" ")
735      print("Outputs to .eps or .epsi have only one frame")
736      print(" ")
737   else   
738      do i = 0,n-1, no_rows*no_columns
739         if( (i+no_rows*no_columns) .gt. (n-1)) then
740            gsn_panel(wks,plot(i:n-1),(/no_rows,no_columns/),resP)
741            no_frames = no_frames + 1
742         else
743            gsn_panel(wks,plot(i:i+no_rows*no_columns-1),\
744                                           (/no_rows,no_columns/),resP)
745            no_frames = no_frames + 1   
746         end if
747      end do
748   end if
749
750   if (format_out .EQ. "png" ) then
751     png_output = new((/no_frames/), string)
752     j = 0
753
754     if (no_frames .eq. 1) then
755        if (ncl_version .GE. 6 ) then
756           png_output(0) = file_out+".png"
757        else
758           png_output(0) = file_out+".00000"+1+".png"
759        end if
760        ;using imagemagick's convert for reducing the white
761        ;space around the plot
762        cmd = "convert -geometry 1000x1000 -density 300 -trim " +  \
763              png_output(0) + " " + png_output(0)
764       system(cmd)
765     else
766
767       do i=0, no_frames-1
768         j = i + 1
769         if (j .LE. 9) then
770           png_output(i) = file_out+".00000"+j+".png"
771         end if
772         if (j .GT. 9 .AND. j .LE. 99) then
773           png_output(i) = file_out+".0000"+j+".png"
774         end if
775         if (j .GT. 99 .AND. j .LE. 999) then
776           png_output(i) = file_out+".000"+j+".png"
777         end if
778         if (j .GT. 999) then
779           png_output(i) = file_out+".00"+j+".png"
780         end if
781
782         ;using imagemagick's convert for reducing the white
783         ;space around the plot
784         cmd = "convert -geometry 1000x1000 -density 300 -trim " +  \
785                png_output(i) + " " + png_output(i)
786         system(cmd)
787       end do
788     end if
789
790     print(" ")
791     print("Output to: "+ png_output)
792     print(" ")
793   else
794     print(" ")
795     print("Output to: " + file_out +"."+ format_out)
796     print(" ")
797   end if
798   
799end
Note: See TracBrowser for help on using the repository browser.