Dealing with IMPLICIT Definitions and Variable Type Errors in FORTRAN Code?

  • Context: Fortran 
  • Thread starter Thread starter Aerospark
  • Start date Start date
  • Tags Tags
    Error Fortran
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
Aerospark
Messages
2
Reaction score
0
So I have been trying to write a code which calls from REFPROP subroutines to get thermodynamic properties and then uses these to do some other calculations. I am facing two issues:

1) The REFPROP subroutines require IMPLICIT definitions so I can't say IMPLICIT none at the top, and this may cause some errors popping up where I don't know, is there a way to get around this?

i.e. this must be at the top of my code
Code:
!SETUP REFPROP
IMPLICIT DOUBLE PRECISION (a-h,o-z)
IMPLICIT INTEGER (i-k,m,n)
PARAMETER (ncmax=20)   !max number of components in mixture
DIMENSION x(ncmax),xliq(ncmax),xvap(ncmax),f(ncmax)
CHARACTER hrf*3, herr*255
CHARACTER*255 hf(ncmax)
CHARACTER*7 hfmix

2) It kept saying "possible change of value from REAL(4) to REAL(8)" as an error, so I defined all of my variables as REAL(8) and the errors went away.. But now all my variables are floating point values and can't be multiplied with integers where they need to..

Are there any ways of avoiding these issues? Also, I am using COMMON blocks to send variable values between subroutines, functions and main program.

Thank you for your time
 
Physics news on Phys.org
Hey Aerospark and welcome to the forums.

I'm not sure what the command is in FORTRAN, but you should consider that if you want to multiply a float by an integer, then create a new temporary float and cast the integer value to the float.

In C we write this as:

Code:
   // x is our temporary float
   float x = 0;
   x = (float)(tempInt);

FORTRAN should have something like this, and if you know what the command is then you can use it to convert integer to float and then everything is done with floating point arithmetic for that floating point word data type.