예제 #1
0
// IDL_LONG64 IDL_SysRtnNumEnabled(int is_function, int enabled)
static IDL_VPTR IDL_CDECL IDL_IDL_SysRtnNumEnabled(int argc, IDL_VPTR *argv, char *argk) {
  IDL_LONG64 result;
  IDL_ENSURE_SIMPLE(argv[0]);
  IDL_ENSURE_SCALAR(argv[0])
  MG_ENSURE_TYPE(argv[0], IDL_TYP_LONG, "int is_function")
  IDL_ENSURE_SIMPLE(argv[1]);
  IDL_ENSURE_SCALAR(argv[1])
  MG_ENSURE_TYPE(argv[1], IDL_TYP_LONG, "int enabled")
  result = (IDL_LONG64) IDL_SysRtnNumEnabled(argv[0]->value.l,   // int is_function
                                             argv[1]->value.l);   // int enabled
  return IDL_GettmpLong64(result);
}
예제 #2
0
static IDL_VPTR IDLOldCnvMapClose(int argc,IDL_VPTR *argv) {
  int s=0;
  IDL_ENSURE_SCALAR(argv[0]);
  IDL_FileFreeUnit(1,argv);
  return (IDL_GettmpLong(s));

}
예제 #3
0
// char *IDL_TypeNameFunc(int type)
static IDL_VPTR IDL_CDECL IDL_IDL_TypeNameFunc(int argc, IDL_VPTR *argv, char *argk) {
  char *result;
  IDL_ENSURE_SIMPLE(argv[0]);
  IDL_ENSURE_SCALAR(argv[0])
  MG_ENSURE_TYPE(argv[0], IDL_TYP_LONG, "int type")
  result = (char *) IDL_TypeNameFunc(argv[0]->value.l);   // int type
  return IDL_StrToSTRING(result);
}
예제 #4
0
// int IDL_TypeSizeFunc(int type)
static IDL_VPTR IDL_CDECL IDL_IDL_TypeSizeFunc(int argc, IDL_VPTR *argv, char *argk) {
  IDL_LONG result;
  IDL_ENSURE_SIMPLE(argv[0]);
  IDL_ENSURE_SCALAR(argv[0])
  MG_ENSURE_TYPE(argv[0], IDL_TYP_LONG, "int type")
  result = (IDL_LONG) IDL_TypeSizeFunc(argv[0]->value.l);   // int type
  return IDL_GettmpLong(result);
}
예제 #5
0
static IDL_VPTR IDL_CDECL IDL_mg_heapid(int argc, IDL_VPTR *argv) {
  IDL_ENSURE_SCALAR(argv[0]);

  if (argv[0]->type != IDL_TYP_PTR && argv[0]->type != IDL_TYP_OBJREF) {
    IDL_MessageFromBlock(msg_block, M_MG_WRONG_TYPE, IDL_MSG_RET);
  }

  return IDL_GettmpULong(argv[0]->value.hvid);
}
예제 #6
0
static IDL_VPTR IDLOldRawWriteHeader(int argc,IDL_VPTR *argv) {
  int s=0;
  IDL_LONG unit=0;
  IDL_FILE_STAT stat;

  struct RadarIDLParm *iprm=NULL;
  struct RawIDLData *iraw=NULL;
  FILE *fp;

  char vstring[256];

  IDL_ENSURE_SCALAR(argv[0]);
  IDL_ENSURE_STRUCTURE(argv[1]);
  IDL_ENSURE_STRUCTURE(argv[2]);
  IDL_EXCLUDE_EXPR(argv[1]);
  IDL_EXCLUDE_EXPR(argv[2]);

  unit=IDL_LongScalar(argv[0]);

  s=IDL_FileEnsureStatus(IDL_MSG_RET,unit,IDL_EFS_USER);

  if (s==FALSE) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  /* Get information about the file */

  IDL_FileFlushUnit(unit);
  IDL_FileStat(unit,&stat);

  /* Find the file pointer */

  fp=stat.fptr;

  if (fp==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  iprm=(struct RadarIDLParm *) argv[1]->value.s.arr->data;
  iraw=(struct RawIDLData *) argv[2]->value.s.arr->data;

  sprintf(vstring,"%d.%.3d",(int) iraw->revision.major,
	                    (int) iraw->revision.minor);
  s=OldRawHeaderFwrite(fp,"rawwrite",vstring,iraw->thr,"IDL output");

  return (IDL_GettmpLong(s));
}
예제 #7
0
파일: mg_net.c 프로젝트: jiezhou87/mglib
/*
  host = MG_NET_NAME2HOST(name)

  Converts the ASCII host name into an unsigned long host value. If name is
  not specified, the local host name is used.
*/
static IDL_VPTR IDL_CDECL mg_net_name2host(int argc, IDL_VPTR argv[], char *argk) {
  struct hostent *hp;
  char *pName, host_name[256];

  if (argc == 0) {
    if (gethostname(host_name, 256) == -1) {
      host_name[0] = '\0';
    }
    pName = host_name;
  } else {
    IDL_ENSURE_STRING(argv[0]);
    IDL_ENSURE_SCALAR(argv[0]);
    pName = IDL_STRING_STR(&(argv[0]->value.str));
  }

  hp = gethostbyname(pName);
  if (!hp) return(IDL_GettmpLong(0));

  return(IDL_GettmpULong(((struct in_addr *) (hp->h_addr))->s_addr));
}
예제 #8
0
static IDL_VPTR IDLOldCnvMapWrite(int argc,IDL_VPTR *argv) {

  int s=0;

  IDL_LONG unit=0;
  IDL_FILE_STAT stat;

  struct CnvMapData *map=NULL;
  struct GridData *grd=NULL;

  struct CnvMapIDLPrm *iprm=NULL;
  struct GridIDLStVec *istvec=NULL;
  struct GridIDLGVec *igvec=NULL;
  struct GridIDLGVec *imvec=NULL;
  struct CnvMapIDLBnd *ibnd=NULL;
  double *icoef=NULL; 

  FILE *fp;

  IDL_ENSURE_SCALAR(argv[0]);
  IDL_ENSURE_STRUCTURE(argv[1]);
  IDL_ENSURE_ARRAY(argv[2]);
  IDL_ENSURE_ARRAY(argv[3]);
  IDL_EXCLUDE_EXPR(argv[1]);
  IDL_EXCLUDE_EXPR(argv[2]);
  IDL_EXCLUDE_EXPR(argv[3]);

  unit=IDL_LongScalar(argv[0]);

  s=IDL_FileEnsureStatus(IDL_MSG_RET,unit,IDL_EFS_USER);

  if (s==FALSE) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  /* Get information about the file */

  IDL_FileFlushUnit(unit);
  IDL_FileStat(unit,&stat);
 
  /* Find the file pointer */

  fp=stat.fptr;
  
  if (fp==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  iprm=(struct CnvMapIDLPrm *) argv[1]->value.s.arr->data;
  if (argv[2]->type==IDL_TYP_STRUCT) 
     istvec=(struct GridIDLStVec *) argv[2]->value.s.arr->data;
  if (argv[3]->type==IDL_TYP_STRUCT) 
     igvec=(struct GridIDLGVec *) argv[3]->value.s.arr->data;
  if (argv[4]->type==IDL_TYP_STRUCT)
     imvec=(struct GridIDLGVec *) argv[4]->value.s.arr->data;
  if (argv[5]->type==IDL_TYP_DOUBLE) 
     icoef=(double *) argv[5]->value.s.arr->data;
  if (argv[6]->type==IDL_TYP_STRUCT) 
     ibnd=(struct CnvMapIDLBnd *) argv[6]->value.s.arr->data;

  map=CnvMapMake(); 
  grd=GridMake();

  IDLCopyCnvMapPrmFromIDL(iprm,map,grd);
  if (istvec !=NULL)  IDLCopyGridStVecFromIDL(istvec,iprm->stnum,
                        argv[2]->value.s.arr->elt_len,grd);
  else grd->stnum=0;

  if (igvec !=NULL) IDLCopyGridGVecFromIDL(igvec,iprm->vcnum,
       argv[3]->value.s.arr->elt_len,grd);
  else grd->vcnum=0;

  if (imvec !=NULL) IDLCopyCnvMapGVecFromIDL(imvec,
                        iprm->modnum,argv[4]->value.s.arr->elt_len,map);
  else map->num_model=0;

  if (ibnd !=NULL) IDLCopyCnvMapBndFromIDL(ibnd,
                        iprm->bndnum,argv[6]->value.s.arr->elt_len,map);
  else map->num_bnd=0;

  if (icoef !=NULL) {
    int n=0;
    map->coef=malloc(sizeof(double)*map->num_coef*4);
    for (n=0;n<map->num_coef;n++) {
      map->coef[4*n]=icoef[n];
      map->coef[4*n+1]= icoef[map->num_coef+n];
      map->coef[4*n+2]=icoef[2*map->num_coef+n];
      map->coef[4*n+3]=icoef[3*map->num_coef+n];
    }
  } else map->num_coef=0;


  s=OldCnvMapFwrite(fp,map,grd);

  CnvMapFree(map);
  GridFree(grd);

  return (IDL_GettmpLong(s));


}
예제 #9
0
static IDL_VPTR IDLOldCnvMapSeek(int argc,IDL_VPTR *argv,char *argk) {

  struct OldCnvMapIDLInx *ifptr;

  int s=0,n;
  struct RfileIndex *finx=NULL;
  static IDL_VPTR vatme;
  double atme=0;

  int outargc=0;
  IDL_VPTR outargv[8];
  static IDL_KW_PAR kw_pars[]={IDL_KW_FAST_SCAN,
			       {"ATME",IDL_TYP_UNDEF,1,
                                IDL_KW_OUT | IDL_KW_ZERO,0,
                                IDL_CHARA(vatme)},
				 {NULL}};


  IDL_LONG unit=0,yr=0,mo=0,dy=0,hr=0,mt=0,sc=0;
  IDL_FILE_STAT stat;

  FILE *fp=NULL;

  IDL_KWCleanup(IDL_KW_MARK);
  outargc=IDL_KWGetParams(argc,argv,argk,kw_pars,outargv,1);


  IDL_ENSURE_SCALAR(outargv[0]);
  IDL_ENSURE_SCALAR(outargv[1]);
  IDL_ENSURE_SCALAR(outargv[2]);
  IDL_ENSURE_SCALAR(outargv[3]);
  IDL_ENSURE_SCALAR(outargv[4]);
  IDL_ENSURE_SCALAR(outargv[5]);
  IDL_ENSURE_SCALAR(outargv[6]);

  if (outargc>7) IDL_ENSURE_ARRAY(outargv[7]);

  unit=IDL_LongScalar(outargv[0]);

  s=IDL_FileEnsureStatus(IDL_MSG_RET,unit,IDL_EFS_USER);

  if (s==FALSE) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  /* Get information about the file */

  IDL_FileFlushUnit(unit);
  IDL_FileStat(unit,&stat);
 
  /* Find the file pointer */

  fp=stat.fptr;
  
  if (fp==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  yr=IDL_LongScalar(outargv[1]);
  mo=IDL_LongScalar(outargv[2]);
  dy=IDL_LongScalar(outargv[3]);
  hr=IDL_LongScalar(outargv[4]);
  mt=IDL_LongScalar(outargv[5]);
  sc=IDL_LongScalar(outargv[6]);

  /* test for existence of index */

  if (outargc>7) {
    /* decode index here */
    finx=malloc(sizeof(struct RfileIndex));
    if (finx==NULL) {
      s=-1;
      return (IDL_GettmpLong(s));
    }
    finx->num=outargv[7]->value.s.arr->n_elts;
    finx->time.start=malloc(sizeof(double)*finx->num);
    if (finx->time.start==NULL) {
      s=-1;
      free(finx);
      return (IDL_GettmpLong(s));
    } 
    finx->time.end=malloc(sizeof(double)*finx->num);
    if (finx->time.end==NULL) {
      s=-1;
      free(finx->time.start);
      free(finx);
      return (IDL_GettmpLong(s));
    } 

    finx->offset=malloc(sizeof(int)*finx->num);
    if (finx->offset==NULL) {
      s=-1;
      free(finx->time.start);
      free(finx->time.end);
      free(finx);
      return (IDL_GettmpLong(s));
    } 
    for (n=0;n<finx->num;n++) {
      ifptr=(struct OldCnvMapIDLInx *) (outargv[7]->value.s.arr->data+
                                    n*outargv[7]->value.s.arr->elt_len);
      finx->time.start[n]=ifptr->st_time;
      finx->time.end[n]=ifptr->ed_time;
      finx->offset[n]=ifptr->offset;
    }
    finx->st_time=finx->time.start[0];
    finx->ed_time=finx->time.end[finx->num-1];

  }


  s=OldCnvMapFseek(fp,yr,mo,dy,hr,mt,sc,finx,&atme);

  if (vatme) IDL_StoreScalar(vatme,IDL_TYP_DOUBLE,(IDL_ALLTYPES *) &atme);
 
  if (finx !=NULL) {
    free(finx->time.start);
    free(finx->time.end);
    free(finx->offset);
    free(finx);
  }
   
  IDL_KWCleanup(IDL_KW_CLEAN);
  return (IDL_GettmpLong(s));


}
예제 #10
0
static IDL_VPTR IDLOldCnvMapLoadInx(int argc,IDL_VPTR *argv) {

  int s=0,n;

  IDL_VPTR vinx=NULL;

  IDL_LONG unit=0;
  IDL_FILE_STAT stat;

  FILE *fp=NULL;

  struct OldCnvMapIDLInx *ifptr=NULL;
  struct RfileIndex *finx=NULL;

  IDL_ENSURE_SCALAR(argv[0]);
  IDL_EXCLUDE_EXPR(argv[1]);

  unit=IDL_LongScalar(argv[0]);

  s=IDL_FileEnsureStatus(IDL_MSG_RET,unit,IDL_EFS_USER);

  if (s==FALSE) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  /* Get information about the file */

  IDL_FileFlushUnit(unit);
  IDL_FileStat(unit,&stat);
 
  /* Find the file pointer */

  fp=stat.fptr;
  
  if (fp==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }
 
  finx=RfileLoadIndex(fp);

  if (finx==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  ifptr=IDLMakeOldCnvMapInx(finx->num,&vinx);
  
  for (n=0;n<finx->num;n++) {
    ifptr[n].st_time=finx->time.start[n];
    ifptr[n].ed_time=finx->time.end[n];
    ifptr[n].offset=finx->offset[n];
  }
  
  free(finx->time.start);
  free(finx->time.end);
  free(finx->offset);
  free(finx);

  IDL_VarCopy(vinx,argv[1]); 
   
  return (IDL_GettmpLong(s));
}
예제 #11
0
static IDL_VPTR IDLOldCnvMapRead(int argc,IDL_VPTR *argv) {

  int s=0;


  IDL_VPTR vprm=NULL,vstvec=NULL,vgvec=NULL,vmvec=NULL,vcoef=NULL,vbnd=NULL;

  IDL_LONG unit=0;
  IDL_FILE_STAT stat;


  struct CnvMapData *map=NULL;
  struct GridData *grd=NULL;

  struct CnvMapIDLPrm *iprm=NULL;
  struct GridIDLStVec *istvec=NULL;
  struct GridIDLGVec *igvec=NULL;
  struct GridIDLGVec *imvec=NULL;
  struct CnvMapIDLBnd *ibnd=NULL;
  double *icoef=NULL; 

  IDL_MEMINT cdim[2];

  FILE *fp=NULL;

  IDL_ENSURE_SCALAR(argv[0]);
  IDL_EXCLUDE_EXPR(argv[1]);
  IDL_EXCLUDE_EXPR(argv[2]);
  IDL_EXCLUDE_EXPR(argv[4]);
  IDL_EXCLUDE_EXPR(argv[5]);
  IDL_EXCLUDE_EXPR(argv[6]);

  unit=IDL_LongScalar(argv[0]);

  s=IDL_FileEnsureStatus(IDL_MSG_RET,unit,IDL_EFS_USER);

  if (s==FALSE) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  /* Get information about the file */

  IDL_FileFlushUnit(unit);
  IDL_FileStat(unit,&stat);
 
  /* Find the file pointer */

  fp=stat.fptr;
  
  if (fp==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }
 

  map=CnvMapMake(); 
  grd=GridMake();

  s=OldCnvMapFread(fp,map,grd);

  if (s==-1) {
    CnvMapFree(map);
    GridFree(grd);
    return (IDL_GettmpLong(s));
  }

  iprm=IDLMakeCnvMapPrm(&vprm);
  if (grd->stnum !=0) istvec=IDLMakeGridStVec(grd->stnum,&vstvec);
  if (grd->vcnum !=0) igvec=IDLMakeGridGVec(grd->vcnum,&vgvec);
  if (map->num_model !=0) imvec=IDLMakeGridGVec(map->num_model,&vmvec);
  if (map->num_bnd !=0) ibnd=IDLMakeCnvMapBnd(map->num_bnd,&vbnd);
  if (map->num_coef !=0) {
    int n=0;
    cdim[1]=4;
    cdim[0]=map->num_coef;
    icoef=(double *) 
      IDL_MakeTempArray(IDL_TYP_DOUBLE,2,cdim,IDL_ARR_INI_ZERO,&vcoef);
   
      for (n=0;n<map->num_coef;n++) {
       icoef[n]=map->coef[4*n];
       icoef[map->num_coef+n]=map->coef[4*n+1];
       icoef[2*map->num_coef+n]=map->coef[4*n+2];
       icoef[3*map->num_coef+n]=map->coef[4*n+3];
      }

  }

  /* copy the data here */
   
  IDLCopyCnvMapPrmToIDL(map,grd,iprm);
  if (istvec !=NULL) IDLCopyGridStVecToIDL(grd,grd->stnum,
                                    vstvec->value.s.arr->elt_len,istvec);
  if (igvec !=NULL) IDLCopyGridGVecToIDL(grd,grd->vcnum,
                                    vgvec->value.s.arr->elt_len,igvec);
  if (imvec !=NULL) IDLCopyCnvMapGVecToIDL(map,map->num_model,
                                           vmvec->value.s.arr->elt_len,imvec);
  if (ibnd !=NULL) IDLCopyCnvMapBndToIDL(map,map->num_bnd,
                                         vbnd->value.s.arr->elt_len,ibnd);

  CnvMapFree(map);
  GridFree(grd);

  IDL_VarCopy(vprm,argv[1]);  
  if (vstvec !=NULL) IDL_VarCopy(vstvec,argv[2]);
  if (vgvec !=NULL) IDL_VarCopy(vgvec,argv[3]);
  if (vmvec !=NULL) IDL_VarCopy(vmvec,argv[4]);
  if (vcoef !=NULL) IDL_VarCopy(vcoef,argv[5]);
  if (vbnd !=NULL) IDL_VarCopy(vbnd,argv[6]);


  return (IDL_GettmpLong(s));

}
예제 #12
0
static IDL_VPTR IDLOldRawSeek(int argc,IDL_VPTR *argv,char *argk) {

  IDL_FILE_STAT stat;
  struct OldRawIDLFp *irawfp;
  struct OldRawFp rawfp;
  int s=0;
  static IDL_VPTR vatme;
  double atme=0;

  IDL_VPTR outargv[8];
  static IDL_KW_PAR kw_pars[]={IDL_KW_FAST_SCAN,
			       {"ATME",IDL_TYP_UNDEF,1,
                                IDL_KW_OUT | IDL_KW_ZERO,0,
                                IDL_CHARA(vatme)},
				 {NULL}};


  IDL_LONG yr=0,mo=0,dy=0,hr=0,mt=0,sc=0;
  FILE *ffp=NULL,*ifp=NULL;

  IDL_KWCleanup(IDL_KW_MARK);
  IDL_KWGetParams(argc,argv,argk,kw_pars,outargv,1);

  IDL_ENSURE_STRUCTURE(outargv[0]);
  IDL_ENSURE_SCALAR(outargv[1]);
  IDL_ENSURE_SCALAR(outargv[2]);
  IDL_ENSURE_SCALAR(outargv[3]);
  IDL_ENSURE_SCALAR(outargv[4]);
  IDL_ENSURE_SCALAR(outargv[5]);
  IDL_ENSURE_SCALAR(outargv[6]);

  yr=IDL_LongScalar(outargv[1]);
  mo=IDL_LongScalar(outargv[2]);
  dy=IDL_LongScalar(outargv[3]);
  hr=IDL_LongScalar(outargv[4]);
  mt=IDL_LongScalar(outargv[5]);
  sc=IDL_LongScalar(outargv[6]);

  irawfp=(struct OldRawIDLFp *) outargv[0]->value.s.arr->data;
  
  s=IDL_FileEnsureStatus(IDL_MSG_RET,irawfp->rawunit,IDL_EFS_USER);

  if (s==FALSE) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  IDL_FileFlushUnit(irawfp->rawunit);
  IDL_FileStat(irawfp->rawunit,&stat);
 

  ffp=stat.fptr;
  
  if (ffp==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }
 
  if (irawfp->inxunit !=-1) {
    IDL_FileFlushUnit(irawfp->inxunit);
    IDL_FileStat(irawfp->inxunit,&stat);
    ifp=stat.fptr;
  }

  if (ifp !=NULL) fflush(ifp);

  rawfp.rawfp=fileno(ffp);
  if (ifp !=NULL) rawfp.inxfp=fileno(ifp);
  else rawfp.inxfp=-1;

  OldRawIDLToRawFp(irawfp,&rawfp);

  s=OldRawSeek(&rawfp,yr,mo,dy,hr,mt,sc,&atme);

  OldRawRawFpToIDL(&rawfp,irawfp);


  if (vatme) IDL_StoreScalar(vatme,IDL_TYP_DOUBLE,(IDL_ALLTYPES *) &atme);
 
  IDL_KWCleanup(IDL_KW_CLEAN);
  return (IDL_GettmpLong(s));
}
예제 #13
0
static IDL_VPTR IDLOldRawWrite(int argc,IDL_VPTR *argv) {
  int s=0;
  IDL_LONG unit=0,recnum;
  IDL_FILE_STAT stat;

  struct RadarIDLParm *iprm=NULL;
  struct RawIDLData *iraw=NULL;

  struct RadarParm *prm=NULL;
  struct RawData *raw=NULL;

  FILE *fp;

  IDL_ENSURE_SCALAR(argv[0]);
  IDL_ENSURE_STRUCTURE(argv[1]);
  IDL_ENSURE_STRUCTURE(argv[2]);
  IDL_ENSURE_SCALAR(argv[3]);
  IDL_EXCLUDE_EXPR(argv[1]);
  IDL_EXCLUDE_EXPR(argv[2]);

  unit=IDL_LongScalar(argv[0]);
  recnum=IDL_LongScalar(argv[3]);

  s=IDL_FileEnsureStatus(IDL_MSG_RET,unit,IDL_EFS_USER);

  if (s==FALSE) {
    s=-1;
    return (IDL_GettmpLong(s));
  }


  /* Get information about the file */

  IDL_FileFlushUnit(unit);
  IDL_FileStat(unit,&stat);

  /* Find the file pointer */

  fp=stat.fptr;

  if (fp==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  iprm=(struct RadarIDLParm *) argv[1]->value.s.arr->data;
  iraw=(struct RawIDLData *) argv[2]->value.s.arr->data;

  prm=RadarParmMake();
  raw=RawMake();

  IDLCopyRadarParmFromIDL(iprm,prm);
  IDLCopyRawDataFromIDL(prm->nrang,prm->mplgs,prm->xcf,iraw,raw);

  s=OldRawFwrite(fp,"rawwrite",prm,raw,recnum,NULL);

  RadarParmFree(prm);
  RawFree(raw);



  return (IDL_GettmpLong(s));
}
예제 #14
0
static IDL_VPTR IDLOldGridWrite(int argc,IDL_VPTR *argv) {

  int s=0;

  IDL_LONG unit=0;
  IDL_FILE_STAT stat;

  struct GridData *grd=NULL;
  struct GridIDLPrm *iprm=NULL;
  struct GridIDLStVec *istvec=NULL;
  struct GridIDLGVec *igvec=NULL;
 
  FILE *fp;

  IDL_ENSURE_SCALAR(argv[0]);
  IDL_ENSURE_STRUCTURE(argv[1]);
  IDL_ENSURE_ARRAY(argv[2]);
  IDL_ENSURE_ARRAY(argv[3]);
  IDL_EXCLUDE_EXPR(argv[1]);
  IDL_EXCLUDE_EXPR(argv[2]);
  IDL_EXCLUDE_EXPR(argv[3]);

  unit=IDL_LongScalar(argv[0]);

  s=IDL_FileEnsureStatus(IDL_MSG_RET,unit,IDL_EFS_USER);

  if (s==FALSE) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  /* Get information about the file */

  IDL_FileFlushUnit(unit);
  IDL_FileStat(unit,&stat);
 
  /* Find the file pointer */

  fp=stat.fptr;
  
  if (fp==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  iprm=(struct GridIDLPrm *) argv[1]->value.s.arr->data;
  if (argv[2]->type==IDL_TYP_STRUCT) 
     istvec=(struct GridIDLStVec *) argv[2]->value.s.arr->data;
  if (argv[3]->type==IDL_TYP_STRUCT) 
     igvec=(struct GridIDLGVec *) argv[3]->value.s.arr->data;


  grd=GridMake(); 

  IDLCopyGridPrmFromIDL(iprm,grd);
  if (istvec !=NULL)  IDLCopyGridStVecFromIDL(istvec,iprm->stnum,
                        argv[2]->value.s.arr->elt_len,grd);
  else grd->stnum=0;

  if (igvec !=NULL) IDLCopyGridGVecFromIDL(igvec,iprm->vcnum,
       argv[3]->value.s.arr->elt_len,grd);
  else grd->vcnum=0;

  s=OldGridFwrite(fp,grd);

  GridFree(grd);

  return (IDL_GettmpLong(s));


}
예제 #15
0
static IDL_VPTR IDLOldGridRead(int argc,IDL_VPTR *argv) {

  int s=0;


  IDL_VPTR vprm=NULL,vstvec=NULL,vgvec=NULL;

  IDL_LONG unit=0;
  IDL_FILE_STAT stat;


  struct GridData *grd=NULL;
  struct GridIDLPrm *iprm=NULL;
  struct GridIDLStVec *istvec=NULL;
  struct GridIDLGVec *igvec=NULL; 

  FILE *fp=NULL;

  IDL_ENSURE_SCALAR(argv[0]);
  IDL_EXCLUDE_EXPR(argv[1]);
  IDL_EXCLUDE_EXPR(argv[2]);
  IDL_EXCLUDE_EXPR(argv[3]);


  unit=IDL_LongScalar(argv[0]);

  s=IDL_FileEnsureStatus(IDL_MSG_RET,unit,IDL_EFS_USER);
   
  if (s==FALSE) {
    s=-1;
    return (IDL_GettmpLong(s));
  }

  /* Get information about the file */

  IDL_FileFlushUnit(unit);
  IDL_FileStat(unit,&stat);
 
  /* Find the file pointer */

  fp=stat.fptr;
  
  if (fp==NULL) {
    s=-1;
    return (IDL_GettmpLong(s));
  }
 

  grd=GridMake(); 

  s=OldGridFread(fp,grd);

  if (s==-1) {
    GridFree(grd);
    return (IDL_GettmpLong(s));
  }

  iprm=IDLMakeGridPrm(&vprm);
  if (grd->stnum !=0) istvec=IDLMakeGridStVec(grd->stnum,&vstvec);
  if (grd->vcnum !=0) igvec=IDLMakeGridGVec(grd->vcnum,&vgvec);

  /* copy the data here */
   
  IDLCopyGridPrmToIDL(grd,iprm);
  if (istvec !=NULL) IDLCopyGridStVecToIDL(grd,grd->stnum,
                                    vstvec->value.s.arr->elt_len,istvec);
  if (igvec !=NULL) IDLCopyGridGVecToIDL(grd,grd->vcnum,
                                    vgvec->value.s.arr->elt_len,igvec);


  
  GridFree(grd);

  IDL_VarCopy(vprm,argv[1]);  
  if (vstvec !=NULL) IDL_VarCopy(vstvec,argv[2]);
  if (vgvec !=NULL) IDL_VarCopy(vgvec,argv[3]);

  return (IDL_GettmpLong(s));

}