Encyclopaedia Index


PHI file, PHIDA file

PHI or PHIDA files are those on to which EARTH 'dumps' the values of the solved-for and stored field variables at the end of a run, for use in re-starts and Post-processor displays. PHI files are sequential formatted, PHIDA files are unformatted, direct access. The choice between them is made by the setting PHIDA=F or T in the PREFIX file. In the VR Editor, the setting is made from 'Options, File format'.

The direct-access files are quickest to write and read. They are usually smaller, but they are not compatible across machines running different operating systems (e.g. Windows and Unix).

By default, the sequential file has the name PHI, the direct-access file PHIDA. If, however, the Q1 file contains the line:

NSAVE=wxyz

where these letters stand for any character string up to 40 characters long, the PHI-file has the latter name.

PHI-file format

The content of formatted sequential files saved and read by EARTH is as follows:

The "header"

The first ten lines of this file contain "header" information, namely:-


    line 1: contents of TEXT, version information. (format 1X,A40, A25))
    line 2: CARTES, ONEPHS, BFC, XCYCLE, CCM, LCMPRS ( ie. 6 logicals ). (format 1X,6L1)
    line 3: NX,NY,NZ,NPHI,DEN1,DEN2,EPOR,NPOR,HPOR,VPOR,LENREC,NUMBLK,
          NMATST,NFMAK1 ( ie. 14 integers ). (format 1X, 7I10)
    line 4: RINNER,FLOAT(NPRPHI),RNFPWV,FLOAT(NFMAK2),RDMAT1,TIM,DT,FLOAT(ISWEEP),FLOAT(ISTEP) (i.e. 9 reals) (format 1X, 9(1PE13.6))
    line 5: (NAME(I),I=1,NPHI) (format 1X, 19A4).
    line 6: x locations of east cell faces ( ie. NX reals, 1X,format 6(1PE13.6) ).
    line : y locations of north cell faces ( ie. NY reals , 1X, format 6(1PE13.6)).
    line : z locations of high cell faces ( ie. NZ reals, 1X, format 6(1PE13.6) ).
    line 9: mean pressure corrections at each slab ( ie. NZ reals, format 1X, 6(1PE13.6) ).
    line 10: (STORE(I),I=1,NPHI) ( ie. NPHI logicals indicating which
          of the NPHI possible ones are stored in the file, format 1X, 79L1).

The "fields"

The above header is followed by the storage of the fields at each slab in the order P1, P2, U1,....C35. There are NX*NY values of each variable at each slab. Each slabs-worth of variable is written with the format (format 1X, 6(1PE13.6)).

An extract of Fortran code to read the fields section might look like:


       DO IZ=1,NZ
         DO IPHI=1,M
           READ(LU,'(1X,6(1PE13.6))') ((PHI(IPHI,IX,IY,IZ),IY=1,NY),IX=1,NX)
         ENDDO
       ENDDO    

where M is the total number of STOREd variables.

Note that if more values are written than the formt allows for, each logical line will be written as several physical lines in the file.

Other Data

