[gradsusr] shape files and printim: memory allocation error
Sergey Varlamov
vsm at jamstec.go.jp
Wed May 2 07:07:03 EDT 2012
Jeff,
The problem was not in the available memory size.
It was in the memory allocation error in GrADS
when it had to allocate memory, for example, for 99000
points using this values assigned to "short int".
In my error case it was truncated to negative value
and then used with malloc() function.
Error had place in the next sequence of operations:
open data
d var
# draw only shape outline:
draw shp JPN_adm0.shp
# all is perfect, map is plotted.
# no error if save it in file:
printim fig1.png
# Now ask for the filled shapes to be plotted
clear shp
set shpopts 2
draw shp JPN_adm0.shp
# All is perfect, map is plotted.
# Try to save it in file:
printim fig2.png
- and here comes memory allocation error (reported by grads)
as results that metafile buffer (short int array) instead of
something like 99000 keeps a negative value as a number of
polygons (or points) following the -7 code marking the start of
filled polygons section.
If you are lucky and have less then 32765 polygons (points?)
nothing will happen and graphical file would be perfectly created.
Possibly, even if you will have a positive "short int" as result
of truncation, some graphical file could be created.
I was not so lucky with the JPN_adm0.shp file
of all-Japan coastal outline.
Code modification for saving number of filled polygons
packed in two short int array members removed the problem.
Sergey
Jeff Lake wrote:
> how much memory does your system have ??
> I have no problems with large shapefiles or GRIB2
> running 16gb on a Quad Core i7 CentOS 6 64bit
>
> -Jeff Lake
> MichiganWxSystem.com
> WeatherMichigan.net
> TheWeatherCenter.net
> GRLevelXStuff.com
>
>
> On 5/2/2012 4:03 AM, Sergey Varlamov wrote:
>
>> Dear GrADS users,
>>
>> If some of you is interested in saving your images with
>> the large FILLED POLYGONS from the shape files
>> using the GrADS printim command or other GrADS utilities
>> that parse the metafile content, it could be fixed.
>>
>> You have to modify source code to get it working.
>> Problem is that the filled polygon size
>> is saved in the metafile/buffer as C short int (<32765).
>> The real filled polygon sizes in the shape files like Japan outline
>> (JPN_adm0.shp) are much larger. The solution I used was to save/write
>> the filled polygon size in the metafile buffer using two short numbers
>> instead of one at the write/save stage and restore it on the read/parse
>> stage.
>>
>> Have to modify code in:
>> gxmeta.c
>> gxsubs.c
>> gxhpng.c
>>
>> and the code of related utilities:
>> gxeps.c
>> gxps.c
>> gxgif.c
>> gxtran.c (this one has one more problem that the buffer
>> size is statically fixed and could be small in some cases...)
>>
>> For me now printim works without problem.
>> Who is interested to get modified code please e-mail me
>> and I'll send you the modified files.
>>
>> Sincerely yours,
>> Sergey Varlamov
>>
>>
>> Sergey Varlamov wrote:
>>
>>> Dear GrADS users,
>>>
>>> Have somebody met a problem with printim that an attempt to save
>>> grads image that includes FILLED poligon constructed using shape files
>>> permanently results in the memory allocation error: gxhpng?
>>>
>>> I am running GrADS 2.0.1 build from the source
>>> on openSUSE linux computer. No problems when
>>> the fillcolor is not set, but regular error with the filled
>>> shapes...
>>>
>>> Would be very thankful for any solution or patch!
>>>
>>> Sergey Varlamov
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>
>>>
>>>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
--
Sergey Varlamov
Senior Scientist
Ocean Downscaled Prediction Research Team
Climate Variation Predictability and Applicability Research Program
Research Institute for Global Change
JAMSTEC, 3173-25 Showa-machi, Kanazawa-ku,
Yokohama, Kanagawa-ken, 236-0001 JAPAN
Tel: +81-45-778-5516 Fax: +81-45-778-5707
E-mail: vsm at jamstec.go.jp
〒236-0001 横浜市金沢区昭和町3173-25
独立行政法人海洋研究開発機構 地球環境変動領域
短期気候変動応用予測研究プログラム
ダウンスケール沿海変動予測研究チーム
Varlamov Sergey
More information about the gradsusr
mailing list