- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Have written a routine to convert a character to integer
Integer :: j
Write (*,*) '# Call str_to_num ("12", j)'
Call str_to_num ("12", j)
Write (*,*) "j: ", j
I am using class(*) and getting error
Program received signal 11 (SIGSEGV): Segmentation fault.
However when I change `Class(*)` with `Integer`, I do get
`" Subroutine str_to_num"` being printed.
Furthermore, changing to `Intent(inout)` rather than `Intent(out)` gets
the routine to work
Subroutine str_to_num &
( &
s, num, fmt, wrn &
)
Character (len=*), Intent (in) :: s
Character (len=*), Intent (in), Optional :: fmt
Class (*), Intent (out) :: num
Character (len=*), Intent (inout), Optional :: wrn
Integer :: ios
Character (len=65) :: frmt
Write (*,*) " Subroutine str_to_num"
Select Type (num)
Type Is (Integer)
Read (s, *, iostat=ios) num
Type Is (Real)
Read (s, *, iostat=ios) num
Type Is (Double Precision)
Read (s, *, iostat=ios) num
Type Is (Real(Real128))
Read (s, *, iostat=ios) num
End Select
End Subroutine
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
First, this is not a compilation error - it's a runtime error. Second, if you got the error you indicated you're running on Linux, and this is the Windows forum. Third, your code excerpt did not show that the caller had an explicit interface for the subroutine - this is required if a dummy argument is polymorphic. If I make sure there is one, the program works for me.
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
First, this is not a compilation error - it's a runtime error. Second, if you got the error you indicated you're running on Linux, and this is the Windows forum. Third, your code excerpt did not show that the caller had an explicit interface for the subroutine - this is required if a dummy argument is polymorphic. If I make sure there is one, the program works for me.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Apologies, you are correct Steve.
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite