Commit c0c3f28a authored by Florence Monna's avatar Florence Monna

working on fortran interface with derived type nrm_context

parent 4c098d17
......@@ -3,7 +3,7 @@
int f_nrm_init_(void * *ctxt, char* uuid)
// struct nrm_context ctxt;
return nrm_init(*ctxt, uuid);
module fnrm
type, bind(C) :: f_nrm_context
type(c_ptr):: context
type(c_ptr):: socket
character(kind=c_char, len=1) :: container_uuid
character(kind=c_char, len=1) :: app_uuid
integer(c_int) :: time
real(c_double) :: acc
end type f_nrm_context
public :: f_nrm_context, f_nrm_init, f_nrm_fini, f_nrm_send_progress, f_nrm_send_phase_context
function nrm_init_impl(ctxt, uuid) &
bind(c, name='nrm_init_wrapper')
import f_nrm_context
integer(c_int) :: nrm_init_impl
type(f_nrm_context), value :: ctxt
character(c_char), intent(in) :: uuid(*)
end function nrm_init_impl
end interface
function nrm_fini_impl(ctxt) &
bind(c, name='nrm_fini_wrapper')
import f_nrm_context
integer(c_int) :: nrm_fini_impl
type(f_nrm_context) :: ctxt
end function nrm_fini_impl
end interface
function nrm_send_progress_impl(ctxt, progress) &
bind(c, name='nrm_send_progress_wrapper')
import f_nrm_context
integer(c_int) :: nrm_send_progress_impl
type(f_nrm_context) :: ctxt
real(c_double) :: progress
end function nrm_send_progress_impl
end interface
function nrm_send_phase_context_impl(ctxt, cpu, aggregation, computeTime, totalTime) &
bind(c, name='nrm_send_phase_context_wrapper')
import f_nrm_context
integer(c_int) :: nrm_send_phase_context_impl
type(f_nrm_context) :: ctxt
integer(c_int) :: cpu
integer(c_int) :: aggregation
real(c_double) :: computeTime
real(c_double) :: totalTime
end function nrm_send_phase_context_impl
end interface
subroutine f_nrm_init(ctxt, uuid, err)
type(f_nrm_context), intent(inout) :: ctxt
character(len=*), intent(in):: uuid
integer, intent(out) :: err
character, target, dimension(1:len_trim(uuid)+1) :: uuid_c
integer :: ii, ll
ll = len_trim(uuid)
do ii = 1, ll
uuid_c(ii) = uuid(ii:ii)
end do
uuid_c(ll+1) = c_null_char
err = int(nrm_init_impl(ctxt, uuid_c))
end subroutine f_nrm_init
subroutine f_nrm_fini(ctxt,err)
type(f_nrm_context), intent(inout) :: ctxt
integer, intent(out) :: err
err= int(nrm_fini_impl(ctxt))
end subroutine f_nrm_fini
subroutine f_nrm_send_progress(ctxt, progress, err)
type(f_nrm_context), intent(inout) :: ctxt
real(8), intent(in) :: progress
integer, intent(out) :: err
err= int(nrm_send_progress_impl(ctxt, real(progress, c_double)))
end subroutine f_nrm_send_progress
subroutine f_nrm_send_phase_context(ctxt, cpu, aggregation, computeTime, totalTime, err)
type(f_nrm_context), intent(inout) :: ctxt
integer, intent(in) :: cpu, aggregation !to change in unsigned int
real(8), intent(in) :: computeTime, totalTime
integer, intent(out) :: err
err= int(nrm_send_phase_context_impl(ctxt, int(cpu, c_int), int(aggregation, c_int), &
real(computeTime, c_double), real(totalTime, c_double)))
end subroutine f_nrm_send_phase_context
end module fnrm
#include "nrm.h"
#include <stdlib.h>
int nrm_init_wrapper(struct nrm_context *ctxt, char* uuid)
return (int) nrm_init(ctxt, uuid);
int nrm_fini_wrapper(struct nrm_context *ctxt)
return (int) nrm_fini(ctxt);
int nrm_send_progress_wrapper(struct nrm_context *ctxt, unsigned long progress)
return (int) nrm_send_progress(ctxt, progress);
int nrm_send_phase_context_wrapper(struct nrm_context *ctxt, unsigned int cpu, unsigned int aggregation, unsigned long long int computeTime, unsigned long long int totalTime)
return (int) nrm_send_phase_context(ctxt, cpu, aggregation, computeTime, totalTime);
integer NRM_PTR
integer*8 f_nrm_init
external f_nrm_init
integer f_nrm_fini
external f_nrm_fini
integer f_nrm_send_progress
external f_nrm_send_progress
integer f_nrm_send_phase_context
external f_nrm_send_phase_context
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment