0

I attached a fortran code with R but i dont get the expected output. My Fortran code is very simple:

  subroutine getintparms(sml,eps,big,mnlam,rsqmax,pmin,exmx)          
  data sml0,eps0,big0,mnlam0,rsqmax0,pmin0,exmx0  /1.0e-5,1.0e-6,9.9&    
  &e35,5,0.999,1.0e-9,250.0/
  sml=sml0                                                              
  eps=eps0                                                              
  big=big0                                                              
  mnlam=mnlam0                                                          
  rsqmax=rsqmax0                                                        
  pmin=pmin0                                                            
  exmx=exmx0                                                            
  return
  end

I call the Fortran code with the following R-code:

dyn.load("C:\\Users\\Fabian\\Documents\\FortranRoutine.dll")
value=.Fortran("getintparms",fdev=double(1), eps=double(1), 
big=double(1),mnlam=integer(1),devmax=double(1),
pmin=double(1),exmx=double(1))

,but i get

$fdev
[1] 4.571853e-315           ->instead of 1.0e-5
$eps
[1] 4.436653e-315           ->instead of 1.0e-6
...
$mnlam
[1] 5                       ->this is correct
...

I have no idea why I get this numbers and I have no idea what i did wrong.

...alright I declared my variables now as...

double precision::sml,eps,big,mnlam,rsqmax,pmin,exmx

Now I have some calls which are calling my getintparms subroutine and i always get the error:

Warning 189 - In a previous call to getintparm, the fifth Argument was of type Real(KIND=2), it is now REAL(KIND=1)

how can I avoid this warning message?

  • 4
    you are using implicit typing in fortran, which causes the reals to be single precision. – agentp Jul 12 '17 at 11:54
  • @agentp I declared my variables as double precision and it works :) Thank you very much for your help :) – F.Schusterschitz Jul 12 '17 at 12:27
  • @agentp i got another question, maybe you can help me again :) I declared my variables as double precision and it works but this is only a part of my code. If i use it for my whole code it says: In a previous call to getintparms, the first Argument was of type Real(KIND=2), it is now (KIND=1). double precision is KIND=2 and real is KIND=1, so i wanted to use real, but with real i get the struggle at the beginning (wrong numbers)... Can you tell me maybe why real is not working? Tank you in advance, Fabian – F.Schusterschitz Jul 13 '17 at 07:16
  • https://gcc.gnu.org/onlinedocs/gfortran/KIND-Type-Parameters.html – user50619 Oct 02 '18 at 15:44

0 Answers0