General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 25th, 2011, 12:34 PM
Notorious_T Notorious_T is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 2 Notorious_T User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 57 sec
Reputation Power: 0
Fortran help?

I am trying to create dynamic functions through the use of allocatable arrays and deferred shape arrays, but making a function name an allocatable array causes a run time error. Also using the deferred colon on my declarations of input variables messes them up so that the value received by my function is not what I actually put in. In fact, if I try to access anything within the variable, it throws a runtime error. Oddly though, it still works within the intrinsic size function.

Here's a short sample code:
Code:
      FUNCTION SRHnorm(a)   
      
      REAL,INTENT(IN)       :: a(:)
      REAL,ALLOCATABLE      :: SRHnorm(:) 
      INTEGER               :: n 
      
      Print *,'Checkpoint 1'
      n = size(a)
      PRINT *,n
      ALLOCATE(SRHnorm(n))
      
      Print *,'Checkpoint 2'
      SRHnorm = a
      
      RETURN
      ENDFUNCTION 


What this simple program should do is return the input variable with a different name.

Is there anything wrong with how I'm writing this? Or is this a compiler error?

-Travis

Reply With Quote
  #2  
Old January 26th, 2011, 08:21 AM
Notorious_T Notorious_T is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 2 Notorious_T User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 57 sec
Reputation Power: 0
I have since found that the allocate statement not working is a bug in the version of gnu fortran compiler that I am using. In version 4.6.0, the allocatable statement initializes the dummy variable to allocated, which is incorrect. Tossing in a deallocate statement before the allocate statement seems to make that part work. However, I still don't know why my input arguments are not assuming the correct shape and or values. Any ideas?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Fortran help?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap