Re: Segmentation fault

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon, 21 Jan 2008 09:44:32 -0700

[1] Always examine the file(s) before you plot. Using

 ncdump -v JPRJ,PLAT,PLONG,JLTS,P1,P2,P3,P4 adria02_grid2.nc

    [SNIP]
 JPRJ = "ME" ;
 PLAT = _, _ ;
 PLONG = _ ;
 JLTS = "" ;
 P1 = _ ;
 P2 = _ ;
 P3 = _ ;
 P4 = _ ;

So, all the map coordinates you are passing to NCL are missing.

In your NCL script, if you add "print(res)" before plotting you would get

Variable: res
Type: logical
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 17
  pmTickMarkDisplayMode : Always
  mpRightCornerLonF : 9.96921e+36
  mpRightCornerLatF : 9.96921e+36
  mpLeftCornerLonF : 9.96921e+36
  mpLeftCornerLatF : 9.96921e+36
  mpLimitMode : Corners
  mpLambertMeridianF : 9.96921e+36
  mpLambertParallel2F : 9.96921e+36
  mpLambertParallel1F : 9.96921e+36
  mpProjection : LambertConformal
  cnInfoLabelOn : False
  gsnSpreadColorEnd : -3
  gsnSpreadColors : True
  cnFillDrawOrder : PreDraw
  cnLineLabelsOn : False
  cnLinesOn : False
  cnFillOn : True

How is NCL to plot the data if you set the various parameters to bogus
values?

=========
[2] If you apply the correct information, NCL plots the data.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
 grid= addfile("adria02_grid2.nc", "r")
;print(grid)
 lat2d = grid->lat_rho
 lon2d = grid->lon_rho
 printMinMax(lat2d, True)
 printMinMax(lon2d, True)

 dimll = dimsizes(lat2d) ; get size of dimensions
 nlat = dimll(0)
 mlon = dimll(1)

 f = addfile("ADRIA02_HydrostaticInsta.nc", "r")
;print(f)
 rx1max= f->rx1max
 rx1max_at_lat2d=lat2d
 rx1max_at_lon2d=lon2d
 printVarSummary(rx1max)
 printMinMax(rx1max, True)

 wks = gsn_open_wks ("x11", "ADRIA02_Hydrostatic")
 gsn_define_colormap (wks,"testcmap")
 i = NhlNewColor(wks,0.8,0.8,0.8) ; add gray to colormap

 res = True ; plot mods desired
 res_at_cnFillOn = True ; color fill
 res_at_cnLinesOn = False ; no contour lines
 res_at_cnLineLabelsOn = False ; no contour labels
 res_at_gsnSpreadColors = True ; use total colormap
 res_at_gsnSpreadColorEnd = -3
 res_at_cnInfoLabelOn = False ; no contour info label

 res_at_pmTickMarkDisplayMode = "Always" ; turn on tickmarks

 res_at_mpProjection = "Mercator"
 res_at_mpLimitMode = "Corners"
 res_at_mpLeftCornerLatF = lat2d(0,0)
 res_at_mpLeftCornerLonF = lon2d(0,0)
 res_at_mpRightCornerLatF = lat2d(nlat-1,mlon-1)
 res_at_mpRightCornerLonF = lon2d(nlat-1,mlon-1)

 print(res)

 plot = gsn_csm_contour_map(wks,rx1max,res)
end

Mathieu Dutour wrote:
> Dear all,
>
> thank you for help on legend thickness problem! I should have
> searched more.
>
> Now I experienced a segmentation fault with the ncl script below.
> What I wanted was to adapt the script roms_1.ncl to my problem,
> that is do a 2 dimensional draw of a field and I did only very
> minimal modification to it.
>
> What is the common cause of segfaults? What is general policy
> against them? Also, maybe it would be good to have all the files
> of example available from the web site so as to be able to test
> all examples for correctness of installation.
>
> Thank you,
>
> Mathieu
>
> The .nc files needed are available from the following links:
> http://www.liga.ens.fr/~dutour/Sending/adria02_grid2.nc
> http://www.liga.ens.fr/~dutour/Sending/ADRIA02_HydrostaticInsta.nc
>
> The error I got on fedora 8 and fedora 5 is:
>
> mathieu_at_oceanus:~/NCL_BathyPaperDraws$ ncl ADRIA02_Hydrostatic.ncl
> Copyright (C) 1995-2007 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 4.3.1
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> warning:GKS:GSVP: --RECTANGLE DEFINITION IS INVALID
> fatal:MapSetTrans: error initializing map: MAPINT/MDPINT/GKS ERROR REPORTED
> FROM libhlu.a(Error.o)
> warning:GKS:GSVP: --RECTANGLE DEFINITION IS INVALID
> fatal:MapSetTrans: error initializing map: MAPINT/MDPINT/GKS ERROR REPORTED
> FROM libhlu.a(Error.o)
> warning:["SetValues.c":474]:SetValuesChild never occurred on
> map.PlotManager: Error in mapPlotClass
> *** glibc detected *** ncl: realloc(): invalid pointer: 0x0c750ae8 ***
>
> The program that create it is:
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> begin
> grid= addfile("adria02_grid2.nc", "r")
> lat2d = grid->lat_rho
> lon2d = grid->lon_rho
>
> f = addfile("ADRIA02_HydrostaticInsta.nc", "r")
> rx1max= f->rx1max
> rx1max_at_lat2d=lat2d
> rx1max_at_lon2d=lon2d
>
> wks = gsn_open_wks ("eps", "ADRIA02_Hydrostatic")
> gsn_define_colormap (wks,"testcmap")
> i = NhlNewColor(wks,0.8,0.8,0.8) ; add gray to colormap
>
>
> res = True ; plot mods desired
> res_at_cnFillOn = True ; color fill
> res_at_cnLinesOn = False ; no contour lines
> res_at_cnLineLabelsOn = False ; no contour labels
> res_at_cnFillDrawOrder = "PreDraw" ; put continents on top
> res_at_gsnSpreadColors = True ; use total colormap
> res_at_gsnSpreadColorEnd = -3
> res_at_cnInfoLabelOn = False ; no contour info label
>
> res_at_mpProjection = "LambertConformal"
> res_at_mpLambertParallel1F = grid->PLAT(0)
> res_at_mpLambertParallel2F = grid->PLAT(1)
> res_at_mpLambertMeridianF = grid->PLONG
>
> res_at_mpLimitMode = "Corners" ; choose range of map
> res_at_mpLeftCornerLatF = grid->P1
> res_at_mpLeftCornerLonF = grid->P2
> res_at_mpRightCornerLatF = grid->P3
> res_at_mpRightCornerLonF = grid->P4
> res_at_mpDataBaseVersion = "HighRes" ; use high resolution coast
> res_at_pmTickMarkDisplayMode = "Always" ; turn on tickmarks
>
> plot = gsn_csm_contour_map(wks,rx1max,res)
> end
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jan 21 2008 - 09:44:32 MST

This archive was generated by hypermail 2.2.0 : Wed Jan 23 2008 - 14:19:33 MST