Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help required

Status
Not open for further replies.

kami1

Technical User
Joined
Sep 18, 2013
Messages
1
Respected reader i have some values on x-axis(input_array) and some values on y-axis(output_array) and i want to make a program in fortran in which if the user input(dtemp_s_dt_s_user_ip) is a number like 18 which is not present in defined input_array than the program will calculate the output valve(fB_op) by interpolation , which is named as fB_op and display it.i also applied a condition that if the user input(dtemp_s_dt_s_user_ip) is > 30 than output(fB_op) will be the 1st element of the output_array and if it is < 10 than it would be the last element of the array.
Actually i have problem in syntax , i am not familiar with fortran so if someone can help in order to make that program running from start to the end.

output_array = (/0.59413 , 0.597 , 0.60084 , 0.554 , 0.4188/)
input_array = (/30 , 25 , 20 , 15 , 10/)
IF ( dtemp_s_dt_s_user_ip .GT. 30 ) THEN
fB_op = input.lenght(0)
ElSE IF (dtemp_s_dt_s_user_ip .LT. 10)
fB_op = input.lenght(4)
write(*,*) 'fB_op = '
ELSE
DO i=0,i .LT. input.lenght() , i++
IF (dtemp_s_dt_s_user_ip .EQ. input_array(i) ) THEN
fB_op = output_array(i)
ELSE IF (dtemp_s_dt_s_user_ip .LT. input_array(i) .AND. dtemp_s_dt_s_user_ip .GT. input_array(i+1))
fB_op = (dtemp_s_dt_s_user_ip - input_array(i)/input_array(i) - input_array(i+1)) * (output_array (i) - output_array (i+1))+ output_array(i)
write(*,*) 'fB_op ='
EXIT
END IF
END DO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top