#include <mpl.h>
#include <stdio.h>
#include <stdlib.h>
#include "spfft.h"

typedef struct {
	int * addr;		/* base address of array */
	int   rank;		/* rank of array */
        int   onDPU;		/* if base address is FE or BE */
	int   extents[7];	/* extents of the array */
} DopeVector;

extern struct FFTCTL *fft_ainit( 
#ifdef __STDMPL__
 int, int *, int, int *, int
#endif
  );
FFT_AINIT ( fe, be )
    int * fe[];        /*  FE(vax) address of FE(vax) arguments */
    DopeVector * be[]; /* a BE(acu) address of BE(acu) dopevectors */
  {
    int  * var1;
    int    dpuVar1;
    int * var2;
    int   dpuVar2;
    int  * var3;
    int    dpuVar3[3];
    int * var4;
    int   dpuVar4;
    int  * var5;
    int    dpuVar5[60];
    int * var6;
    int   dpuVar6;
      
      /* copy in scalar argument from front-end */
      {
        int  * ptr;
        var1 = &dpuVar1;
        copyIn( (char*)(fe+1), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var1), sizeof(*var1));
        else 
          {
            fprintf(stderr, "Error in FFT_AINIT.m : No address to FE argument 1 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var2 = &dpuVar2;
        copyIn( (char*)(fe+2), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var2), sizeof(*var2));
        else 
          {
            fprintf(stderr, "Error in FFT_AINIT.m : No address to FE argument 2 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int  * ptr;
        var3 = dpuVar3;
        copyIn( (char*)(fe+3), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var3), 3*sizeof(*var3));
        else 
          {
            fprintf(stderr, "Error in FFT_AINIT.m : No address to FE argument 3 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var4 = &dpuVar4;
        copyIn( (char*)(fe+4), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var4), sizeof(*var4));
        else 
          {
            fprintf(stderr, "Error in FFT_AINIT.m : No address to FE argument 4 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int  * ptr;
        var5 = dpuVar5;
        copyIn( (char*)(fe+5), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var5), 2*(*var4)*sizeof(*var5));
        else 
          {
            fprintf(stderr, "Error in FFT_AINIT.m : No address to FE argument 5 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var6 = &dpuVar6;
        copyIn( (char*)(fe+6), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var6), sizeof(*var6));
        else 
          {
            fprintf(stderr, "Error in FFT_AINIT.m : No address to FE argument 6 \n");
            exit(1); 
          }
      }
      
    /* call the mpl function */ 
    *var1 = (int) fft_ainit( *var2, var3, *var4, var5, *var6);
      
      { /* copy scalar call-by-reference argument back to FE */
        int  * ptr;
        copyIn((char*) (fe+1),(char*)(&ptr), sizeof(ptr));
        copyOut((char*)(var1),(char*)(ptr), sizeof(*var1));
      }
      
  }

extern void fft_free( 
#ifdef __STDMPL__
int
#endif
  );
FFT_FREE ( fe, be )
    int * fe[];        /*  FE(vax) address of FE(vax) arguments */
    DopeVector * be[]; /* a BE(acu) address of BE(acu) dopevectors */
  {
    int * var1;
    int   dpuVar1;
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var1 = &dpuVar1;
        copyIn( (char*)(fe+1), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var1), sizeof(*var1));
        else 
          {
            fprintf(stderr, "Error in FFT_FREE.m : No address to FE argument 1 \n");
            exit(1); 
          }
      }
      
    /* call the mpl function */ 
    fft_free( *var1);
  }

extern struct FFTCTL *fft_init( 
#ifdef __STDMPL__
int, int, int, int, int, int, int, int
#endif
  );
FFT_INIT ( fe, be )
    int * fe[];        /*  FE(vax) address of FE(vax) arguments */
    DopeVector * be[]; /* a BE(acu) address of BE(acu) dopevectors */
  {
    int  * var1;
    int    dpuVar1;
    int * var2;
    int   dpuVar2;
    int * var3;
    int   dpuVar3;
    int * var4;
    int   dpuVar4;
    int * var5;
    int   dpuVar5;
    int * var6;
    int   dpuVar6;
    int * var7;
    int   dpuVar7;
    int * var8;
    int   dpuVar8;
    int * var9;
    int   dpuVar9;
      
      /* copy in scalar argument from front-end */
      {
        int  * ptr;
        var1 = &dpuVar1;
        copyIn( (char*)(fe+1), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var1), sizeof(*var1));
        else 
          {
            fprintf(stderr, "Error in FFT_INIT.m : No address to FE argument 1 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var2 = &dpuVar2;
        copyIn( (char*)(fe+2), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var2), sizeof(*var2));
        else 
          {
            fprintf(stderr, "Error in FFT_INIT.m : No address to FE argument 2 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var3 = &dpuVar3;
        copyIn( (char*)(fe+3), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var3), sizeof(*var3));
        else 
          {
            fprintf(stderr, "Error in FFT_INIT.m : No address to FE argument 3 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var4 = &dpuVar4;
        copyIn( (char*)(fe+4), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var4), sizeof(*var4));
        else 
          {
            fprintf(stderr, "Error in FFT_INIT.m : No address to FE argument 4 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var5 = &dpuVar5;
        copyIn( (char*)(fe+5), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var5), sizeof(*var5));
        else 
          {
            fprintf(stderr, "Error in FFT_INIT.m : No address to FE argument 5 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var6 = &dpuVar6;
        copyIn( (char*)(fe+6), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var6), sizeof(*var6));
        else 
          {
            fprintf(stderr, "Error in FFT_INIT.m : No address to FE argument 6 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var7 = &dpuVar7;
        copyIn( (char*)(fe+7), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var7), sizeof(*var7));
        else 
          {
            fprintf(stderr, "Error in FFT_INIT.m : No address to FE argument 7 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var8 = &dpuVar8;
        copyIn( (char*)(fe+8), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var8), sizeof(*var8));
        else 
          {
            fprintf(stderr, "Error in FFT_INIT.m : No address to FE argument 8 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var9 = &dpuVar9;
        copyIn( (char*)(fe+9), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var9), sizeof(*var9));
        else 
          {
            fprintf(stderr, "Error in FFT_INIT.m : No address to FE argument 9 \n");
            exit(1); 
          }
      }
      
    /* call the mpl function */ 
    *var1 = (int) fft_init( *var2, *var3, *var4, *var5, *var6, *var7, *var8, *var9);
      
      { /* copy scalar call-by-reference argument back to FE */
        int  * ptr;
        copyIn((char*) (fe+1),(char*)(&ptr), sizeof(ptr));
        copyOut((char*)(var1),(char*)(ptr), sizeof(*var1));
      }
  }

extern void fft_srt( 
#ifdef __STDMPL__
plural FLTYP *, int, int
#endif
  );
FFT_SRT ( fe, be )
    int * fe[];        /*  FE(vax) address of FE(vax) arguments */
    DopeVector * be[]; /* a BE(acu) address of BE(acu) dopevectors */
  {
    plural FLTYP  * var1;
    plural FLTYP    dpuVar1;
    int * var2;
    int   dpuVar2;
    int * var3;
    int   dpuVar3;
      
    if (be[1]->onDPU) 
      var1 = (plural FLTYP  *)be[1]->addr;
    else  /* Arrays must be on DPU */
      { 
         fprintf(stderr, "Error in FFT_SRT.m : argument 1 must be on DPU\n");
         exit(1); 
      }
     
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var2 = &dpuVar2;
        copyIn( (char*)(fe+2), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var2), sizeof(*var2));
        else 
          {
            fprintf(stderr, "Error in FFT_SRT.m : No address to FE argument 2 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var3 = &dpuVar3;
        copyIn( (char*)(fe+3), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var3), sizeof(*var3));
        else 
          {
            fprintf(stderr, "Error in FFT_SRT.m : No address to FE argument 3 \n");
            exit(1); 
          }
      }
      
    /* call the mpl function */ 
    fft_srt( var1, *var2, *var3);
  }

extern void sp_fft( 
#ifdef __STDMPL__
plural FLTYP *, int, int
#endif
  );
SP_FFT ( fe, be )
    int * fe[];        /*  FE(vax) address of FE(vax) arguments */
    DopeVector * be[]; /* a BE(acu) address of BE(acu) dopevectors */
  {
    plural FLTYP  * var1;
    plural FLTYP    dpuVar1;
    int * var2;
    int   dpuVar2;
    int * var3;
    int   dpuVar3;
      
    if (be[1]->onDPU) 
      var1 = (plural FLTYP  *)be[1]->addr;
    else  /* Arrays must be on DPU */
      { 
         fprintf(stderr, "Error in SP_FFT.m : argument 1 must be on DPU\n");
         exit(1); 
      }
     
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var2 = &dpuVar2;
        copyIn( (char*)(fe+2), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var2), sizeof(*var2));
        else 
          {
            fprintf(stderr, "Error in SP_FFT.m : No address to FE argument 2 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var3 = &dpuVar3;
        copyIn( (char*)(fe+3), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var3), sizeof(*var3));
        else 
          {
            fprintf(stderr, "Error in SP_FFT.m : No address to FE argument 3 \n");
            exit(1); 
          }
      }
      
    /* call the mpl function */ 
    sp_fft( var1, *var2, *var3);
  }
