Assignments in Modules

From: Ed Wells (wellsed_at_wam.umd.edu)
Date: 10/23/03


Date: 23 Oct 2003 10:43:39 -0700

After some simple testing I've decided I may not really understand how
to use modules in modern Fortran. In the simple code that follows I
attempt to do two things:

1) In an declaration, give a module variable an initial value and then
use that value in the bounds for a module declared array, and

2) after the declaration statements, assign values to my module array
variables using simple assignments of array constructors.

The problem is, these things do not work, though they seem "obvious"
as things I would want in my modules (global data with defined values
and arrays automatically bounded by globally defined variables). So,
besides the use of "obvious", why do these things not work and how can
I get around this problem? I've tested the following code using Intel
ifc 7.1 on RedHat Linux 8.0 (with libc problems fixed) and on a Sun
machine with Sun WorkShop 6 update 1 Fortran 95 6.1.

Thank you,

Ed Wells

Code follows:

module test
implicit none
public
 integer :: NA=3
 integer :: x(1:3,1:NA)
  x(:,1) = (/ 1, 2, 3 /)
  x(:,2) = (/ 4, 5, 6 /)
  x(:,3) = (/ 7, 8, 9 /)

end module test
!
program tester
use test
implicit none
 integer :: i
! call setup(x)
 do i=1,3
  write(*,*) x(:,i)
 end do
end program tester



Relevant Pages

  • Re: Assignments in Modules
    ... Ed Wells wrote: ... > 1) In an declaration, give a module variable an initial value and then ... > 2) after the declaration statements, assign values to my module array ...
    (comp.lang.fortran)
  • Re: Need help on PHP for MPE/ix
    ... If one item is an array, it must be declared as such in the list ... So, please show us the declaration of the record buffer, and its ... Of Pavan Kumar Rati ... Need help on PHP for MPE/ix ...
    (comp.sys.hp.mpe)
  • Re: Difference between C and advanced C
    ... static and type qualifiers in parameter array declarators ... trailing comma allowed in enum declaration ... additional predefined macro names ... additional strftime conversion specifiers ...
    (comp.lang.c)
  • Re: avoiding writing an interface blocks
    ... the reason this needs an explicit interface is because of the ... example, an array, and not specify the argument types. ... type, period, with any kind of declaration. ... C-type pointers, including to ...
    (comp.lang.fortran)
  • Re: Does the order of declarations matter?
    ... > subroutine sub ... > Or must the declaration for N appear before the declaration ... parameter or array bound shall be specified in a prior ...
    (comp.lang.fortran)