主题:Fortran 调用 C函数 问题
这是 .c 文件
——————————————————————————————————
#include <stdio.h>
#include <sys/sysinfo.h>
#include <stdlib.h>
void show ()
{
struct sysinfo info;
unsigned long ram_total = 0, ram_used = 0, swap_total = 0, swap_used = 0;
int mem_unit;
sysinfo(&info);
mem_unit = info->mem_unit;
ram_total = info.totalram * mem_unit / 1024000;
ram_used = ram_total - info.freeram * mem_unit / 1024000;
swap_total = info.totalswap * mem_unit / 1024000;
swap_used = swap_total - info.freeswap * mem_unit / 1024000;
printf("系统共有内存%ldMb, 已用%ldMb, 共有交换分区%ldMb, 已用%ldMb\n",
ram_total, ram_used, swap_total, swap_used);
return;
}
——————————————————————————————————————————
这是.f90文件
program main
call show()
end program main
请问如何做才能在fotran文件里调用上面.c文件里的show()函数呢???谢谢!
——————————————————————————————————
#include <stdio.h>
#include <sys/sysinfo.h>
#include <stdlib.h>
void show ()
{
struct sysinfo info;
unsigned long ram_total = 0, ram_used = 0, swap_total = 0, swap_used = 0;
int mem_unit;
sysinfo(&info);
mem_unit = info->mem_unit;
ram_total = info.totalram * mem_unit / 1024000;
ram_used = ram_total - info.freeram * mem_unit / 1024000;
swap_total = info.totalswap * mem_unit / 1024000;
swap_used = swap_total - info.freeswap * mem_unit / 1024000;
printf("系统共有内存%ldMb, 已用%ldMb, 共有交换分区%ldMb, 已用%ldMb\n",
ram_total, ram_used, swap_total, swap_used);
return;
}
——————————————————————————————————————————
这是.f90文件
program main
call show()
end program main
请问如何做才能在fotran文件里调用上面.c文件里的show()函数呢???谢谢!