Hello,
This is fairly "simple" to solve but it requires a good overview of the TELEMAC system -- maybe docs.opentelemac.org would help in your case -- Here are a few pointers ...
First advice: try to rely on TELEMAC for everything that is parallel-related.
In other terms, if you use one of the two BINARY FILE available (SELAFIN format) to store your time-space varying wind variables (just like a RESULT FILE), then TELEMAC will automatically handle the parallel split in puzzle pieces like it would do for the GEO file for instance. This will avoid having to hard-code the opening of your file in the PRINCI -- please never do this again ever by the way, but try using the available FORMATED and BINARY file -- and let TELEMAC open / read / close your file for you.
Your goal: converting your text file into a SELAFIN file.
Second, if this and what is below looks like Chineese written in English, please note that we provide training course to all for all level of use of the system !
Third, since TELEMAC will have done all the work for you, you just need to add the appropriate lines of code that will read your wind variables in METEO. In a simpler case than yours, for METEO, I would advise you to use the subroutine FIND_IN_SEL:
CALL FIND_IN_SEL(PRIVE%ADR(1)%P,'WIND U',T2D_FILES(T2DBI1)%LU,WSEB,OK,TIME=BID)
CALL FIND_IN_SEL(PRIVE%ADR(2)%P,'WIND V',T2D_FILES(T2DBI1)%LU,WSEB,OK,TIME=BID)
(you can find an example of such use in PROSOU, there used with FORCE)
folowed by lines such as these:
CALL OV( 'X=Y ', WINDX , PRIVE%ADR(1)%P%R ,Z, 1.D0, NPOIN )
CALL OV( 'X=Y ', WINDY , PRIVE%ADR(2)%P%R ,Z, 1.D0, NPOIN )
... and this will all work in parallel
Of course you also have to deal with time in your case, which complicates things for METEO a little ...
Forth advice: try to do what is done in READ_FIC_FRLIQ for instance, where you go through your BINARY FILE once at the begining, storing the time stamps into one array, and then read your wind two time steps at a time, so you can linearly time-intepolate at every node of your sub-mesh. You then advance the read when AT (the time in TELEMAC) move in your time stamps`array ... something of the sort:
(Please note that the code below comes from what I did version v5p2, almost 10 years ago, so please update to the most recent variable names ...)
!#####> SEB-changes
!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
LOGICAL DEJA
DATA DEJA /.FALSE./
INTEGER i,n,j(12),windREF(2), KwindHST,NwindHST, nvBNI1, ERRALL
CHARACTER(LEN=32) :: windNAM
REAL :: rTmp
REAL, DIMENSION(:), ALLOCATABLE :: WSEB
DOUBLE PRECISION alpha
DOUBLE PRECISION, ALLOCATABLE :: windHST(:)
SAVE DEJA, nvBNI1,KwindHST,NwindHST,windREF,windHST
!***********************************************************************
! The program below is valid only if the user wants wind
IF(VENT) THEN
!
!-----------------------------------------------------------------------
! For time interpolation purposes, save the time history
IF(.NOT.DEJA) THEN
!~~~~> read header and check presence of VENTOX,Y
REWIND NBI1
READ(NBI1)
READ(NBI1) j(1),j(2)
nvBNI1 = j(1)+j(2)
DO i = 1,nvBNI1
READ(NBI1) windNAM
IF( windNAM(1:12).EQ.'WIND ALONG X' ) windREF(1) = i
IF( windNAM(1:12).EQ.'WIND ALONG Y' ) windREF(2) = i
ENDDO
READ(NBI1) ( j(i),i=3,12 )
IF( j(12).EQ.1 ) READ(NBI1) ( j(i),i=3,8 )
READ(NBI1) ( j(i),i=3,6 )
DO i = 1,4
READ(NBI1)
ENDDO
!~~~~> read core and count number of time steps
NwindHST = 0
1972 READ(NBI1,END=2006,ERR=2006) rTmp
DO i = 1,nvBNI1
READ(NBI1)
ENDDO
NwindHST = NwindHST + 1
GOTO 1972
2006 ALLOCATE( windHST(NwindHST), STAT=ERRALL ) ! do not forget to DEALLOCATE
IF( ERRALL.NE.0 ) THEN
WRITE(LU,'(A,I)') 'Error allocating wind tables ', NwindHST
STOP
ENDIF
!~~~~> re-read file and save time profile
REWIND NBI1
DO i = 1,2+nvBNI1+6
READ(NBI1)
ENDDO
IF( j(12).EQ.1 ) READ(NBI1)
DO n = 1,NwindHST
READ(NBI1) rTmp
windHST(n) = 1.D0 * rTmp
DO i = 1,nvBNI1
READ(NBI1)
ENDDO
ENDDO
!
!-----------------------------------------------------------------------
! For time interpolation purposes, read VENTOX and VENTOY, time 1 and 2
! -> this required 4 PRIVE tables.
! This assumes that:
! - VENTOX is placed before VENTOY in the BINARY FILE 1
! ( windREF(1) < windREF(2) )
! - PRIVE%ADR(1) will be VENTOX ( time before )
! - PRIVE%ADR(2) will be VENTOY ( time before )
! - PRIVE%ADR(3) will be VENTOX ( time after )
! - PRIVE%ADR(4) will be VENTOY ( time after )
! - this should also work even if windREF(1)=windREF(2)=0 ...
!~~~~> initialise PRIVE just in case there was no VENTOX / VENTOY
CALL OV( 'X=C ', PRIVE%ADR(1)%P%R , Z,Z, FUAIR, NPOIN )
CALL OV( 'X=C ', PRIVE%ADR(2)%P%R , Z,Z, FVAIR, NPOIN )
CALL OV( 'X=C ', PRIVE%ADR(3)%P%R , Z,Z, FUAIR, NPOIN )
CALL OV( 'X=C ', PRIVE%ADR(4)%P%R , Z,Z, FVAIR, NPOIN )
ALLOCATE( WSEB(NPOIN), STAT=ERRALL )
IF( ERRALL.NE.0 ) THEN
WRITE(LU,'(A,I)') 'Error allocating buffer tables ', NPOIN
STOP
ENDIF
!~~~~> move reading pointer back to the proper time stamp
! -> and initialisation of VENTOX and VENTOY ( PRIVE(1 to 4) )
REWIND NBI1
DO i = 1,2+nvBNI1+6
READ(NBI1)
ENDDO
IF( j(12).EQ.1 ) READ(NBI1)
!~~~~> first time step
READ(NBI1) rTmp
DO i = 1,windREF(1)
READ(NBI1) ( WSEB(n), n=1,NPOIN )
DO n = 1,NPOIN
PRIVE%ADR(3)%P%R(n) = WSEB(n)
PRIVE%ADR(1)%P%R(n) = WSEB(n)
ENDDO
ENDDO
DO i = windREF(1)+1,windREF(2)
READ(NBI1) ( WSEB(n), n=1,NPOIN )
DO n = 1,NPOIN
PRIVE%ADR(4)%P%R(n) = WSEB(n)
PRIVE%ADR(2)%P%R(n) = WSEB(n)
ENDDO
ENDDO
DO i = windREF(2)+1,nvBNI1
READ(NBI1)
ENDDO
KwindHST = 1
!~~~~> done it, once is enough !
DEJA=.TRUE.
DEALLOCATE( WSEB )
ENDIF
!
!-----------------------------------------------------------------------
! At every time step, check if you need to advance in your BINARY file
! -> AT is the current TELEMAC time, windAT is the curretn wind time
ALLOCATE( WSEB(NPOIN), STAT=ERRALL )
IF( ERRALL.NE.0 ) THEN
WRITE(LU,'(A,I)') 'Error allocating buffer tables ', NPOIN
STOP
ENDIF
! This assumes that:
! - if AT is outside (before or after) the range of windHST, then
! before = after and the interpolation should work just the same
DO WHILE ( AT.GT.windHST(KwindHST) )
!~~~~> replace old records
DO n = 1,NPOIN
PRIVE%ADR(1)%P%R(n) = PRIVE%ADR(3)%P%R(n)
PRIVE%ADR(2)%P%R(n) = PRIVE%ADR(4)%P%R(n)
ENDDO
IF( KwindHST.LT.NwindHST ) THEN
!~~~~> read new records from next time step if you can
READ(NBI1)
DO i = 1,windREF(1)
READ(NBI1) ( WSEB(n), n=1,NPOIN )
DO n = 1,NPOIN
PRIVE%ADR(3)%P%R(n) = WSEB(n)
ENDDO
ENDDO
DO i = windREF(1)+1,windREF(2)
READ(NBI1) ( WSEB(n), n=1,NPOIN )
DO n = 1,NPOIN
PRIVE%ADR(4)%P%R(n) = WSEB(n)
ENDDO
ENDDO
DO i = windREF(2)+1,nvBNI1
READ(NBI1)
ENDDO
KwindHST = KwindHST + 1
ENDIF
ENDDO
!
DEALLOCATE( WSEB )
!
!-----------------------------------------------------------------------
! Interpolate the wind through time
! Notes: if windREF(1)=windREF(2)=0, then PRIVE are set to FUAIR,FVAIR
alpha = 0.D0
IF( KwindHST.GT.1 ) THEN
alpha = ( AT-windHST(KwindHST-1) ) /
& ( windHST(KwindHST)-windHST(KwindHST-1) )
ENDIF
DO n = 1,NPOIN
WINDX(n) = (1.D0-alpha) * PRIVE%ADR(1)%P%R(n) +
& alpha * PRIVE%ADR(3)%P%R(n)
WINDY(n) = (1.D0-alpha) * PRIVE%ADR(2)%P%R(n) +
& alpha * PRIVE%ADR(4)%P%R(n)
ENDDO
! END OF IF( VENT )
ENDIF
!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
!#####< SEB-changes
I trust this helps.
Sebastien