Page 1 of 1

Post-Processing

Posted: Thu May 05, 2011 1:18 am -1100
by manexi
Hello.

I've been wondering if there is a possibility to transfer ALL the output data into an Excel/Text file otherwise than having to "create" a curve under WUFIGraph and export it in txt format.

The problem being that WUFIGraph becomes VERY slow after some curves which each take time to calculate... If I could just select the data but avoid the graph creation that would accelerate post-processing analysis.

I tried to read the wfd directly, but it's coded in an unknown format (or so it seems).

Any ideas on this?

Thank you!
Manexi

Posted: Thu May 05, 2011 4:04 am -1100
by veitner
There is no easy way but I could send you some source-code to read the result file - in fortran, java or object-pascal.

Posted: Thu May 05, 2011 4:46 am -1100
by manexi
That would be great!

If I'm able to read it, I might be able to extract exaclty what I need. Either java or FORTRAN (or both) would be great.

Thank you!
Manexi

wufi2dfile.f90

Posted: Thu May 05, 2011 4:59 am -1100
by veitner
!
! File: wufi2dfile.f90
!
! Created on September 21, 2006, 1:41 PM
!

MODULE WUFI2DFILE
implicit none
INTEGER,PARAMETER :: NDATA=8
TYPE HEADER
INTEGER(2) :: BYTEORDER1
INTEGER(2) :: BYTEORDER2
INTEGER(1) :: L
CHARACTER(9) :: INFO
INTEGER(2) :: VERSION
INTEGER(4) :: GIPOS,OPTPOS,RGBPOS,CIPOS,GRIDPOS,DATAPOS
INTEGER :: NCTS
END TYPE HEADER
! TYPE GENERALINFO
!.....RESERVED FOR FURTHER USE
! END TYPE GENERALINFO
TYPE MINMAX
REAL(4) MIN, MAX
END TYPE MINMAX

TYPE OPTION
TYPE (MINMAX) UB(NDATA)
END TYPE OPTION
TYPE TRGB
INTEGER(1), DIMENSION(16) :: R,G,B
END TYPE TRGB
TYPE CALCINFO_BOOL
LOGICAL(1) HEAT,CAP,HEATOFVAP,HEATOFFUS,EXACT,CONV,LIST,HMEAN,CORR
END TYPE CALCINFO_BOOL
TYPE CALCINFO
TYPE (CALCINFO_BOOL) BOOL
END TYPE CALCINFO



TYPE TAB
REAL(4) :: X,Y
END TYPE TAB

TYPE TABD
REAL(4) :: X,Y,DY
END TYPE TABD

TYPE TCOLOR
INTEGER(2) :: R,G,B
END TYPE TCOLOR
TYPE MATERIAL
CHARACTER(50) :: QBMAT
LOGICAL :: LADIAB
TYPE(TCOLOR) :: COLOR
INTEGER(2) :: NLMBX,NLMBY,NMYX,NMYY, &
&NFKSX,NFKSY,NFKRX,NFKRY,NSOR
REAL(4) :: RHO,CAP,DLAMX,DLAMY,ZULAM,TETAI, &
&POR,RHI,WF,W95,WMAX
REAL :: GAMMAX,GAMMAY
TYPE(TAB),DIMENSION(:),ALLOCATABLE :: BLTABX,BLTABY,BMYTABX,BMYTABY, &
&FKTABSX,FKTABSY,FKTABRX,FKTABRY
TYPE(TABD),DIMENSION(:),ALLOCATABLE :: SORTAB
LOGICAL :: LLMAUTO,LSOR,NOFI,NOTRANS,LWCINI
CHARACTER(90) :: FVNAME
!fixed values
REAL(4) :: FVRH,FVTETA
END TYPE MATERIAL



CONTAINS

SUBROUTINE HEADOUT(OBIN,FBPOS,MIMAPOS,NCTSPOS,HEAD,DATAOUT,STARTDATE,MIMA,X,Y,NI,NJ,nks,materials,matcls)

INTEGER,INTENT(INOUT) :: FBPOS,MIMAPOS,NCTSPOS
INTEGER, INTENT(IN) :: OBIN,ni,nj,nks
TYPE(HEADER), INTENT(INOUT) :: HEAD
LOGICAL(2),DIMENSION(NDATA),INTENT(IN) :: DATAOUT
TYPE(MINMAX),DIMENSION(NDATA),INTENT(IN) :: MIMA
CHARACTER(16),INTENT(IN) :: STARTDATE
REAL,DIMENSION(NI),INTENT(IN) :: x
REAL,DIMENSION(NJ),INTENT(IN) :: y
INTEGER,DIMENSION(ni*nj),INTENT(IN) :: MATCLS
TYPE(MATERIAL),DIMENSION(:),INTENT(IN) :: MATERIALS

INTEGER(4) NXX,NYY
REAL(4), DIMENSION(:),ALLOCATABLE:: XX
REAL(4), DIMENSION(:),ALLOCATABLE:: YY
INTEGER :: NIJ


TYPE (OPTION) :: OPT
TYPE (TRGB) :: RGB
TYPE (CALCINFO) ::CI

