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

TOPIC: How to add a fortran subroutine in Telemac ?

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12296

  • special_20
  • special_20's Avatar
Hello all,

For the purpose of my study I wanted to add a fortran subroutine in Telemac2d. I started with a basic "hello world" subroutine (named hello_world()) :

SUBROUTINE hello_world()
WRITE(*,*) 'Hello world'
END

that I call in telemac2d.f .

I have added the declaration of hello_world.f in the makefile* files such that they look like :

SRCS= \
hello_world.f \
friction_def.f\
...

And when I try to compile I have the following error message :


Building the who calls who tree for HOMERE_TELEMAC2D and dependents
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/home/globc/barthelemy/HYDRO/MASCARET_DA/MascaretDA/v6p2r1/telemac2d/tel2d_v6p2/sources/hello_world.f:1.1:

SUBROUTINE hello_world()
1
Error: Non-numeric character in statement label at (1)
/home/globc/barthelemy/HYDRO/MASCARET_DA/MascaretDA/v6p2r1/telemac2d/tel2d_v6p2/sources/hello_world.f:1.1:

SUBROUTINE hello_world()
1
Error: Unclassifiable statement at (1)
/home/globc/barthelemy/HYDRO/MASCARET_DA/MascaretDA/v6p2r1/telemac2d/tel2d_v6p2/sources/hello_world.f:3.1:

WRITE(*,*) 'HELLO WORLD'
1
Error: Non-numeric character in statement label at (1)
/home/globc/barthelemy/HYDRO/MASCARET_DA/MascaretDA/v6p2r1/telemac2d/tel2d_v6p2/sources/hello_world.f:3.1:

WRITE(*,*) 'HELLO WORLD'
1
Error: Unclassifiable statement at (1)
/home/globc/barthelemy/HYDRO/MASCARET_DA/MascaretDA/v6p2r1/telemac2d/tel2d_v6p2/sources/hello_world.f:5.1:

END
1
Error: Non-numeric character in statement label at (1)
/home/globc/barthelemy/HYDRO/MASCARET_DA/MascaretDA/v6p2r1/telemac2d/tel2d_v6p2/sources/hello_world.f:5.1:

END
1
Error: Unclassifiable statement at (1)
... The following command failed for the reason above


Can you please tell me what's wrong with my subroutine and what I should to make it OK ?
The administrator has disabled public write access.

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12305

  • riadh
  • riadh's Avatar
Hello

Are you sure that you want to add the new subroutine into source codes of Telemac?
Actually an easier way is to add it simply to the fortran file without any changes in the main sources of Telemac and thus without any recompilation.

If you want really to add a new routine to the source code, you need to
- add it name in the makefile (.f as you have done)
- add the corresponding object file (.o) in the makefile
- add the header into the interface (interface_telemac2d.f), this is optional, but really recommended

Finally, I see that you are more familiar with C language more than Fortran. I invite you to look for a short introduction (course or book) of Fortran. Actually, for a subroutine without any argument, the is no need for parentheses, and thus, it writes:
SUBROUTINE HELLO_WORD
...
END
You can also start by editing an existing subroutine.

With my best regards

Riadh ATA
The administrator has disabled public write access.

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12309

  • special_20
  • special_20's Avatar
riadh wrote:
an easier way is to add it simply to the fortran file without any changes in the main sources of Telemac and thus without any recompilation.

I didn't know about this option can you tell me more ?

I added the header into the interface and I added the corresponding object file in both makefile.gfo and makefile.wnt files (I don't know where to add it in the simple makefile file)but still I've got the same error message when compiling
The administrator has disabled public write access.

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12312

  • special_20
  • special_20's Avatar
OK, now that I have added 6 spaces at the beginning of each line of my hello_world subroutine it compiles and it runs (in the case where I add the subroutine in the sources folder and modify consistently the interface and the makefile).

If I use the fortran file can I make changes into the telemac sources ? I ask the question because when using the fortran file and compiling I've got the following error message :

"telemac2d.f:(.text+0x55dd): undefined reference to `hello_world_'"
The administrator has disabled public write access.

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12314

  • jmhervouet
  • jmhervouet's Avatar
Hello,

Yes, if you put all your modified or new subroutines in the FORTRAN FILE they will have priority over the libraries, and there is no need to change the makefiles.

REgards,

Jean-Michel Hervouet
The administrator has disabled public write access.

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12316

  • special_20
  • special_20's Avatar
Hello Jean-Michel,

OK I see. Still a question remains : does the fortran file have to be in the telemac sources folder and in the folder where there is the .cas file ?
The administrator has disabled public write access.

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12318

  • jmhervouet
  • jmhervouet's Avatar
Hello,

No, this file has to be put with other data like the parameter file and geometry file. FORTRAN FILE is a keyword, so for example:

FORTRAN FILE = yourfile.f

in the *.cas file.

Ragards,

JMH
The administrator has disabled public write access.

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12320

  • special_20
  • special_20's Avatar
Yes that's what I've done, here is the line of my .cas :

FICHIER FORTRAN : 'hello_world.f'

But if I don't copy hello_world.f to the telemac2d sources folder I've got the following error message when compiling :

telemac2d.o: In function `telemac2d_':
telemac2d.f:(.text+0x567e): undefined reference to `hello_world_'
collect2: ld returned 1 exit status
... The following command failed for the reason above

That's what I don't understand.
The administrator has disabled public write access.

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12322

  • pilou1253
  • pilou1253's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 584
  • Thank you received: 106
Hi,

In your fortran file you should put all the subroutines you have modified and those you may create. You should check the manuals or even better the validation cases to have a better illustration.

For example, if you want to call a subroutine called hello_world from subroutine telemac2d.f, you should:
- copy and paste the whole telemac2d.f subroutine in your fortran file (named fortran.f for example)
- add the call to your new subroutine where you wish by writing CALL HELLO_WORLD
- paste the content of your hello_world.f in fortran.f.

This should work. You can use the fortran file to make modifications in several subroutines simultaneously (or even create new ones).

Good luck!
PL
The administrator has disabled public write access.

How to add a fortran subroutine in Telemac ? 10 years 8 months ago #12333

  • special_20
  • special_20's Avatar
OK, this time I understood what JMH meant when he said "put all your modified or new subroutines in the FORTRAN FILE".

Although I see many advantages to write all of my new or modified subroutines in to the FORTRAN FILE I chose, for some reasons, not to use this FORTRAN FILE and declare each of my new subroutines into the makefile and the interface_telemac2d.f file.

Many thanks to all for your explanations ;)
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.