Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28385 Discussions

Passing Arguments Between C and Fortran

rampy
Beginner
252 Views
Hi I have a pass arguments between Fortran and C . I am able to pass arguments and characters from Fortran to C . But passing the arguments after manipulating it in C , I am not able to pass it back to Fortran. Here is my code

template.f90


PROGRAM PHREEQC_TEMPLATE

CHARACTER (LEN=10)::NAME1,NAME2,NAME3
REAL NO,PH,DUMMY, sum

WRITE(*,*)'Input Name1'
READ(*,*)NAME1
WRITE(*,*)'Input Name2'
READ(*,*)NAME2
WRITE(*,*)'Input Name3'
READ(*,*)NAME3
WRITE(*,*)'Input pH value'
READ(*,*)PH
WRITE(*,*)'Write Solution Number'
READ(*,*)NO



!DEC$ ATTRIBUTES ALIAS:"_get" :: GET
!DEC$ ATTRIBUTES ALIAS:"_conc" :: CONC

CALL GET(NAME1,NAME2,NAME3)
CALL CONC(NO,PH)
READ(*,*)DUMMY
END PROGRAM PHREEQC_TEMPLATE


C Code

#include
#include
#include
#include

void get(char fname1[],char fname2[],char fname3[])
{
char solution_name;
char pH;
printf("The char variables from Fortran to C is: ");
printf("%s ",fname1);
printf("%s ",fname2);
printf("%s ",fname3);
}

void conc(float* no, float* ph)
{
float num1= *no;
float num2= *ph;
float sum = 0;
sum = num1 + num2;
printf("%f ",num1);
printf("%f ",num2);
printf("%f ",sum);
}

I want to pass Sum back to Fortran. How can I do it. I am using Intel Fortran Compiler and Microsoft Visual Basic C

Rampy
0 Kudos
0 Replies
Reply