



















#include <stdarg.h>
#include <stdlib.h>
#include <stddef.h>
#include "bsp_lib.h"
#include "bsp_lib_f77.h"

#ifdef CRAYMPP
#include <fortran.h>
extern char *bsp_craystr_cstr(_fcd);
#define F77STRHEADER(f,l) _fcd f
#define F77STR(f,l) bsp_craystr_cstr(f)
#else
#define F77STRHEADER(f,l) char *f, int l
#define F77STR(f,l) bsp_f77str_cstr(f,l)

#endif






int BSPPID() {
  return (bsp_pid());
}

int BSPNPROCS() {
  return(bsp_nprocs());
}












void BSPEND() {
  bsp_end();
}





void BSPSYNC() {
  bsp_sync_cpp(0,"not_profiled");
}

void BSPSYNC_CPP(int* lineno, F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_sync_cpp(0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_sync_cpp(*lineno,str);
  free(str);
#endif
}



void BSPPUSHREGISTER(void *addr,int *size) {
  bsp_push_reg_cpp(addr,*size,0,"unprofiled");
}

void BSPPUSHREG(void *addr,int *size) {
  bsp_push_reg_cpp(addr,*size,0,"unprofiled");
}

void BSPPUSHREG_CPP(void *addr,int *size,int* lineno,
		    F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_push_reg_cpp(addr,*size,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_push_reg_cpp(addr,*size,*lineno,str);
  free(str);
#endif
}



void BSPPOPREG(void *addr) {
  bsp_pop_reg_cpp(addr,0,"unprofiled");
}
void BSPPOPREGISTER(void *addr) {
  bsp_pop_reg_cpp(addr,0,"unprofiled");
}

void BSPPOPREG_CPP(void *addr, int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_pop_reg_cpp(addr,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_pop_reg_cpp(addr,*lineno,str);
  free(str);
#endif
}



void BSPGET(int *pid, void *src, int *offset, void *dst, int *nbytes) {
  bsp_get_cpp(*pid,src,*offset,dst,*nbytes,0,"unprofiled");
}

void BSPGET_CPP(int *pid, void *src, int *offset, void *dst, int *nbytes,
                int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_get_cpp(*pid,src,*offset,dst,*nbytes,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_get_cpp(*pid,src,*offset,dst,*nbytes,*lineno,str);
  free(str);
#endif
}



void BSPHPGET(int *pid, void *src, int *offset, void *dst, int *nbytes) {
  bsp_get_cpp(*pid,src,*offset,dst,*nbytes,0,"unprofiled");
}

void BSPHPGET_CPP(int *pid, void *src, int *offset, void *dst, int *nbytes,
                  int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_hpget_cpp(*pid,src,*offset,dst,*nbytes,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_hpget_cpp(*pid,src,*offset,dst,*nbytes,*lineno,str);
  free(str);
#endif
}



void BSPPUT(int *pid, void *src, void *dst, int *offset, int *nbytes) {
  bsp_put_cpp(*pid,src,dst,*offset,*nbytes,0,"unprofiled");
}

void BSPPUT_CPP(int *pid, void *src, void *dst, int *offset, int *nbytes,
                int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_put_cpp(*pid,src,dst,*offset,*nbytes,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_put_cpp(*pid,src,dst,*offset,*nbytes,*lineno,str);
  free(str);
#endif
}



void BSPHPPUT(int *pid, void *src, void *dst, int *offset, int *nbytes) {
  bsp_hpput_cpp(*pid,src,dst,*offset,*nbytes,0,"unprofiled");
}

void BSPHPPUT_CPP(int *pid, void *src, void *dst, int *offset, int *nbytes,
                int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_hpput_cpp(*pid,src,dst,*offset,*nbytes,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_hpput_cpp(*pid,src,dst,*offset,*nbytes,*lineno,str);
  free(str);
#endif
}



void BSPABORT(F77STRHEADER(string,len)) { 
  bsp_abort(F77STR(string,len));
}



double BSPTIME()  {return(bsp_time()); } 
double BSPDTIME() {return(bsp_dtime());}




void BSPSETTAGSIZE(int *tag_bytes) {
  bsp_set_tagsize_cpp(tag_bytes,0,"unprofiled");
}

void BSPSETTAGSIZE_CPP(int *tag_bytes,
                       int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_set_tagsize_cpp(tag_bytes,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_set_tagsize_cpp(tag_bytes,*lineno,str);
  free(str);
#endif
}



void BSPQSIZE(int *packets,int *accum_nbytes) {
  bsp_qsize_cpp(packets,accum_nbytes,0,"unprofiled");
}

void BSPQSIZE_CPP(int *packets,int *accum_nbytes,
                  int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_qsize_cpp(packets,accum_nbytes,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_qsize_cpp(packets,accum_nbytes,*lineno,str);
  free(str);
#endif
}




void BSPGETTAG(int *status,void *tag) {
  bsp_get_tag_cpp(status,tag,0,"unprofiled");
}

void BSPGETTAG_CPP(int *status,void *tag,
                   int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_get_tag_cpp(status,tag,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_get_tag_cpp(status,tag,*lineno,str);
  free(str);
#endif
}



void BSPSEND(int *pid, void *tag, void *payload, int *nbytes) {
  bsp_send_cpp(*pid,tag,payload,*nbytes,0,"unprofiled");
}


void BSPSEND_CPP(int *pid, void *tag, void *payload, int *nbytes,
                 int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_send_cpp(*pid,tag,payload,*nbytes,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_send_cpp(*pid,tag,payload,*nbytes,*lineno,str);
  free(str);
#endif
}



void BSPMOVE(void *payload,int *nbytes) {
  bsp_move_cpp(payload,*nbytes,0,"unprofiled");
}

void BSPMOVE_CPP(void *payload,int *nbytes,
                 int* lineno,F77STRHEADER(filename,len)) {
#if defined(TURBO) && !defined(PROFILE)
  bsp_move_cpp(payload,*nbytes,0,"unprofiled");
#else
  char *str = F77STR(filename,len);
  bsp_move_cpp(payload,*nbytes,*lineno,str);
  free(str);
#endif
}

