Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: run telemac2d with wind effect that change in spac

run telemac2d with wind effect that change in spac 12 years 9 months ago #3608

  • mtayel
  • mtayel's Avatar
hello all,
i had ran telemac2d with wind effect that change in space and time using the attached meteo subroutine but all of that was in scalar mode.

i read the wind data from a text file for the whole NPOINT=41891 at each time step sequentially.
the problem will raise up when i try the same code in parallel mode since NPOINT will be changed according to the number of processes that I will use(for example if i use two processes it will be 20793 and 21254). so it will not access the same point in the text file to read the data from.

i need to change the attached code to work in parallel mode with any number of processes and read the correct data from the text file.

another question when i try to use WINDX%R in parallel it give me an error.
please be open to give me a lot of ideas
thanks
Attachments:
The administrator has disabled public write access.

Re: run telemac2d with wind effect that change in spac 12 years 9 months ago #3609

  • sebourban
  • sebourban's Avatar
  • OFFLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
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 :ohmy:

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. :whistle:

Sebastien
The administrator has disabled public write access.

Re: run telemac2d with wind effect that change in spac 12 years 9 months ago #3610

  • mtayel
  • mtayel's Avatar
thanks for your helpful reply
could you please provide more comments over the last attached code please.
another point about the training how and where can i get it?
how many levels provided? how much the coast?
and if it is possible for taking it over the internet like video chatting, since it will be very difficult currently to stay in France ?

thanks
The administrator has disabled public write access.

Re: run telemac2d with wind effect that change in spac 12 years 9 months ago #3611

  • sebourban
  • sebourban's Avatar
  • OFFLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
As is expalined on this website ...:

« The TELEMAC consortium offers a wide range of services, from making the source code available on this website, providing documentation and support for the use of the system, expert training from beginner through advanced level: ot-training @ opentelemac.org and consultancy services: ot-consultancy @ opentelemac.org. »

Please send your details and request to the address above.

Note that France is not the only country we operate in as several organisations make up the distribution Consortium. I reside myself in the UK.

As for the explanations, it would be better if you could point to the lines of code you do not understand as it looks self-explanatory to me.

Hope this helps.

Sebastien.
The administrator has disabled public write access.

Re: run telemac2d with wind effect that change in spac 12 years 9 months ago #3612

  • mtayel
  • mtayel's Avatar
if you please give me an explanation for the rule of each variable you had defined in the following section it will help me:
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(:)


another thing if you give me an example about the continent of the file NBI1 so i can follow the code easier.
last point how i can construct and build such selafin file containing the wind data

really thanks
The administrator has disabled public write access.

Re: run telemac2d with wind effect that change in spac 12 years 9 months ago #3617

  • mtayel
  • mtayel's Avatar
ok
i seached on telemac manual about serafin file format and it will be easy for me but it still remaining is the explantion about for each variable in order to understand the last code faster and easier
thanks
The administrator has disabled public write access.

Re: run telemac2d with wind effect that change in spac 12 years 9 months ago #3623

  • sebourban
  • sebourban's Avatar
  • OFFLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
Please note that I wrote this code 10 years ago for wind ... my memory might not be very good ... so just looking a little bit closer:


# the following are to know whether you have entered the surbroutine already or not, i.e. to distinguish the first iteration from the rest. This is very much the way TELEMAC does it in other parts of the code. This enable reading your input file through only one.
LOGICAL DEJA
DATA DEJA /.FALSE./

# the following are temporary arrays to read various important parameters off the SELAFIN format (such as the number of time records or the number of variables (in your case 2, for u and v ?)
INTEGER i,n,j(12),windREF(2), KwindHST,NwindHST, nvBNI1, ERRALL
CHARACTER(LEN=32) :: windNAM
REAL :: rTmp

# the following is necessary because only floats are stored in a SELAFIN file (as opposed to DOUBLE PRECISIONs). So you read WSEB values as an array of floats and you copy them into your DOUBLE PRECISION PRIVE array.
REAL, DIMENSION(:), ALLOCATABLE :: WSEB

# this is for the linear interpolation betweeen two time steps of your file
DOUBLE PRECISION alpha

# this should store all of the time steps read in your input file, so you know when to move on ... this technique is also used in other parts of the TELEMAC system
DOUBLE PRECISION, ALLOCATABLE :: windHST(:)

# and this is to SAVE so that next time the subroutine is being called, TELEMAC remembers the values it had set already.
SAVE DEJA, nvBNI1,KwindHST,NwindHST,windREF,windHST

Hope this helps ...

Sébastien
The administrator has disabled public write access.
The following user(s) said Thank You: mtayel

Re: run telemac2d with wind effect that change in spac 12 years 9 months ago #3628

  • mtayel
  • mtayel's Avatar
thaks for your help
there is two things i want to ask about
1- in the following code what is BID
CALL FIND_IN_SEL(PRIVE%ADR(1)%P,'WIND U',T2D_FILES(T2DBI1)%LU,WSEB,OK,TIME=BID)
2- according to last code when AT is changed (after the first call and change of DEJA i.e from the second call to meteo subroutine)the "do while" loop will be executed at least once even if it is not required. since the do while will execute the code inside once and then chick the condition after
The administrator has disabled public write access.

Re: run telemac2d with wind effect that change in spac 12 years 9 months ago #3630

  • sebourban
  • sebourban's Avatar
  • OFFLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
Hello,

1.- I am not sure what BID is :blush:
(try removing TIME=BID from the list of arguments)

2.- The inside of the loop DO WHILE ( AT.GT.windHST(KwindHST) ) will not be executed, not even once, if AT .LE. windHST(KwindHST) ... I am pretty sure of this. Use the old good method of "print to screen" for debugging if you are not sure.

Hope this helps.
Sébastien.
The administrator has disabled public write access.

Re: run telemac2d with wind effect that change in spac 12 years 9 months ago #3631

  • mtayel
  • mtayel's Avatar
ok
i search the internet for the operation of do while loop one of them is wikipedia on the following web sitewhich say the code is executed then evaluate the condition. on the other side another web sites say "do while" loop is equal to "while" loop as you mentioned above.
so to be sure i will try to debug the do while loop

last point just to complete my understanding, in parallel run NPOINT will be local to each "submesh" and "selafin wind data file that divided between processors". so i must use selafin file in order to let telemac divide it between the processes. for example if NPOINT=41891 in case of one processor it could be NPOINT=2200 and NPOINT=2300 in case of 2 processors
is what i understand correct or not?

thanks really for your help and advice
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: pham

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.