INTEGER :: I,J
INTEGER(1) :: L=16
!needed for paralellisation
INTEGER(2),DIMENSION(:),ALLOCATABLE :: tmp
!
NIJ = NI*NJ
ALLOCATE(XX(NI))
ALLOCATE(YY(NJ))
ALLOCATE(tmp(NIJ))
HEAD%L=9
HEAD%INFO='$w2dflow$'
HEAD%VERSION=4
HEAD%BYTEORDER1=65226
HEAD%BYTEORDER2=48875
CI%BOOL%HEAT=.TRUE.
CI%BOOL%CAP=.FALSE.
CI%BOOL%HEATOFVAP=.TRUE.
! HEAD%GIPOS=SIZEOF(HEAD)
HEAD%OPTPOS=SIZEOF(HEAD)
HEAD%RGBPOS=HEAD%OPTPOS+SIZEOF(OPT)
HEAD%CIPOS=HEAD%RGBPOS+SIZEOF(RGB)
HEAD%GRIDPOS=HEAD%CIPOS+SIZEOF(CI)
! HEAD%DATAPOS=HEAD%GRIDPOS+SIZEOF(GD)+2*NI*NJ+
! * NKS*SIZEOF(MAT(1)) !UNABLE TO CALCULATE IT THE
! WRITE IT AGAIN AT THE END OF THIS PROCEDURE
NCTSPOS=1+SIZEOF(HEAD)-SIZEOF(HEAD%NCTS)
FBPOS=1
WRITE(OBIN,POS=FBPOS) HEAD
FBPOS=FBPOS+SIZEOF(HEAD)
WRITE(OBIN,POS=FBPOS) OPT
FBPOS=FBPOS+SIZEOF(OPT)
WRITE(OBIN,POS=FBPOS) L
FBPOS=FBPOS+SIZEOF(L)
WRITE(OBIN,POS=FBPOS) STARTDATE
FBPOS=FBPOS+SIZEOF(STARTDATE)
WRITE(OBIN,POS=FBPOS) (DATAOUT(I), I=1,NDATA)
FBPOS=FBPOS+SIZEOF(DATAOUT(1))*NDATA
WRITE(OBIN,POS=FBPOS) CI%BOOL
FBPOS=FBPOS+SIZEOF(CI%BOOL)
MIMAPOS=FBPOS
WRITE(OBIN,POS=FBPOS) MIMA
FBPOS=FBPOS+SIZEOF(MIMA)
NXX=NI
NYY=NJ
XX(1:NI)=X(1:NI)
YY(1:NJ)=Y(1:NJ)
WRITE(OBIN,POS=FBPOS) NXX,NYY,XX(1:NI),YY(1:NJ)
FBPOS=FBPOS+SIZEOF(NXX)+SIZEOF(NYY) &
& +SIZEOF(XX(1))*NI+SIZEOF(YY(1))*NJ
!.....MATERIALCLASSIFICATION
WRITE(OBIN,POS=FBPOS) NKS
FBPOS=FBPOS+SIZEOF(NKS)
! WRITE(OBIN,POS=FBPOS) ((MATCLS(I,J),J=1,NJ),I=1,NI)
tmp(1:NIJ) = MATCLS(1:NIJ)
WRITE(OBIN,POS=FBPOS) tmp(1:NIJ)!MATCLS(1:NIJ)
FBPOS=FBPOS+SIZEOF(tmp(1))*NI*NJ!SIZEOF(MATCLS(1))*NI*NJ
CALL PRINT_MATERIALS(OBIN,FBPOS,MATERIALS)
!ZERO BASED!!!
HEAD%DATAPOS=FBPOS-1
WRITE(OBIN,POS=1) HEAD
DEALLOCATE(XX)
DEALLOCATE(YY)
DEALLOCATE(tmp)
RETURN
END SUBROUTINE HEADOUT

SUBROUTINE PRINT_MATERIALS(OBIN,FBPOS,MATERIALS)
INTEGER, INTENT(IN) :: OBIN
INTEGER,INTENT(INOUT) :: FBPOS
TYPE(MATERIAL),DIMENSION(:),INTENT(IN) :: MATERIALS
INTEGER :: N,K,tt
TYPE(TAB) :: mt2
TYPE(TABD) :: mt3
INTEGER :: tab2s
INTEGER :: tab3s
TYPE(MATERIAL) :: M
!for g95
tab2s=sizeof(mt2)
tab3s=sizeof(mt3)

