Hi
I have used FPS 4.0 for along time. I ran into some problems in the program I am writing for my research and just decided to switch to gfortran because its more recent and I can use a newer debugger. I found Code::Block IDE that utilize gfortran as compiler and GDB as a debugger. It was easier to get to writing programs and compiling them than NetBeans and Eclipse. To use what I wrote before under FPS 4.0 I had to change few areas of my code and I seem to get it compiled fine.
Now I am working through run time problems. The first one was dealing with data conversions.
I want to be able to convert from integer to string. I know that this is only done via internal write. I could do this using fixed format statement. I am running into a problem when I use a variable format statement. I am not sure why. Any idea’s????
The following is the code I wrote for that function
the first function works fine - fixed format statement.
I wanted to be able touse variable format statement - funtion two; to be able to generate numbers like 0001 and so on. I get the following error when I run it:
Fortran runtime error: Missing initial left parenthesis in format
"(I3)"
^
any idea's???
mtamimi@netzero.net
I have used FPS 4.0 for along time. I ran into some problems in the program I am writing for my research and just decided to switch to gfortran because its more recent and I can use a newer debugger. I found Code::Block IDE that utilize gfortran as compiler and GDB as a debugger. It was easier to get to writing programs and compiling them than NetBeans and Eclipse. To use what I wrote before under FPS 4.0 I had to change few areas of my code and I seem to get it compiled fine.
Now I am working through run time problems. The first one was dealing with data conversions.
I want to be able to convert from integer to string. I know that this is only done via internal write. I could do this using fixed format statement. I am running into a problem when I use a variable format statement. I am not sure why. Any idea’s????
The following is the code I wrote for that function
Code:
program conversiontest
implicit none
character(Len=20) :: Int2Str, TmpStr,Int2StrwFrmt
TmpStr = adjustl("I") // adjustl(Int2Str(5))
print *, TmpStr
TmpStr = adjustl("I") // adjustl(Int2Str(50))
print *, TmpStr
TmpStr = adjustl("I") // adjustl(Int2Str(65))
print *, TmpStr
TmpStr = Int2StrwFrmt(5,"I3")
print *, TmpStr
end program conversiontest
Character(Len=20) Function Int2Str(InInt)
implicit none
integer :: InInt
Write(Int2Str,'(i10)') InInt
end Function Int2Str
Character(Len=20) Function Int2StrwFrmt(InInt,FormatString)
implicit none
integer :: InInt
Character(Len=20) :: TempString
character*(*) :: FormatString
TempString = Char(34) // char(40) // &
& Adjustl(FormatString) // &
& Char(41) // char(34)
write(*,*) TempString, len_trim(TempString)
Write(Int2StrwFrmt,TempString(:len_trim(TempString)) ) InInt
end Function Int2StrwFrmt
the first function works fine - fixed format statement.
I wanted to be able touse variable format statement - funtion two; to be able to generate numbers like 0001 and so on. I get the following error when I run it:
Fortran runtime error: Missing initial left parenthesis in format
"(I3)"
^
any idea's???
mtamimi@netzero.net