<p><b>duda</b> 2012-01-05 14:49:04 -0700 (Thu, 05 Jan 2012)</p><p>Add new functionality in global_scvt:<br>
<br>
 - in addition to the n final generating points, write 3n-6 refinement points <br>
   to the end of the locs.dat.out file, which can then be used on the next <br>
   execution of global_scvt by setting np to 4n-6 in the namelist<br>
<br>
 - using a new namelist parameter min_dx, which gives the targeted minimum<br>
   grid distance, compute an estimate for the number of required <br>
   generating points to meet that target based on the specified density function<br>
<br>
<br>
M    src/module_grid_params.F<br>
M    src/grid_gen.F<br>
M    src/module_grid_meta.F<br>
M    src/module_scvt.F<br>
M    namelist.input<br>
</p><hr noshade><pre><font color="gray">Modified: trunk/grid_gen/global_scvt/namelist.input
===================================================================
--- trunk/grid_gen/global_scvt/namelist.input        2012-01-05 19:39:29 UTC (rev 1298)
+++ trunk/grid_gen/global_scvt/namelist.input        2012-01-05 21:49:04 UTC (rev 1299)
@@ -5,4 +5,5 @@
  eps = 0.000000001
  l2_conv = .true.
  inf_conv = .false.
+ min_dx = 120000.0
 /

Modified: trunk/grid_gen/global_scvt/src/grid_gen.F
===================================================================
--- trunk/grid_gen/global_scvt/src/grid_gen.F        2012-01-05 19:39:29 UTC (rev 1298)
+++ trunk/grid_gen/global_scvt/src/grid_gen.F        2012-01-05 21:49:04 UTC (rev 1299)
@@ -18,6 +18,10 @@
    integer :: if
    character (len=80) :: frame_name
 
+   real :: pi
+   real :: area_per_sample, nhexs, sum_nhexs, hex_area
+   type (geo_point) :: p
+
    integer :: i, j, k, nb, ier
 
    real, allocatable, dimension(:)       :: rlat, rlon, vclat, vclon, x, y, z, xc, yc, zc
@@ -35,6 +39,30 @@
 
    call read_namelist()
 
+
+   pi = 4.0*atan(1.0)
+
+   area_per_sample = 4.0 * pi * 6370000**2.0 / 6000000.0
+   sum_nhexs = 0.0
+   write(0,'(a,f10.1)') 'Computing an estimate for the required number of cells to reach dx=', min_dx
+   do if = 1,5
+      nhexs = 0.0
+      do i=1,6000000
+         call random_point(p)
+         d1 = density_for_point(p)
+         dl = min_dx / (d1 ** 0.25)
+         hex_area = sqrt(3.0) / 2.0 * dl**2.0
+         nhexs = nhexs + area_per_sample / hex_area
+      end do
+!      write(0,'(a,i2,a,i)') 'Estimate ',if,' for required # hexs:', nint(nhexs)
+      sum_nhexs = sum_nhexs + nhexs
+      write(0,'(a,i3,a)',advance='no') ' ...',if*20,'%'
+   end do
+   write(0,*) ' '
+   write(0,*) 'Estimated # hexs:', nint(sum_nhexs/5.0)
+   write(0,*) ' '
+
+
    n = np
 
    ntmax = 6*n

Modified: trunk/grid_gen/global_scvt/src/module_grid_meta.F
===================================================================
--- trunk/grid_gen/global_scvt/src/module_grid_meta.F        2012-01-05 19:39:29 UTC (rev 1298)
+++ trunk/grid_gen/global_scvt/src/module_grid_meta.F        2012-01-05 21:49:04 UTC (rev 1299)
@@ -928,10 +928,13 @@
       !    of a grid using the grid_gen code
       !
       open(22,file='locs.dat.out',form='formatted')
-      write(22,*) n,n
-      do i=1,n
+      write(22,*) nCells,nEdges
+      do i=1,nCells
          write(22,'(10x,f22.10,f23.10,f23.10)') xCell(i), yCell(i), zCell(i)
       end do
+      do i=1,nEdges
+         write(22,'(10x,f22.10,f23.10,f23.10)') xEdge(i), yEdge(i), zEdge(i)
+      end do
    !  do i=1,nCells
    !     write(22,'(f13.10,1x,f13.10)') latCell(i), lonCell(i)
    !  end do

Modified: trunk/grid_gen/global_scvt/src/module_grid_params.F
===================================================================
--- trunk/grid_gen/global_scvt/src/module_grid_params.F        2012-01-05 19:39:29 UTC (rev 1298)
+++ trunk/grid_gen/global_scvt/src/module_grid_params.F        2012-01-05 21:49:04 UTC (rev 1299)
@@ -5,6 +5,7 @@
    logical :: l2_conv, inf_conv
    integer :: n_scvt_iterations
    real :: eps
+   real :: min_dx
 
    contains
 
@@ -15,7 +16,7 @@
       integer :: funit
       real :: pi
 
-      namelist /domains/ np, locs_as_xyz, n_scvt_iterations, eps, l2_conv, inf_conv
+      namelist /domains/ np, locs_as_xyz, n_scvt_iterations, eps, l2_conv, inf_conv, min_dx
 
       pi = 4.0*atan(1.0)
 
@@ -27,6 +28,7 @@
       eps = 0.0000000001
       l2_conv = .true.
       inf_conv = .false.
+      min_dx = 120000.0
 
       open(funit,file='namelist.input',status='old',form='formatted')
       read(funit,domains)

Modified: trunk/grid_gen/global_scvt/src/module_scvt.F
===================================================================
--- trunk/grid_gen/global_scvt/src/module_scvt.F        2012-01-05 19:39:29 UTC (rev 1298)
+++ trunk/grid_gen/global_scvt/src/module_scvt.F        2012-01-05 21:49:04 UTC (rev 1299)
@@ -189,6 +189,43 @@
 
 
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   !  SUBROUTINE RANDOM_POINT
+   !
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+   subroutine random_point(p)
+
+      type (geo_point), intent(inout) :: p
+      real :: x, y, z, m
+      real :: pi
+
+      pi = 4.0*atan(1.0)
+
+      x = 0.0
+      y = 0.0
+      z = 0.0
+      m = 2.0
+
+      do while (m &gt; 1.0 .or. (x == 0.0 .and. y == 0.0 .and. z == 0.0))
+         call random_number(x)
+         call random_number(y)
+         call random_number(z)
+         x = x * 2.0 - 1.0
+         y = y * 2.0 - 1.0
+         z = z * 2.0 - 1.0
+         m = x**2 + y**2 + z**2
+      end do
+
+      m = 1.0 / sqrt(m)
+      x = x * m
+      y = y * m
+      z = z * m
+
+      call convert_xl(x, y, z, p)
+
+   end subroutine random_point
+
+
+   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !  FUNCTION DENSITY_FOR_POINT
    !
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

</font>
</pre>