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

TOPIC: Problem adding a fortran subroutine in Telemac

Problem adding a fortran subroutine in Telemac 7 years 2 months ago #27880

  • Cynthia
  • Cynthia's Avatar
Hello,

I'm trying for the first time to add a fortran subroutine to a 2D telemac model.
I started with something simple which I put in 'test.f':

SUBROUTINE HELLO_WORLD
print *, 'start!'
print *, 'FINISHED!'
END

In the cas file I added: FICHIER FORTRAN = 'test.f'
The model runs correctly, I don't have any erorrs (after adding 6 spaces at the beginning of each line of my fortran code). But I don't see anything printed.

My goal is actually to get ouput of telemac straight into a .csv file with the following fortran code:

SUBROUTINE HELLO_WORLD
use DECLARATIONS_TELEMAC2D
implicit none
print *, 'start!'
integer :: n
open(unit=20,file=trim(TITCAS) // '.CSV',action='write')
DO n = 1,NPOIN
write(20,*) , n,AT,X(n),Y(n),ZF%R(n),H%R(n)
End Do
close(unit=20)
print *, 'FINISHED!'
END

this also runs and gives no errors but I don't see a file. I used the option 'do not delete working directory' cause I think the file should be there. In this map I only see a new file: 't2dfort.f' which contains my fortran code.

Could anyone help me out where I can find my output?

Thanks a lot!
Cynthia
The administrator has disabled public write access.

Problem adding a fortran subroutine in Telemac 7 years 2 months ago #27881

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi Cynthia

You could add your own program but it could only be taken in account if your subroutine is called somwhere.
In telemac, there is no call to hello_world so you cannot see something...

You should take time to read the user manual and find the best telemac subroutine you could modify to obtain your result. There is some description of the most used subroutine in the manual.

Nevertheless, in your case, you could also post-process the result to create the csv after the computation

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

Problem adding a fortran subroutine in Telemac 7 years 2 months ago #27883

  • qilong
  • qilong's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 340
  • Thank you received: 33
Hi Cynthia,

Have you tried to call HELLO_WORLD from telemac main program? Does it give any error?

I'm just wondering it it really works in this way.

Kind regards,
Qilong
The administrator has disabled public write access.

Problem adding a fortran subroutine in Telemac 7 years 1 month ago #27893

  • Cynthia
  • Cynthia's Avatar
Hi Qilong,

I could run my telemac 2D model through Fudaa Prepro with the fortran code 'test.f' which had the subroutine 'Hello_World'. This didn't give any errors but also no output. I changed the name "Hello_World" to "BIEF_VALIDA" thanks to C.Coulet. Now I see an output file! :)

It's not yet what I wanted, because in the file are only my variables for each gridpoint at the last time step. I would like to have them for specific time steps but I'm still working on that!

I cannot reach for the subroutine Hello_world separately from the telemac main program because I only have acces to Telemac through Fudaa Prepro (because of safety restrictions from the company).

I hope that answered your question!
Regards,
Cynthia
The administrator has disabled public write access.

Problem adding a fortran subroutine in Telemac 7 years 1 month ago #27896

  • Phelype
  • Phelype's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 140
  • Thank you received: 64
Hello Cynthia,

Changing the name of your subroutine to replace one of Telemac's native subroutines is not an advisable thing to do. Also modifying the source code from the Telemac root (as your company will not allow you to do) is also not recommended.

The correct way to proceed is to copy (or download) the source code of the Telemac subroutine of interest, modify the copy, and include it in the fortran file.

For example, see the file attached. I created a subroutine of my own, then, in the subroutine TELEMAC2D I called it just after the start of the time loop (line 1566). Then I just included the telemac2d.F in the keyword FORTRAN FILE.

Use this as an example and follow from here.

File Attachment:

File Name: telemac2d.f
File Size: 96 KB


Regards,

Phelype
The administrator has disabled public write access.
The following user(s) said Thank You: Cynthia

Problem adding a fortran subroutine in Telemac 7 years 1 month ago #28032

  • Cynthia
  • Cynthia's Avatar
Hello Phelype,

I tried to run a subroutine based upon your example.
I took the telemac2d.f file from the source code and then copied the little subroutine you made into it. Just as a test. Unfortunally I got errors, which I don't understand.

As another test. I took the original telemac2d.f file (whithout any modifications) and only changed: fortran file = telemac2d.f in the cas-file and copied the telemac2d.f file into my working directory. This gave the same errors, which you can find in the attachments.

Any help?
Thanks a lot!
Cynthia
Attachments:
The administrator has disabled public write access.

Problem adding a fortran subroutine in Telemac 7 years 1 month ago #28033

  • Phelype
  • Phelype's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 140
  • Thank you received: 64
Hello Cynthia,

The error you are showing is quite strange given normal usage circumstances. My guess is that you are mixing different versions of the code.

I say that because the error log you uploaded says that the statement "USE DECLARATIONS_TELEMAC2D" is in the line 257 of the code. But at the bottom of the error log it says that your telemac installation is in the directory "/data/telemac/v7p1r0", thus I presume you are using V7P1R0. So I went checking, and the version of telemac where the statement "USE DECLARATIONS_TELEMAC2D" is in the line 257 is V7P0. This explains many of the errors in the log.

TL;DR, I think you are using the telemac2d.f from V7P0 while using telemac V7P1R0. If I'm correct, then using the correct version of telemac2d.f should solve the problem. Otherwise, please inform what version of telemac you are using.

Hope this helps.

Regards,

Phelype
The administrator has disabled public write access.

Problem adding a fortran subroutine in Telemac 7 years 1 month ago #28035

  • Cynthia
  • Cynthia's Avatar
Hi Phelype,

you were correct!
I downloaded the telemac2d.f file again from the server version v7p0r1 and now it works! I somehow must have taken the wrong version before!

Thanks a lot!
Cynthia
The administrator has disabled public write access.

Problem adding a fortran subroutine in Telemac 7 years 1 month ago #27902

  • qilong
  • qilong's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 340
  • Thank you received: 33
Thanks for you reply, Cynthia!

If your own subroutine can be compiled into the telemac program, I'm thinking maybe you could copy all the code in telemac2d.f to the same fortran file where you put your subroutine, and modify it (for example add a call to 'Hello_World'), it might also work.

But this is only my guess... I sometimes modify telemac2d.f and put it in the same fortran file with other modified subroutines. It works fine to me. But all the subroutines I modified are already in the source code, not new ones I created.

Regards,
Qilong
The administrator has disabled public write access.
The following user(s) said Thank You: Cynthia

Problem adding a fortran subroutine in Telemac 7 years 1 month ago #28056

  • riadh
  • riadh's Avatar
Hello Cynthia

Before starting to develop a new feature within Telemac subroutines, the best practice says that you should First verify that this feature is really New.
This means that for case, you want to generate some result variables and write them to an ascii file. This task can be achieved automatically by Telemac by the use of the keyword LIST OF POINTS= node nubmer.

This could be done also by post-processing tools like Blue Kenue by the feature "Time profile"

with my kind regards

Riadh
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.