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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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 input.in  I have the Fortran program we'll call process.x which takes the input from input.in 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 input.in

Input.in 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:

Code:
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
tcl>




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 ...in case still cannot find solution



This page is a thread posted to the opentalk forum at www.opentalk.org.uk 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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho