I am having array problems in MS FORTRAN ver 3.31 
Author Message
 I am having array problems in MS FORTRAN ver 3.31

I am trying to read in a sentence, then through a loop put each word of
the sentence into a seperate array space.  My problem is that I seem to
not be able to declare and call the array properly.  

Since I don't know how many words will be in the entered sentence, I want
to be able to leave the array open as far as data blocks.

I want to use a counting integer as the array caller.  such as when the
integer is incremented, it will go to the next array block.

for example: (for array "word")

H=H+1
word(H)=NextWordInTheSentence

But It won't let me do that legally due to the way i have delcared it.  I
have declared it several different ways.  I wam not sure which is the
correct way:

dimension word(1,*)
dimension word(*)
character word(1,*)
character word(*)
integer word(1,*)
integer word(*)

Every time i try to use an asterisk, it gives a compile error saying
something like an adjustable array is only for dummy arrays.

This is the first time I have used arrays with MS fortran 3.31

Thanks for any help that you can give,
Dave Troupe
        ___.___.___.___.___.___.___.___.___.___.___.___
       !                   Dave Troupe                 !      
       !          Computational Science Student        !      
       !                                               !      
       !              Sparkman High School             !        
       !              2697 Carter's Gin Rd.            !        
       !                Toney, AL 35773                !        
       !                                               !    
       !              Phone: (256) 852-5800            !
       !              Fax:   (256) 852-7809            !
       !                                               !

       !___.___.___.___.___.___.___.___.___.___.___.___!  



Wed, 18 Jun 1902 08:00:00 GMT  
 I am having array problems in MS FORTRAN ver 3.31

Quote:

> I am trying to read in a sentence, then through a loop put each word of
> the sentence into a seperate array space.  My problem is that I seem to
> not be able to declare and call the array properly.

> Since I don't know how many words will be in the entered sentence, I want
> to be able to leave the array open as far as data blocks.

> I want to use a counting integer as the array caller.  such as when the
> integer is incremented, it will go to the next array block.

> for example: (for array "word")

> H=H+1
> word(H)=NextWordInTheSentence

> But It won't let me do that legally due to the way i have delcared it.  I
> have declared it several different ways.  I wam not sure which is the
> correct way:

> dimension word(1,*)
> dimension word(*)
> character word(1,*)
> character word(*)
> integer word(1,*)
> integer word(*)

> Every time i try to use an asterisk, it gives a compile error saying
> something like an adjustable array is only for dummy arrays.

> This is the first time I have used arrays with MS FORTRAN 3.31

> Thanks for any help that you can give,
> Dave Troupe
>         ___.___.___.___.___.___.___.___.___.___.___.___
>        !                   Dave Troupe                 !
>        !          Computational Science Student        !
>        !                                               !
>        !              Sparkman High School             !
>        !              2697 Carter's Gin Rd.            !
>        !                Toney, AL 35773                !
>        !                                               !
>        !              Phone: (256) 852-5800            !
>        !              Fax:   (256) 852-7809            !
>        !                                               !

>        !___.___.___.___.___.___.___.___.___.___.___.___!

Here is a start:

The 8 following the CHARACTER* is the maximum length word that you can
store in the WORD array.  If this needs to be larger, just change the 8
to whatever the largest word that you will be storing.  The parameter
MAXWRD is set to 500: this means that you can store up to 500 words in
the WORD array.  

      INTEGER      H

      INTEGER           MAXWRD
      PARAMETER       ( MAXWRD = 500 )
      CHARACTER*8  WORD(MAXWRD)

      H = 0

  100 IF ( H .LT. MAXWRD ) THEN
         H = H + 1
         WORD(H) = NextWordInTheSequence
      ELSE
         WRITE (*,'(A)') ' Out of space in WORD array'
         STOP
      ENDIF      

      GOTO 100

      END

Jerry . . .

--

Custom Solutions              http://www.cs-software.com/
209 Bayberry Run
Summerville, SC  29485-8778    Your source for discounted
Voice:  (843) 871 9081           Fortran compilers and
Fax:    (843) 873 8626             related software



