Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Linking tcl and fortran

Posted by Avarice (Avarice), 24 July 2003
Alright, i've looked and i cannot find a good tutorial about linking fortran and tcl.  I found plenty for C but that doesn't help me.

Alright i have a GUI to input data.  Then it saves data into a file we'll call  I have the Fortran program we'll call process.x which takes the input from and process and gives out several outputs such as output.dat output.plot input.out.  

proc runcommand {} { What do i put here so that it reads or executes or whatever process.x }

i'm so confused.

Thankyou so much Graham

Posted by admin (Graham Ellis), 24 July 2003
Do you want your Fortran program to be able to share variable space with Tcl and/or add extra commands written in Fortran to Tcl?

The reason it's well documented and easy to do this sort of thing in C is because Tcl is written in C, and was originally intended as a language for embedding.  Fortran can also be interfaced to C on most operating systems; I've done it in a Microsoft environment and on Solaris, and if I needed to make Fortran code available in Tcl I would do it as a two-step process
    a) Write a C wrapper around my Fortran Subroutines
    b) Write a C application that called that wrapper and also the Tcl libraries

Posted by Avarice (Avarice), 25 July 2003
Unfortunately i do not have the fortran source code for the program so i can't do that.  what happens is my tcl interface saves a bunch of variables in a file contains a shit load of numbers

The fortran program reads these numbers and runs a simulation

I need to add a run button to my interface so that when the user clicks it then it runs the fortran program.

Posted by Avarice (Avarice), 25 July 2003
btw is there a way to delete/destroy array variables like $int_wx(5)?

Posted by Avarice (Avarice), 25 July 2003
could i just

proc runcommand {} {
   exec immersion_t_2d.x}

?? also what is the deal with | piping things?

Posted by admin (Graham Ellis), 26 July 2003
If you're running a program in another language from Tcl, it doesn't matter what language the second program is written in - that only matters if you're trying to build them into a single executable which is how I initially understood your question.   In your first post, you say "I found plenty for C" ... then that material will be just as applicable for your Fortran program too.

The unset command can be used to delete a variable, and that includes a variable in an array:

bash-2.04$ tcl
tcl>set tab(tom) 30
tcl>set tab(john) 14
tcl>set tab(another) 25
tcl>array names tab
tom another john
tcl>unset tab(john)
tcl>array names tab
tom another

Posted by Don (Don), 11 August 2003
Plese Help,
i really dont know how to start linking tcl and fortran.

Let say i have a function in fortram called AFunct ,... then i need to call it from to Tcl and get the return value(if it can return) , .....

how to wrap any concrete example

Posted by admin (Graham Ellis), 11 August 2003
You really need to use a C "bridge".  See John Ousterhout's book on Tcl which has excellent coverage of this, and then look at Fortran/C documentation so see how to do that link.  You should be able to find plenty of example;  I'm away from my desk for a few days and don't have any examples to hand at the moment, but do follow up in (say) 7 days time if you haven't come up with an answer.  By then I'll be back and able to post some better links / assistance.

Posted by Don (Don), 11 August 2003
oh, thanks for the advice,  i'll look for the book soon,..............     ,

just need to know first that it CAN actually be done, before i really start my long long program.... if it can't be done, then no use that i start with Tcl.

i'll come to the forum again after the 7 day case still cannot find solution

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho