Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Compilation error when using Class(*), Intent (out)

$
0
0

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


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>