My dear friend:
my new version compiler is ifort version 19.0.2.187
system is linux(redhat)
my compiler is following:
ifort -c head_sublibf.f90 -std03 -fPIC -assume nounderscore -assume bscc -assume byterecl -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fpp
my code Complier and link is ok ,but run my code ,when it call the subroutinue is core .
If optional no default, i have it trc = 1 and channel = 0, my code runing is ok!
please help me ,thank!
following is part code :
! my module:head_sublibf.f90 hdd_get is polymorphism interface
MODULE head_sublibf
interface
integer( c_int ) function hdd_seti_by_name(name,head_buffer,result,trc,channel ) bind( C )
use, intrinsic::ISO_C_BINDING
implicit none
character (len = *) ::name
integer(C_INT), dimension(*)::head_buffer
integer (C_INT):: result
integer (C_INT),OPTIONAL:: trc
integer (C_INT),OPTIONAL:: channel
end function hdd_seti_by_name
end interface
INTERFACE hdd_get
MODULE PROCEDURE fhddgeti_byname
MODULE PROCEDURE fhddgetl_byname
MODULE PROCEDURE fhddgetf_byname
MODULE PROCEDURE fhddgetd_byname
END INTERFACE
integer(C_INT) FUNCTION fhddgeti_byname( name,head_buffer,result,trc,channel )
use,intrinsic::ISO_C_BINDING
implicit none
character (len = *) ::name
integer(C_INT), dimension(*)::head_buffer
integer (C_INT):: result
integer (C_INT),OPTIONAL:: trc
integer (C_INT),OPTIONAL:: channel
integer (C_INT)::trc_default
integer (C_INT)::channel_default
write(*,*) "--------- fhddgeti :",name
write(*,*) "trc:",trc
write(*,*) "channel: ",channel
if(present(trc) ) then
trc_default =trc
else
! write(*,*) " default parameter --- trc"
trc_default =1
endif
if(present(channel)) then
channel_default =channel
else
! write(*,*) " default parameter --- channel"
channel_default =0
endif
! write(*,*) "--------- fhddgeti - name :",no
! write(*,*) "--------- fhddgeti - trc:",trc_default
! write(*,*) "--------- fhddgeti - channel:",channel_default
fhddgeti_byname = hdd_geti_by_name(name,head_buffer,result,trc_default,channel_default)
END FUNCTION
............
END MODULE
following is program. it call module (head_sublibf.f90)
1 dytest1 = hdd_get("max_samples",head,iresult,1,0)
2 write(*,*) "AM---name parameter samples-------n :",dytest1, iresult
3 dytest = hdd_get("max_samples",head,iresult)
4 write(*,*) "AM---name parameter samples --- name:",dytest, iresult
code Line Numbers 1 optional parameter is 1,0 .i give it .the subroutine call is right. Line Numbers 2 give right resulte.
code Line Numbers 3 the optional parameter i use default value. (default is 1,0). the subroutine call is core.
i don't know why?
please tell me 。 where is wrong ? thanks!