Reputation: 45
I have to a file to read and have fun with it. for exemple, I would like to have the delta T in it, I use :
function GetDeltaT (whereabout) result (DeltaT)
implicit none
character(16) , intent (in) :: whereabout
real(8) :: CurrentTime
Real(8):: DeltaT
open(20,file=whereabout,status='old',action='read')
read (20,*) DeltaT
read (20,*) CurrentTime
DeltaT=CurrentTime-DeltaT
close(20)
return
end function GetDeltaT
my problem is the definition of whereabout here : sometime I use 16 length title (as AL026_pdcham.txt
for example)
But I can also use less. But when it is not 16 character long (AL03_pdcham.txt
for example)
I have this warning message :
Warning: Character length of actual argument shorter than of dummy argument 'whereabout' (15/16) |
and at the execution :
At line 46 of file C:\Users\LambourgA\Documents\stage\V1\ModularStructureRT V5\R
eadData.f90 (unit = 20, file = 'Ó3u')
Fortran runtime error: Invalid argument
Process returned 2 (0x2) execution time : 0.042 s
Press any key to continue.
How can I fix this ?
Upvotes: 0
Views: 257
Reputation: 78316
Try replacing
character(16) , intent (in) :: whereabout
with
character(len=*), intent (in) :: whereabout
Now go back to your Fortran tutorial and learn about assumed type parameters.
Upvotes: 3