Is this a valid language construct?

This is a discussion on Is this a valid language construct? within the Fortran forums in Programming Languages category; In the following subroutine, an array (arrin) is taken its real values and then operated on with other stuff. Is this a valid F90/F95 construct? Gfortran 4.3 doesn't like it for some reason: it compiled but crashed. ! test array func: is it possible? subroutine test_array1_proc(arrin, arrout) implicit none complex*16 :: arrin(:, real*8 :: arrout(:, ! For some reason gfortran 4.3 causes segfault below. ! It tries to read in array with pointer address zero. ! I had no time to verify why --- let's forget this for now. arrout = arrout + real(arrin) * 2.d0 end subroutine Wirawan...

Go Back   Application Development Forum > Programming Languages > Fortran

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-19-2008, 02:14 PM
Wirawan Purwanto
Guest
 
Default Is this a valid language construct?

In the following subroutine, an array (arrin) is taken its real values
and then operated on with other stuff. Is this a valid F90/F95
construct? Gfortran 4.3 doesn't like it for some reason: it compiled
but crashed.

! test array func: is it possible?
subroutine test_array1_proc(arrin, arrout)
implicit none
complex*16 :: arrin(:,
real*8 :: arrout(:,

! For some reason gfortran 4.3 causes segfault below.
! It tries to read in array with pointer address zero.
! I had no time to verify why --- let's forget this for now.
arrout = arrout + real(arrin) * 2.d0
end subroutine


Wirawan
Reply With Quote
  #2  
Old 08-19-2008, 02:32 PM
Wirawan Purwanto
Guest
 
Default Re: Is this a valid language construct?

Ugh...I have to reply to my own question. It IS. My own mistake is
that I did not declare this procedure within a module, and therefore
the caller cannot know whether to pass the array content (F77 style)
or the array descriptor (the correct, F90 way).

:-<

Wirawan
Reply With Quote
  #3  
Old 08-19-2008, 02:41 PM
Dick Hendrickson
Guest
 
Default Re: Is this a valid language construct?

Wirawan Purwanto wrote:
> In the following subroutine, an array (arrin) is taken its real values
> and then operated on with other stuff. Is this a valid F90/F95
> construct? Gfortran 4.3 doesn't like it for some reason: it compiled
> but crashed.
>
> ! test array func: is it possible?
> subroutine test_array1_proc(arrin, arrout)
> implicit none
> complex*16 :: arrin(:,
> real*8 :: arrout(:,
>
> ! For some reason gfortran 4.3 causes segfault below.
> ! It tries to read in array with pointer address zero.
> ! I had no time to verify why --- let's forget this for now.
> arrout = arrout + real(arrin) * 2.d0
> end subroutine
>
>
> Wirawan

It's reasonably standard. The *8 and *16 aren't standard, but
Gfortran surely will do the right thing.

The first thing to remember when you get some sort of
memory access error when using assumed shape arrays is
that you need an explicit interface on the calling side.
Is test_array1_proc a module subroutine? If so, are you
USEing the module? Otherwise, it should be an internal
subroutine, or, as a last resort, write an explicit interface
yourself.

Or, are either arrin or arrout either allocatable or pointer
arrays on the calling side? If so, have they been allocated
or associated with an array?

Dick Hendrickson
Reply With Quote
  #4  
Old 08-19-2008, 03:26 PM
Richard Maine
Guest
 
Default Re: Is this a valid language construct?

Dick Hendrickson <dick.hendrickson@att.net> wrote:

> The first thing to remember when you get some sort of
> memory access error when using assumed shape arrays is
> that you need an explicit interface on the calling side.


Good call (as noted in the OP's followup to himself).

Another thing to check in things like this is that the array shapes are
conformable. That was the first thing that occurred to me here, but
apparently Dick's first thing was the better starting point.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:11 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.