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

TOPIC: use additional variables in Selafin files

use additional variables in Selafin files 7 years 1 month ago #25964

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
Dear everyone,

I have a selafin file that I use as "PREVIOUS COMPUTATION FILE", in which I have additional variables (describing the coverage of N plant species) that I need to use for computing the drag force (exerted by plants considered as vertical structures).

How can I access these variables in Telemac2d?

I know that there are a few slots available for that (variables 23 to 26 named N, O, R and Z if I'm correct), but I am looking for a more generic solution, because we aim at more than 4 species and also other variables.

Is that possible?

Thank you for your help!
The administrator has disabled public write access.

use additional variables in Selafin files 7 years 1 month ago #25965

  • riadh
  • riadh's Avatar
Hello Olivier,

If you see at the top a telemac2d subroutine, you will see that you have an array called ALIRE with lots of 0 and 1.
1 means the varible to be read in case of previous computational file. You can identify the location of your variables and change the corresponding row in ALIRE from 0 to 1.

I hope that this helps

with my best regards

Riadh
The administrator has disabled public write access.

use additional variables in Selafin files 7 years 1 month ago #25966

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
Thank you Riadh. That works pretty well. The only thing I don't know now is how to access the variable in the code.

These are the lines I added in "nomvar_telemac2d.f":

      TEXTE (34) = 'TRANS. N-S                      '
      TEXTE (35) = 'TRANS. NW-SE                    '
      TEXTE (36) = 'TRANS. W-E                      '
      TEXTE (37) = 'TRANS. SW-NE                    '
      TEXTE (38) = 'COVERAGE SP. 1                  '
!      
      TEXTPR (34) = 'TRANS. N-S                      '
      TEXTPR (35) = 'TRANS. NW-SE                    '
      TEXTPR (36) = 'TRANS. W-E                      '
      TEXTPR (37) = 'TRANS. SW-NE                    '
      TEXTPR (38) = 'COVERAGE SP. 1                  '
!
      MNEMO(34)   = 'TR1     '
      MNEMO(35)   = 'TR2     '
      MNEMO(36)   = 'TR3     '
      MNEMO(37)   = 'TR4     '
      MNEMO(38)   = 'SP1     '

In "telemac2d.F", I modified the variable ALIRE accordingly and the standard output file tells me that the variable SP1 has been read from the PREVIOUS COMPUTATION FILE. That's great :-)

Now, how can I access variable 34 to 38 in the code?

Thank you for your help!
The administrator has disabled public write access.

use additional variables in Selafin files 7 years 1 month ago #25969

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
Actually, I am not so sure it works well. The reason why I said that is because I saw those lines in the standard output:
TITLE OF PREVIOUS COMPUTATION: created with pputils

 NAME: VELOCITY U        UNIT: M/S
 NAME: VELOCITY V        UNIT: M/S
 NAME: FREE SURFACE      UNIT: M
 NAME: BOTTOM            UNIT: M
 NAME: COVERAGE SP. 1    UNIT:

But If I want to export the last variable (VARIABLES FOR GRAPHIC PRINTOUTS), the model stops with a segmentation fault...

Basically, what I need is to access in the code some variables I have in a Selafin file (the same where I have the bathymetry and the variables from a previous simulation). Maybe the concept of clandestine variables (that I saw several times in the code) is useful in this case? But I don't know how it works...

Thank you for your help!
The administrator has disabled public write access.

use additional variables in Selafin files 7 years 1 month ago #25970

  • josekdiaz
  • josekdiaz's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 161
  • Thank you received: 47
Hello,

I believe this is called a "PRIVATE VARIABLE" and I haven't test its usage myself but this and this one by PL ilustrate how its supposed to be done.

Hope it helps.

José Díaz
The administrator has disabled public write access.

use additional variables in Selafin files 7 years 1 month ago #25973

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
Thank you José.

However, if I'm not mistaken, private variables are limited to 4. I am looking for a solution where I can do that for more (about 10 to 20).
The administrator has disabled public write access.

use additional variables in Selafin files 7 years 1 month ago #25976

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3632
  • Thank you received: 1010
Hi Olivier

You could extent the number of private variables by a keyword (NUMBER OF PRIVATE VARIABLES or something similar).
By the way, if I understand well what you want to do, I think it will be easier to use the geometry file instead of the previous computational file.
There was recent developments which allow you to declare some private variables in the geometry file, and use them directly in the code.
So you don't have to modify the ALIRE variable and all the telemac code. All the variables declared are available in the PRIVE structure of declaration_telemac2d.

Hope this helps

Regards
Christophe
The administrator has disabled public write access.
The following user(s) said Thank You: o.gourgue

use additional variables in Selafin files 7 years 1 month ago #25982

  • Svensmolders
  • Svensmolders's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 104
  • Thank you received: 20
Hi Olivier,

Christophe is right. In the FONSTR subroutine lines were added were there is a check if the name of private variables is present in the geometry file. If so, the variables from the geometry file are read and put directly in the appropriate arrays.
Besides that it is not so dificult to add your own variable and let FONSTR read it from the geometry file. I did something like that for salinity. FONSTR is reading my initial salinity field from the variable SALINITY in the geometry file. I also tried this with the PRIVATE VARIABLES and that also worked.

Sven
The administrator has disabled public write access.
The following user(s) said Thank You: o.gourgue

use additional variables in Selafin files 7 years 1 month ago #25986

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
Thank you Christophe and Sven.

This looks promising, but as I feared, that does not work for more than 4 private variables. Here is my setup for 5 private variables (TR1, TR2, TR3, TR4 and SP1). For this test, these are homogeneous fields with value 1, 2, 3, 4 and 5, respectively.

I print them in the DRAGFO subroutine (where I want to access them in the final configuration). As you can see in the standard output, it works for the first 4, but not for the 5th variable (which remains 0).

I looked a bit at the FONSTR subroutine, it seems that the variable N_NAMES_PRIV remains 4 even if we use more than 4 private variables. And if I force it to be 5, I have a segmentation fault...

Would you have some suggestion to go further?

I also have a side question (probably more easy). In the CAS file, I'm getting trouble with the keyword NAMES OF PRIVATE VARIABLES if gets too long. For example, this works

NAMES OF PRIVATE VARIABLES            = 'TR1';'TR2';'TR3';'TR4';'SP1'

But it doesn't work anymore for a longer list or longer names. Is there a way to circumvent that? Is there a maximum size for strings in the CAS file or something like that?

Thank you all for your help!
The administrator has disabled public write access.

use additional variables in Selafin files 7 years 1 month ago #25988

  • Svensmolders
  • Svensmolders's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 104
  • Thank you received: 20
Hi Olivier,

I'm not an expert on the code, but my best guess on the segmentation error would be that somewhere in one or more subroutines you need to add some more information on the fifth PRIVATE VARIABLE. Maybe the memory is not allocated automatically for this.I remember two years ago we had a similar problem when we tried to implement 100 tracers.
Anyway I would check if the arrays of the PRIVATE VARIABLES (probably hard coded) in other subroutines. I will send you my user fortran file for the salinity case and there you can find a list of all subroutines I changed to make it work. You can look for the PRIVATE ARRAYS in these subroutines and extend them from 4 to any number you like.

Hope it will work

Sven
The administrator has disabled public write access.
The following user(s) said Thank You: o.gourgue
  • Page:
  • 1
  • 2
Moderators: pham

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