After the field values come a number of further lines which are not needed for post-processing. These are:


    next line: if PRPS is stored, the values of the properties read from the PRPS file (format (1X,6(1PE13.6))
    next line: three integers (format (1X,3I10)), being: 
               the number of patchwise variables NFPWVT, 
               the number of F array elements allocated directly by the user via NFUSER, and 
               number of F-array elements allocated using GXMAKE, NFGMAK.
    next line: NFPWVT reals, written with format (1X,6(1PE13.6))
    next line: NFUSER reals, written with format (1X,6(1PE13.6))
    next line: NFGMAK reals, written with format (1X,6(1PE13.6))

It is not possible to recreate any of these fields outside Earth. If a PHI file is being generated 'artificially', they can be omitted. To prevent Earth trying to read them, the 3rd real on line 4 (RNFPWV) should be set to any negative value.

If MOFOR is active, there follow a series of lines which contain the transformation matrices needed to move the moving objects to their correct positions. This sequence of lines starts with a header line:


    MOFOR      NREFF  (format (A8,I6))

where NREFF is the number of frames of reference to write. Following this, there will be NREFF sets of lines:


    Frame_name (format (A))
    16 reals (format (1X,6(1PE13.6))

where Frame_name is the name of the moving object. The frame names are also echoed near the top of the RESULT file.

If the file is being read for post-processing, then once the field values have been read, the rest of the file can be read as character strings until the 'MOFOR' header is detected, or the end of file is reached.

PHIDA-file format

The content of unformatted direct access files saved and read by EARTH is as follows:

The "header"

The first ten records of this file contain "header" information, namely:-


    rec1: contents of TEXT and version information ( ie. character*40 run title and 
    character*25 version information).
    rec2: CARTES, ONEPHS, BFC, XCYCLE, CCM, LCMPRS ( ie. 6 logicals ).
    rec3: NX,NY,NZ,NPHI,DEN1,DEN2,EPOR,NPOR,HPOR,VPOR,LENREC,NUMBLK,
          NMATST,NFMAK1 ( ie. 14 integers ).
    rec4: RINNER,FLOAT(NPRPHI),RNFPWV,FLOAT(NFMAK2),RDMAT1,
     1                FLOAT(IDMAT2),TIM,DT,FLOAT(ISWEEP),FLOAT(ISTEP)  ( ie. 10 reals ).
    rec5: (NAME(I),I=1,NPHI) ( ie. NPHI names, each character*4 ).
    rec6: x locations of east cell faces ( ie. NX reals ).
    rec7: y locations of north cell faces ( ie. NY reals ).
    rec8: z locations of high cell faces ( ie. NZ reals ).
    rec9: mean pressure corrections at each slab ( ie. NZ reals ).
    rec10: (STORE(I),I=1,NPHI) ( ie. NPHI logicals indicating which
          of the NPHI possible ones are stored in the file ).

The "fields"

The above header is followed by the storage of the fields at each slab in the order P1, P2, U1,....C35. There are NX*NY values of each variable at each slab; since LENREC signifies the number of words per record, the number of records ,NREC , needed to store NX*NY values is given by the Fortran formula,

NREC=NX*NY/LENREC
IF(MOD(NX*NY,NREC).NE.0) NREC=NREC+1 .

It should be noted that records 5 to 10 may also be 'folded', according to the above formula, with use of NPHI, NX ,NY, NZ, NZ and NPHI respectively in place of NX*NY. The default setting of LENREC is 256.

LENREC

The LENREC parameter is normally set at installation time in the CONFIGuration file. If LENREC=50, and NX*NY=60, and the variables stored are P1, U1, W1 and C1, the storage in the file will be as follows:


    record 11 ( IZ=1 ): 50 values of P1
    record 12 ( IZ=1 ): 10 values of P1
    record 13 ( IZ=1 ): 50 values of U1
    record 14 ( IZ=1 ): 10 values of U1
    record 15 ( IZ=1 ): 50 values of W1
    record 16 ( IZ=1 ): 10 values of W1
    record 17 ( IZ=1 ): 50 values of C1
    record 18 ( IZ=1 ): 10 values of C1
    
    record 19 ( IZ=2 ): 50 values of P1
    record 20 ( IZ=2 ): 10 values of P1
    record 21 ( IZ=2 ): 50 values of U1
    record 22 ( IZ=2 ): 10 values of U1
    .

    .
    .
    etc.

In total there are 10 + NREC*M*NZ records on the file, where M denotes the number of field variables stored.

Other Data

Following the fields is the same data as in the PHI file, as described above. In this case, the records are 'folded' using the number of variables written. To read the file for post-processing, the records between the field values and the MOFOR section can be read as a character*80 string until the MOFOR header is found or end of file is reached.


wbs