int main(int argc,char *argv[]) { FILE *fp; int yr,mo,dy,hr,mt; double sc; fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } while(OldCnvMapFread(fp,&map,&grd) !=-1) { TimeEpochToYMDHMS(map.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stderr,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d pnts=%d\n", yr,mo,dy,hr,mt,(int) sc,grd.vcnum); map.Bx=0.0; map.By=0.0; map.Bz=0.0; OldCnvMapFwrite(stdout,&map,&grd); } fclose(fp); return 0; }
int main (int argc,char *argv[]) { int arg; unsigned char help=0; unsigned char option=0; unsigned char vb=0; FILE *fp; int yr,mo,dy,hr,mt; double sc; int s; OptionAdd(&opt,"-help",'x',&help); OptionAdd(&opt,"-option",'x',&option); OptionAdd(&opt,"vb",'x',&vb); arg=OptionProcess(1,argc,argv,&opt,NULL); if (help==1) { OptionPrintInfo(stdout,hlpstr); exit(0); } if (option==1) { OptionDump(stdout,&opt); exit(0); } if (arg==argc) fp=stdin; else fp=fopen(argv[arg],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } while (OldCnvMapFread(fp,&map,&grd) !=-1) { if (vb) { TimeEpochToYMDHMS(map.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stderr,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr,mo,dy,hr,mt,(int) sc); } s=CnvMapFwrite(stdout,&map,&grd); } if (fp !=stdin) fclose(fp); return 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)); }
int main(int argc,char *argv[]) { FILE *fp; struct RfileIndex *inx=NULL; int yr=2005,mo=3,dy=31,hr=10,mt=30; double sc=0,atme; int s; if (argc>2) { fp=fopen(argv[2],"r"); if (fp==NULL) { fprintf(stderr,"Index not found.\n"); exit(-1); } inx=RfileLoadIndex(fp); fclose(fp); if (inx==NULL) { fprintf(stderr,"Error loading index.\n"); exit(-1); } } fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } s=OldCnvMapFseek(fp,yr,mo,dy,hr,mt,(int) sc,inx,&atme); if (s==-1) { fprintf(stderr,"file does not contain that interval.\n"); exit(-1); } fprintf(stdout,"Requested:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr,mo,dy,hr,mt,(int) sc); TimeEpochToYMDHMS(atme,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"Found:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr,mo,dy,hr,mt,(int) sc); while(OldCnvMapFread(fp,&map,&grd) !=-1) { TimeEpochToYMDHMS(map.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d pnts=%d\n", yr,mo,dy,hr,mt,(int) sc,grd.vcnum); } fclose(fp); return 0; }
int32 OldCnvMapIDLRead(int argc,char *argv[]) { int32 *idlstnum; int32 *idlvcnum; int32 *idlmodnum; int32 *idlcoefnum; int32 *idlbndnum; IDL_STRING *idlptr=NULL; struct CnvMapData map; struct GridData grd; IDL_FILE_STAT stat; FILE *fp; int unit; int s; unit = *( (int32 *) argv[0]); /* Make sure that the "STDIO" keyword was used to * open the file in IDL. */ s=IDL_FileEnsureStatus(IDL_MSG_RET,unit,IDL_EFS_STDIO); if (s==FALSE) return -1; /* Get information about the file */ IDL_FileStat(unit,&stat); /* Find the file pointer */ fp=stat.fptr; if (fp==NULL) return -1; fflush(fp); /* Read in the record */ memset(&grd,0,sizeof(struct GridData)); memset(&map,0,sizeof(struct CnvMapData)); s=OldCnvMapFread(fp,&map,&grd); if (s==-1) return -1; /* get the output pointers */ idlstnum=(int32 *) argv[1]; idlvcnum=(int32 *) argv[2]; idlmodnum=(int32 *) argv[3]; idlcoefnum=(int32 *) argv[4]; idlbndnum=(int32 *) argv[5]; idlptr=(IDL_STRING *) argv[6]; IDL_StrEnsureLength(idlptr,sizeof(struct GridData)+ grd.stnum*sizeof(struct GridSVec)+ grd.vcnum*sizeof(struct GridGVec)+ sizeof(struct CnvMapData)+ map.num_model*sizeof(struct GridGVec)+ map.num_coef*4*sizeof(double)+ map.num_bnd*2*sizeof(double)); memcpy(idlptr->s,&grd,sizeof(struct GridData)); memcpy(idlptr->s+sizeof(struct GridData),grd.sdata, grd.stnum*sizeof(struct GridSVec)); memcpy(idlptr->s+sizeof(struct GridData)+grd.stnum*sizeof(struct GridSVec), grd.data,grd.vcnum*sizeof(struct GridGVec)); memcpy(idlptr->s+sizeof(struct GridData)+grd.stnum*sizeof(struct GridSVec)+ grd.vcnum*sizeof(struct GridGVec), &map,sizeof(struct CnvMapData)); memcpy(idlptr->s+sizeof(struct GridData)+grd.stnum*sizeof(struct GridSVec)+ grd.vcnum*sizeof(struct GridGVec)+sizeof(struct CnvMapData), map.model,map.num_model*sizeof(struct GridGVec)); memcpy(idlptr->s+sizeof(struct GridData)+grd.stnum*sizeof(struct GridSVec)+ grd.vcnum*sizeof(struct GridGVec)+sizeof(struct CnvMapData)+ map.num_model*sizeof(struct GridGVec),map.coef, map.num_coef*4*sizeof(double)); memcpy(idlptr->s+sizeof(struct GridData)+grd.stnum*sizeof(struct GridSVec)+ grd.vcnum*sizeof(struct GridGVec)+sizeof(struct CnvMapData)+ map.num_model*sizeof(struct GridGVec)+map.num_coef*4*sizeof(double), map.bnd_lat,map.num_bnd*sizeof(double)); memcpy(idlptr->s+sizeof(struct GridData)+grd.stnum*sizeof(struct GridSVec)+ grd.vcnum*sizeof(struct GridGVec)+sizeof(struct CnvMapData)+ map.num_model*sizeof(struct GridGVec)+map.num_coef*4*sizeof(double)+ map.num_bnd*sizeof(double),map.bnd_lon,map.num_bnd*sizeof(double)); *idlstnum=grd.stnum; *idlvcnum=grd.vcnum; *idlmodnum=map.num_model; *idlcoefnum=map.num_coef; *idlbndnum=map.num_bnd; return s; }