DO K=1,SIZE(MATERIALS)
M = MATERIALS(K)
WRITE(OBIN,POS=FBPOS) M%QBMAT
FBPOS=FBPOS+SIZEOF(M%QBMAT)
!
WRITE(OBIN,POS=FBPOS) M%COLOR
FBPOS=FBPOS+SIZEOF(M%COLOR)
!
WRITE(OBIN,POS=FBPOS) M%NLMBX
FBPOS=FBPOS+SIZEOF(M%NLMBX)
WRITE(OBIN,POS=FBPOS) M%NLMBY
FBPOS=FBPOS+SIZEOF(M%NLMBY)
WRITE(OBIN,POS=FBPOS) M%NMYX
FBPOS=FBPOS+SIZEOF(M%NMYX)
WRITE(OBIN,POS=FBPOS) M%NMYY
FBPOS=FBPOS+SIZEOF(M%NMYY)
WRITE(OBIN,POS=FBPOS) M%NFKSX
FBPOS=FBPOS+SIZEOF(M%NFKSX)
WRITE(OBIN,POS=FBPOS) M%NFKSY
FBPOS=FBPOS+SIZEOF(M%NFKSY)
WRITE(OBIN,POS=FBPOS) M%NFKRX
FBPOS=FBPOS+SIZEOF(M%NFKRX)
WRITE(OBIN,POS=FBPOS) M%NFKRY
FBPOS=FBPOS+SIZEOF(M%NFKRY)
WRITE(OBIN,POS=FBPOS) M%NSOR
FBPOS=FBPOS+SIZEOF(M%NSOR)
!
WRITE(OBIN,POS=FBPOS) M%RHO
FBPOS=FBPOS+SIZEOF(M%RHO)
WRITE(OBIN,POS=FBPOS) M%W95
FBPOS=FBPOS+SIZEOF(M%W95)
WRITE(OBIN,POS=FBPOS) M%CAP
FBPOS=FBPOS+SIZEOF(M%CAP)
WRITE(OBIN,POS=FBPOS) M%DLAMX
FBPOS=FBPOS+SIZEOF(M%DLAMX)
WRITE(OBIN,POS=FBPOS) M%DLAMY
FBPOS=FBPOS+SIZEOF(M%DLAMY)
WRITE(OBIN,POS=FBPOS) M%ZULAM
FBPOS=FBPOS+SIZEOF(M%ZULAM)
WRITE(OBIN,POS=FBPOS) M%POR
FBPOS=FBPOS+SIZEOF(M%POR)
WRITE(OBIN,POS=FBPOS) M%WF
FBPOS=FBPOS+SIZEOF(M%WF)
WRITE(OBIN,POS=FBPOS) M%WMAX
FBPOS=FBPOS+SIZEOF(M%WMAX)
WRITE(OBIN,POS=FBPOS) M%TETAI
FBPOS=FBPOS+SIZEOF(M%TETAI)
WRITE(OBIN,POS=FBPOS) M%RHI
FBPOS=FBPOS+SIZEOF(M%RHI)
!
WRITE(OBIN,POS=FBPOS) (M%BLTABX(N),N=1,M%NLMBX)
FBPOS=FBPOS+M%NLMBX*tab2s
WRITE(OBIN,POS=FBPOS) (M%BLTABY(N),N=1,M%NLMBY)
FBPOS=FBPOS+M%NLMBY*tab2s
WRITE(OBIN,POS=FBPOS) (M%BMYTABX(N),N=1,M%NMYX)
FBPOS=FBPOS+M%NMYX*tab2s
WRITE(OBIN,POS=FBPOS) (M%BMYTABY(N),N=1,M%NMYY)
FBPOS=FBPOS+M%NMYY*tab2s
WRITE(OBIN,POS=FBPOS) (M%FKTABSX(N),N=1,M%NFKSX)
FBPOS=FBPOS+M%NFKSX*tab2s
WRITE(OBIN,POS=FBPOS) (M%FKTABSY(N),N=1,M%NFKSY)
FBPOS=FBPOS+M%NFKSY*tab2s
WRITE(OBIN,POS=FBPOS) (M%FKTABRX(N),N=1,M%NFKRX)
FBPOS=FBPOS+M%NFKRX*tab2s
WRITE(OBIN,POS=FBPOS) (M%FKTABRY(N),N=1,M%NFKRY)
FBPOS=FBPOS+M%NFKRY*tab2s
WRITE(OBIN,POS=FBPOS) (M%SORTAB(N),N=1,M%NSOR)
FBPOS=FBPOS+M%NSOR*tab3s
END DO
END SUBROUTINE PRINT_MATERIALS

SUBROUTINE PRINTVEC(OBIN,FBPOS,DATAOUT,v11,v12,v21,v22,v31,v32,v41,v42,MIMA,NI,NJ)
INTEGER,INTENT(INOUT) :: FBPOS
INTEGER,INTENT(IN) :: OBIN,NI,NJ
LOGICAL(2),DIMENSION(NDATA),INTENT(IN) :: DATAOUT
REAL,DIMENSION(ni*nj) :: v11,v12,v21,v22,v31,v32,v41,v42
TYPE(MINMAX), DIMENSION(NDATA),INTENT(INOUT) :: MIMA
!
INTEGER I,J,ID,II,IJ,VECSIZE
REAL(4), DIMENSION(:,:),ALLOCATABLE :: AMO,FI
REAL(4) :: SX,SY
REAL(4) :: PI18,MIN,MAX

!
DATA PI18/57.2957795131/
!
ALLOCATE(AMO(NJ,NI))
ALLOCATE(FI(NJ,NI))

VECSIZE=SIZEOF(AMO(1,1))*NI*NJ
DO 100 ID=5,8
IF (.NOT.DATAOUT(ID)) GOTO 100
!PRINT FLUK
IF (ID.EQ.5) THEN
AMO = RESHAPE(v11,(/NJ,NI/))
FI = RESHAPE(v12,(/NJ,NI/))
!PRINT FLUD
ELSE IF (ID.EQ.6) THEN
AMO = RESHAPE(v21,(/NJ,NI/))
FI = RESHAPE(v22,(/NJ,NI/))
!PRINT FLUT
ELSE IF (ID.EQ.7) THEN
AMO = RESHAPE(v31,(/NJ,NI/))
FI = RESHAPE(v32,(/NJ,NI/))
!PRINT VXY
ELSE IF (ID.EQ.8) THEN
AMO = RESHAPE(v41,(/NJ,NI/))
FI = RESHAPE(v42,(/NJ,NI/))
END IF
MIN=MINVAL(AMO(2:NJ-1,2:NI-1))
IF (MIN.LT.MIMA(ID)%MIN) MIMA(ID)%MIN=MIN
MAX=MAXVAL(AMO(2:NJ-1,2:NI-1))
IF (MAX.GT.MIMA(ID)%MAX) MIMA(ID)%MAX=MAX
WRITE(OBIN,POS=FBPOS) ((AMO(J,I),J=1,NJ),I=1,NI)
FBPOS=FBPOS+VECSIZE
WRITE(OBIN,POS=FBPOS) ((FI(J,I),J=1,NJ),I=1,NI)
FBPOS=FBPOS+VECSIZE
100 END DO
DEALLOCATE(AMO)
DEALLOCATE(FI)
RETURN
END SUBROUTINE PRINTVEC

SUBROUTINE PRINTSCA(OBIN,FBPOS,DATAOUT,RH,WC,TETA,PD,MIMA,NI,NJ)
!
INTEGER,INTENT(INOUT) :: FBPOS
INTEGER,INTENT(IN) :: OBIN,NI,NJ
LOGICAL(2),DIMENSION(NDATA),INTENT(IN) :: DATAOUT
REAL,DIMENSION(ni*nj) :: rh,wc,teta,pd
TYPE(MINMAX), DIMENSION(NDATA),INTENT(INOUT) :: MIMA

