---------------------------------------------------------------------------- Note below is part of some very old documentation. Everything should be correct except in our case the information file and the data file are the same file. ---------------------------------------------------------------------------- REFERENCE LIST OF USER CALLABLE ROUTINES Name Purpose -------- -------------------------------------------------------- WRTDATD write to info/data files, existing files are appended. REAINFD read from an existing information file with search. READAT read from an existing data file. This must always be preceeded with a call to REAINFD. APPDAT append to info/data file entry in existing file. ERRMES set the logical unit number for messages (default=6). CALLING ROUTINE DECLARATIONS The fortran calling program for these routines should have the following declarations: parameter (n1=?, n2=?, n3=?, n4=?) ! whatever size you need real*4 a(n1,n2,n3,n4), first(4),delta(4) integer*2 ndim(4) character dfile*56,id*8,name*8,units*24,text1*48,text2*48, character dnam(4)*24,duni(4)*24, ifile*56 logical aok where........ Name Type Size Description ---- ---- ---- ---------------------------------------- DFILE C*56 1 data file name ID C*8 1 identification for the data NAME C*8 1 name of the field UNITS C*24 1 units of the field TEXT1 C*48 1 descriptive text: line 1 TEXT2 C*48 1 descriptive text: line 2 DNAM C*24 4 name of each of the four dimensions DUNI C*24 4 units of each of the four dimensions FIRST R*4 4 first grid node value for each dimension DELTA R*4 4 grid node interval for each dimension NDIM I*2 4 number of grid nodes for each dimension BAD.DATA R*4 1 the value for missing data OFFSET I*4 1 the record number preceding the data A R*4 ? data to pass to or receive from data base OK LOG 1 returned .TRUE. if the call was successful DESCRIPTION OF ROUTINES 1. WRITE DATA (new files created, existing ones appended) call wrtdatd (a,n1,n2,n3,n4,i1,i2,j1,j2,k1,k2,l1,l2, ifile,dfile, id,name,units,text1,text2,dnam,duni, bad,first,delta,ndim, aok) a(n1,n2,n3,n4) is the array of data to write n1,n2,n3,n4 the dimensions of array a i1,i2 the 1st dimension elements to write. i1 <= i2 <= n1 Eg. to write elements 1 through 72, set i1,i2=1,72 j1,j2 same as i1,i2 but for the 2nd dimension of a k1,k2 same as i1,i2 but for the 3rd dimension of a l1,l2 same as i1,i2 but for the 4th dimension of a ifile name of the information file to write to dfile name of the data file to write to id,..ndim the information to write aok if aok is returned as true, the data was written ok, if aok is false there was a problem. 2. READ INFORMATION FILE call reainfd (ifile,sid,sname, id,name,units,text1,text2,dnam,duni, bad,first,delta,ndim,aok) ifile the information file name to read from sid the search id (if null no search is done) sname the search name (if null no search is done) id,..ndim the returned information aok if aok is returned true the file was read ok. 3. READ DATA call readat (a,n1,n2,n3,n4,i1,i2,j1,j2,k1,k2,l1,l2,aok) Note: This routine may only be called after a successful call to reainfd (read an information file) ! a(n1,n2,n3,n4) the destination array n1,n2,n3,n4 the dimensions of array a i1,i2 the 1st dimension elements of a to read. Eg. a window of the data may be read by specifying i1 > 1 and/or i2 < ndim(1). j1,j2 same as i1,i2 but for the 2nd dimension of a k1,k2 same as i1,i2 but for the 3rd dimension of a l1,l2 same as i1,i2 but for the 4th dimension of a aok if returned true then the data was read ok. The data is returned in array a. When a window of the data is requested, eg. i1 > 1 and/or i2 < ndim(1), the data is returned in the first i2-i1+1 elements. Eg. if the first dimension of the data has 72 elements, and the request is i1=12, i2=36, then elements 12 through 36 are returned in elements 1 through 25 of a. EXAMPLE APPLICATIONS PROGRAMS An example program is shown below. It reads some specific data from a users data file and puts the data into the data base. It then reads the data from the data base to verify it got there successfully. PROGRAM DEMO C program that creates an information and data file C from some specifc data and then reads the new C data to check the result. PARAMETER (NX=7,NY=10) REAL*4 A(NX,NY), BAD,FIRST(4),DELTA(4) CHARACTER ID*8,NAME*8,UNITS*24,TEXT1*48,TEXT2*48, CHARACTER DNAM(4)*48,DUNI(4)*48, IFILE*56,DFILE*56 INTEGER*2 NDIM(4) LOGICAL AOK C supply the information describing the data DATA IFILE/'TESTDATA.INF '/, DFILE/'TESTDATA.DAT '/, > ID/'ID ONE'/,NAME/'NAME #1'/, FIRST/-180.,23.,2*0./, > DELTA/5.,4.,2*1./,NDIM/7,10,2*1/, BAD/1.E10/ C read my specific data with my subroutine CALL MYDATA (A,NX,NY) C write data using wrtdatd routine CALL WRTDATD > (A,NX,NY,1,1, 1,NX,1,NY,1,1,1,1, IFILE,DFILE,ID,NAME, > UNITS,TEXT1,TEXT2,DNAM,DUNI, BAD,FIRST,DELTA,NDIM,AOK) IF(.NOT.AOK) STOP 'WRTDATD' C zero the data for the read data test below DO 1 J=1,NY DO 1 I=1,NX 1 A(I,J)=0. C specify what data to read IFILE='TESTDATA.INF ' ID=' ' NAME=' ' C read data into array A using reainfd & readat routine CALL REAINFD (IFILE,ID,NAME,ID,NAME,UNITS,TEXT1,TEXT2, > DNAM,DUNI,BAD,FIRST,DELTA,NDIM,AOK) IF(.NOT.AOK) STOP 'REAINFD' CALL READAT > (A,NX,NY,1,1, 1,NX,1,NY,1,1,1,1,AOK) IF(.NOT.AOK) STOP 'READAT' C confirm that data is correct WRITE(5,'(7F5.1)') ((A(I,J),I=1,NX),J=1,NY) END C - - - - - - - - - - - - - - - C SUBROUTINE MYDATA (A,NX,NY) C example routine to read some data REAL*4 A(NX,NY) OPEN(UNIT=1,NAME='TESTDATA.TST',STATUS='OLD',READONLY) READ(1,*) ((A(I,J),I=1,NX),J=1,NY) CLOSE(UNIT=1) RETURN END