Commit de4c31fb authored by Florence Monna's avatar Florence Monna Committed by Swann Perarnau

Add Fortran interface for libnrm

parent 37e1a6ea
......@@ -37,5 +37,5 @@ AM_CONDITIONAL([PMPI_API],[test "x$pmpi" = xtrue])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_FILES([Makefile src/Makefile libnrm.pc])
AC_CONFIG_FILES([Makefile src/Makefile libnrm.pc libf_nrm.pc])
AC_OUTPUT
prefix=@prefix@
exec_prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: libf_nrm
Description: Argo Node Resource Manager Client API Fortran wrappers
Version: 0.0.1
Requires: libzmq libnrm
Libs: -L${libdir} -lnrm -lf_nrm
Cflags: -I${includedir}
......@@ -2,13 +2,19 @@ AM_CPPFLAGS = @LIBZMQ_CFLAGS@
lib_LTLIBRARIES = libnrm.la
lib_LTLIBRARIES += libf-nrm.la
if PMPI_API
lib_LTLIBRARIES += libnrm-pmpi.la
endif
libnrm_la_SOURCES = downstream_api.c nrm.h
libnrm_la_LIBADD = @LIBZMQ_LIBS@
libf_nrm_la_SOURCES = downstream_api.c f_downstream_api.c nrm.h
libf_nrm_la_LIBADD = @LIBZMQ_LIBS@
libnrm_pmpi_la_SOURCES = downstream_api.c mpi_api.c nrm.h
libnrm_pmpi_la_LIBADD = @LIBZMQ_LIBS@
include_HEADERS = nrm.h
include_HEADERS = nrm.h f_nrm.h
......@@ -17,16 +17,34 @@
#include "nrm.h"
struct nrm_context* nrm_ctxt_create(void)
{
struct nrm_context *ctxt;
ctxt = calloc(1, sizeof(struct nrm_context));
assert(ctxt != NULL);
return ctxt;
}
int nrm_ctxt_delete(struct nrm_context *ctxt)
{
assert(ctxt != NULL);
free(ctxt);
return 0;
}
int nrm_init(struct nrm_context *ctxt, const char *uuid)
{
assert(ctxt != NULL);
assert(uuid != NULL);
const char *uri = getenv(NRM_ENV_URI);
size_t buff_size;
if(uri == NULL)
uri = NRM_DEFAULT_URI;
ctxt->container_uuid = getenv("ARGO_CONTAINER_UUID");
assert(ctxt->container_uuid != NULL);
ctxt->app_uuid = (char *)uuid;
buff_size = strnlen(uuid, 255) + 1;
ctxt->app_uuid = malloc(buff_size*sizeof(char));
strncpy(ctxt->app_uuid, uuid, buff_size);
ctxt->context = zmq_ctx_new();
ctxt->socket = zmq_socket(ctxt->context, ZMQ_DEALER);
zmq_setsockopt(ctxt->socket, ZMQ_IDENTITY, ctxt->app_uuid, strnlen(uuid, 255));
......@@ -49,6 +67,7 @@ int nrm_fini(struct nrm_context *ctxt)
snprintf(buf, 512, NRM_EXIT_FORMAT, ctxt->app_uuid);
int err = zmq_send(ctxt->socket, buf, strnlen(buf, 512), 0);
assert(err > 0);
free(ctxt->app_uuid);
zmq_close(ctxt->socket);
zmq_ctx_destroy(ctxt->context);
return 0;
......
#include "nrm.h"
#include <stdlib.h>
#include <stdint.h>
int f_nrm_ctxt_create_(uintptr_t *ctxt)
{
*ctxt = nrm_ctxt_create();
return 0;
}
int f_nrm_ctxt_delete_(uintptr_t *ctxt)
{
return nrm_ctxt_delete(*((struct nrm_context **)ctxt));
}
int f_nrm_init_(uintptr_t *ctxt, char* uuid_in, int* size)
{
char* uuid = calloc(*size+1, sizeof(char));
int i, err;
for (i = 0; i < *size; i++)
{
uuid[i] = uuid_in[i];
if (uuid_in[i] == ' ')
{
uuid[i] = 0;
i = *size;
}
}
uuid[*size] = 0;
err = nrm_init(*((struct nrm_context **)ctxt), uuid);
free(uuid);
return err;
}
int f_nrm_fini_(uintptr_t *ctxt)
{
return nrm_fini(*((struct nrm_context **)ctxt));
}
int f_nrm_send_progress_(uintptr_t *ctxt, unsigned long *progress)
{
return nrm_send_progress(*((struct nrm_context **)ctxt), *progress);
}
int f_nrm_send_phase_context_(uintptr_t *ctxt, unsigned int *cpu, unsigned int *aggregation, unsigned long long int *computeTime, unsigned long long int *totalTime)
{
return nrm_send_phase_context(*((struct nrm_context **)ctxt), *cpu, *aggregation, *computeTime, *totalTime);
}
integer NRM_PTR
parameter(NRM_PTR=8)
integer(kind=NRM_PTR) f_nrm_ctxt_create
external f_nrm_ctxt_create
integer f_nrm_ctxt_delete
external f_nrm_ctxt_delete
integer(kind=NRM_PTR) 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
......@@ -36,6 +36,9 @@ struct nrm_context {
#define NRM_PHASE_CONTEXT_FORMAT "{\"api\":\"down_event\",\"type\":\"phase_context\", \"cpu\": %u, \"aggregation\": %u, \"computetime\": %llu, \"totaltime\": %llu, \"application_uuid\": \"%s\"}"
#define NRM_EXIT_FORMAT "{\"api\": \"down_event\", \"type\":\"application_exit\"}"
struct nrm_context* nrm_ctxt_create(void);
int nrm_ctxt_delete(struct nrm_context *);
int nrm_init(struct nrm_context *, const char *);
int nrm_fini(struct nrm_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