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

  • Thread starter Thread starter Aerospark
  • Start date Start date
  • Tags Tags
    Error Fortran
AI Thread Summary
The discussion revolves around challenges faced while integrating REFPROP subroutines in a Fortran code to obtain thermodynamic properties. One major issue is the requirement for IMPLICIT definitions, which complicates the use of IMPLICIT NONE and may lead to undetected errors. A workaround is sought for this limitation. Another problem arises from type conversion errors, specifically the "possible change of value from REAL(4) to REAL(8" message. The user resolved this by defining all variables as REAL(8), but this created difficulties when attempting to multiply floating-point values with integers. Suggestions include creating a temporary float variable to handle integer-to-float conversions, utilizing Fortran's intrinsic functions for type conversion to streamline arithmetic operations. The conversation emphasizes the importance of correctly managing data types and variable definitions in Fortran programming.
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
 
Technology 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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
25
Views
3K
Replies
5
Views
5K
Replies
59
Views
11K
Replies
8
Views
2K
Replies
8
Views
4K
Replies
4
Views
2K
Back
Top