Re: qsort

From: Michael Barlage (barlage AT atmo.arizona.edu)
Date: Thu Jun 16 2005 - 11:31:02 MDT

  • Next message: jerry: "reorder dimension"

    Sorry Dennis, I should have supplied more machine info. I've run this
    using NCL v032 on a Linux FC3 Machine with 1GB RAM and 2GB Swap and using
    NCL v031 on a Linux FC3 Machine with 2GB RAM and 2GB Swap. I've also just
    run it on a DEC Alpha machine with the same results.

    This simple code I provided is for debug purposes and won't bring the
    first machine to it's knees until about iteration 100. That's why I was
    curious about what 'top' tells you about the process memory usage. When I
    run this, every iteration will take about 30MB more memory until it
    eventually runs out of swap.

    M

    ==================================
    Michael Barlage, PhD
    Research Scientist
    Institute of Atmospheric Physics
    University of Arizona
    (520) 626-3552
    barlage@atmo.arizona.edu
    ==================================

    On Thu, 16 Jun 2005, Dennis Shea wrote:

    > >Just like to know if anyone has noticed any memory issues while using
    > >qsort. I'm sorting large arrays in a loop and deleting variables along the
    > >way to save memory but it seems that everytime qsort is called, temp
    > >variables are created and then not deleted(that's my diagnosis anyway).
    > >Run this test program and top. It eventually sucks up my machine memory:
    > >
    > >begin
    > > do i = 0,200
    > > print((/i/))
    > > x1D = new((/4000000/),integer)
    > > x1D = 1
    > > qsort(x1D)
    > > delete(x1D)
    > > end do
    > >end
    > >
    > >Also, I think the example on qsort is incorrect. 'qsort_x = qsort(x)' will
    > >not work.
    > >
    > >http://www.ncl.ucar.edu/Document/Functions/Built-in/qsort.shtml
    > >
    > Hello
    >
    > [1]
    > yes ... the documentation is incorrect.
    > qsort is a procedure not a function.
    > I have fixed that. [do a reload on the above page]
    >
    > It should be:
    >
    > x = (/4.3, 0.9, 5.2, 7.7, 2.3, -4.7, -9.1/)
    > qsort(x)
    >
    > THX for the 'heads-up'
    > ----
    > [2]
    > I copied your code and ran the following on several of our machines.
    > [SGI: 64GB memory], [linux: 8GB and 2GB], [Solaris: ?1GB or 2 GB]
    >
    > %>ncl testQ.ncl
    > Copyright (C) 1995-2004 - All Rights Reserved
    > University Corporation for Atmospheric Research
    > NCAR Command Language Version 4.2.0.a032
    > The use of this software is governed by a License Agreement.
    > See http://ngwww.ucar.edu/ncl/ for more details.
    > (0) 0
    > (0) 1
    > (0) 2
    > (0) 3
    > (0) 4
    > (0) 5
    > (0) 6
    > (0) 7
    > (0) 8
    > (0) 9
    > [I stopped it here]
    >
    > I also tried some large vectors on a large memory machine:
    >
    > /home/tempest/shea>ncl
    > ncl 0> N = 10000000
    > ncl 1> x = random_uniform(-10,10,N)
    > ncl 2> qsort(x)
    > ncl 3> N = 50000000 ; this is *slow* but works
    > ncl 4> y = random_uniform(-10,10,N)
    > ncl 5> qsort(y)
    > ncl 6> quit
    >
    > Not fast but no memory error.
    >
    > What OS [uname -a] and how much memory do you have available?
    >
    > ---
    > Incidently,
    >
    > do i = 0,200
    > print((/i/))
    > x1D = new((/4000000/),integer)
    > x1D = 1
    > qsort(x1D)
    > delete(x1D) ; *no* need to do this here because
    > ; the size/type does not change with
    > ; each iteration
    > end do
    >
    > ---
    > I suspect that the above is a sample for debug
    > but the best way would be
    >
    > x1D = new((/4000000/),integer) ; one memory allocation
    >
    > do i = 0,200
    > print((/i/)) ; or print("i="+i)
    > x1D = 1 ; all 1
    > qsort(x1D) ; obviously no need in this trivial case
    > end do
    >
    > Regards
    > D
    >
    >

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Mon Jun 20 2005 - 08:43:23 MDT