INTEGER I,J,ID,SCSIZE
REAL(4), DIMENSION(:,:),ALLOCATABLE :: FI
REAL(4) MIN, MAX
!
ALLOCATE(FI(NJ,NI))
SCSIZE=SIZEOF(FI(1,1))*NI*NJ
DO 10 ID=1,4
IF (.NOT.DATAOUT(ID)) GOTO 10
!PRINT WC
IF (ID.EQ.1) THEN
FI=RESHAPE(WC,(/NJ,NI/))
!PRINT RH
ELSE IF (ID.EQ.2) THEN
FI=RESHAPE(RH,(/NJ,NI/))
!PRINT TETA
ELSE IF (ID.EQ.3) THEN
FI=RESHAPE(TETA,(/NJ,NI/))
!PRINT PD
ELSE IF (ID.EQ.4) THEN
FI=RESHAPE(PD,(/NJ,NI/))
END IF
MIN=MINVAL(FI(1:NJ,1:NI))
IF (MIN.LT.MIMA(ID)%MIN) MIMA(ID)%MIN=MIN
MAX=MAXVAL(FI(1:NJ,1:NI))
IF (MAX.GT.MIMA(ID)%MAX) MIMA(ID)%MAX=MAX
WRITE(OBIN,POS=FBPOS) ((FI(J,I),J=1,NJ),I=1,NI)
FBPOS=FBPOS+SCSIZE
10 END DO
DEALLOCATE(FI)
RETURN
END SUBROUTINE PRINTSCA

SUBROUTINE PRINTBIN(OBIN,FBPOS,MIMAPOS,NCTSPOS,TIME,DATAOUT,RH,WC,TETA,PD,v11,v12,v21,v22,v31,v32,v41,v42,MIMA,NI,NJ,NT)
INTEGER,INTENT(INOUT) :: FBPOS,MIMAPOS,NCTSPOS
INTEGER,INTENT(IN) :: OBIN,NI,NJ,NT
LOGICAL(2),DIMENSION(NDATA),INTENT(IN) :: DATAOUT
REAL,DIMENSION(ni*nj) :: RH,WC,TETA,PD,v11,v12,v21,v22,v31,v32,v41,v42
REAL(8),INTENT(IN) :: TIME
TYPE(MINMAX),DIMENSION(NDATA),INTENT(INOUT) :: MIMA

WRITE(OBIN,POS=FBPOS) TIME
FBPOS=FBPOS+SIZEOF(TIME)
CALL PRINTSCA(OBIN,FBPOS,DATAOUT,RH,WC,TETA,PD,MIMA,NI,NJ)
CALL PRINTVEC(OBIN,FBPOS,DATAOUT,v11,v12,v21,v22,v31,v32,v41,v42,MIMA,NI,NJ)
WRITE(OBIN,POS=MIMAPOS) MIMA
WRITE(OBIN,POS=NCTSPOS) NT
RETURN
END SUBROUTINE PRINTBIN

!--------------------------------------------------------------------------------------
! READ
!--------------------------------------------------------------------------------------

SUBROUTINE HEADIN(OBIN,HEAD,DATAOUT,STARTDATE,MIMA,X,Y,NI,NJ,nks,materials,matcls,FBPOS)

INTEGER,INTENT(INOUT) :: ni,nj,nks,FBPOS
INTEGER, INTENT(IN) :: OBIN
TYPE(HEADER), INTENT(INOUT) :: HEAD
LOGICAL(2),DIMENSION(NDATA),INTENT(INOUT) :: DATAOUT
TYPE(MINMAX),DIMENSION(NDATA),INTENT(INOUT) :: MIMA
CHARACTER(16),INTENT(INOUT) :: STARTDATE
REAL,DIMENSION(:),ALLOCATABLE,INTENT(INOUT) :: x
REAL,DIMENSION(:),ALLOCATABLE,INTENT(INOUT) :: y
INTEGER,DIMENSION(:),ALLOCATABLE,INTENT(INOUT) :: MATCLS
TYPE(MATERIAL),DIMENSION(:),ALLOCATABLE,INTENT(INOUT) :: MATERIALS

INTEGER(4) NXX,NYY
REAL(4), DIMENSION(:),ALLOCATABLE:: XX
REAL(4), DIMENSION(:),ALLOCATABLE:: YY
INTEGER :: NIJ


TYPE (OPTION) :: OPT
TYPE (TRGB) :: RGB
TYPE (CALCINFO) ::CI

INTEGER :: I,J
INTEGER(1) :: L=16
!needed for paralellisation
INTEGER(2),DIMENSION(:),ALLOCATABLE :: tmp
!


READ(OBIN) HEAD
READ(OBIN) OPT
READ(OBIN) L
READ(OBIN) STARTDATE
READ(OBIN) DATAOUT
READ(OBIN) CI%BOOL
READ(OBIN) MIMA

READ(OBIN) NXX,NYY
NI=NXX
NJ=NYY
NIJ = NI*NJ
ALLOCATE(XX(NI))
ALLOCATE(YY(NJ))
ALLOCATE(tmp(NIJ))

READ(OBIN) XX(1:NI),YY(1:NJ)

allocate(x(ni))
allocate(y(nj))
x(1:NI)=XX(1:NI)
y(1:NJ)=YY(1:NJ)
READ(OBIN) NKS


READ(OBIN) tmp(1:NIJ)!MATCLS(1:NIJ)
allocate(matcls(nij))
MATCLS = tmp

