Allocatable Arrays As Outputs
- From: Infinity77 <andrea.gavana@xxxxxxxxx>
- Date: Wed, 30 Jan 2008 07:47:12 -0800 (PST)
Hi All,
first of all, please forgive my poor mastering of Fortran. I am
still a beginner who uses Fortran sporadically.
I have a subroutine in which I declare 4 output variables as
allocatable. This is because, a priori, I don't know their lengths
(they're all one-dimensional vectors), and I discover this information
only when I read a file which contains both their lengths and the data
used to fill these vectors.
My problem is, I don't know how to correctly "declare" these variables
in the main program, as I keep getting errors on assumed-shape/size
and dummy arguments. My knowledge of Fortran is so slim I can't find a
way to solve this problem.
I am attaching a simplified version of my small program (1 subroutine
+ the main) in which I have only 1 allocatable array. I have used my
google-fu but either I can't interpret correctly the problem or what I
am doing is completely wrong.
Thank you for all your suggestions.
Andrea.
subroutine ReadINSPEC(fileName, propertyNames)
use ReadECLIPSEBinary
implicit none
character (len=*), intent(in) :: filename
character (len=8), allocatable, intent(out) :: propertyNames(:)
integer numberOfProps
character (len=4) keywordType
character (len=8) keywordName
logical feof
open(unit=1, file=filename, form='UNFORMATTED',
convert='BIG_ENDIAN')
feof = .false.
while_loop: do while (.not.feof)
read(1, end=20, err=18) keywordName, numberOfProps,
keywordType
if (keywordName == 'NAME') then
allocate(propertyNames(numberOfProps))
call ReadECLIPSEData(1, numberOfProps,
stringVector=propertyNames)
exit while_loop
endif
18 continue
enddo while_loop
20 continue
deallocate(propertyNames)
close(1)
return
end subroutine ReadINSPEC
program main
! ???????
! I don't know if this is possible or not...
! ???????
character(len=14) :: fileName
character(len=8) :: propertyNames(:)
fileName = 'OPT_INJ.INSPEC'
call ReadINSPEC(fileName, propertyNames)
end program main
.
- Follow-Ups:
- Re: Allocatable Arrays As Outputs
- From: bonzaboy
- Re: Allocatable Arrays As Outputs
- From: Reinhold Bader
- Re: Allocatable Arrays As Outputs
- Prev by Date: Re: Exit code with Fortran 90
- Next by Date: Re: Allocatable Arrays As Outputs
- Previous by thread: Exit code with Fortran 90
- Next by thread: Re: Allocatable Arrays As Outputs
- Index(es):
Relevant Pages
|