From: rudra on
This might be a silly question and/or i am missing a faq but plz help
me. I have a subroutine declared as:
5 subroutine
lm_a(oidxdn,opnu,opold,oqnu,oqold, &
6
clabl_1,lmx,w_oidn,w_opp,w_oqnu,w_oqold, &
7
d_ialpha,d_ifmt3d,d_itrans,d_jbasdn,d_ldn,d_lmaxw, &
8
d_ltmax,d_mdn,d_mmixat,d_mmixpq,d_nbas,d_nclass,d_ndimin, &
9
d_ngen,d_nit,d_nitat,d_niter,d_nkdmx,d_nkxyz,d_nl,d_nopts, &
10
d_norder,d_npts,d_nrxc,d_nrxyz,d_nsp, &
11
d_as,d_beta,d_dele,d_deltr,d_efermi,d_kap2,d_kfit, &
12
d_emax,d_emaxc,d_emin,d_eminc,d_eps,d_facvol,d_gamma,d_ommax1, &
13
d_ommax2,d_range,d_rmaxes,d_rmaxs,d_rmaxs2,d_rmines,d_rms2, &
14
d_rmsdel,d_tolef,d_toleto,d_tolews,d_vmtz,d_wc,d_width,sw13, &
15 asnit)

In the main program, I have defined an interface
interface
43 subroutine
lm_a(oidxdn,opnu,opold,oqnu,oqold, &
44 clabl_1,lmx,&!
w_oidn,w_opp,w_oqnu,w_oqold, &
45
d_ialpha,d_ifmt3d,d_itrans,d_jbasdn,d_ldn,d_lmaxw, &
46
d_ltmax,d_mdn,d_mmixat,d_mmixpq,d_nbas,d_nclass,d_ndimin, &
47
d_ngen,d_nit,d_nitat,d_niter,d_nkdmx,d_nkxyz,d_nl,d_nopts, &
48
d_norder,d_npts,d_nrxc,d_nrxyz,d_nsp, &
49
d_as,d_beta,d_dele,d_deltr,d_efermi,d_kap2,d_kfit, &
50
d_emax,d_emaxc,d_emin,d_eminc,d_eps,d_facvol,d_gamma,d_ommax1, &
51
d_ommax2,d_range,d_rmaxes,d_rmaxs,d_rmaxs2,d_rmines,d_rms2, &
52
d_rmsdel,d_tolef,d_toleto,d_tolews,d_vmtz,d_wc,d_width,switch,
& asnit)
53
54
integer::d_ialpha,d_ifmt3d,d_itrans,d_jbasdn,d_ldn,d_lmaxw, &
55
d_ltmax(3),d_mdn,d_mmixat,d_mmixpq,d_nbas,d_nclass,d_ndimin, &
56
d_ngen,d_nit,d_nitat,d_niter,d_nkdmx,d_nkxyz(3),d_nl,d_nopts, &
57
d_norder,d_npts,d_nrxc,d_nrxyz(3),d_nsp,oidxdn,opnu,opold,oqnu, &
58
oqold,lmx(200),lmxrho(200),asnit!,oidxdn,opnu,opold,oqnu,oqold
59 double
precision::d_as,d_beta,d_dele,d_deltr,d_efermi,d_kap2, &
60
d_emax,d_emaxc,d_emin,d_eminc,d_eps,d_facvol,d_gamma,d_ommax1(3)&

61 ,d_ommax2(3),d_range,d_rmaxes,d_rmaxs,d_rmaxs2,d_rmines,d_rms2,
&
62
d_rmsdel,d_tolef,d_toleto,d_tolews,d_vmtz,d_wc,d_width,d_kfit
63 logical:: switch(31)
64 character(4)::clabl_1
65 end subroutine lm_a
66 end interface

and then called the subroutine as
273 !Function for atom A
274 call
lm_a(oidxdn,opnu,opold,oqnu,oqold,clabl_1,lmx, &
275
d_ialpha,d_ifmt3d,d_itrans,d_jbasdn,d_ldn, &
276
d_lmaxw,d_ltmax,d_mdn,d_mmixat,d_mmixpq,d_nbas,d_nclass, &
277
d_ndimin,d_ngen,d_nit,d_nitat,d_niter,d_nkdmx,d_nkxyz,d_nl, &
278
d_nopts,d_norder,d_npts,d_nrxc,d_nrxyz,d_nsp,d_as,d_beta,d_dele,&
279
d_deltr,d_efermi,d_kap2,d_kfit,d_emax,d_emaxc,d_emin,d_eminc, &
280
d_eps,d_facvol,d_gamma,d_ommax1,d_ommax2,d_range,d_rmaxes, &
281
d_rmaxs,d_rmaxs2,d_rmines,d_rms2,d_rmsdel,d_tolef,d_toleto, &
282 d_tolews,d_vmtz,d_wc,d_width,switch,nit)