allocate(MATERIALS(NKS))
CALL READ_MATERIALS(OBIN,NKS,MATERIALS,FBPOS)

DEALLOCATE(XX)
DEALLOCATE(YY)
DEALLOCATE(tmp)
RETURN
END SUBROUTINE HEADIN

SUBROUTINE READ_MATERIALS(OBIN,NKS,MATERIALS,FBPOS)
INTEGER, INTENT(IN) :: OBIN,NKS
TYPE(MATERIAL),DIMENSION(:),INTENT(INOUT) :: MATERIALS
INTEGER, INTENT(INOUT) :: FBPOS
INTEGER :: N,K,tt
TYPE(TAB) :: mt2
TYPE(TABD) :: mt3
INTEGER :: tab2s
INTEGER :: tab3s
TYPE(MATERIAL) :: M
!for g95
tab2s=sizeof(mt2)
tab3s=sizeof(mt3)

DO K=1,NKS

READ(OBIN) MATERIALS(K)%QBMAT
READ(OBIN) MATERIALS(K)%COLOR

READ(OBIN) MATERIALS(K)%NLMBX
READ(OBIN) MATERIALS(K)%NLMBY
READ(OBIN) MATERIALS(K)%NMYX
READ(OBIN) MATERIALS(K)%NMYY
READ(OBIN) MATERIALS(K)%NFKSX
READ(OBIN) MATERIALS(K)%NFKSY
READ(OBIN) MATERIALS(K)%NFKRX
READ(OBIN) MATERIALS(K)%NFKRY
READ(OBIN) MATERIALS(K)%NSOR
!
READ(OBIN) MATERIALS(K)%RHO
READ(OBIN) MATERIALS(K)%W95
READ(OBIN) MATERIALS(K)%CAP
READ(OBIN) MATERIALS(K)%DLAMX
READ(OBIN) MATERIALS(K)%DLAMY
READ(OBIN) MATERIALS(K)%ZULAM
READ(OBIN) MATERIALS(K)%POR
READ(OBIN) MATERIALS(K)%WF
READ(OBIN) MATERIALS(K)%WMAX
READ(OBIN) MATERIALS(K)%TETAI
READ(OBIN) MATERIALS(K)%RHI
!
allocate(MATERIALS(K)%BLTABX(MATERIALS(K)%NLMBX))
allocate(MATERIALS(K)%BLTABY(MATERIALS(K)%NLMBY))
allocate(MATERIALS(K)%BMYTABX(MATERIALS(K)%NMYX))
allocate(MATERIALS(K)%BMYTABY(MATERIALS(K)%NMYY))
allocate(MATERIALS(K)%FKTABSX(MATERIALS(K)%NFKSX))
allocate(MATERIALS(K)%FKTABSY(MATERIALS(K)%NFKSY))
allocate(MATERIALS(K)%FKTABRX(MATERIALS(K)%NFKRX))
allocate(MATERIALS(K)%FKTABRY(MATERIALS(K)%NFKRY))
allocate(MATERIALS(K)%SORTAB(MATERIALS(K)%NSOR))

READ(OBIN) (MATERIALS(K)%BLTABX(N),N=1,MATERIALS(K)%NLMBX)
READ(OBIN) (MATERIALS(K)%BLTABY(N),N=1,MATERIALS(K)%NLMBY)
READ(OBIN) (MATERIALS(K)%BMYTABX(N),N=1,MATERIALS(K)%NMYX)
READ(OBIN) (MATERIALS(K)%BMYTABY(N),N=1,MATERIALS(K)%NMYY)
READ(OBIN) (MATERIALS(K)%FKTABSX(N),N=1,MATERIALS(K)%NFKSX)
READ(OBIN) (MATERIALS(K)%FKTABSY(N),N=1,MATERIALS(K)%NFKSY)
READ(OBIN) (MATERIALS(K)%FKTABRX(N),N=1,MATERIALS(K)%NFKRX)
READ(OBIN) (MATERIALS(K)%FKTABRY(N),N=1,MATERIALS(K)%NFKRY)
READ(OBIN) (MATERIALS(K)%SORTAB(N),N=1,MATERIALS(K)%NSOR)
END DO
END SUBROUTINE READ_MATERIALS

SUBROUTINE READSCA(OBIN,DATAOUT,RH,WC,TETA,PD,NI,NJ,FBPOS)
INTEGER, INTENT(INOUT) :: FBPOS
INTEGER,INTENT(IN) :: OBIN,NI,NJ
LOGICAL(2),DIMENSION(NDATA),INTENT(IN) :: DATAOUT
REAL,DIMENSION(ni*nj),INTENT(INOUT) :: rh,wc,teta,pd

INTEGER I,J,ID,SCSIZE
REAL(4), DIMENSION(:,:),ALLOCATABLE :: FI
!
ALLOCATE(FI(NJ,NI))
SCSIZE=SIZEOF(FI(1,1))*NI*NJ
DO 10 ID=1,4
IF (.NOT.DATAOUT(ID)) GOTO 10
READ(OBIN) ((FI(J,I),J=1,NJ),I=1,NI)
!PRINT WC
IF (ID.EQ.1) THEN
WC=RESHAPE(FI,(/NJ*NI/))
!PRINT RH
ELSE IF (ID.EQ.2) THEN
RH=RESHAPE(FI,(/NJ*NI/))
!PRINT TETA
ELSE IF (ID.EQ.3) THEN
TETA=RESHAPE(FI,(/NJ*NI/))
!PRINT PD
ELSE IF (ID.EQ.4) THEN
PD=RESHAPE(FI,(/NJ*NI/))
END IF
10 END DO
DEALLOCATE(FI)
RETURN
END SUBROUTINE READSCA

