- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm using the TCL/TK code to call an execute file which is written by Fortran code.
I don't know how to exchange the data between these two languages. So I do it through the data file.
When the TCL/TK code generates a project, it will write data to a file with a specific extention inside the project folder. And it calls the Fortran code to read the file and do some calcation. The problem is how to assign the path of the data file to Fortran code. Because every time when a project is generated, it may have different path and different name. And the Fortran code needs to know the path of the project so it can read the data file inside the folder.
Is there any way to solve this problem? I don't have much experience in Fortran.
P.S. I'm using the Intel Fortran Compiler 10 (Windows).
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm using the TCL/TK code to call an execute file which is written by Fortran code.
I don't know how to exchange the data between these two languages. So I do it through the data file.
When the TCL/TK code generates a project, it will write data to a file with a specific extention inside the project folder. And it calls the Fortran code to read the file and do some calcation. The problem is how to assign the path of the data file to Fortran code. Because every time when a project is generated, it may have different path and different name. And the Fortran code needs to know the path of the project so it can read the data file inside the folder.
Is there any way to solve this problem? I don't have much experience in Fortran.
P.S. I'm using the Intel Fortran Compiler 10 (Windows).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm using the TCL/TK code to call an execute file which is written by Fortran code.
I don't know how to exchange the data between these two languages. So I do it through the data file.
When the TCL/TK code generates a project, it will write data to a file with a specific extention inside the project folder. And it calls the Fortran code to read the file and do some calcation. The problem is how to assign the path of the data file to Fortran code. Because every time when a project is generated, it may have different path and different name. And the Fortran code needs to know the path of the project so it can read the data file inside the folder.
Is there any way to solve this problem? I don't have much experience in Fortran.
P.S. I'm using the Intel Fortran Compiler 10 (Windows).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If what you want is to find the location of the running executable, you can do that. You can then use that to construct the path to the data file. First you call the Win32 API GetModuleHandle with an argument of NULL to mean the current running program, and then GetModuleFileName to get the name of that file.
However, if the application will always be run from within Visual Studio, you don't need any path at all, as the default is the project folder.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your program is invoked as "myprog.exe", then the following Windows API will recover the complete path to your executable:
[cpp]CHARACTER(LEN=256) :: fpname INTEGER :: nc ! get local root path from opsys; nc returned as ! stringlength of total path nc = GetModuleFileName(GetModuleHandle('MYPROG.EXE'C), &
fpname, LEN(fpname)) [/cpp]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PROGRAM MAIN
IMPLICIT REAL*8 (A-H,O-Z)
ALLOCATABLE :: X(:), XBASE(:), XOPT(:), XNEW(:), GQ(:), D(:),
1 FVAL(:), PQ(:), HQ(:), VLAG(:), W(:), XPT(:,:), BMAT(:,:),
2 ZMAT(:,:)
OPEN ( 15, file='D:System FileDesktopGIDm1.gidinput.inp' )
READ (15, *) N,NPT,IPRINT,NPTM,NF,NP,NDIM,NH,IDZ,KOPT,KNEW,
1 RHO_FLAG,JUMP_FLAG,FLAG_310
Hi,
I'm using the TCL/TK code to call an execute file which is written by Fortran code.
I don't know how to exchange the data between these two languages. So I do it through the data file.
When the TCL/TK code generates a project, it will write data to a file with a specific extention inside the project folder. And it calls the Fortran code to read the file and do some calcation. The problem is how to assign the path of the data file to Fortran code. Because every time when a project is generated, it may have different path and different name. And the Fortran code needs to know the path of the project so it can read the data file inside the folder.
Is there any way to solve this problem? I don't have much experience in Fortran.
P.S. I'm using the Intel Fortran Compiler 10 (Windows).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know TCL/TK but at the point in the TCL/TK code that runs the fortran program you should be able to append the name of the data file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Something like
package require registry
registrySet "HKEY_CLASSES_ROOT\TclScript\YourProgram\ProjectFolder" (arguments here) ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Carlos,
The program has no idea where the project folder is. There is no information available to it that would give that. All it knows is where the executable is. If that was created in a project, then it is likely that the project folder is one level up in the folder tree, which you can get by appending .. to the executable path (without the filename).
Note that if you call GetModuleHandle, you can pass NULL as the first argument instead of the executable name.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page