Previous: IDSGET
Up: IDSGET
Previous Page: IDSGET
Next Page: Retrieving data set information

Example

Fortran:

subroutine gt_show1
* 
*   ********************************************************************
*   *                                                                  *
*$$ *   subroutine gt_show1  demonstration of idsget function          *
*   *                        with data copying                         *
*   *                                                                  *
*   *   Ryszard Zybert    Dec  2 12:16:22 1993                         *
*   ********************************************************************
* 
      structure /VECT3/
              real  X
              real  Y
              real  Z
      end structure
      structure /POINT/
              real  X
              real  Y
              real  Z
      end structure
      structure /TRACKS/
              real  Q
              record/VECT3/  P
              record/POINT/  VERTEX
              integer  PID
              integer  N_HITS
              integer  FIRST_HIT
      end structure
      record/point/ vl(100)
      record/tracks/ tl(50)
      real zl(1000)
      save
      data iv1,iv2,iv3/3*0/

call idsget('TRACKS',iv1,1,is,ngot,50,nc,tl,ierr) write(*,*)'Got ', nc, ' tracks' write(*,*)(tl(i).vertex.z,i=1,nc)

call idsget('TRACKS.VERTEX',iv2,1,is,ngot,100,nc,vl,ierr) write(*,*)'Got ', nc, ' vertices' write(*,*)(vl(i).z,i=1,nc)

call idsget('TRACKS.VERTEX.Z',iv3,1,is,ngot,1000,nc,zl,ierr) write(*,*)'Got ', nc, ' numbers' write(*,*)(zl(i),i=1,nc)

end subroutine gt_show2 * * ******************************************************************** * * * *$$ * subroutine gt_show2 demonstration of idsget function * * * with pointers * * * * * * Ryszard Zybert Dec 2 12:16:22 1993 * * ******************************************************************** * structure /VECT3/ real X real Y real Z end structure structure /POINT/ real X real Y real Z end structure structure /TRACKS/ real Q record/VECT3/ P record/POINT/ VERTEX integer PID integer N_HITS integer FIRST_HIT end structure record/point/ v pointer (p_v,v) record/tracks/ t(1) pointer (p_t,t) real z pointer (p_z,z) save data iv1,iv2,iv3/3*0/

p_t = idsget('TRACKS',iv1,1,is,ngot,0,0,0,ierr) write(*,*)'Got ', ngot, ' tracks' write(*,*)(t(i).vertex.z,i=1,ngot)

p_v = idsget('TRACKS.VERTEX',iv2,1,is,ngot,0,0,0,ierr) write(*,*)'Got ', ngot, ' vertices' do i=1,ngot write(*,*)v.z p_v = p_v + is enddo

p_z = idsget('TRACKS.VERTEX.Z',iv3,1,is,ngot,0,0,0,ierr) write(*,*)'Got ', ngot, ' numbers' do i=1,ngot write(*,*)z p_z = p_z + is enddo

end

c:
int gt_show()
/*
*   ********************************************************************
*   *                                                                  *
*$$ *   int gt_show  demonstration of idsget function                  *
*   *                                                                  *
*   *   Ryszard Zybert    Dec  2 12:12:42 1993                         *
*   ********************************************************************
*/
{
typedef struct VECT3
{
               float X;
               float Y;
               float Z;
};
typedef struct POINT
{
               float X;
               float Y;
               float Z;
};
typedef struct TRACKS
{
               float Q;
               struct VECT3 P;
               struct POINT VERTEX;
               int PID;
               int N_HITS;
               int FIRST_HIT;
};

struct POINT vl[100]; struct TRACKS tl[50]; float zl[1000];

struct POINT *v; struct TRACKS *t; float *z;

static int iv1=0, iv2=0, iv3=0; int ngot,nc,ierr,is,i,nd;

/* using pointers - no copying */

t = (struct TRACKS *)idsget("TRACKS",&iv1,1,&is,&ngot,0,0,0,&ierr); printf("Got %i tracks\n",ngot); for( i=0; i<ngot; i++ ) printf("%f\n",(t++)->VERTEX.Z);

idsget("TRACKS.VERTEX",&iv2,1,&is,&ngot,0,0,0,&ierr); printf("Got %i vertices\n",ngot); for( i=1; i<=ngot; i++) { v=(struct POINT *)idsget("TRACKS.VERTEX",&iv2,i,&is,&nd,0,0,0,&ierr); printf("%f\n",v->Z); }

printf("\n"); nd = 2; i = 0; while( nd>1) { z=(float *)idsget("TRACKS.VERTEX.Z",&iv3,++i,&is,&nd,0,0,0,&ierr); printf("%i %f\n",i,*z); }

/* copying data */

idsget("TRACKS",&iv1,1,&is,&ngot,50,&nc,tl,&ierr); printf("Got %i tracks\n",nc); for( i=0; i<nc; i++ ) printf("%f\n",tl[i].VERTEX.Z);

idsget("TRACKS.VERTEX",&iv2,1,&is,&ngot,100,&nc,vl,&ierr); printf("Got %i vertices\n",nc); for( i=0; i<nc; i++ ) printf("%f\n",vl[i].Z);

idsget("TRACKS.VERTEX.Z",&iv3,1,&is,&ngot,1000,&nc,zl,&ierr); printf("Got %i numbers\n",nc); for( i=0; i<nc; i++ ) printf("%f\n",zl[i]);

return 0; }

wwwd@na49
Fri Nov 4 23:36:02 MET 1994