SUBROUTINE READVEC(OBIN,DATAOUT,v11,v12,v21,v22,v31,v32,v41,v42,NI,NJ,FBPOS)
INTEGER, INTENT(INOUT) :: FBPOS
INTEGER,INTENT(IN) :: OBIN,NI,NJ
LOGICAL(2),DIMENSION(NDATA),INTENT(IN) :: DATAOUT
REAL,DIMENSION(ni*nj) :: v11,v12,v21,v22,v31,v32,v41,v42
!
INTEGER I,J,ID,II,IJ,VECSIZE
REAL(4), DIMENSION(:,:),ALLOCATABLE :: AMO,FI
REAL(4) :: SX,SY
REAL(4) :: PI18,MIN,MAX

!
DATA PI18/57.2957795131/
!
ALLOCATE(AMO(NJ,NI))
ALLOCATE(FI(NJ,NI))

VECSIZE=SIZEOF(AMO(1,1))*NI*NJ
DO 100 ID=5,8
IF (.NOT.DATAOUT(ID)) GOTO 100
READ(OBIN) ((AMO(J,I),J=1,NJ),I=1,NI)
READ(OBIN) ((FI(J,I),J=1,NJ),I=1,NI)
!PRINT FLUK
IF (ID.EQ.5) THEN
v11 = RESHAPE(AMO,(/NJ*NI/))
v12 = RESHAPE(FI,(/NJ*NI/))
!PRINT FLUD
ELSE IF (ID.EQ.6) THEN
v21 = RESHAPE(AMO,(/NJ*NI/))
v22 = RESHAPE(FI,(/NJ*NI/))
!PRINT FLUT
ELSE IF (ID.EQ.7) THEN
v31 = RESHAPE(AMO,(/NJ*NI/))
v32 = RESHAPE(FI,(/NJ*NI/))
!PRINT VXY
ELSE IF (ID.EQ.8) THEN
v41 = RESHAPE(AMO,(/NJ*NI/))
v42 = RESHAPE(FI,(/NJ*NI/))
END IF

100 END DO
DEALLOCATE(AMO)
DEALLOCATE(FI)
RETURN
END SUBROUTINE READVEC

SUBROUTINE READBIN(OBIN,TIME,DATAOUT,RH,WC,TETA,PD,v11,v12,v21,v22,v31,v32,v41,v42,NI,NJ,FBPOS)
INTEGER,INTENT(IN) :: OBIN,NI,NJ
LOGICAL(2),DIMENSION(NDATA),INTENT(IN) :: DATAOUT
REAL,DIMENSION(ni*nj),INTENT(INOUT) :: rh,wc,teta,pd,v11,v12,v21,v22,v31,v32,v41,v42
REAL(8),INTENT(INOUT) :: TIME
INTEGER, INTENT(INOUT) :: FBPOS

READ(OBIN) TIME
CALL READSCA(OBIN,DATAOUT,RH,WC,TETA,PD,NI,NJ,FBPOS)
CALL READVEC(OBIN,DATAOUT,v11,v12,v21,v22,v31,v32,v41,v42,NI,NJ,FBPOS)
RETURN
END SUBROUTINE READBIN

END MODULE WUFI2DFILE

sample program wfddiff.f90

Posted: Thu May 05, 2011 5:02 am -1100
by veitner
!
! File: wfddiff.f90
!
! Created on September 21, 2006, 1:41 PM
!

program wfddiff
USE WUFI2DFILE
implicit none

INTEGER :: IARGC
INTEGER :: ARGCOUNT

CHARACTER(255) :: wfd1,wfd2
INTEGER :: IBIN1=10000,IBIN2=11000,OBIN=1000,OBIN2=2000

!in
TYPE(HEADER) :: head1,head2
INTEGER :: ni1,ni2,nj1,nj2,nks1,nks2
LOGICAL(2),DIMENSION(NDATA) :: dataout1,dataout2,DATAOUTOUT
TYPE(MINMAX),DIMENSION(NDATA) :: mima1,mima2
CHARACTER(16):: startdate1,startdate2
REAL,DIMENSION(:),ALLOCATABLE :: x1,x2
REAL,DIMENSION(:),ALLOCATABLE :: y1,y2
INTEGER,DIMENSION(:),ALLOCATABLE :: matcls1,matcls2
TYPE(MATERIAL),DIMENSION(:),ALLOCATABLE :: materials1,materials2

REAL,DIMENSION(:), ALLOCATABLE :: rh1,rh2,wc1,wc2,teta1,teta2,pd1,pd2
REAL,DIMENSION(:), ALLOCATABLE :: v111,v112,v121,v122,v131,v132,v141,v142,v211,v212,v221,v222,v231,v232,v241,v242
REAL(8) :: time1,time2
character(len=32) :: fmt1
integer :: l
!-------------

!out/in
INTEGER :: FBPOS,MIMAPOS,NCTSPOS,FBPOSIN1,FBPOSIN2

TYPE(MINMAX),DIMENSION(NDATA) :: mimaout

!----------------------

INTEGER :: i,j,count

ARGCOUNT = IARGC()
if(ARGCOUNT.ne.2) then
write(*,*) '2 arguments needed, 1st wfd file, 2nd wfd file'
stop
end if

CALL GETARG(1,wfd1)
wfd1 = TRIM(wfd1)
CALL GETARG(2,wfd2)
wfd2 = TRIM(wfd2)

OPEN(UNIT=IBIN1,FILE=wfd1,&
STATUS='OLD', FORM='UNFORMATTED',ACCESS='STREAM')
OPEN(UNIT=IBIN2,FILE=wfd2,&
STATUS='OLD', FORM='UNFORMATTED',ACCESS='STREAM')
OPEN(UNIT=OBIN,FILE='diff.wfd',&
STATUS='REPLACE', FORM='UNFORMATTED',ACCESS='STREAM')
OPEN(UNIT=OBIN2,FILE='diffmax.txt',STATUS='REPLACE')