but as soon as it getes asnit, it gives segmentation fault, as evident
in the part of the subroutine:
! --- Set up the file logical units ---
168 write(*,*) "is it here"
169 write(*,*) asnit
170 if ((asnit==1).or.(asnit==2))then

is it here
forrtl: severe (174): SIGSEGV, segmentation fault occurred

i.e. not even writing asnit value.
plz help
From: dpb on
rudra wrote:
> This might be a silly question and/or i am missing a faq but plz help
> me. I have a subroutine declared as:
> 5 subroutine
> lm_a(oidxdn,opnu,opold,oqnu,oqold, &
> 6
....

> d_rmsdel,d_tolef,d_toleto,d_tolews,d_vmtz,d_wc,d_width,sw13, &
> 15 asnit)

HEAVENS!!!!

How about grouping a bunch of these arguments into one (or several) UDTs
or refactor the subroutine (several times maybe?) or some such????

> In the main program, I have defined an interface
> interface
> 43 subroutine
> lm_a(oidxdn,opnu,opold,oqnu,oqold, &
> 44 clabl_1,lmx,&!
....

> d_rmsdel,d_tolef,d_toleto,d_tolews,d_vmtz,d_wc,d_width,switch,
> & asnit)
> 53
> 54
> integer::d_ialpha,d_ifmt3d,d_itrans,d_jbasdn,d_ldn,d_lmaxw, &
> 55
....
> oqold,lmx(200),lmxrho(200),asnit!,oidxdn,opnu,opold,oqnu,oqold
> 59 double
> precision::d_as,d_beta,d_dele,d_deltr,d_efermi,d_kap2, &
> 60
> d_emax,d_emaxc,d_emin,d_eminc,d_eps,d_facvol,d_gamma,d_ommax1(3)&
....
> 63 logical:: switch(31)
> 64 character(4)::clabl_1
> 65 end subroutine lm_a
> 66 end interface
>
> and then called the subroutine as
> 273 !Function for atom A
> 274 call
> lm_a(oidxdn,opnu,opold,oqnu,oqold,clabl_1,lmx, &
....

Undoubtedly there's a mismatch in one or more of the arguments in the
subroutine as opposed to the call.

Since you didn't show the actual subroutine declarations, which one is
impossible to tell (and would be difficult owing to the number if given,
but at least doable).

As for the interface, put it (the subroutine) in a module and get the
benefits automagically via USE.

--
From: rudra on
I have given the actual subroutine declaration
its not possible to include the lm_a in a module
From: Gordon Sande on
On 2010-05-25 14:28:52 -0300, rudra <bnrj.rudra(a)gmail.com> said:

> This might be a silly question and/or i am missing a faq but plz help
> me. I have a subroutine declared as:
> 5 subroutine
> lm_a(oidxdn,opnu,opold,oqnu,oqold, &
> 6
> clabl_1,lmx,w_oidn,w_opp,w_oqnu,w_oqold, &
> 7
> d_ialpha,d_ifmt3d,d_itrans,d_jbasdn,d_ldn,d_lmaxw, &
> 8
> d_ltmax,d_mdn,d_mmixat,d_mmixpq,d_nbas,d_nclass,d_ndimin, &
> 9
> d_ngen,d_nit,d_nitat,d_niter,d_nkdmx,d_nkxyz,d_nl,d_nopts, &
> 10
> d_norder,d_npts,d_nrxc,d_nrxyz,d_nsp, &
> 11
> d_as,d_beta,d_dele,d_deltr,d_efermi,d_kap2,d_kfit, &
> 12
> d_emax,d_emaxc,d_emin,d_eminc,d_eps,d_facvol,d_gamma,d_ommax1, &
> 13
> d_ommax2,d_range,d_rmaxes,d_rmaxs,d_rmaxs2,d_rmines,d_rms2, &
> 14
> d_rmsdel,d_tolef,d_toleto,d_tolews,d_vmtz,d_wc,d_width,sw13, &
> 15 asnit)
>
> In the main program, I have defined an interface
> interface
> 43 subroutine
> lm_a(oidxdn,opnu,opold,oqnu,oqold, &
> 44 clabl_1,lmx,&!
> w_oidn,w_opp,w_oqnu,w_oqold, &
> 45
> d_ialpha,d_ifmt3d,d_itrans,d_jbasdn,d_ldn,d_lmaxw, &
> 46
> d_ltmax,d_mdn,d_mmixat,d_mmixpq,d_nbas,d_nclass,d_ndimin, &
> 47
> d_ngen,d_nit,d_nitat,d_niter,d_nkdmx,d_nkxyz,d_nl,d_nopts, &
> 48
> d_norder,d_npts,d_nrxc,d_nrxyz,d_nsp, &
> 49
> d_as,d_beta,d_dele,d_deltr,d_efermi,d_kap2,d_kfit, &
> 50
> d_emax,d_emaxc,d_emin,d_eminc,d_eps,d_facvol,d_gamma,d_ommax1, &
> 51
> d_ommax2,d_range,d_rmaxes,d_rmaxs,d_rmaxs2,d_rmines,d_rms2, &
> 52
> d_rmsdel,d_tolef,d_toleto,d_tolews,d_vmtz,d_wc,d_width,switch,
> & asnit)
> 53
> 54
> integer::d_ialpha,d_ifmt3d,d_itrans,d_jbasdn,d_ldn,d_lmaxw, &
> 55
> d_ltmax(3),d_mdn,d_mmixat,d_mmixpq,d_nbas,d_nclass,d_ndimin, &
> 56
> d_ngen,d_nit,d_nitat,d_niter,d_nkdmx,d_nkxyz(3),d_nl,d_nopts, &
> 57
> d_norder,d_npts,d_nrxc,d_nrxyz(3),d_nsp,oidxdn,opnu,opold,oqnu, &
> 58
> oqold,lmx(200),lmxrho(200),asnit!,oidxdn,opnu,opold,oqnu,oqold
> 59 double
> precision::d_as,d_beta,d_dele,d_deltr,d_efermi,d_kap2, &
> 60
> d_emax,d_emaxc,d_emin,d_eminc,d_eps,d_facvol,d_gamma,d_ommax1(3)&
>
> 61 ,d_ommax2(3),d_range,d_rmaxes,d_rmaxs,d_rmaxs2,d_rmines,d_rms2,
> &
> 62
> d_rmsdel,d_tolef,d_toleto,d_tolews,d_vmtz,d_wc,d_width,d_kfit
> 63 logical:: switch(31)
> 64 character(4)::clabl_1
> 65 end subroutine lm_a
> 66 end interface
>
> and then called the subroutine as
> 273 !Function for atom A
> 274 call
> lm_a(oidxdn,opnu,opold,oqnu,oqold,clabl_1,lmx, &
> 275
> d_ialpha,d_ifmt3d,d_itrans,d_jbasdn,d_ldn, &
> 276
> d_lmaxw,d_ltmax,d_mdn,d_mmixat,d_mmixpq,d_nbas,d_nclass, &
> 277
> d_ndimin,d_ngen,d_nit,d_nitat,d_niter,d_nkdmx,d_nkxyz,d_nl, &
> 278
> d_nopts,d_norder,d_npts,d_nrxc,d_nrxyz,d_nsp,d_as,d_beta,d_dele,&
> 279
> d_deltr,d_efermi,d_kap2,d_kfit,d_emax,d_emaxc,d_emin,d_eminc, &
> 280
> d_eps,d_facvol,d_gamma,d_ommax1,d_ommax2,d_range,d_rmaxes, &
> 281
> d_rmaxs,d_rmaxs2,d_rmines,d_rms2,d_rmsdel,d_tolef,d_toleto, &
> 282 d_tolews,d_vmtz,d_wc,d_width,switch,nit)
>
> but as soon as it getes asnit, it gives segmentation fault, as evident
> in the part of the subroutine:
> ! --- Set up the file logical units ---
> 168 write(*,*) "is it here"
> 169 write(*,*) asnit
> 170 if ((asnit==1).or.(asnit==2))then
>
> is it here
> forrtl: severe (174): SIGSEGV, segmentation fault occurred
>
> i.e. not even writing asnit value.
> plz help

If you have the source for lm_a then put it in a module and let the compiler
create an interface for you. There is no need for you to be writing interfaces.
There is a good chance you will get it wrong given the untidy source you have
shown.

Segment faults usually come from either subscripts out of range or bad calls.
The problem may or may not be immediately evident. You can eliminate cause
number 2 by letting the compiler generte interfaces which will then catch
the bad calls. See above!

You could also try a debugging setup like the Salford/Silverfrost FTN95 which
will catch all the usual causes. Requires all source and giving up on religous
objections to running under Windows long enough to debug your program. FTN95
is free for personal use.

The pieces you show suggest that any advice will be a pure guess as they could
mean anything. A delayed result of the real cause is as good a guess as any.
It also means that what you have shown is of no help in finding the problem!
To be concrete, one does not know which variables are arrya and which are not
as there declaratons anywhere. A compiler generated inteface wold at least get
that right.




From: dpb on
rudra wrote:
> I have given the actual subroutine declaration

You didn't give the variable declarations in the subroutine itself,
however, nor in the calling routine; only in a separate interface body
(which there should be no reason for making manually in virtually all
circumstances)

> its not possible to include the lm_a in a module

Why not?

--