/*
 * This file was generated automatically by xsubpp version 1.9508 from the 
 * contents of McIDAS.xs. Do not edit this file, edit McIDAS.xs instead.
 *
 *	ANY CHANGES MADE HERE WILL BE LOST! 
 *
 */

#line 1 "McIDAS.xs"

/*
 * THIS FILE WAS GENERATED BY PDL::PP! Do not modify!
 */
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "pdl.h"
#include "pdlcore.h"
static Core* PDL; /* Structure hold core C functions */
static int __pdl_debugging = 0;
static int __pdl_boundscheck = 0;
static SV* CoreSV;       /* Gets pointer to perl var holding core structure */

/* we need to handle croak ourserlves */
/* #undef croak
   #define croak barf
 */

#if ! 1
# define PP_INDTERM(max, at) at
#else
# define PP_INDTERM(max, at) (__pdl_boundscheck? PDL->safe_indterm(max,at, __FILE__, __LINE__) : at)
#endif

typedef struct pdl_h_grdlist_struct {
		PDL_TRANS_START(20);
		pdl_thread  __pdlthread;PDL_Long  __inc_file_256;PDL_Long  __inc_file_1;PDL_Long  __inc_level_3000;PDL_Long  __inc_rows_3000;PDL_Long  __inc_columns_3000;PDL_Long  __inc_year_3000;PDL_Long  __inc_day_3000;PDL_Long  __inc_hour_3000;PDL_Long  __inc_validity_3000;PDL_Long  __inc_num_grid_3000;PDL_Long  __inc_maptype_3000;PDL_Long  __inc_proj_34_3000;PDL_Long  __inc_proj_35_3000;PDL_Long  __inc_proj_36_3000;PDL_Long  __inc_proj_37_3000;PDL_Long  __inc_proj_38_3000;PDL_Long  __inc_proj_39_3000;PDL_Long  __inc_gridname_4;PDL_Long  __inc_gridname_3000;PDL_Long  __inc_levelunits_4;PDL_Long  __inc_levelunits_3000;PDL_Long  __inc_gridorigin_4;PDL_Long  __inc_gridorigin_3000;PDL_Long  __1_size;PDL_Long  __256_size;PDL_Long  __3000_size;PDL_Long  __4_size;
		
		char __ddone; /* Dims done */
		} pdl_h_grdlist_struct;