FBPOSIN1 = 1
FBPOSIN2 = 1
call HEADIN(IBIN1,HEAD1,DATAOUT1,STARTDATE1,MIMA1,X1,Y1,NI1,NJ1,nks1,materials1,matcls1,FBPOSIN1)

call HEADIN(IBIN2,HEAD2,DATAOUT2,STARTDATE2,MIMA2,X2,Y2,NI2,NJ2,nks2,materials2,matcls2,FBPOSIN2)

if(ni1.ne.ni2.or.nj1.ne.nj2) then
write(*,*) 'Different size of domains'
stop
end if

do i=1,NDATA
DATAOUTOUT(i) = dataout1(i).and.dataout2(i)
end do


allocate(rh1(ni1*nj1))
allocate(wc1(ni1*nj1))
allocate(teta1(ni1*nj1))
allocate(pd1(ni1*nj1))

allocate(rh2(ni1*nj1))
allocate(wc2(ni1*nj1))
allocate(teta2(ni1*nj1))
allocate(pd2(ni1*nj1))

allocate(v111(ni1*nj1))
allocate(v112(ni1*nj1))
allocate(v121(ni1*nj1))
allocate(v122(ni1*nj1))
allocate(v131(ni1*nj1))
allocate(v132(ni1*nj1))
allocate(v141(ni1*nj1))
allocate(v142(ni1*nj1))

allocate(v211(ni1*nj1))
allocate(v212(ni1*nj1))
allocate(v221(ni1*nj1))
allocate(v222(ni1*nj1))
allocate(v231(ni1*nj1))
allocate(v232(ni1*nj1))
allocate(v241(ni1*nj1))
allocate(v242(ni1*nj1))



do i=1,NDATA
mimaout(i)%MIN = HUGE(mimaout(i)%MIN)
mimaout(i)%MAX = -HUGE(mimaout(i)%MAX)
end do


call HEADOUT(OBIN,FBPOS,MIMAPOS,NCTSPOS,HEAD1,DATAOUT1,STARTDATE1,MIMAOUT,X1,Y1,NI1,NJ1,nks1,materials1,matcls1)

write(*,fmt='(a),1x', ADVANCE='NO') 'Timestep:'
count = MIN(head1%ncts,head2%ncts)
do i=0,count
call READBIN(IBIN1,TIME1,DATAOUT1,RH1,WC1,TETA1,PD1,v111,v112,v121,v122,v131,v132,v141,v142,NI1,NJ1,FBPOSIN1)
call READBIN(IBIN2,TIME2,DATAOUT2,RH2,WC2,TETA2,PD2,v211,v212,v221,v222,v231,v232,v241,v242,NI2,NJ2,FBPOSIN2)

wc1 = wc1 - wc2
rh1 = rh1 - rh2
teta1 = teta1 - teta2
pd1 = pd1 - pd2

v111 = v111 - v211
v112 = v112 - v212

v121 = v121 - v221
v122 = v122 - v222

v131 = v131 - v231
v132 = v132 - v232

v141 = v141 - v241
v142 = v142 - v242

call PRINTBIN(OBIN,FBPOS,MIMAPOS,NCTSPOS,TIME1,DATAOUT1,RH1,WC1,TETA1,PD1,v111,v112,v121,v122,v131,v132,v141,v142,&
MIMAOUT,NI1,NJ1,i)
write(OBIN2,*) 'Timestep:',i
if(DATAOUT1(1)) write(OBIN2,5000) &
'Max(WC)',MAXVAL((wc1)), &
'Min(WC)',MINVAL((wc1)), &
'Sum(ABS(WC))',SUM(ABS(wc1))
if(DATAOUT1(2)) write(OBIN2,5000) 'Max(RH)',MAXVAL((rh1)), &
'Min(RH)',MINVAL((rh1)), &
'Sum(ABS(RH))',SUM(ABS(rh1))
if(DATAOUT1(3)) write(OBIN2,5000) 'Max(TETA)',MAXVAL((teta1)), &
'Min(TETA)',MINVAL((teta1)), &
'Sum(ABS(TETA))',SUM(ABS(teta1))
if(DATAOUT1(4)) write(OBIN2,5000) 'Max(PD)',MAXVAL((pd1)), &
'Min(PD)',MINVAL((pd1)), &
'Sum(ABS(PD))',SUM(ABS(pd1))

if(DATAOUT1(5)) write(OBIN2,5000) 'Max(FLUK)',MAXVAL((v111)), &
'Min(FLUK)',MINVAL((v111)), &
'Sum(ABS(FLUK))',SUM(ABS(v111))
if(DATAOUT1(5)) write(OBIN2,5000) 'Max(FLUK_dir)',MAXVAL((v112)), &
'Min(FLUK_dir)',MINVAL((v112)), &
'Sum(ABS(FLUK_dir))',SUM(ABS(v112))

if(DATAOUT1(6)) write(OBIN2,5000) 'Max(FLUD)',MAXVAL((v121)), &
'Min(FLUD)',MINVAL((v121)), &
'Sum(ABS(FLUD))',SUM(ABS(v121))
if(DATAOUT1(6)) write(OBIN2,5000) 'Max(FLUD_dir)',MAXVAL((v122)), &
'Min(FLUD_dir)',MINVAL((v122)), &
'Sum(ABS(FLUD_dir))',SUM(ABS(v122))

if(DATAOUT1(7)) write(OBIN2,5000) 'Max(FLUT)',MAXVAL((v131)), &
'Min(FLUT)',MINVAL((v131)), &
'Sum(FLUT)',SUM(ABS(v131))
if(DATAOUT1(7)) write(OBIN2,5000) 'Max(FLUT_dir)',MAXVAL((v132)), &
'Min(FLUT_dir)',MINVAL((v132)), &
'Sum(ABS(FLUT_dir))',SUM(ABS(v132))

