forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

namelist and array slices

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
brucebowler
Guest





PostPosted: Wed Jun 06, 2007 8:10 pm    Post subject: namelist and array slices Reply with quote

I have some code that has a bit that looks like this

Code:

         real corr(10,10)
         common /opts/ corr
         namelist /nmlst/ corr
         read (10,nml=nmlst)


the file associated with unit 10 looks like

Code:

          &nmlst
          corr(1,1:3) = 0,1,2
           /


When I run it, I get an error

Code:

           error 77, Digit(s) expected.


I get the same thing if I use corr(1,1)=0,1,2. It works (in this simple example) if I just use corr=0,1,2. Since in reality, I really want to place things in slices in the middle of the array, I'd really like to be able to use the array slice feature, but it seems that I can't. Is that indeed true or am I doing something wrong, syntactically?

Thanks!
Bruce
Back to top
brucebowler
Guest





PostPosted: Wed Jun 06, 2007 9:57 pm    Post subject: Complete working example, showing the bug. Reply with quote

Code:

program merge
character (len=8) :: filename /'test.opt'/
real :: chlEnd(10), chlCoeff(10,10)
namelist /optlist/ chlEnd,  chlCoeff
open (unit=11,file=filename)
read (11, nml=optlist)
end program merge


test.opt that looks like this fails

Code:

&optlist
chlEnd = 0.55347,1.0
chlcoeff(1,1:3) = 0.7621,-2.5648,5.134
/


while test.opt that looks like this works

Code:

&optlist
chlcoeff(1,1:3) = 0.7621,-2.5648,5.134
chlEnd = 0.55347,1.0
/
Back to top
Martin



Joined: 09 Sep 2004
Posts: 43

PostPosted: Mon Jun 11, 2007 1:42 am    Post subject: Reply with quote

Hi Bruce,

I could not reproduce the problem mentioned in your first message. Which version of FTN95 did you try this with?

I am not sure the input file in your second message is valid. You are attempting to specify the values of the chlEnd array, but you only specify the first two values when the array length is 10. FTN95 attempts to read the 3rd value and finds the chlcoeff assignment instead of a digit - so it gives the "Digit(s) expected" error. I'm not sure this is allowed by the standard (although it seems strange if it is only allowed when it is the last assignment in a namelist block). I will check the standard on this and get back to you soon. In the meantime you could explicitly specify the range of the array you are assigning to with:

Code:
&optlist
chlEnd(1:2) = 0.55347,1.0
chlcoeff(1,1:3) = 0.7621,-2.5648,5.134
/
Back to top
View user's profile Send private message
brucebowler
Guest





PostPosted: Mon Jun 11, 2007 1:13 pm    Post subject: Reply with quote

Hi Martin, I'll give that a shot when I get a chance, but I believe it is permitted to give fewer elements than necessary, with the remaining elements filled with "nulls" as needed. The following (I'll admit it's not from "the standard", but it is a fairly authoritative source, at least in my book) confirms that belief.

http://docs.hp.com/en/B3908-90002/ch08s04 says, in part,

"If the name in a name-value pair is that of an array, the number of the values following the equals sign must be separated by value separators and must not exceed the number of elements in the array. If there are fewer values than elements, null values are supplied for the unfilled elements."
Back to top
brucebowler
Guest





PostPosted: Mon Jun 11, 2007 3:31 pm    Post subject: Reply with quote

OK, I had a chance to test it... (this is 5.0.1, by the way).

The problem appears to only occur with 2D arrays if the item immediately prior in the input file is a 1D array that does not have enough data to fill the array.

Add another variable to the namelist called chlStart and dimension it (10) and add that variable to the namelist statement.

make test.opt look like

&optlist
chlstart = 0,1
chlend = 1,2
/

When you run the program, chlStart and chlEnd will have the right values.

Add the chlCoeff line to the end of the input file and it fails with Error 77.

Make test.opt look like

&optlist
chlStart=0,1
chlEnd=1,2,8*0
chlcoeff(...)
/

and the program works.

Make the chlEnd line look like chlEnd(1:2) = 1,2 and the program works.

From this I conclude there's some funky error in the RTL routines that get called when one reads a multidimensional array from namelist.
Back to top
Martin



Joined: 09 Sep 2004
Posts: 43

PostPosted: Tue Jun 19, 2007 11:05 pm    Post subject: Reply with quote

Thanks Bruce.

The standard does indeed state that fewer values than elements may be specified for arrays, so this is a bug in FTN95.

You are also right in that this is only a problem when a multi-dimensional array is the item immediately following an array that has fewer values than elements. Specifically, it is the "," character within the parenthesis that is throwing it off as it thinks it is a value separator in this case.

I will report the problem within our bug tracking system and we will look into fixing it in the near future.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2816
Location: South Pole, Antarctica

PostPosted: Sun Dec 23, 2012 9:09 pm    Post subject: Reply with quote

If it is a bug was it fixed? Either i have some corruption due to 2GB limit or i've got similar problem unable to load for two damn nights some simple array with format like the author above.

By the way, what "Digit(s) expected" in Error 77 means?

I gave up after whole weekend day and night digging...things are that this definitely somehow worked before. Preliminary, when i define format explicitly

iz=5
READ (A,'(30x,30(e11.3))') (Var(ii,iz),ii=1,30)

all works fine, but when use character variable as a format:

iz=5
charFormat='(30x,30(e11.3))'
READ (A,charFormat) (Var(ii,iz),ii=1,30)

i get error 77...What is the length limit for charFormat variable i can use?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group