Welcome, Guest
Username: Password: Remember me

TOPIC: Saving variables for next timestep within fortran subroutine

Saving variables for next timestep within fortran subroutine 6 months 3 days ago #44765

  • DeVos_TUM
  • DeVos_TUM's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 4
Hi all,

I am trying to extend the implemented Green-Ampt method for Telemac2D. For this I need to save some parameters from one timestep to the next.

For example, I want to save the time when the precipitation starts in the simulation (TPS). I define TPS as a double precision and add the line "SAVE TPS", so that once it starts raining TPS will get the current time (AT) and from then on, the subroutine can use the saved value of TPS.

However, I also need to save some vectors. I have one vector, which represents the ponding time (TPSA) at every time step. This vector is initialized with zeros and will be calculated, once the rain starts. If the current time exceeds the calculated ponding time at one node, the ponding time at this node should not be calculated again in the next time step, but kept to that value from there on. At this step I basically fail :S It seems, that values from some nodes are copied to other nodes at random timesteps.

Can someone maybe give me a hint how to accomplish this?

"SAVE TPSA" does not work, since it is not just a number, but a vector. I tried to define TPSA as a BIEF OBJECT in declarations_telemac2d, but this produced a very weird error, once I started running the simulation.

P.S.: Obviously, I am still rather unexperienced in fortran programming, so it might be a very basic mistake I am making, but I have not found the solutions in other forum posts so far.
Attachments:
The administrator has disabled public write access.

Saving variables for next timestep within fortran subroutine 6 months 2 days ago #44770

  • pham
  • pham's Avatar
  • OFFLINE
  • Administrator
  • Posts: 1559
  • Thank you received: 602
Hello Frederik,

If I were you, I would not declare the local array TPSA as you did, but with DOUBLE PRECISION, ALLOCATABLE :: TPSA(:), then allocate it the first time (in your test with LT e.g.= and save it. Same for the other arrays of dimension NPOIN.

Hope this helps,

Chi-Tuan
The administrator has disabled public write access.
The following user(s) said Thank You: DeVos_TUM

Saving variables for next timestep within fortran subroutine 6 months 2 days ago #44775

  • DeVos_TUM
  • DeVos_TUM's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 4
Hi Chi-Tuan,

thanks for your help!
I defined the variables as you advised and the fortran subroutines compiled successfully, but then the simulation didn't run because of a segmentation error. I then tried running the simulation in debug mode, but realised that my Telemac installation for Windows via the wintel gitlab didn't build the debug version :S ...

I attached my simulation folder containing the .slf,.cli files and so on, including the prompt from the simulation run in "log.txt". I am testing the subroutine on the simple pluie example. I would highly appreciate, if you could further guide me towards the solution.


Kind regards
Frederik
The administrator has disabled public write access.

Saving variables for next timestep within fortran subroutine 6 months 2 days ago #44776

  • DeVos_TUM
  • DeVos_TUM's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 4
I wanted to attach the temporary simulation folder, but apparently that made the attachment too big. So here it is without the folder...
Attachments:
The administrator has disabled public write access.

Saving variables for next timestep within fortran subroutine 5 months 3 weeks ago #44829

  • pham
  • pham's Avatar
  • OFFLINE
  • Administrator
  • Posts: 1559
  • Thank you received: 602
Hallo Frederik,

If you declare a variable as ALLOCATABLE, you have to use ALLOCATE command once to define how you allocate this variable.

You can find enclosed some examples of modifications.

Some advice to better implement (at least):
- do not use tabulations,
- use WRITE(LU,*) rather than PRINT *. The messages will then be written in the good order in case running in parallel,
- review your implementation, I am not sure you can get other values for TPSA and GA_T different from 0 how you currently implement this subroutine,
- if you are not sure in this specific subroutine, use SAVE rather than SAVE with a few variables, every variable which need to be saved will be.

Hope this helps,

Chi-Tuan

File Attachment:

File Name: runoff_greenampt.f
File Size: 17 KB
The administrator has disabled public write access.
The following user(s) said Thank You: DeVos_TUM

Saving variables for next timestep within fortran subroutine 5 months 3 weeks ago #44836

  • DeVos_TUM
  • DeVos_TUM's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 4
Hi Chi-Tuan,

thanks for your help, the script now runs smoothly!

Thanks also for your advice on better coding practices, I will also include them in the script. TPSA and GA_T can get other values, if the rain intensity is high enough and the hydraulic conductivity low enough. But this is something I would probably like to discuss more in detail at the TUC...

Thanks again
Frederik
The administrator has disabled public write access.
Moderators: pham

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