void pdl_h_grdlist_redodims(pdl_trans *__tr ) {
	int __dim;
	pdl_h_grdlist_struct *__privtrans = (pdl_h_grdlist_struct *) __tr;
	
	{
	    int __creating[20];
__privtrans->__1_size = -1;
__privtrans->__256_size = -1;
__privtrans->__3000_size = -1;
__privtrans->__4_size = -1;
__creating[0] = 0;
__creating[1] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[1]);
__creating[2] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[2]);
__creating[3] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[3]);
__creating[4] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[4]);
__creating[5] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[5]);
__creating[6] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[6]);
__creating[7] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[7]);
__creating[8] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[8]);
__creating[9] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[9]);
__creating[10] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[10]);
__creating[11] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[11]);
__creating[12] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[12]);
__creating[13] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[13]);
__creating[14] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[14]);
__creating[15] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[15]);
__creating[16] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[16]);
__creating[17] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[17]);
__creating[18] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[18]);
__creating[19] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[19]);
if((__privtrans->pdls[0]->state & PDL_NOMYDIMS) && __privtrans->pdls[0]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER file");
if((!__creating[1]) && (__privtrans->pdls[1]->state & PDL_NOMYDIMS) && __privtrans->pdls[1]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER level");
if((!__creating[2]) && (__privtrans->pdls[2]->state & PDL_NOMYDIMS) && __privtrans->pdls[2]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER rows");
if((!__creating[3]) && (__privtrans->pdls[3]->state & PDL_NOMYDIMS) && __privtrans->pdls[3]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER columns");
if((!__creating[4]) && (__privtrans->pdls[4]->state & PDL_NOMYDIMS) && __privtrans->pdls[4]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER year");
if((!__creating[5]) && (__privtrans->pdls[5]->state & PDL_NOMYDIMS) && __privtrans->pdls[5]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER day");
if((!__creating[6]) && (__privtrans->pdls[6]->state & PDL_NOMYDIMS) && __privtrans->pdls[6]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER hour");
if((!__creating[7]) && (__privtrans->pdls[7]->state & PDL_NOMYDIMS) && __privtrans->pdls[7]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER validity");
if((!__creating[8]) && (__privtrans->pdls[8]->state & PDL_NOMYDIMS) && __privtrans->pdls[8]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER num_grid");
if((!__creating[9]) && (__privtrans->pdls[9]->state & PDL_NOMYDIMS) && __privtrans->pdls[9]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER maptype");
if((!__creating[10]) && (__privtrans->pdls[10]->state & PDL_NOMYDIMS) && __privtrans->pdls[10]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER proj_34");
if((!__creating[11]) && (__privtrans->pdls[11]->state & PDL_NOMYDIMS) && __privtrans->pdls[11]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER proj_35");
if((!__creating[12]) && (__privtrans->pdls[12]->state & PDL_NOMYDIMS) && __privtrans->pdls[12]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER proj_36");
if((!__creating[13]) && (__privtrans->pdls[13]->state & PDL_NOMYDIMS) && __privtrans->pdls[13]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER proj_37");
if((!__creating[14]) && (__privtrans->pdls[14]->state & PDL_NOMYDIMS) && __privtrans->pdls[14]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER proj_38");
if((!__creating[15]) && (__privtrans->pdls[15]->state & PDL_NOMYDIMS) && __privtrans->pdls[15]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER proj_39");
if((!__creating[16]) && (__privtrans->pdls[16]->state & PDL_NOMYDIMS) && __privtrans->pdls[16]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER num_grids");
if((!__creating[17]) && (__privtrans->pdls[17]->state & PDL_NOMYDIMS) && __privtrans->pdls[17]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER gridname");
if((!__creating[18]) && (__privtrans->pdls[18]->state & PDL_NOMYDIMS) && __privtrans->pdls[18]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER levelunits");
if((!__creating[19]) && (__privtrans->pdls[19]->state & PDL_NOMYDIMS) && __privtrans->pdls[19]->trans == 0)
   barf("Error in h_grdlist:" "CANNOT CREATE PARAMETER gridorigin");
 {
/* no RedoDimsCode */
}
 {
 static char *__parnames[] = {"file","level","rows","columns","year","day","hour","validity","num_grid","maptype","proj_34","proj_35","proj_36","proj_37","proj_38","proj_39","num_grids","gridname","levelunits","gridorigin"};
		static int __realdims[] = {2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,2,2};
		static char __funcname[] = "PDL::McIDAS::h_grdlist";
		static pdl_errorinfo __einfo = {
			__funcname, __parnames, 20
		};
		
		 PDL->initthreadstruct(2,__privtrans->pdls,
			__realdims,__creating,20,
                      &__einfo,&(__privtrans->__pdlthread),
                        __privtrans->vtable->per_pdl_flags);
		}
   if(((__privtrans->pdls[0]))->ndims < 2) {
      if (((__privtrans->pdls[0]))->ndims < 1 && __privtrans->__256_size <= 1) __privtrans->__256_size = 1;
      if (((__privtrans->pdls[0]))->ndims < 2 && __privtrans->__1_size <= 1) __privtrans->__1_size = 1;
   }
   if(__privtrans->__256_size == -1 || (((__privtrans->pdls[0]))->ndims > 0 && __privtrans->__256_size == 1)) {
      __privtrans->__256_size = ((__privtrans->pdls[0]))->dims[0];
   } else if(((__privtrans->pdls[0]))->ndims > 0 && __privtrans->__256_size != ((__privtrans->pdls[0]))->dims[0]) {
      if(((__privtrans->pdls[0]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
   if(__privtrans->__1_size == -1 || (((__privtrans->pdls[0]))->ndims > 1 && __privtrans->__1_size == 1)) {
      __privtrans->__1_size = ((__privtrans->pdls[0]))->dims[1];
   } else if(((__privtrans->pdls[0]))->ndims > 1 && __privtrans->__1_size != ((__privtrans->pdls[0]))->dims[1]) {
      if(((__privtrans->pdls[0]))->dims[1] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[0])));
if(!__creating[1]) {
   if(((__privtrans->pdls[1]))->ndims < 1) {
      if (((__privtrans->pdls[1]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[1]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[1]))->dims[0];
   } else if(((__privtrans->pdls[1]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[1]))->dims[0]) {
      if(((__privtrans->pdls[1]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[1])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,1,dims,0);
}if(!__creating[2]) {
   if(((__privtrans->pdls[2]))->ndims < 1) {
      if (((__privtrans->pdls[2]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[2]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[2]))->dims[0];
   } else if(((__privtrans->pdls[2]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[2]))->dims[0]) {
      if(((__privtrans->pdls[2]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[2])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,2,dims,0);
}if(!__creating[3]) {
   if(((__privtrans->pdls[3]))->ndims < 1) {
      if (((__privtrans->pdls[3]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[3]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[3]))->dims[0];
   } else if(((__privtrans->pdls[3]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[3]))->dims[0]) {
      if(((__privtrans->pdls[3]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[3])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,3,dims,0);
}if(!__creating[4]) {
   if(((__privtrans->pdls[4]))->ndims < 1) {
      if (((__privtrans->pdls[4]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[4]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[4]))->dims[0];
   } else if(((__privtrans->pdls[4]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[4]))->dims[0]) {
      if(((__privtrans->pdls[4]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[4])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,4,dims,0);
}if(!__creating[5]) {
   if(((__privtrans->pdls[5]))->ndims < 1) {
      if (((__privtrans->pdls[5]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[5]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[5]))->dims[0];
   } else if(((__privtrans->pdls[5]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[5]))->dims[0]) {
      if(((__privtrans->pdls[5]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[5])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,5,dims,0);
}if(!__creating[6]) {
   if(((__privtrans->pdls[6]))->ndims < 1) {
      if (((__privtrans->pdls[6]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[6]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[6]))->dims[0];
   } else if(((__privtrans->pdls[6]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[6]))->dims[0]) {
      if(((__privtrans->pdls[6]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[6])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,6,dims,0);
}if(!__creating[7]) {
   if(((__privtrans->pdls[7]))->ndims < 1) {
      if (((__privtrans->pdls[7]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[7]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[7]))->dims[0];
   } else if(((__privtrans->pdls[7]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[7]))->dims[0]) {
      if(((__privtrans->pdls[7]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[7])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,7,dims,0);
}if(!__creating[8]) {
   if(((__privtrans->pdls[8]))->ndims < 1) {
      if (((__privtrans->pdls[8]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[8]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[8]))->dims[0];
   } else if(((__privtrans->pdls[8]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[8]))->dims[0]) {
      if(((__privtrans->pdls[8]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[8])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,8,dims,0);
}if(!__creating[9]) {
   if(((__privtrans->pdls[9]))->ndims < 1) {
      if (((__privtrans->pdls[9]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[9]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[9]))->dims[0];
   } else if(((__privtrans->pdls[9]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[9]))->dims[0]) {
      if(((__privtrans->pdls[9]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[9])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,9,dims,0);
}if(!__creating[10]) {
   if(((__privtrans->pdls[10]))->ndims < 1) {
      if (((__privtrans->pdls[10]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[10]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[10]))->dims[0];
   } else if(((__privtrans->pdls[10]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[10]))->dims[0]) {
      if(((__privtrans->pdls[10]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[10])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,10,dims,0);
}if(!__creating[11]) {
   if(((__privtrans->pdls[11]))->ndims < 1) {
      if (((__privtrans->pdls[11]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[11]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[11]))->dims[0];
   } else if(((__privtrans->pdls[11]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[11]))->dims[0]) {
      if(((__privtrans->pdls[11]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[11])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,11,dims,0);
}if(!__creating[12]) {
   if(((__privtrans->pdls[12]))->ndims < 1) {
      if (((__privtrans->pdls[12]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[12]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[12]))->dims[0];
   } else if(((__privtrans->pdls[12]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[12]))->dims[0]) {
      if(((__privtrans->pdls[12]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[12])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,12,dims,0);
}if(!__creating[13]) {
   if(((__privtrans->pdls[13]))->ndims < 1) {
      if (((__privtrans->pdls[13]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[13]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[13]))->dims[0];
   } else if(((__privtrans->pdls[13]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[13]))->dims[0]) {
      if(((__privtrans->pdls[13]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[13])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,13,dims,0);
}if(!__creating[14]) {
   if(((__privtrans->pdls[14]))->ndims < 1) {
      if (((__privtrans->pdls[14]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[14]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[14]))->dims[0];
   } else if(((__privtrans->pdls[14]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[14]))->dims[0]) {
      if(((__privtrans->pdls[14]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[14])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,14,dims,0);
}if(!__creating[15]) {
   if(((__privtrans->pdls[15]))->ndims < 1) {
      if (((__privtrans->pdls[15]))->ndims < 1 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[15]))->ndims > 0 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[15]))->dims[0];
   } else if(((__privtrans->pdls[15]))->ndims > 0 && __privtrans->__3000_size != ((__privtrans->pdls[15]))->dims[0]) {
      if(((__privtrans->pdls[15]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[15])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,15,dims,0);
}if(!__creating[16]) {
PDL->make_physical(((__privtrans->pdls[16])));
} else {
 int dims[1]; /* Use ninds+1 to avoid smart (stupid) compilers */
 PDL->thread_create_parameter(&__privtrans->__pdlthread,16,dims,0);
}if(!__creating[17]) {
   if(((__privtrans->pdls[17]))->ndims < 2) {
      if (((__privtrans->pdls[17]))->ndims < 1 && __privtrans->__4_size <= 1) __privtrans->__4_size = 1;
      if (((__privtrans->pdls[17]))->ndims < 2 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__4_size == -1 || (((__privtrans->pdls[17]))->ndims > 0 && __privtrans->__4_size == 1)) {
      __privtrans->__4_size = ((__privtrans->pdls[17]))->dims[0];
   } else if(((__privtrans->pdls[17]))->ndims > 0 && __privtrans->__4_size != ((__privtrans->pdls[17]))->dims[0]) {
      if(((__privtrans->pdls[17]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[17]))->ndims > 1 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[17]))->dims[1];
   } else if(((__privtrans->pdls[17]))->ndims > 1 && __privtrans->__3000_size != ((__privtrans->pdls[17]))->dims[1]) {
      if(((__privtrans->pdls[17]))->dims[1] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[17])));
} else {
 int dims[3]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__4_size;dims[1] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,17,dims,0);
}if(!__creating[18]) {
   if(((__privtrans->pdls[18]))->ndims < 2) {
      if (((__privtrans->pdls[18]))->ndims < 1 && __privtrans->__4_size <= 1) __privtrans->__4_size = 1;
      if (((__privtrans->pdls[18]))->ndims < 2 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__4_size == -1 || (((__privtrans->pdls[18]))->ndims > 0 && __privtrans->__4_size == 1)) {
      __privtrans->__4_size = ((__privtrans->pdls[18]))->dims[0];
   } else if(((__privtrans->pdls[18]))->ndims > 0 && __privtrans->__4_size != ((__privtrans->pdls[18]))->dims[0]) {
      if(((__privtrans->pdls[18]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[18]))->ndims > 1 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[18]))->dims[1];
   } else if(((__privtrans->pdls[18]))->ndims > 1 && __privtrans->__3000_size != ((__privtrans->pdls[18]))->dims[1]) {
      if(((__privtrans->pdls[18]))->dims[1] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[18])));
} else {
 int dims[3]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__4_size;dims[1] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,18,dims,0);
}if(!__creating[19]) {
   if(((__privtrans->pdls[19]))->ndims < 2) {
      if (((__privtrans->pdls[19]))->ndims < 1 && __privtrans->__4_size <= 1) __privtrans->__4_size = 1;
      if (((__privtrans->pdls[19]))->ndims < 2 && __privtrans->__3000_size <= 1) __privtrans->__3000_size = 1;
   }
   if(__privtrans->__4_size == -1 || (((__privtrans->pdls[19]))->ndims > 0 && __privtrans->__4_size == 1)) {
      __privtrans->__4_size = ((__privtrans->pdls[19]))->dims[0];
   } else if(((__privtrans->pdls[19]))->ndims > 0 && __privtrans->__4_size != ((__privtrans->pdls[19]))->dims[0]) {
      if(((__privtrans->pdls[19]))->dims[0] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
   if(__privtrans->__3000_size == -1 || (((__privtrans->pdls[19]))->ndims > 1 && __privtrans->__3000_size == 1)) {
      __privtrans->__3000_size = ((__privtrans->pdls[19]))->dims[1];
   } else if(((__privtrans->pdls[19]))->ndims > 1 && __privtrans->__3000_size != ((__privtrans->pdls[19]))->dims[1]) {
      if(((__privtrans->pdls[19]))->dims[1] != 1) {
         barf("Error in h_grdlist:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[19])));
} else {
 int dims[3]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__4_size;dims[1] = __privtrans->__3000_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,19,dims,0);
}{ void *hdrp = NULL;
   if (!hdrp && __privtrans->pdls[0]->hdrsv && (__privtrans->pdls[0]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[0]->hdrsv;
   if (!hdrp && !__creating[1] && __privtrans->pdls[1]->hdrsv && (__privtrans->pdls[1]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[1]->hdrsv;
   if (!hdrp && !__creating[2] && __privtrans->pdls[2]->hdrsv && (__privtrans->pdls[2]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[2]->hdrsv;
   if (!hdrp && !__creating[3] && __privtrans->pdls[3]->hdrsv && (__privtrans->pdls[3]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[3]->hdrsv;
   if (!hdrp && !__creating[4] && __privtrans->pdls[4]->hdrsv && (__privtrans->pdls[4]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[4]->hdrsv;
   if (!hdrp && !__creating[5] && __privtrans->pdls[5]->hdrsv && (__privtrans->pdls[5]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[5]->hdrsv;
   if (!hdrp && !__creating[6] && __privtrans->pdls[6]->hdrsv && (__privtrans->pdls[6]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[6]->hdrsv;
   if (!hdrp && !__creating[7] && __privtrans->pdls[7]->hdrsv && (__privtrans->pdls[7]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[7]->hdrsv;
   if (!hdrp && !__creating[8] && __privtrans->pdls[8]->hdrsv && (__privtrans->pdls[8]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[8]->hdrsv;
   if (!hdrp && !__creating[9] && __privtrans->pdls[9]->hdrsv && (__privtrans->pdls[9]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[9]->hdrsv;
   if (!hdrp && !__creating[10] && __privtrans->pdls[10]->hdrsv && (__privtrans->pdls[10]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[10]->hdrsv;
   if (!hdrp && !__creating[11] && __privtrans->pdls[11]->hdrsv && (__privtrans->pdls[11]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[11]->hdrsv;
   if (!hdrp && !__creating[12] && __privtrans->pdls[12]->hdrsv && (__privtrans->pdls[12]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[12]->hdrsv;
   if (!hdrp && !__creating[13] && __privtrans->pdls[13]->hdrsv && (__privtrans->pdls[13]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[13]->hdrsv;
   if (!hdrp && !__creating[14] && __privtrans->pdls[14]->hdrsv && (__privtrans->pdls[14]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[14]->hdrsv;
   if (!hdrp && !__creating[15] && __privtrans->pdls[15]->hdrsv && (__privtrans->pdls[15]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[15]->hdrsv;
   if (!hdrp && !__creating[16] && __privtrans->pdls[16]->hdrsv && (__privtrans->pdls[16]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[16]->hdrsv;
   if (!hdrp && !__creating[17] && __privtrans->pdls[17]->hdrsv && (__privtrans->pdls[17]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[17]->hdrsv;
   if (!hdrp && !__creating[18] && __privtrans->pdls[18]->hdrsv && (__privtrans->pdls[18]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[18]->hdrsv;
   if (!hdrp && !__creating[19] && __privtrans->pdls[19]->hdrsv && (__privtrans->pdls[19]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[19]->hdrsv;
if (hdrp) {
   if ( __privtrans->pdls[1]->hdrsv != hdrp )
      __privtrans->pdls[1]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[2]->hdrsv != hdrp )
      __privtrans->pdls[2]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[3]->hdrsv != hdrp )
      __privtrans->pdls[3]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[4]->hdrsv != hdrp )
      __privtrans->pdls[4]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[5]->hdrsv != hdrp )
      __privtrans->pdls[5]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[6]->hdrsv != hdrp )
      __privtrans->pdls[6]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[7]->hdrsv != hdrp )
      __privtrans->pdls[7]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[8]->hdrsv != hdrp )
      __privtrans->pdls[8]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[9]->hdrsv != hdrp )
      __privtrans->pdls[9]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[10]->hdrsv != hdrp )
      __privtrans->pdls[10]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[11]->hdrsv != hdrp )
      __privtrans->pdls[11]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[12]->hdrsv != hdrp )
      __privtrans->pdls[12]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[13]->hdrsv != hdrp )
      __privtrans->pdls[13]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[14]->hdrsv != hdrp )
      __privtrans->pdls[14]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[15]->hdrsv != hdrp )
      __privtrans->pdls[15]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[16]->hdrsv != hdrp )
      __privtrans->pdls[16]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[17]->hdrsv != hdrp )
      __privtrans->pdls[17]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[18]->hdrsv != hdrp )
      __privtrans->pdls[18]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
   if ( __privtrans->pdls[19]->hdrsv != hdrp )
      __privtrans->pdls[19]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
}}
if(__privtrans->pdls[0]->ndims <= 0 || __privtrans->pdls[0]->dims[0] <= 1)
		  __privtrans->__inc_file_256 = 0; else
		 __privtrans->__inc_file_256 = __privtrans->pdls[0]->dimincs[0];if(__privtrans->pdls[0]->ndims <= 1 || __privtrans->pdls[0]->dims[1] <= 1)
		  __privtrans->__inc_file_1 = 0; else
		 __privtrans->__inc_file_1 = __privtrans->pdls[0]->dimincs[1];if(__privtrans->pdls[1]->ndims <= 0 || __privtrans->pdls[1]->dims[0] <= 1)
		  __privtrans->__inc_level_3000 = 0; else
		 __privtrans->__inc_level_3000 = __privtrans->pdls[1]->dimincs[0];if(__privtrans->pdls[2]->ndims <= 0 || __privtrans->pdls[2]->dims[0] <= 1)
		  __privtrans->__inc_rows_3000 = 0; else
		 __privtrans->__inc_rows_3000 = __privtrans->pdls[2]->dimincs[0];if(__privtrans->pdls[3]->ndims <= 0 || __privtrans->pdls[3]->dims[0] <= 1)
		  __privtrans->__inc_columns_3000 = 0; else
		 __privtrans->__inc_columns_3000 = __privtrans->pdls[3]->dimincs[0];if(__privtrans->pdls[4]->ndims <= 0 || __privtrans->pdls[4]->dims[0] <= 1)
		  __privtrans->__inc_year_3000 = 0; else
		 __privtrans->__inc_year_3000 = __privtrans->pdls[4]->dimincs[0];if(__privtrans->pdls[5]->ndims <= 0 || __privtrans->pdls[5]->dims[0] <= 1)
		  __privtrans->__inc_day_3000 = 0; else
		 __privtrans->__inc_day_3000 = __privtrans->pdls[5]->dimincs[0];if(__privtrans->pdls[6]->ndims <= 0 || __privtrans->pdls[6]->dims[0] <= 1)
		  __privtrans->__inc_hour_3000 = 0; else
		 __privtrans->__inc_hour_3000 = __privtrans->pdls[6]->dimincs[0];if(__privtrans->pdls[7]->ndims <= 0 || __privtrans->pdls[7]->dims[0] <= 1)
		  __privtrans->__inc_validity_3000 = 0; else
		 __privtrans->__inc_validity_3000 = __privtrans->pdls[7]->dimincs[0];if(__privtrans->pdls[8]->ndims <= 0 || __privtrans->pdls[8]->dims[0] <= 1)
		  __privtrans->__inc_num_grid_3000 = 0; else
		 __privtrans->__inc_num_grid_3000 = __privtrans->pdls[8]->dimincs[0];if(__privtrans->pdls[9]->ndims <= 0 || __privtrans->pdls[9]->dims[0] <= 1)
		  __privtrans->__inc_maptype_3000 = 0; else
		 __privtrans->__inc_maptype_3000 = __privtrans->pdls[9]->dimincs[0];if(__privtrans->pdls[10]->ndims <= 0 || __privtrans->pdls[10]->dims[0] <= 1)
		  __privtrans->__inc_proj_34_3000 = 0; else
		 __privtrans->__inc_proj_34_3000 = __privtrans->pdls[10]->dimincs[0];if(__privtrans->pdls[11]->ndims <= 0 || __privtrans->pdls[11]->dims[0] <= 1)
		  __privtrans->__inc_proj_35_3000 = 0; else
		 __privtrans->__inc_proj_35_3000 = __privtrans->pdls[11]->dimincs[0];if(__privtrans->pdls[12]->ndims <= 0 || __privtrans->pdls[12]->dims[0] <= 1)
		  __privtrans->__inc_proj_36_3000 = 0; else
		 __privtrans->__inc_proj_36_3000 = __privtrans->pdls[12]->dimincs[0];if(__privtrans->pdls[13]->ndims <= 0 || __privtrans->pdls[13]->dims[0] <= 1)
		  __privtrans->__inc_proj_37_3000 = 0; else
		 __privtrans->__inc_proj_37_3000 = __privtrans->pdls[13]->dimincs[0];if(__privtrans->pdls[14]->ndims <= 0 || __privtrans->pdls[14]->dims[0] <= 1)
		  __privtrans->__inc_proj_38_3000 = 0; else
		 __privtrans->__inc_proj_38_3000 = __privtrans->pdls[14]->dimincs[0];if(__privtrans->pdls[15]->ndims <= 0 || __privtrans->pdls[15]->dims[0] <= 1)
		  __privtrans->__inc_proj_39_3000 = 0; else
		 __privtrans->__inc_proj_39_3000 = __privtrans->pdls[15]->dimincs[0];if(__privtrans->pdls[17]->ndims <= 0 || __privtrans->pdls[17]->dims[0] <= 1)
		  __privtrans->__inc_gridname_4 = 0; else
		 __privtrans->__inc_gridname_4 = __privtrans->pdls[17]->dimincs[0];if(__privtrans->pdls[17]->ndims <= 1 || __privtrans->pdls[17]->dims[1] <= 1)
		  __privtrans->__inc_gridname_3000 = 0; else
		 __privtrans->__inc_gridname_3000 = __privtrans->pdls[17]->dimincs[1];if(__privtrans->pdls[18]->ndims <= 0 || __privtrans->pdls[18]->dims[0] <= 1)
		  __privtrans->__inc_levelunits_4 = 0; else
		 __privtrans->__inc_levelunits_4 = __privtrans->pdls[18]->dimincs[0];if(__privtrans->pdls[18]->ndims <= 1 || __privtrans->pdls[18]->dims[1] <= 1)
		  __privtrans->__inc_levelunits_3000 = 0; else
		 __privtrans->__inc_levelunits_3000 = __privtrans->pdls[18]->dimincs[1];if(__privtrans->pdls[19]->ndims <= 0 || __privtrans->pdls[19]->dims[0] <= 1)
		  __privtrans->__inc_gridorigin_4 = 0; else
		 __privtrans->__inc_gridorigin_4 = __privtrans->pdls[19]->dimincs[0];if(__privtrans->pdls[19]->ndims <= 1 || __privtrans->pdls[19]->dims[1] <= 1)
		  __privtrans->__inc_gridorigin_3000 = 0; else
		 __privtrans->__inc_gridorigin_3000 = __privtrans->pdls[19]->dimincs[1]; __privtrans->__ddone = 1;
	}
    }
    

pdl_trans * pdl_h_grdlist_copy(pdl_trans *__tr ) {
	int __dim;
	pdl_h_grdlist_struct *__privtrans = (pdl_h_grdlist_struct *) __tr;
	
	{
	    pdl_h_grdlist_struct *__copy
 			= malloc(sizeof(pdl_h_grdlist_struct));
			PDL_TR_CLRMAGIC(__copy);
			__copy->flags = __privtrans->flags;
			__copy->vtable = __privtrans->vtable;
			__copy->__datatype = __privtrans->__datatype;
			__copy->freeproc = NULL;
			__copy->__ddone = __privtrans->__ddone;
			{int i;
			 for(i=0; i<__copy->vtable->npdls; i++)
				__copy->pdls[i] = __privtrans->pdls[i];
			}
			
			if(__copy->__ddone) {
				PDL->thread_copy(&(__privtrans->__pdlthread),&(__copy->__pdlthread));__privtrans->__inc_file_256=__copy->__inc_file_256;__privtrans->__inc_file_1=__copy->__inc_file_1;__privtrans->__inc_level_3000=__copy->__inc_level_3000;__privtrans->__inc_rows_3000=__copy->__inc_rows_3000;__privtrans->__inc_columns_3000=__copy->__inc_columns_3000;__privtrans->__inc_year_3000=__copy->__inc_year_3000;__privtrans->__inc_day_3000=__copy->__inc_day_3000;__privtrans->__inc_hour_3000=__copy->__inc_hour_3000;__privtrans->__inc_validity_3000=__copy->__inc_validity_3000;__privtrans->__inc_num_grid_3000=__copy->__inc_num_grid_3000;__privtrans->__inc_maptype_3000=__copy->__inc_maptype_3000;__privtrans->__inc_proj_34_3000=__copy->__inc_proj_34_3000;__privtrans->__inc_proj_35_3000=__copy->__inc_proj_35_3000;__privtrans->__inc_proj_36_3000=__copy->__inc_proj_36_3000;__privtrans->__inc_proj_37_3000=__copy->__inc_proj_37_3000;__privtrans->__inc_proj_38_3000=__copy->__inc_proj_38_3000;__privtrans->__inc_proj_39_3000=__copy->__inc_proj_39_3000;__privtrans->__inc_gridname_4=__copy->__inc_gridname_4;__privtrans->__inc_gridname_3000=__copy->__inc_gridname_3000;__privtrans->__inc_levelunits_4=__copy->__inc_levelunits_4;__privtrans->__inc_levelunits_3000=__copy->__inc_levelunits_3000;__privtrans->__inc_gridorigin_4=__copy->__inc_gridorigin_4;__privtrans->__inc_gridorigin_3000=__copy->__inc_gridorigin_3000;__copy->__1_size=__privtrans->__1_size;__copy->__256_size=__privtrans->__256_size;__copy->__3000_size=__privtrans->__3000_size;__copy->__4_size=__privtrans->__4_size;
			}
			return (pdl_trans*)__copy;
	}
    }
    

void pdl_h_grdlist_readdata(pdl_trans *__tr ) {
	int __dim;
	pdl_h_grdlist_struct *__privtrans = (pdl_h_grdlist_struct *) __tr;
	
	{
	    {/* Start generic loop */

	switch(__privtrans->__datatype) { case -42: /* Warning eater */ {1;
	} break; case PDL_L: {
	PDL_Byte * file_datap = ((PDL_Byte *)(PDL_REPRP_TRANS((__privtrans->pdls[0]),(__privtrans->vtable->per_pdl_flags[0]))));
	PDL_Byte * file_physdatap = ((PDL_Byte *)((__privtrans->pdls[0])->data));

	PDL_Long * level_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[1]),(__privtrans->vtable->per_pdl_flags[1]))));
	PDL_Long * level_physdatap = ((PDL_Long *)((__privtrans->pdls[1])->data));

	PDL_Long * rows_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[2]),(__privtrans->vtable->per_pdl_flags[2]))));
	PDL_Long * rows_physdatap = ((PDL_Long *)((__privtrans->pdls[2])->data));

	PDL_Long * columns_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[3]),(__privtrans->vtable->per_pdl_flags[3]))));
	PDL_Long * columns_physdatap = ((PDL_Long *)((__privtrans->pdls[3])->data));

	PDL_Long * year_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[4]),(__privtrans->vtable->per_pdl_flags[4]))));
	PDL_Long * year_physdatap = ((PDL_Long *)((__privtrans->pdls[4])->data));

	PDL_Long * day_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[5]),(__privtrans->vtable->per_pdl_flags[5]))));
	PDL_Long * day_physdatap = ((PDL_Long *)((__privtrans->pdls[5])->data));

	PDL_Long * hour_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[6]),(__privtrans->vtable->per_pdl_flags[6]))));
	PDL_Long * hour_physdatap = ((PDL_Long *)((__privtrans->pdls[6])->data));

	PDL_Long * validity_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[7]),(__privtrans->vtable->per_pdl_flags[7]))));
	PDL_Long * validity_physdatap = ((PDL_Long *)((__privtrans->pdls[7])->data));

	PDL_Long * num_grid_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[8]),(__privtrans->vtable->per_pdl_flags[8]))));
	PDL_Long * num_grid_physdatap = ((PDL_Long *)((__privtrans->pdls[8])->data));

	PDL_Long * maptype_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[9]),(__privtrans->vtable->per_pdl_flags[9]))));
	PDL_Long * maptype_physdatap = ((PDL_Long *)((__privtrans->pdls[9])->data));

	PDL_Long * proj_34_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[10]),(__privtrans->vtable->per_pdl_flags[10]))));
	PDL_Long * proj_34_physdatap = ((PDL_Long *)((__privtrans->pdls[10])->data));

	PDL_Long * proj_35_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[11]),(__privtrans->vtable->per_pdl_flags[11]))));
	PDL_Long * proj_35_physdatap = ((PDL_Long *)((__privtrans->pdls[11])->data));

	PDL_Long * proj_36_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[12]),(__privtrans->vtable->per_pdl_flags[12]))));
	PDL_Long * proj_36_physdatap = ((PDL_Long *)((__privtrans->pdls[12])->data));

	PDL_Long * proj_37_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[13]),(__privtrans->vtable->per_pdl_flags[13]))));
	PDL_Long * proj_37_physdatap = ((PDL_Long *)((__privtrans->pdls[13])->data));

	PDL_Long * proj_38_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[14]),(__privtrans->vtable->per_pdl_flags[14]))));
	PDL_Long * proj_38_physdatap = ((PDL_Long *)((__privtrans->pdls[14])->data));

	PDL_Long * proj_39_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[15]),(__privtrans->vtable->per_pdl_flags[15]))));
	PDL_Long * proj_39_physdatap = ((PDL_Long *)((__privtrans->pdls[15])->data));

	PDL_Long * num_grids_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[16]),(__privtrans->vtable->per_pdl_flags[16]))));
	PDL_Long * num_grids_physdatap = ((PDL_Long *)((__privtrans->pdls[16])->data));

	PDL_Byte * gridname_datap = ((PDL_Byte *)(PDL_REPRP_TRANS((__privtrans->pdls[17]),(__privtrans->vtable->per_pdl_flags[17]))));
	PDL_Byte * gridname_physdatap = ((PDL_Byte *)((__privtrans->pdls[17])->data));

	PDL_Byte * levelunits_datap = ((PDL_Byte *)(PDL_REPRP_TRANS((__privtrans->pdls[18]),(__privtrans->vtable->per_pdl_flags[18]))));
	PDL_Byte * levelunits_physdatap = ((PDL_Byte *)((__privtrans->pdls[18])->data));

	PDL_Byte * gridorigin_datap = ((PDL_Byte *)(PDL_REPRP_TRANS((__privtrans->pdls[19]),(__privtrans->vtable->per_pdl_flags[19]))));
	PDL_Byte * gridorigin_physdatap = ((PDL_Byte *)((__privtrans->pdls[19])->data));

	/* THREADLOOPBEGIN */
 if(PDL->startthreadloop(&(__privtrans->__pdlthread),__privtrans->vtable->readdata,
 	__tr)) return;
   do { register int __tind1=0,__tind2=0;
        register int __tnpdls = __privtrans->__pdlthread.npdls;
      register int __tdims1 = __privtrans->__pdlthread.dims[1];
      register int __tdims0 = __privtrans->__pdlthread.dims[0];
      register int *__offsp = PDL->get_threadoffsp(&__privtrans->__pdlthread);
 register int __tinc0_0 = __privtrans->__pdlthread.incs[0];register int __tinc0_1 = __privtrans->__pdlthread.incs[1];register int __tinc0_2 = __privtrans->__pdlthread.incs[2];register int __tinc0_3 = __privtrans->__pdlthread.incs[3];register int __tinc0_4 = __privtrans->__pdlthread.incs[4];register int __tinc0_5 = __privtrans->__pdlthread.incs[5];register int __tinc0_6 = __privtrans->__pdlthread.incs[6];register int __tinc0_7 = __privtrans->__pdlthread.incs[7];register int __tinc0_8 = __privtrans->__pdlthread.incs[8];register int __tinc0_9 = __privtrans->__pdlthread.incs[9];register int __tinc0_10 = __privtrans->__pdlthread.incs[10];register int __tinc0_11 = __privtrans->__pdlthread.incs[11];register int __tinc0_12 = __privtrans->__pdlthread.incs[12];register int __tinc0_13 = __privtrans->__pdlthread.incs[13];register int __tinc0_14 = __privtrans->__pdlthread.incs[14];register int __tinc0_15 = __privtrans->__pdlthread.incs[15];register int __tinc0_16 = __privtrans->__pdlthread.incs[16];register int __tinc0_17 = __privtrans->__pdlthread.incs[17];register int __tinc0_18 = __privtrans->__pdlthread.incs[18];register int __tinc0_19 = __privtrans->__pdlthread.incs[19];register int __tinc1_0 = __privtrans->__pdlthread.incs[__tnpdls+0];register int __tinc1_1 = __privtrans->__pdlthread.incs[__tnpdls+1];register int __tinc1_2 = __privtrans->__pdlthread.incs[__tnpdls+2];register int __tinc1_3 = __privtrans->__pdlthread.incs[__tnpdls+3];register int __tinc1_4 = __privtrans->__pdlthread.incs[__tnpdls+4];register int __tinc1_5 = __privtrans->__pdlthread.incs[__tnpdls+5];register int __tinc1_6 = __privtrans->__pdlthread.incs[__tnpdls+6];register int __tinc1_7 = __privtrans->__pdlthread.incs[__tnpdls+7];register int __tinc1_8 = __privtrans->__pdlthread.incs[__tnpdls+8];register int __tinc1_9 = __privtrans->__pdlthread.incs[__tnpdls+9];register int __tinc1_10 = __privtrans->__pdlthread.incs[__tnpdls+10];register int __tinc1_11 = __privtrans->__pdlthread.incs[__tnpdls+11];register int __tinc1_12 = __privtrans->__pdlthread.incs[__tnpdls+12];register int __tinc1_13 = __privtrans->__pdlthread.incs[__tnpdls+13];register int __tinc1_14 = __privtrans->__pdlthread.incs[__tnpdls+14];register int __tinc1_15 = __privtrans->__pdlthread.incs[__tnpdls+15];register int __tinc1_16 = __privtrans->__pdlthread.incs[__tnpdls+16];register int __tinc1_17 = __privtrans->__pdlthread.incs[__tnpdls+17];register int __tinc1_18 = __privtrans->__pdlthread.incs[__tnpdls+18];register int __tinc1_19 = __privtrans->__pdlthread.incs[__tnpdls+19];file_datap += __offsp[0];
level_datap += __offsp[1];
rows_datap += __offsp[2];
columns_datap += __offsp[3];
year_datap += __offsp[4];
day_datap += __offsp[5];
hour_datap += __offsp[6];
validity_datap += __offsp[7];
num_grid_datap += __offsp[8];
maptype_datap += __offsp[9];
proj_34_datap += __offsp[10];
proj_35_datap += __offsp[11];
proj_36_datap += __offsp[12];
proj_37_datap += __offsp[13];
proj_38_datap += __offsp[14];
proj_39_datap += __offsp[15];
num_grids_datap += __offsp[16];
gridname_datap += __offsp[17];
levelunits_datap += __offsp[18];
gridorigin_datap += __offsp[19];

	for(__tind2=0; __tind2<__tdims1 ; __tind2++) {
	 for(__tind1=0; __tind1<__tdims0 ; __tind1++) {
	  /* This is the tightest threadloop. Make sure inside is optimal. */
{register PDL_Long __inc_day_3000 = __privtrans->__inc_day_3000;
register PDL_Long __inc_validity_3000 = __privtrans->__inc_validity_3000;
register PDL_Long __inc_gridname_4 = __privtrans->__inc_gridname_4;
register PDL_Long __inc_gridname_3000 = __privtrans->__inc_gridname_3000;
register PDL_Long __inc_year_3000 = __privtrans->__inc_year_3000;
register PDL_Long __inc_rows_3000 = __privtrans->__inc_rows_3000;
register PDL_Long __inc_hour_3000 = __privtrans->__inc_hour_3000;
register PDL_Long __inc_level_3000 = __privtrans->__inc_level_3000;
register PDL_Long __inc_levelunits_4 = __privtrans->__inc_levelunits_4;
register PDL_Long __inc_levelunits_3000 = __privtrans->__inc_levelunits_3000;
register PDL_Long __inc_maptype_3000 = __privtrans->__inc_maptype_3000;
register PDL_Long __inc_gridorigin_4 = __privtrans->__inc_gridorigin_4;
register PDL_Long __inc_gridorigin_3000 = __privtrans->__inc_gridorigin_3000;
register PDL_Long __inc_proj_34_3000 = __privtrans->__inc_proj_34_3000;
register PDL_Long __inc_proj_35_3000 = __privtrans->__inc_proj_35_3000;
register PDL_Long __inc_proj_36_3000 = __privtrans->__inc_proj_36_3000;
register PDL_Long __inc_file_256 = __privtrans->__inc_file_256;
register PDL_Long __inc_file_1 = __privtrans->__inc_file_1;
register PDL_Long __inc_proj_37_3000 = __privtrans->__inc_proj_37_3000;
register PDL_Long __inc_columns_3000 = __privtrans->__inc_columns_3000;
register PDL_Long __inc_proj_38_3000 = __privtrans->__inc_proj_38_3000;
register PDL_Long __inc_num_grid_3000 = __privtrans->__inc_num_grid_3000;
register PDL_Long __inc_proj_39_3000 = __privtrans->__inc_proj_39_3000;

h_grdlist(level_datap,rows_datap,columns_datap,year_datap,day_datap,hour_datap,validity_datap,num_grid_datap,maptype_datap,proj_34_datap,proj_35_datap,proj_36_datap,proj_37_datap,proj_38_datap,proj_39_datap,num_grids_datap,file_datap,gridname_datap,levelunits_datap,gridorigin_datap);
}	/* THREADLOOPEND */
	 file_datap += __tinc0_0;
level_datap += __tinc0_1;
rows_datap += __tinc0_2;
columns_datap += __tinc0_3;
year_datap += __tinc0_4;
day_datap += __tinc0_5;
hour_datap += __tinc0_6;
validity_datap += __tinc0_7;
num_grid_datap += __tinc0_8;
maptype_datap += __tinc0_9;
proj_34_datap += __tinc0_10;
proj_35_datap += __tinc0_11;
proj_36_datap += __tinc0_12;
proj_37_datap += __tinc0_13;
proj_38_datap += __tinc0_14;
proj_39_datap += __tinc0_15;
num_grids_datap += __tinc0_16;
gridname_datap += __tinc0_17;
levelunits_datap += __tinc0_18;
gridorigin_datap += __tinc0_19;

	 } file_datap += __tinc1_0
	     			     - __tinc0_0 *
				       __tdims0;
level_datap += __tinc1_1
	     			     - __tinc0_1 *
				       __tdims0;
rows_datap += __tinc1_2
	     			     - __tinc0_2 *
				       __tdims0;
columns_datap += __tinc1_3
	     			     - __tinc0_3 *
				       __tdims0;
year_datap += __tinc1_4
	     			     - __tinc0_4 *
				       __tdims0;
day_datap += __tinc1_5
	     			     - __tinc0_5 *
				       __tdims0;
hour_datap += __tinc1_6
	     			     - __tinc0_6 *
				       __tdims0;
validity_datap += __tinc1_7
	     			     - __tinc0_7 *
				       __tdims0;
num_grid_datap += __tinc1_8
	     			     - __tinc0_8 *
				       __tdims0;
maptype_datap += __tinc1_9
	     			     - __tinc0_9 *
				       __tdims0;
proj_34_datap += __tinc1_10
	     			     - __tinc0_10 *
				       __tdims0;
proj_35_datap += __tinc1_11
	     			     - __tinc0_11 *
				       __tdims0;
proj_36_datap += __tinc1_12
	     			     - __tinc0_12 *
				       __tdims0;
proj_37_datap += __tinc1_13
	     			     - __tinc0_13 *
				       __tdims0;
proj_38_datap += __tinc1_14
	     			     - __tinc0_14 *
				       __tdims0;
proj_39_datap += __tinc1_15
	     			     - __tinc0_15 *
				       __tdims0;
num_grids_datap += __tinc1_16
	     			     - __tinc0_16 *
				       __tdims0;
gridname_datap += __tinc1_17
	     			     - __tinc0_17 *
				       __tdims0;
levelunits_datap += __tinc1_18
	     			     - __tinc0_18 *
				       __tdims0;
gridorigin_datap += __tinc1_19
	     			     - __tinc0_19 *
				       __tdims0;

	} file_datap -= __tinc1_0 *
     				  __tdims1;level_datap -= __tinc1_1 *
     				  __tdims1;rows_datap -= __tinc1_2 *
     				  __tdims1;columns_datap -= __tinc1_3 *
     				  __tdims1;year_datap -= __tinc1_4 *
     				  __tdims1;day_datap -= __tinc1_5 *
     				  __tdims1;hour_datap -= __tinc1_6 *
     				  __tdims1;validity_datap -= __tinc1_7 *
     				  __tdims1;num_grid_datap -= __tinc1_8 *
     				  __tdims1;maptype_datap -= __tinc1_9 *
     				  __tdims1;proj_34_datap -= __tinc1_10 *
     				  __tdims1;proj_35_datap -= __tinc1_11 *
     				  __tdims1;proj_36_datap -= __tinc1_12 *
     				  __tdims1;proj_37_datap -= __tinc1_13 *
     				  __tdims1;proj_38_datap -= __tinc1_14 *
     				  __tdims1;proj_39_datap -= __tinc1_15 *
     				  __tdims1;num_grids_datap -= __tinc1_16 *
     				  __tdims1;gridname_datap -= __tinc1_17 *
     				  __tdims1;levelunits_datap -= __tinc1_18 *
     				  __tdims1;gridorigin_datap -= __tinc1_19 *
     				  __tdims1;
 file_datap -= __privtrans->__pdlthread.offs[0];
level_datap -= __privtrans->__pdlthread.offs[1];
rows_datap -= __privtrans->__pdlthread.offs[2];
columns_datap -= __privtrans->__pdlthread.offs[3];
year_datap -= __privtrans->__pdlthread.offs[4];
day_datap -= __privtrans->__pdlthread.offs[5];
hour_datap -= __privtrans->__pdlthread.offs[6];
validity_datap -= __privtrans->__pdlthread.offs[7];
num_grid_datap -= __privtrans->__pdlthread.offs[8];
maptype_datap -= __privtrans->__pdlthread.offs[9];
proj_34_datap -= __privtrans->__pdlthread.offs[10];
proj_35_datap -= __privtrans->__pdlthread.offs[11];
proj_36_datap -= __privtrans->__pdlthread.offs[12];
proj_37_datap -= __privtrans->__pdlthread.offs[13];
proj_38_datap -= __privtrans->__pdlthread.offs[14];
proj_39_datap -= __privtrans->__pdlthread.offs[15];
num_grids_datap -= __privtrans->__pdlthread.offs[16];
gridname_datap -= __privtrans->__pdlthread.offs[17];
levelunits_datap -= __privtrans->__pdlthread.offs[18];
gridorigin_datap -= __privtrans->__pdlthread.offs[19];

      } while(PDL->iterthreadloop(&__privtrans->__pdlthread,2));
 	break;}
	default:barf("PP INTERNAL ERROR! PLEASE MAKE A BUG REPORT\n");}
}
	}
    }
    



void pdl_h_grdlist_free(pdl_trans *__tr ) {
	int __dim;
	pdl_h_grdlist_struct *__privtrans = (pdl_h_grdlist_struct *) __tr;
	
	{
	    
			PDL_TR_CLRMAGIC(__privtrans);
			
			if(__privtrans->__ddone) {
				PDL->freethreadloop(&(__privtrans->__pdlthread));
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			}
			
	}
    }
    



static char pdl_h_grdlist_vtable_flags[] =
	 	{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	 pdl_transvtable pdl_h_grdlist_vtable = {
		0,0, 1, 20, pdl_h_grdlist_vtable_flags,
		pdl_h_grdlist_redodims, pdl_h_grdlist_readdata, NULL,
		pdl_h_grdlist_free,NULL,NULL,pdl_h_grdlist_copy,NULL,
		sizeof(pdl_h_grdlist_struct),"pdl_h_grdlist_vtable",
		NULL
	 };

typedef struct pdl_h_grd2pdl_struct {
		PDL_TRANS_START(3);
		pdl_thread  __pdlthread;PDL_Long  __inc_file_256;PDL_Long  __inc_file_1;PDL_Long  __inc_data_elements;PDL_Long  __1_size;PDL_Long  __256_size;PDL_Long  __elements_size;
		
		char __ddone; /* Dims done */
		} pdl_h_grd2pdl_struct;

void pdl_h_grd2pdl_redodims(pdl_trans *__tr ) {
	int __dim;
	pdl_h_grd2pdl_struct *__privtrans = (pdl_h_grd2pdl_struct *) __tr;
	
	{
	    int __creating[3];
__privtrans->__1_size = -1;
__privtrans->__256_size = -1;
__privtrans->__elements_size = -1;
__creating[0] = 0;
__creating[1] = 0;
__creating[2] = PDL_CR_SETDIMSCOND(__privtrans,__privtrans->pdls[2]);
if((__privtrans->pdls[0]->state & PDL_NOMYDIMS) && __privtrans->pdls[0]->trans == 0)
   barf("Error in h_grd2pdl:" "CANNOT CREATE PARAMETER num_grid");
if((__privtrans->pdls[1]->state & PDL_NOMYDIMS) && __privtrans->pdls[1]->trans == 0)
   barf("Error in h_grd2pdl:" "CANNOT CREATE PARAMETER file");
if((!__creating[2]) && (__privtrans->pdls[2]->state & PDL_NOMYDIMS) && __privtrans->pdls[2]->trans == 0)
   barf("Error in h_grd2pdl:" "CANNOT CREATE PARAMETER data");
 {
/* no RedoDimsCode */
}
 {
 static char *__parnames[] = {"num_grid","file","data"};
		static int __realdims[] = {0,2,1};
		static char __funcname[] = "PDL::McIDAS::h_grd2pdl";
		static pdl_errorinfo __einfo = {
			__funcname, __parnames, 3
		};
		
		 PDL->initthreadstruct(2,__privtrans->pdls,
			__realdims,__creating,3,
                      &__einfo,&(__privtrans->__pdlthread),
                        __privtrans->vtable->per_pdl_flags);
		}
PDL->make_physical(((__privtrans->pdls[0])));
   if(((__privtrans->pdls[1]))->ndims < 2) {
      if (((__privtrans->pdls[1]))->ndims < 1 && __privtrans->__256_size <= 1) __privtrans->__256_size = 1;
      if (((__privtrans->pdls[1]))->ndims < 2 && __privtrans->__1_size <= 1) __privtrans->__1_size = 1;
   }
   if(__privtrans->__256_size == -1 || (((__privtrans->pdls[1]))->ndims > 0 && __privtrans->__256_size == 1)) {
      __privtrans->__256_size = ((__privtrans->pdls[1]))->dims[0];
   } else if(((__privtrans->pdls[1]))->ndims > 0 && __privtrans->__256_size != ((__privtrans->pdls[1]))->dims[0]) {
      if(((__privtrans->pdls[1]))->dims[0] != 1) {
         barf("Error in h_grd2pdl:" "Wrong dims\n");
      }
   }
   if(__privtrans->__1_size == -1 || (((__privtrans->pdls[1]))->ndims > 1 && __privtrans->__1_size == 1)) {
      __privtrans->__1_size = ((__privtrans->pdls[1]))->dims[1];
   } else if(((__privtrans->pdls[1]))->ndims > 1 && __privtrans->__1_size != ((__privtrans->pdls[1]))->dims[1]) {
      if(((__privtrans->pdls[1]))->dims[1] != 1) {
         barf("Error in h_grd2pdl:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[1])));
if(!__creating[2]) {
   if(((__privtrans->pdls[2]))->ndims < 1) {
      if (((__privtrans->pdls[2]))->ndims < 1 && __privtrans->__elements_size <= 1) __privtrans->__elements_size = 1;
   }
   if(__privtrans->__elements_size == -1 || (((__privtrans->pdls[2]))->ndims > 0 && __privtrans->__elements_size == 1)) {
      __privtrans->__elements_size = ((__privtrans->pdls[2]))->dims[0];
   } else if(((__privtrans->pdls[2]))->ndims > 0 && __privtrans->__elements_size != ((__privtrans->pdls[2]))->dims[0]) {
      if(((__privtrans->pdls[2]))->dims[0] != 1) {
         barf("Error in h_grd2pdl:" "Wrong dims\n");
      }
   }
PDL->make_physical(((__privtrans->pdls[2])));
} else {
 int dims[2]; /* Use ninds+1 to avoid smart (stupid) compilers */dims[0] = __privtrans->__elements_size;
 PDL->thread_create_parameter(&__privtrans->__pdlthread,2,dims,0);
}{ void *hdrp = NULL;
   if (!hdrp && __privtrans->pdls[0]->hdrsv && (__privtrans->pdls[0]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[0]->hdrsv;
   if (!hdrp && __privtrans->pdls[1]->hdrsv && (__privtrans->pdls[1]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[1]->hdrsv;
   if (!hdrp && !__creating[2] && __privtrans->pdls[2]->hdrsv && (__privtrans->pdls[2]->state & PDL_HDRCPY))
      hdrp = __privtrans->pdls[2]->hdrsv;
if (hdrp) {
   if ( __privtrans->pdls[2]->hdrsv != hdrp )
      __privtrans->pdls[2]->hdrsv = (void*) newRV( (SV*) SvRV((SV*) hdrp) );
}}
if(__privtrans->pdls[1]->ndims <= 0 || __privtrans->pdls[1]->dims[0] <= 1)
		  __privtrans->__inc_file_256 = 0; else
		 __privtrans->__inc_file_256 = __privtrans->pdls[1]->dimincs[0];if(__privtrans->pdls[1]->ndims <= 1 || __privtrans->pdls[1]->dims[1] <= 1)
		  __privtrans->__inc_file_1 = 0; else
		 __privtrans->__inc_file_1 = __privtrans->pdls[1]->dimincs[1];if(__privtrans->pdls[2]->ndims <= 0 || __privtrans->pdls[2]->dims[0] <= 1)
		  __privtrans->__inc_data_elements = 0; else
		 __privtrans->__inc_data_elements = __privtrans->pdls[2]->dimincs[0]; __privtrans->__ddone = 1;
	}
    }
    

pdl_trans * pdl_h_grd2pdl_copy(pdl_trans *__tr ) {
	int __dim;
	pdl_h_grd2pdl_struct *__privtrans = (pdl_h_grd2pdl_struct *) __tr;
	
	{
	    pdl_h_grd2pdl_struct *__copy
 			= malloc(sizeof(pdl_h_grd2pdl_struct));
			PDL_TR_CLRMAGIC(__copy);
			__copy->flags = __privtrans->flags;
			__copy->vtable = __privtrans->vtable;
			__copy->__datatype = __privtrans->__datatype;
			__copy->freeproc = NULL;
			__copy->__ddone = __privtrans->__ddone;
			{int i;
			 for(i=0; i<__copy->vtable->npdls; i++)
				__copy->pdls[i] = __privtrans->pdls[i];
			}
			
			if(__copy->__ddone) {
				PDL->thread_copy(&(__privtrans->__pdlthread),&(__copy->__pdlthread));__privtrans->__inc_file_256=__copy->__inc_file_256;__privtrans->__inc_file_1=__copy->__inc_file_1;__privtrans->__inc_data_elements=__copy->__inc_data_elements;__copy->__1_size=__privtrans->__1_size;__copy->__256_size=__privtrans->__256_size;__copy->__elements_size=__privtrans->__elements_size;
			}
			return (pdl_trans*)__copy;
	}
    }
    

void pdl_h_grd2pdl_readdata(pdl_trans *__tr ) {
	int __dim;
	pdl_h_grd2pdl_struct *__privtrans = (pdl_h_grd2pdl_struct *) __tr;
	
	{
	    {/* Start generic loop */

	switch(__privtrans->__datatype) { case -42: /* Warning eater */ {1;
	} break; case PDL_L: {
	PDL_Long * num_grid_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[0]),(__privtrans->vtable->per_pdl_flags[0]))));
	PDL_Long * num_grid_physdatap = ((PDL_Long *)((__privtrans->pdls[0])->data));

	PDL_Byte * file_datap = ((PDL_Byte *)(PDL_REPRP_TRANS((__privtrans->pdls[1]),(__privtrans->vtable->per_pdl_flags[1]))));
	PDL_Byte * file_physdatap = ((PDL_Byte *)((__privtrans->pdls[1])->data));

	PDL_Long * data_datap = ((PDL_Long *)(PDL_REPRP_TRANS((__privtrans->pdls[2]),(__privtrans->vtable->per_pdl_flags[2]))));
	PDL_Long * data_physdatap = ((PDL_Long *)((__privtrans->pdls[2])->data));

	/* THREADLOOPBEGIN */
 if(PDL->startthreadloop(&(__privtrans->__pdlthread),__privtrans->vtable->readdata,
 	__tr)) return;
   do { register int __tind1=0,__tind2=0;
        register int __tnpdls = __privtrans->__pdlthread.npdls;
      register int __tdims1 = __privtrans->__pdlthread.dims[1];
      register int __tdims0 = __privtrans->__pdlthread.dims[0];
      register int *__offsp = PDL->get_threadoffsp(&__privtrans->__pdlthread);
 register int __tinc0_0 = __privtrans->__pdlthread.incs[0];register int __tinc0_1 = __privtrans->__pdlthread.incs[1];register int __tinc0_2 = __privtrans->__pdlthread.incs[2];register int __tinc1_0 = __privtrans->__pdlthread.incs[__tnpdls+0];register int __tinc1_1 = __privtrans->__pdlthread.incs[__tnpdls+1];register int __tinc1_2 = __privtrans->__pdlthread.incs[__tnpdls+2];num_grid_datap += __offsp[0];
file_datap += __offsp[1];
data_datap += __offsp[2];

	for(__tind2=0; __tind2<__tdims1 ; __tind2++) {
	 for(__tind1=0; __tind1<__tdims0 ; __tind1++) {
	  /* This is the tightest threadloop. Make sure inside is optimal. */
{register PDL_Long __inc_data_elements = __privtrans->__inc_data_elements;
register PDL_Long __inc_file_256 = __privtrans->__inc_file_256;
register PDL_Long __inc_file_1 = __privtrans->__inc_file_1;

long int n_els; n_els=__privtrans->__elements_size;grd2pdl(n_els, file_datap, num_grid_datap,data_datap );
}	/* THREADLOOPEND */
	 num_grid_datap += __tinc0_0;
file_datap += __tinc0_1;
data_datap += __tinc0_2;

	 } num_grid_datap += __tinc1_0
	     			     - __tinc0_0 *
				       __tdims0;
file_datap += __tinc1_1
	     			     - __tinc0_1 *
				       __tdims0;
data_datap += __tinc1_2
	     			     - __tinc0_2 *
				       __tdims0;

	} num_grid_datap -= __tinc1_0 *
     				  __tdims1;file_datap -= __tinc1_1 *
     				  __tdims1;data_datap -= __tinc1_2 *
     				  __tdims1;
 num_grid_datap -= __privtrans->__pdlthread.offs[0];
file_datap -= __privtrans->__pdlthread.offs[1];
data_datap -= __privtrans->__pdlthread.offs[2];

      } while(PDL->iterthreadloop(&__privtrans->__pdlthread,2));
 	break;}
	default:barf("PP INTERNAL ERROR! PLEASE MAKE A BUG REPORT\n");}
}
	}
    }
    



void pdl_h_grd2pdl_free(pdl_trans *__tr ) {
	int __dim;
	pdl_h_grd2pdl_struct *__privtrans = (pdl_h_grd2pdl_struct *) __tr;
	
	{
	    
			PDL_TR_CLRMAGIC(__privtrans);
			
			if(__privtrans->__ddone) {
				PDL->freethreadloop(&(__privtrans->__pdlthread));
				;;;;;;;
			}
			
	}
    }
    



static char pdl_h_grd2pdl_vtable_flags[] =
	 	{ 0,0,0};
	 pdl_transvtable pdl_h_grd2pdl_vtable = {
		0,0, 2, 3, pdl_h_grd2pdl_vtable_flags,
		pdl_h_grd2pdl_redodims, pdl_h_grd2pdl_readdata, NULL,
		pdl_h_grd2pdl_free,NULL,NULL,pdl_h_grd2pdl_copy,NULL,
		sizeof(pdl_h_grd2pdl_struct),"pdl_h_grd2pdl_vtable",
		NULL
	 };



#line 1121 "McIDAS.c"
XS(XS_PDL__McIDAS_set_debugging)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PDL::McIDAS::set_debugging(i)");
    {
	int	i = (int)SvIV(ST(0));
	int	RETVAL;
	dXSTARG;
#line 1119 "McIDAS.xs"
	RETVAL = __pdl_debugging;
	__pdl_debugging = i;
#line 1134 "McIDAS.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PDL__McIDAS_set_boundscheck)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: PDL::McIDAS::set_boundscheck(i)");
    {
	int	i = (int)SvIV(ST(0));
	int	RETVAL;
	dXSTARG;
#line 1128 "McIDAS.xs"
       if (! 1)
         warn("Bounds checking is disabled for PDL::McIDAS");
       RETVAL = __pdl_boundscheck;
       __pdl_boundscheck = i;
#line 1154 "McIDAS.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_PDL_h_grdlist)
{
    dXSARGS;
    SP -= items;
    {
#line 1142 "McIDAS.xs"
  char *objname = "PDL"; /* maybe that class should actually depend on the value set
                            by pp_bless ? (CS) */
  HV *bless_stash = 0;
  SV *parent = 0;
  int   nreturn;
  SV *level_SV;
  SV *rows_SV;
  SV *columns_SV;
  SV *year_SV;
  SV *day_SV;
  SV *hour_SV;
  SV *validity_SV;
  SV *num_grid_SV;
  SV *maptype_SV;
  SV *proj_34_SV;
  SV *proj_35_SV;
  SV *proj_36_SV;
  SV *proj_37_SV;
  SV *proj_38_SV;
  SV *proj_39_SV;
  SV *num_grids_SV;
  SV *gridname_SV;
  SV *levelunits_SV;
  SV *gridorigin_SV;
  pdl  *level;
  pdl  *rows;
  pdl  *columns;
  pdl  *year;
  pdl  *day;
  pdl  *hour;
  pdl  *validity;
  pdl  *num_grid;
  pdl  *maptype;
  pdl  *proj_34;
  pdl  *proj_35;
  pdl  *proj_36;
  pdl  *proj_37;
  pdl  *proj_38;
  pdl  *proj_39;
  pdl  *num_grids;
  pdl  *file;
  pdl  *gridname;
  pdl  *levelunits;
  pdl  *gridorigin;
#line 1210 "McIDAS.c"
#line 1187 "McIDAS.xs"
{
  /* Check if you can get a package name for this input value.  It can be either a PDL (SVt_PVMG) or
     a hash which is a derived PDL subclass (SVt_PVHV) */
  if (SvROK(ST(0)) && ((SvTYPE(SvRV(ST(0))) == SVt_PVMG) || (SvTYPE(SvRV(ST(0))) == SVt_PVHV))) {
    parent = ST(0);
    objname = HvNAME((bless_stash = SvSTASH(SvRV(ST(0)))));  /* The package to bless output vars into is taken from the first input var */
  }
  if (items == 20) { /* all variables on stack, read in output and temp vars */
    nreturn = 0;
    level = PDL->SvPDLV(ST(0));
    rows = PDL->SvPDLV(ST(1));
    columns = PDL->SvPDLV(ST(2));
    year = PDL->SvPDLV(ST(3));
    day = PDL->SvPDLV(ST(4));
    hour = PDL->SvPDLV(ST(5));
    validity = PDL->SvPDLV(ST(6));
    num_grid = PDL->SvPDLV(ST(7));
    maptype = PDL->SvPDLV(ST(8));
    proj_34 = PDL->SvPDLV(ST(9));
    proj_35 = PDL->SvPDLV(ST(10));
    proj_36 = PDL->SvPDLV(ST(11));
    proj_37 = PDL->SvPDLV(ST(12));
    proj_38 = PDL->SvPDLV(ST(13));
    proj_39 = PDL->SvPDLV(ST(14));
    num_grids = PDL->SvPDLV(ST(15));
    file = PDL->SvPDLV(ST(16));
    gridname = PDL->SvPDLV(ST(17));
    levelunits = PDL->SvPDLV(ST(18));
    gridorigin = PDL->SvPDLV(ST(19));
  }
  else if (items == 1) { /* only input variables on stack, create outputs and temps */
    nreturn = 19;
    file = PDL->SvPDLV(ST(0));
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       level_SV = sv_newmortal();
       level = PDL->null();
       PDL->SetSV_PDL(level_SV,level);
       if (bless_stash) level_SV = sv_bless(level_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       level_SV = POPs;
       PUTBACK;
       level = PDL->SvPDLV(level_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       rows_SV = sv_newmortal();
       rows = PDL->null();
       PDL->SetSV_PDL(rows_SV,rows);
       if (bless_stash) rows_SV = sv_bless(rows_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       rows_SV = POPs;
       PUTBACK;
       rows = PDL->SvPDLV(rows_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       columns_SV = sv_newmortal();
       columns = PDL->null();
       PDL->SetSV_PDL(columns_SV,columns);
       if (bless_stash) columns_SV = sv_bless(columns_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       columns_SV = POPs;
       PUTBACK;
       columns = PDL->SvPDLV(columns_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       year_SV = sv_newmortal();
       year = PDL->null();
       PDL->SetSV_PDL(year_SV,year);
       if (bless_stash) year_SV = sv_bless(year_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       year_SV = POPs;
       PUTBACK;
       year = PDL->SvPDLV(year_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       day_SV = sv_newmortal();
       day = PDL->null();
       PDL->SetSV_PDL(day_SV,day);
       if (bless_stash) day_SV = sv_bless(day_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       day_SV = POPs;
       PUTBACK;
       day = PDL->SvPDLV(day_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       hour_SV = sv_newmortal();
       hour = PDL->null();
       PDL->SetSV_PDL(hour_SV,hour);
       if (bless_stash) hour_SV = sv_bless(hour_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       hour_SV = POPs;
       PUTBACK;
       hour = PDL->SvPDLV(hour_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       validity_SV = sv_newmortal();
       validity = PDL->null();
       PDL->SetSV_PDL(validity_SV,validity);
       if (bless_stash) validity_SV = sv_bless(validity_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       validity_SV = POPs;
       PUTBACK;
       validity = PDL->SvPDLV(validity_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       num_grid_SV = sv_newmortal();
       num_grid = PDL->null();
       PDL->SetSV_PDL(num_grid_SV,num_grid);
       if (bless_stash) num_grid_SV = sv_bless(num_grid_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       num_grid_SV = POPs;
       PUTBACK;
       num_grid = PDL->SvPDLV(num_grid_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       maptype_SV = sv_newmortal();
       maptype = PDL->null();
       PDL->SetSV_PDL(maptype_SV,maptype);
       if (bless_stash) maptype_SV = sv_bless(maptype_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       maptype_SV = POPs;
       PUTBACK;
       maptype = PDL->SvPDLV(maptype_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       proj_34_SV = sv_newmortal();
       proj_34 = PDL->null();
       PDL->SetSV_PDL(proj_34_SV,proj_34);
       if (bless_stash) proj_34_SV = sv_bless(proj_34_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       proj_34_SV = POPs;
       PUTBACK;
       proj_34 = PDL->SvPDLV(proj_34_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       proj_35_SV = sv_newmortal();
       proj_35 = PDL->null();
       PDL->SetSV_PDL(proj_35_SV,proj_35);
       if (bless_stash) proj_35_SV = sv_bless(proj_35_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       proj_35_SV = POPs;
       PUTBACK;
       proj_35 = PDL->SvPDLV(proj_35_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       proj_36_SV = sv_newmortal();
       proj_36 = PDL->null();
       PDL->SetSV_PDL(proj_36_SV,proj_36);
       if (bless_stash) proj_36_SV = sv_bless(proj_36_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       proj_36_SV = POPs;
       PUTBACK;
       proj_36 = PDL->SvPDLV(proj_36_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       proj_37_SV = sv_newmortal();
       proj_37 = PDL->null();
       PDL->SetSV_PDL(proj_37_SV,proj_37);
       if (bless_stash) proj_37_SV = sv_bless(proj_37_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       proj_37_SV = POPs;
       PUTBACK;
       proj_37 = PDL->SvPDLV(proj_37_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       proj_38_SV = sv_newmortal();
       proj_38 = PDL->null();
       PDL->SetSV_PDL(proj_38_SV,proj_38);
       if (bless_stash) proj_38_SV = sv_bless(proj_38_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       proj_38_SV = POPs;
       PUTBACK;
       proj_38 = PDL->SvPDLV(proj_38_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       proj_39_SV = sv_newmortal();
       proj_39 = PDL->null();
       PDL->SetSV_PDL(proj_39_SV,proj_39);
       if (bless_stash) proj_39_SV = sv_bless(proj_39_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       proj_39_SV = POPs;
       PUTBACK;
       proj_39 = PDL->SvPDLV(proj_39_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       num_grids_SV = sv_newmortal();
       num_grids = PDL->null();
       PDL->SetSV_PDL(num_grids_SV,num_grids);
       if (bless_stash) num_grids_SV = sv_bless(num_grids_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       num_grids_SV = POPs;
       PUTBACK;
       num_grids = PDL->SvPDLV(num_grids_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       gridname_SV = sv_newmortal();
       gridname = PDL->null();
       PDL->SetSV_PDL(gridname_SV,gridname);
       if (bless_stash) gridname_SV = sv_bless(gridname_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       gridname_SV = POPs;
       PUTBACK;
       gridname = PDL->SvPDLV(gridname_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       levelunits_SV = sv_newmortal();
       levelunits = PDL->null();
       PDL->SetSV_PDL(levelunits_SV,levelunits);
       if (bless_stash) levelunits_SV = sv_bless(levelunits_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       levelunits_SV = POPs;
       PUTBACK;
       levelunits = PDL->SvPDLV(levelunits_SV);
    }
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       gridorigin_SV = sv_newmortal();
       gridorigin = PDL->null();
       PDL->SetSV_PDL(gridorigin_SV,gridorigin);
       if (bless_stash) gridorigin_SV = sv_bless(gridorigin_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       gridorigin_SV = POPs;
       PUTBACK;
       gridorigin = PDL->SvPDLV(gridorigin_SV);
    }
  }
  else {
    croak ("Usage:  PDL::h_grdlist(level,rows,columns,year,day,hour,validity,num_grid,maptype,proj_34,proj_35,proj_36,proj_37,proj_38,proj_39,num_grids,file,gridname,levelunits,gridorigin) (you may leave temporaries or output variables out of list)");
  }
}
{
}
 { pdl_h_grdlist_struct  *__privtrans;
   __privtrans = malloc(sizeof(*__privtrans));
   PDL_TR_SETMAGIC(__privtrans);
   __privtrans->flags = 0;
   __privtrans->__ddone = 0;
   __privtrans->vtable = &pdl_h_grdlist_vtable;
   __privtrans->freeproc = PDL->trans_mallocfreeproc;
file = PDL->make_now(file);
level = PDL->make_now(level);
rows = PDL->make_now(rows);
columns = PDL->make_now(columns);
year = PDL->make_now(year);
day = PDL->make_now(day);
hour = PDL->make_now(hour);
validity = PDL->make_now(validity);
num_grid = PDL->make_now(num_grid);
maptype = PDL->make_now(maptype);
proj_34 = PDL->make_now(proj_34);
proj_35 = PDL->make_now(proj_35);
proj_36 = PDL->make_now(proj_36);
proj_37 = PDL->make_now(proj_37);
proj_38 = PDL->make_now(proj_38);
proj_39 = PDL->make_now(proj_39);
num_grids = PDL->make_now(num_grids);
gridname = PDL->make_now(gridname);
levelunits = PDL->make_now(levelunits);
gridorigin = PDL->make_now(gridorigin);
__privtrans->__datatype = 0;if(!((level->state & PDL_NOMYDIMS) &&
		       level->trans == NULL) && __privtrans->__datatype < level->datatype) {
		 	__privtrans->__datatype = level->datatype;
		    }
if(!((rows->state & PDL_NOMYDIMS) &&
		       rows->trans == NULL) && __privtrans->__datatype < rows->datatype) {
		 	__privtrans->__datatype = rows->datatype;
		    }
if(!((columns->state & PDL_NOMYDIMS) &&
		       columns->trans == NULL) && __privtrans->__datatype < columns->datatype) {
		 	__privtrans->__datatype = columns->datatype;
		    }
if(!((year->state & PDL_NOMYDIMS) &&
		       year->trans == NULL) && __privtrans->__datatype < year->datatype) {
		 	__privtrans->__datatype = year->datatype;
		    }
if(!((day->state & PDL_NOMYDIMS) &&
		       day->trans == NULL) && __privtrans->__datatype < day->datatype) {
		 	__privtrans->__datatype = day->datatype;
		    }
if(!((hour->state & PDL_NOMYDIMS) &&
		       hour->trans == NULL) && __privtrans->__datatype < hour->datatype) {
		 	__privtrans->__datatype = hour->datatype;
		    }
if(!((validity->state & PDL_NOMYDIMS) &&
		       validity->trans == NULL) && __privtrans->__datatype < validity->datatype) {
		 	__privtrans->__datatype = validity->datatype;
		    }
if(!((num_grid->state & PDL_NOMYDIMS) &&
		       num_grid->trans == NULL) && __privtrans->__datatype < num_grid->datatype) {
		 	__privtrans->__datatype = num_grid->datatype;
		    }
if(!((maptype->state & PDL_NOMYDIMS) &&
		       maptype->trans == NULL) && __privtrans->__datatype < maptype->datatype) {
		 	__privtrans->__datatype = maptype->datatype;
		    }
if(!((proj_34->state & PDL_NOMYDIMS) &&
		       proj_34->trans == NULL) && __privtrans->__datatype < proj_34->datatype) {
		 	__privtrans->__datatype = proj_34->datatype;
		    }
if(!((proj_35->state & PDL_NOMYDIMS) &&
		       proj_35->trans == NULL) && __privtrans->__datatype < proj_35->datatype) {
		 	__privtrans->__datatype = proj_35->datatype;
		    }
if(!((proj_36->state & PDL_NOMYDIMS) &&
		       proj_36->trans == NULL) && __privtrans->__datatype < proj_36->datatype) {
		 	__privtrans->__datatype = proj_36->datatype;
		    }
if(!((proj_37->state & PDL_NOMYDIMS) &&
		       proj_37->trans == NULL) && __privtrans->__datatype < proj_37->datatype) {
		 	__privtrans->__datatype = proj_37->datatype;
		    }
if(!((proj_38->state & PDL_NOMYDIMS) &&
		       proj_38->trans == NULL) && __privtrans->__datatype < proj_38->datatype) {
		 	__privtrans->__datatype = proj_38->datatype;
		    }
if(!((proj_39->state & PDL_NOMYDIMS) &&
		       proj_39->trans == NULL) && __privtrans->__datatype < proj_39->datatype) {
		 	__privtrans->__datatype = proj_39->datatype;
		    }
if(!((num_grids->state & PDL_NOMYDIMS) &&
		       num_grids->trans == NULL) && __privtrans->__datatype < num_grids->datatype) {
		 	__privtrans->__datatype = num_grids->datatype;
		    }
if(__privtrans->__datatype == PDL_L) {}
else __privtrans->__datatype = PDL_L;
if(PDL_B != file->datatype) {
	     file = PDL->get_convertedpdl(file,PDL_B);
	  }if( (level->state & PDL_NOMYDIMS) && level->trans == NULL ) {
	     level->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != level->datatype) {
	     level = PDL->get_convertedpdl(level,__privtrans->__datatype);
	  }if( (rows->state & PDL_NOMYDIMS) && rows->trans == NULL ) {
	     rows->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != rows->datatype) {
	     rows = PDL->get_convertedpdl(rows,__privtrans->__datatype);
	  }if( (columns->state & PDL_NOMYDIMS) && columns->trans == NULL ) {
	     columns->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != columns->datatype) {
	     columns = PDL->get_convertedpdl(columns,__privtrans->__datatype);
	  }if( (year->state & PDL_NOMYDIMS) && year->trans == NULL ) {
	     year->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != year->datatype) {
	     year = PDL->get_convertedpdl(year,__privtrans->__datatype);
	  }if( (day->state & PDL_NOMYDIMS) && day->trans == NULL ) {
	     day->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != day->datatype) {
	     day = PDL->get_convertedpdl(day,__privtrans->__datatype);
	  }if( (hour->state & PDL_NOMYDIMS) && hour->trans == NULL ) {
	     hour->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != hour->datatype) {
	     hour = PDL->get_convertedpdl(hour,__privtrans->__datatype);
	  }if( (validity->state & PDL_NOMYDIMS) && validity->trans == NULL ) {
	     validity->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != validity->datatype) {
	     validity = PDL->get_convertedpdl(validity,__privtrans->__datatype);
	  }if( (num_grid->state & PDL_NOMYDIMS) && num_grid->trans == NULL ) {
	     num_grid->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != num_grid->datatype) {
	     num_grid = PDL->get_convertedpdl(num_grid,__privtrans->__datatype);
	  }if( (maptype->state & PDL_NOMYDIMS) && maptype->trans == NULL ) {
	     maptype->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != maptype->datatype) {
	     maptype = PDL->get_convertedpdl(maptype,__privtrans->__datatype);
	  }if( (proj_34->state & PDL_NOMYDIMS) && proj_34->trans == NULL ) {
	     proj_34->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != proj_34->datatype) {
	     proj_34 = PDL->get_convertedpdl(proj_34,__privtrans->__datatype);
	  }if( (proj_35->state & PDL_NOMYDIMS) && proj_35->trans == NULL ) {
	     proj_35->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != proj_35->datatype) {
	     proj_35 = PDL->get_convertedpdl(proj_35,__privtrans->__datatype);
	  }if( (proj_36->state & PDL_NOMYDIMS) && proj_36->trans == NULL ) {
	     proj_36->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != proj_36->datatype) {
	     proj_36 = PDL->get_convertedpdl(proj_36,__privtrans->__datatype);
	  }if( (proj_37->state & PDL_NOMYDIMS) && proj_37->trans == NULL ) {
	     proj_37->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != proj_37->datatype) {
	     proj_37 = PDL->get_convertedpdl(proj_37,__privtrans->__datatype);
	  }if( (proj_38->state & PDL_NOMYDIMS) && proj_38->trans == NULL ) {
	     proj_38->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != proj_38->datatype) {
	     proj_38 = PDL->get_convertedpdl(proj_38,__privtrans->__datatype);
	  }if( (proj_39->state & PDL_NOMYDIMS) && proj_39->trans == NULL ) {
	     proj_39->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != proj_39->datatype) {
	     proj_39 = PDL->get_convertedpdl(proj_39,__privtrans->__datatype);
	  }if( (num_grids->state & PDL_NOMYDIMS) && num_grids->trans == NULL ) {
	     num_grids->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != num_grids->datatype) {
	     num_grids = PDL->get_convertedpdl(num_grids,__privtrans->__datatype);
	  }if( (gridname->state & PDL_NOMYDIMS) && gridname->trans == NULL ) {
	     gridname->datatype = PDL_B;
	  } else if(PDL_B != gridname->datatype) {
	     gridname = PDL->get_convertedpdl(gridname,PDL_B);
	  }if( (levelunits->state & PDL_NOMYDIMS) && levelunits->trans == NULL ) {
	     levelunits->datatype = PDL_B;
	  } else if(PDL_B != levelunits->datatype) {
	     levelunits = PDL->get_convertedpdl(levelunits,PDL_B);
	  }if( (gridorigin->state & PDL_NOMYDIMS) && gridorigin->trans == NULL ) {
	     gridorigin->datatype = PDL_B;
	  } else if(PDL_B != gridorigin->datatype) {
	     gridorigin = PDL->get_convertedpdl(gridorigin,PDL_B);
	  }{}/* No flow: 0 */__privtrans->__pdlthread.inds = 0;__privtrans->pdls[0] = file;
__privtrans->pdls[1] = level;
__privtrans->pdls[2] = rows;
__privtrans->pdls[3] = columns;
__privtrans->pdls[4] = year;
__privtrans->pdls[5] = day;
__privtrans->pdls[6] = hour;
__privtrans->pdls[7] = validity;
__privtrans->pdls[8] = num_grid;
__privtrans->pdls[9] = maptype;
__privtrans->pdls[10] = proj_34;
__privtrans->pdls[11] = proj_35;
__privtrans->pdls[12] = proj_36;
__privtrans->pdls[13] = proj_37;
__privtrans->pdls[14] = proj_38;
__privtrans->pdls[15] = proj_39;
__privtrans->pdls[16] = num_grids;
__privtrans->pdls[17] = gridname;
__privtrans->pdls[18] = levelunits;
__privtrans->pdls[19] = gridorigin;
PDL->make_trans_mutual((pdl_trans *)__privtrans);
if (nreturn) {
  if (nreturn - items > 0) EXTEND (SP, nreturn - items);
  ST(0) = level_SV;
  ST(1) = rows_SV;
  ST(2) = columns_SV;
  ST(3) = year_SV;
  ST(4) = day_SV;
  ST(5) = hour_SV;
  ST(6) = validity_SV;
  ST(7) = num_grid_SV;
  ST(8) = maptype_SV;
  ST(9) = proj_34_SV;
  ST(10) = proj_35_SV;
  ST(11) = proj_36_SV;
  ST(12) = proj_37_SV;
  ST(13) = proj_38_SV;
  ST(14) = proj_39_SV;
  ST(15) = num_grids_SV;
  ST(16) = gridname_SV;
  ST(17) = levelunits_SV;
  ST(18) = gridorigin_SV;
  XSRETURN(nreturn);
} else {
  XSRETURN(0);
}
}
#line 1755 "McIDAS.c"
	PUTBACK;
	return;
    }
}

XS(XS_PDL_h_grd2pdl)
{
    dXSARGS;
    SP -= items;
    {
#line 1734 "McIDAS.xs"
  char *objname = "PDL"; /* maybe that class should actually depend on the value set
                            by pp_bless ? (CS) */
  HV *bless_stash = 0;
  SV *parent = 0;
  int   nreturn;
  SV *data_SV;
  pdl  *data;
  pdl  *num_grid;
  pdl  *file;
#line 1776 "McIDAS.c"
#line 1744 "McIDAS.xs"
{
  /* Check if you can get a package name for this input value.  It can be either a PDL (SVt_PVMG) or
     a hash which is a derived PDL subclass (SVt_PVHV) */
  if (SvROK(ST(0)) && ((SvTYPE(SvRV(ST(0))) == SVt_PVMG) || (SvTYPE(SvRV(ST(0))) == SVt_PVHV))) {
    parent = ST(0);
    objname = HvNAME((bless_stash = SvSTASH(SvRV(ST(0)))));  /* The package to bless output vars into is taken from the first input var */
  }
  if (items == 3) { /* all variables on stack, read in output and temp vars */
    nreturn = 0;
    data = PDL->SvPDLV(ST(0));
    num_grid = PDL->SvPDLV(ST(1));
    file = PDL->SvPDLV(ST(2));
  }
  else if (items == 2) { /* only input variables on stack, create outputs and temps */
    nreturn = 1;
    num_grid = PDL->SvPDLV(ST(0));
    file = PDL->SvPDLV(ST(1));
    if (strcmp(objname,"PDL") == 0) { /* shortcut if just PDL */
       data_SV = sv_newmortal();
       data = PDL->null();
       PDL->SetSV_PDL(data_SV,data);
       if (bless_stash) data_SV = sv_bless(data_SV, bless_stash);
    } else {
       PUSHMARK(SP);
       XPUSHs(sv_2mortal(newSVpv(objname, 0)));
       PUTBACK;
       perl_call_method("initialize", G_SCALAR);
       SPAGAIN;
       data_SV = POPs;
       PUTBACK;
       data = PDL->SvPDLV(data_SV);
    }
  }
  else {
    croak ("Usage:  PDL::h_grd2pdl(data,num_grid,file) (you may leave temporaries or output variables out of list)");
  }
}
{
}
 { pdl_h_grd2pdl_struct  *__privtrans;
   __privtrans = malloc(sizeof(*__privtrans));
   PDL_TR_SETMAGIC(__privtrans);
   __privtrans->flags = 0;
   __privtrans->__ddone = 0;
   __privtrans->vtable = &pdl_h_grd2pdl_vtable;
   __privtrans->freeproc = PDL->trans_mallocfreeproc;
num_grid = PDL->make_now(num_grid);
file = PDL->make_now(file);
data = PDL->make_now(data);
__privtrans->__datatype = 0;if(__privtrans->__datatype < num_grid->datatype) {
		 	__privtrans->__datatype = num_grid->datatype;
		    }
if(!((data->state & PDL_NOMYDIMS) &&
		       data->trans == NULL) && __privtrans->__datatype < data->datatype) {
		 	__privtrans->__datatype = data->datatype;
		    }
if(__privtrans->__datatype == PDL_L) {}
else __privtrans->__datatype = PDL_L;
if(__privtrans->__datatype != num_grid->datatype) {
	     num_grid = PDL->get_convertedpdl(num_grid,__privtrans->__datatype);
	  }if(PDL_B != file->datatype) {
	     file = PDL->get_convertedpdl(file,PDL_B);
	  }if( (data->state & PDL_NOMYDIMS) && data->trans == NULL ) {
	     data->datatype = __privtrans->__datatype;
	  } else if(__privtrans->__datatype != data->datatype) {
	     data = PDL->get_convertedpdl(data,__privtrans->__datatype);
	  }{}/* No flow: 0 */__privtrans->__pdlthread.inds = 0;__privtrans->pdls[0] = num_grid;
__privtrans->pdls[1] = file;
__privtrans->pdls[2] = data;
PDL->make_trans_mutual((pdl_trans *)__privtrans);
if (nreturn) {
  if (nreturn - items > 0) EXTEND (SP, nreturn - items);
  ST(0) = data_SV;
  XSRETURN(nreturn);
} else {
  XSRETURN(0);
}
}
#line 1856 "McIDAS.c"
	PUTBACK;
	return;
    }
}

#ifdef __cplusplus
extern "C"
#endif
XS(boot_PDL__McIDAS)
{
    dXSARGS;
    char* file = __FILE__;

    XS_VERSION_BOOTCHECK ;

        newXSproto("PDL::McIDAS::set_debugging", XS_PDL__McIDAS_set_debugging, file, "$");
        newXSproto("PDL::McIDAS::set_boundscheck", XS_PDL__McIDAS_set_boundscheck, file, "$");
        newXSproto("PDL::h_grdlist", XS_PDL_h_grdlist, file, ";@");
        newXSproto("PDL::h_grd2pdl", XS_PDL_h_grd2pdl, file, ";@");

    /* Initialisation Section */

#line 1825 "McIDAS.xs"
   /* Get pointer to structure of core shared C routines */
   CoreSV = perl_get_sv("PDL::SHARE",FALSE);  /* SV* value */
#ifndef aTHX_
#define aTHX_
#endif
   if (CoreSV==NULL)
     Perl_croak(aTHX_ "This module requires use of PDL::Core first");
   PDL = (Core*) (void*) SvIV( CoreSV );  /* Core* value */
   if (PDL->Version != PDL_CORE_VERSION)
     Perl_croak(aTHX_ "PDL::McIDAS needs to be recompiled against the newly installed PDL");

#line 1891 "McIDAS.c"

    /* End of Initialisation Section */

    XSRETURN_YES;
}