if(DATAOUT1(8)) write(OBIN2,5000) 'Max(VXY)',MAXVAL((v141)), &
'Min(VXY)',MINVAL((v141)), &
'Sum(ABS(VXY))',SUM(ABS(v141))
if(DATAOUT1(8)) write(OBIN2,5000) 'Max(VXY_dir)',MAXVAL((v142)), &
'Min(VXY_dir)',MINVAL((v142)), &
'Sum(ABS(VXY_dir))',SUM(ABS(v142))


5000 format(3(a20,': ',e12.5))

l=1
if (i>0) then
l=log10(real(i+21))+1
end if
write(fmt1,*) l
fmt1='(i'//trim(fmt1)//',1x,3(1h.),1x)'
write(*,fmt=fmt1, ADVANCE='NO') i
if (mod(i+1,20).eq.0) write(*,*)
! write(*,fmt='(i1,1x,3(1h.),1x)', ADVANCE='NO') i+32
! write(*,fmt='(3(1h.))',ADVANCE='NO')
! write(*,fmt='(a,a,a,a,a)',ADVANCE='NO') achar(8),achar(8),achar(8),achar(8),achar(8)
!do j=1,14
! write(*,fmt='(a)',ADVANCE='NO') achar(8)
!end do

end do

write(*,fmt='(a16)', ADVANCE='NO') 'finished'

write(OBIN2,*) 'Global maximums:'
if(DATAOUT1(1)) write(OBIN2,5000) 'Max WC',mimaout(1)%max,'Min WC',mimaout(1)%min
if(DATAOUT1(2)) write(OBIN2,5000) 'Max RH',mimaout(2)%max,'Min RH',mimaout(2)%min
if(DATAOUT1(3)) write(OBIN2,5000) 'Max TETA',mimaout(3)%max,'Min TETA',mimaout(3)%min
if(DATAOUT1(4)) write(OBIN2,5000) 'Max PD',mimaout(4)%max,'Min PD',mimaout(4)%min

if(DATAOUT1(5)) write(OBIN2,5000) 'Max FLUK',mimaout(5)%max,'Min FLUK',mimaout(5)%min
if(DATAOUT1(6)) write(OBIN2,5000) 'Max FLUD',mimaout(6)%max,'Min FLUD',mimaout(6)%min
if(DATAOUT1(7)) write(OBIN2,5000) 'Max FLUT',mimaout(7)%max,'Min FLUT',mimaout(7)%min
if(DATAOUT1(8)) write(OBIN2,5000) 'Max VXY',mimaout(8)%max,'Min VXY',mimaout(8)%min


CLOSE(IBIN1)
CLOSE(IBIN2)
CLOSE(OBIN)
CLOSE(OBIN2)

deallocate(rh1)
deallocate(wc1)
deallocate(teta1)
deallocate(pd1)
deallocate(matcls1)
deallocate(x1)
deallocate(y1)
DO I=1,SIZE(MATERIALS1)
DEALLOCATE(MATERIALS1(I)%BLTABX)
DEALLOCATE(MATERIALS1(I)%BLTABY)
DEALLOCATE(MATERIALS1(I)%BMYTABX)
DEALLOCATE(MATERIALS1(I)%BMYTABY)
DEALLOCATE(MATERIALS1(I)%FKTABSX)
DEALLOCATE(MATERIALS1(I)%FKTABSY)
DEALLOCATE(MATERIALS1(I)%FKTABRX)
DEALLOCATE(MATERIALS1(I)%FKTABRY)
DEALLOCATE(MATERIALS1(I)%SORTAB)
END DO
DEALLOCATE(MATERIALS1)

deallocate(rh2)
deallocate(wc2)
deallocate(teta2)
deallocate(pd2)
deallocate(matcls2)
deallocate(x2)
deallocate(y2)
DO I=1,SIZE(MATERIALS2)
DEALLOCATE(MATERIALS2(I)%BLTABX)
DEALLOCATE(MATERIALS2(I)%BLTABY)
DEALLOCATE(MATERIALS2(I)%BMYTABX)
DEALLOCATE(MATERIALS2(I)%BMYTABY)
DEALLOCATE(MATERIALS2(I)%FKTABSX)
DEALLOCATE(MATERIALS2(I)%FKTABSY)
DEALLOCATE(MATERIALS2(I)%FKTABRX)
DEALLOCATE(MATERIALS2(I)%FKTABRY)
DEALLOCATE(MATERIALS2(I)%SORTAB)
END DO
DEALLOCATE(MATERIALS2)

DEALLOCATE(v111)
DEALLOCATE(v112)
DEALLOCATE(v121)
DEALLOCATE(v122)
DEALLOCATE(v131)
DEALLOCATE(v132)
DEALLOCATE(v141)
DEALLOCATE(v142)

DEALLOCATE(v211)
DEALLOCATE(v212)
DEALLOCATE(v221)
DEALLOCATE(v222)
DEALLOCATE(v231)
DEALLOCATE(v232)
DEALLOCATE(v241)
DEALLOCATE(v242)

end program wfddiff

Re: Post-Processing

Posted: Fri Jul 28, 2017 1:23 am -1100
by tmartincps
I'm very new to WUFI and don't know anything about Java or Fortran. Is there a simpler way to do this now? I realize this post is from 2011, surely there is something a bit automated and end user friendly by now? :D

Re: Post-Processing

Posted: Fri Jul 28, 2017 2:00 am -1100
by Christian Bludau
What do you want to do? WUFI Graph has become much faster since than, but automatic evaluation still is not possible.