Dummy Argument making a dummy of me 
Author Message
 Dummy Argument making a dummy of me

Hello all,
in using the code at the bottom of this file, I can't get a dummy argument
to be passed back out of the subroutine READDATA below. I know that the
subroutine does read the data in, but I can't get it back out to GETDATA,
after the call, the vector y is all zeros. I haven't included all of the
code, just what seems relevant.

module garchdatadims
save
integer :: y_length,
character*80 :: y_file
end module garchdatadims

!=============================================================
module garchdata
save
real(8), allocatable :: y(:,:)
end module garchdata

!==============================================================
subroutine getdata
use garchdatadims
use garchdata
implicit none

allocate ( y(y_length,1) )
call readdata(y_file,y_length,1,y)

end subroutine getdata

!==============================================================
subroutine readdata(filename,m,n,datamatrix)
implicit none
character*80, intent(in) :: filename
integer, intent(in) :: m,n
integer :: i
real(8), intent(out) :: datamatrix(m,n)

open(unit=71,file=filename)

do i=1,m
  read(unit=71,fmt=100) datamatrix(m,:)
end do

100 format (D26.16)

close(71)

end subroutine readdata

--
Matthew C Roberts
Graduate Student
Department of Economics
NC State University


% TO REPLY TO THIS MESSAGE
% REMOVE ALL CAPITAL LETTERS
% FROM THE EMAIL ADDRESS



Wed, 18 Jun 1902 08:00:00 GMT  
 Dummy Argument making a dummy of me


Wed, 18 Jun 1902 08:00:00 GMT  
 Dummy Argument making a dummy of me

--
Matthew C Roberts
Graduate Student
Department of Economics
NC State University


% TO REPLY TO THIS MESSAGE
% REMOVE ALL CAPITAL LETTERS
% FROM THE EMAIL ADDRESS



Quote:
> Hello all,
> in using the code at the bottom of this file, I can't get a dummy argument
> to be passed back out of the subroutine READDATA below. I know that the
> subroutine does read the data in, but I can't get it back out to GETDATA,
> after the call, the vector y is all zeros. I haven't included all of the
> code, just what seems relevant.

> module garchdatadims
> save
> integer :: y_length,
> character*80 :: y_file
> end module garchdatadims

> !=============================================================
> module garchdata
> save
> real(8), allocatable :: y(:,:)
> end module garchdata

> !==============================================================
> subroutine getdata
> use garchdatadims
> use garchdata
> implicit none

> allocate ( y(y_length,1) )
> call readdata(y_file,y_length,1,y)

> end subroutine getdata

> !==============================================================
> subroutine readdata(filename,m,n,datamatrix)
> implicit none
> character*80, intent(in) :: filename
> integer, intent(in) :: m,n
> integer :: i
> real(8), intent(out) :: datamatrix(m,n)

> open(unit=71,file=filename)

> do i=1,m
>   read(unit=71,fmt=100) datamatrix(m,:)
> end do

> 100 format (D26.16)

> close(71)

> end subroutine readdata

> --
> Matthew C Roberts
> Graduate Student
> Department of Economics
> NC State University


> % TO REPLY TO THIS MESSAGE
> % REMOVE ALL CAPITAL LETTERS
> % FROM THE EMAIL ADDRESS



Wed, 18 Jun 1902 08:00:00 GMT  
 Dummy Argument making a dummy of me


Wed, 18 Jun 1902 08:00:00 GMT  
 Dummy Argument making a dummy of me

[stuff on problem reading in data]

Quote:
>!==============================================================
>subroutine readdata(filename,m,n,datamatrix)
>implicit none
>character*80, intent(in) :: filename
>integer, intent(in) :: m,n
>integer :: i
>real(8), intent(out) :: datamatrix(m,n)
>open(unit=71,file=filename)
>do i=1,m
>  read(unit=71,fmt=100) datamatrix(m,:)
>end do
>100 format (D26.16)
>close(71)
>end subroutine readdata

I haven't used format statements in a while, but this looks to me like
a) you are missing an implied DO on the read statement, and b) you are
looking for data that is one word per line in the file. Is that how you
file looks?
--

Balaji         1 609.452.6516
SGI/GFDL Princeton University



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

 Relevant Pages 

1. array section as actual argument where dummy argument is INTENT(OUT)

2. Actual argument is incompatible with dummy argument

3. Intel error: type of actual argument differs from type of dummy argument

4. arguments/dummy arguments

5. Actual Argument & Dummy Argument question

6. Procedures as arguments - set dummy arguments

7. Danger: Heed "Dummy arguments" warning

8. Arguments, dummies, and working arrays

9. Dummy argument INTENT() attribute question.

10. Type as a dummy argument

11. Scope of dummy arguments in statement functions.

12. Allocation status of a dummy argument

 

 
Powered by phpBB® Forum Software