Wed, 18 Jun 1902 08:00:00 GMT  
 I am having array problems in MS FORTRAN ver 3.31
What you want is to dynamically re-size your array.  However v3.31
doesn't have this feature.

Your only real choice is to size the array bigger than you think
you'll need.  Be sure to use the $LARGE  compiler directive, or
you might run out of space.

The newer compilers would allow you to create very large arrays, and
to change the size on the fly as demand dictates. For now, lets assume
that you are stuck with 3.31 and need some way to access a lot of
data without having a huge array.

One approach would be to create a sort of 'virtual memory', which
basically means that you use your disk drive to store most of it.
In windows, this sort of thing gets handled by the operating system
and you just create the big array and go about your business,
blissfully unaware of where your data is at any given point in time.

In this case, we must do it all explicitly.

$LARGE
$DEBUG
      character*30 word(500),c,getword
      common /vm/ word,ipage,imax,ichange
      open(10,file='vm.dat',access='DIRECT',FORM='UNFORMATTED',
     x recl=500*30,status='NEW')
      write(10,rec=1) word
      close(10)
      ipage = 0
      imax = 0
c
c  store some stuff
c
      c = 'word1'
      call storew(1,c)
      c = 'word501'
      call storew(501,c)
      c = 'word1001'
      call storew(1001,c)
c
c   get some stuff back
c
      c = getword(501)
      write(*,*)  ' c501=',c
      c = getword(1001)
      write(*,*)  ' c1001=',c
      c = getword(1)
      write(*,*)  ' c1=',c
      stop
      end
      subroutine storew(i,c)
      character*30 word(500),c
      common /vm/ word,ipage,imax,ichange
c
c     get page number and offset into page where
c     member i needs to go
c
      inew = (i-1)/500 + 1
      ipos = i-(inew-1)*500
c
c     first see if the page is already in memory
c
      if(ipage.ne.inew) then
         open(10,file='vm.dat',access='DIRECT',FORM='UNFORMATTED',
     x   recl=500*30,status='OLD')

c
c        we need to write out the old page if it has been
c        changed
c
         if(ichange.eq.1) then
            write(10,rec=ipage) (word(j),j=1,500)
         end if
c
c        its not in memory. if it exists, read it in
c
         if(inew.le.imax) then
            read(10,rec=inew) (word(j),j=1,500)
         else
c
c           it doesn't exist, so create as many new
c           pages as needed to get up to the new page
c
            do 100 j=1,500
               word(j) = '                              '
  100       continue
            do 200 j=imax+1,inew
               write(10,rec=j) (word(k),k=1,500)
  200       continue
            imax = inew
         end if
         close(10)
      end if
c
c     page inew is now in memory
c
      ipage = inew
      word(ipos) = c
      ichange = 1
      return
      end
      character*30 function getword(i)
      character*30 word(500),c
      common /vm/ word,ipage,imax,ichange
c
c     get page number and offset into page where
c     member i needs to come from
c
      inew = (i-1)/500 + 1
      ipos = i-(inew-1)*500
c
c     first see if the page is already in memory
c
      if(ipage.ne.inew) then
         open(10,file='vm.dat',access='DIRECT',FORM='UNFORMATTED',
     x   recl=500*30,status='OLD')

c
c        we need to write out the old page if it has been
c        changed
c
         if(ichange.eq.1) write(10,rec=ipage) (word(j),j=1,500)
         ichange = 0
c
c        its not in memory. if it exists, read it in
c
         if(inew.le.imax) then
            read(10,rec=inew) (word(j),j=1,500)
         else
c
c           it doesn't exist, so create as many new
c           pages as needed to get up to the new page
c
            do 100 j=1,500
               word(j) = ' '
  100       continue
            do 200 j=imax+1,inew
               write(10,rec=j) (word(k),k=1,500)
  200       continue
            imax = inew
         end if
         endfile(10)
         close(10)
      end if
      getword = word(ipos)
      return
      end

STOREW stores data in the vitual WORD arraw, and GETWORD returns an
element.  The size of the data is increased whenever you reference an
element outsize of the range already created (might want to put a
reasonable bounds check in here).

