Segmentation fault when using the fortran subroutine

From: Leung YU Ting <ting19xx_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 23 2013 - 09:39:14 MDT

HI

     When I want to use the HWSSSP of fishpack Fortran subroutine in NCL. I also add a subroutine hstub.f to define the dimension of variables as shown below;

C NCLFORTSTART
      SUBROUTINE HWSSSPDRV (TS,TF,M,MBDCND,BDTS,BDTF,PS,PF,N,NBDCND,
     1 BDPS,BDPF,ELMBDA,F,NLON,NLAT,PERTRB,
     2 IERROR,W,LWORK)
      DIMENSION F(NLON,NLAT) ,BDTS(NLON),BDTF(NLON),BDPS(NLAT),
     1 BDPF(NLAT),W(LWORK)
C NCLEND
      print*, "1"
      CALL HWSSSP(TS,TF,M,MBDCND,BDTS,BDTF,PS,PF,N,NBDCND,BDPS,
     1 BDPF,ELMBDA,F,NLON,PERTRB,IERROR,W)
      print*, "2"
      RETURN
      print*, "3"
      END

The ncl script used is shown below;

    rawtime=hdata->time
    time=ut_calendar(rawtime, -3)
    lat=hdata->lat(::-1)
    lon=hdata->lon

    wantedtime=2000120100

    timeind=ind(wantedtime .eq. time)

    wantedhgt1=short2flt(hdata->hgt(timeind-1, {500}, ::-1, :))
    wantedhgt2=short2flt(hdata->hgt(timeind+1, {500}, ::-1, :))

    guv1=z2geouv(wantedhgt1, lat, lon, 1)
    gu1=guv1(0, :, :)
    gv1=guv1(1, :, :)
    gvort1=uv2vr_cfd(gu1, gv1, lat, lon, 3)
    copy_VarCoords(wantedhgt1, gvort1)

    guv2=z2geouv(wantedhgt2, lat, lon, 1)
    gu2=guv2(0, :, :)
    gv2=guv2(1, :, :)
    gvort2=uv2vr_cfd(gu2, gv2, lat, lon, 3)
    copy_VarCoords(wantedhgt2, gvort2)

    gvort_tend=gvort2-gvort1
    copy_VarCoords(gvort1, gvort_tend)

    PI = 3.14159265358979
    NLAT = dimsizes(lat)
    NLON = dimsizes(lon)
    PERTRB = 0.
    IERROR = 1
    TS= 0.
    TF= PI
    M=NLAT-1
    MBDCND=9
    BDTS=new(NLON, float)
    BDTF=new(NLON, float)
    PS=0.
    PF=2.*PI*357.5/360.
    N=NLON-1
    M=NLAT-1
    NBDCND=0
    BDPS=new(NLAT, float)
    BDPF=new(NLAT, float)
    ELMBDA=0.
    IDIMF= NLON
    LWORK = 11*(M+1)+6*(N+1)
    W=new(LWORK,float)
    F=gvort_tend

    HSTUB::HWSSSPDRV(TS,TF,M,MBDCND,BDTS,BDTF,PS,PF,N,NBDCND,BDPS,BDPF,ELMBDA,F,NLON,NLAT,PERTRB,IERROR,W,LWORK)
 
The output is;
 1
 2
Segmentation fault (core dumped)

It seems the script stop at return the variables. So I use gdb to check the script. It is stop at _NclGetObj. What can I do to solve this problem?

Program received signal SIGSEGV, Segmentation fault.
0x000000000061d5f2 in _NclGetObj ()
(gdb) where
#0 0x000000000061d5f2 in _NclGetObj ()
#1 0x000000000064828f in VarValRep ()
#2 0x000000000064de18 in _NclGetVarRepValue ()
#3 0x0000000000649689 in VarVarWrite ()
#4 0x000000000064e2d4 in _NclAssignVarToVar ()
#5 0x00000000006cd4f9 in _NclRemapIntrParameters ()
#6 0x00000000006c2070 in CallINTRINSIC_PROC_CALL ()
#7 0x00000000006c91ad in _NclExecute ()
#8 0x00000000005af1b1 in yyparse ()
#9 0x00000000005aa592 in main ()
(gdb)

Regards
Marco
                                               

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 23 09:39:32 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 01 2013 - 08:58:14 MDT