This is a very primitive example.  For instance what happens if you
get into a situation where you are comparing data from two different
parts of the virtual array:

IF(GETWORD(I).NE.GETWORD(J)) THEN....

where I and J are loop variables, and I and J are not in the
same page of memory.   This leads to something call 'thrashing',
in which data is being constantly swaped in and out of memory.

You can handle this by by making WORD a two dimensional array
in which several different pages of memory can be stored at once.
You must then keep track of which pages are in memory at any given
time, decide which one to 'swap out' when you need to load a new page,
etc.  Thiese are the sorts of issues that must be resolved to
implement viirtual memory, and also in memory cacheing.  

On Mon, 9 Nov 1998 08:41:27 -0600, Dave Troupe

Quote:

>I am trying to read in a sentence, then through a loop put each word of
>the sentence into a seperate array space.  My problem is that I seem to
>not be able to declare and call the array properly.  

>Since I don't know how many words will be in the entered sentence, I want
>to be able to leave the array open as far as data blocks.

>I want to use a counting integer as the array caller.  such as when the
>integer is incremented, it will go to the next array block.

>for example: (for array "word")

>H=H+1
>word(H)=NextWordInTheSentence

>But It won't let me do that legally due to the way i have delcared it.  I
>have declared it several different ways.  I wam not sure which is the
>correct way:

>dimension word(1,*)
>dimension word(*)
>character word(1,*)
>character word(*)
>integer word(1,*)
>integer word(*)

>Every time i try to use an asterisk, it gives a compile error saying
>something like an adjustable array is only for dummy arrays.

>This is the first time I have used arrays with MS FORTRAN 3.31

>Thanks for any help that you can give,
>Dave Troupe
>        ___.___.___.___.___.___.___.___.___.___.___.___
>       !                   Dave Troupe                 !      
>       !          Computational Science Student        !      
>       !                                               !      
>       !              Sparkman High School             !        
>       !              2697 Carter's Gin Rd.            !        
>       !                Toney, AL 35773                !        
>       !                                               !    
>       !              Phone: (256) 852-5800            !
>       !              Fax:   (256) 852-7809            !
>       !                                               !

>       !___.___.___.___.___.___.___.___.___.___.___.___!  



Wed, 18 Jun 1902 08:00:00 GMT  
 I am having array problems in MS FORTRAN ver 3.31
Dave:

MS Fortran V3.31 doesn't allow for dynamic arrays -- there's no allocate
statement. You have to declare your array statically, e.g. dimension
word(100), and when populating the array ensure that the index doesn't
exceed the upper bound.

The message you're getting is basically saying that the '(*)' dimension
specified is only allowed when declaring a subroutine/function
parameter.

-----
// Lee Silver
// Information Concepts Inc.

   WE LISTEN.

Quote:
> I am trying to read in a sentence, then through a loop put each word of
> the sentence into a seperate array space.  My problem is that I seem to
> not be able to declare and call the array properly.

> Since I don't know how many words will be in the entered sentence, I want
> to be able to leave the array open as far as data blocks.

> I want to use a counting integer as the array caller.  such as when the
> integer is incremented, it will go to the next array block.

> for example: (for array "word")

> H=H+1
> word(H)=NextWordInTheSentence



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. I am having compiler problems with MS FORTRAN 3.31

2. I need some suggestions about Binary Searching with MS Fortran 3.31 (rather old, I know)

3. large character strings in MS Fortran 3.31

4. I am using MS FORTRAN 77 ver 3.31 and have a question...

5. I need some help with MS FORTRAN 77 ver. 3.31

6. I am having problems setting the page break through Active X

7. I am having a problem configuring my DAQ to generate continous waveforms

8. MS Fortran / large arrays in COMMON problem

9. Emacs VHDL Mode 3.31 released

10. Anyone remember bugs in MS Fortran 3.13 and 3.31?????

11. MS Fortran DLL called from MS VB 6.0 problem

12. Mixed Language problem?: MS Fortran PS to DEC Visual Fortran

 

 
Powered by phpBB® Forum Software