LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-15-2006, 09:10 AM   #1
TheBrick
Member
 
Registered: Mar 2006
Location: London
Distribution: SUSE 10.0 Home soon to go (no internet conection), gentoo laptop, slack on development box
Posts: 81

Rep: Reputation: 15
bash + fortran into .exe would this work


O.K please bear with me as I am no coding guru. Maybe this is not the correct area to post so moderators please move if apropeate.

I have a program that I have written which is a combination of fortran and bash. The fortran dose the number crunching and the bash gets random numbers from the internet (as I need truly random numbers) puts the output files in the correct place, alters a few input parameters then re-runs the fortran for a new set of parameters.

I have been alerted to the fact that I can get access to run this code on the universities windows machines. i.e I can have a batch of .exe cued up to run on the spear cpu cycles. I would like to take this opportunity as it would save time. The problem is of course my bash. Some of my parameter changes require re-compiles and hence I would have to have several exe any how but I do not want to have a separate recompile for every parameter change. The main thing the bash script dose that I can't find a way of solving in fortran is the housekeeping. I create various dir in by shell script with variours names like /azrun/parameterA0_point1/paramiterB0_point6/ e.t.c and dump the output files from this run into the dir. I can't seem to do thing like this in fortran.

Could I take the bash.exe from cygwin and some how link this in with my shell script and fortran to create a .exe. Or is there a program to compile bash on windows. I have google but with not much luck. I am sorry this is probably not very clear, I really need a black board to explain properly.

Any sugestions welcome. Apart from rewrite the whole lot in C! (not a dislike of C it that 1. I only know basic C and 2. I do not have time to rewrite 1000s of lines of code that has already been tested and checked e.t.c)
 
Old 08-15-2006, 12:02 PM   #2
asgeirss
Member
 
Registered: Aug 2003
Location: Vancouver, Canada
Distribution: RH, SL
Posts: 37

Rep: Reputation: 15
Two quick suggestions for you:

1 - Check if your university can provide you with access to a unix/linux computing cluster, or if you can get your own account on grid resources. If you are going to be doing a lot of large scale projects in the future, this is probably the best option. There are hundreds of linux-based clusters around the world. This is the first windows-based cluster I have ever heard of.

2 - Keep your fortran code as is, and convert the bash script to a windows shell script. I am far from a windows expert, but I very much doubt there is any way to run a bash script under Windows.

Good luck.
- Dave
 
Old 08-15-2006, 12:47 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
I am not aware of computer/human generated "truly random number" so I would be interested in how this works. I consider bash and shell scripts the same thing. I am somewhat confused since you talk about recompiling bash due to parameter changes but I assume you are really saying you need to recompile your fortran program.

A batch file is simplistic compared to bash scripting but it might be possible to do you what you want. Recompiling the fortran code for window should be easy too.
 
Old 08-15-2006, 01:40 PM   #4
asgeirss
Member
 
Registered: Aug 2003
Location: Vancouver, Canada
Distribution: RH, SL
Posts: 37

Rep: Reputation: 15
Michael,
For random numbers, you can use a physical quantum-mechanical process, like radioactive or atomic excited state decay. The length of time between decays in a sample is *truly* random. This doesn't have a flat distribution, however, so you need to transform it.
- Dave
 
Old 08-15-2006, 01:57 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Thanks for the info. After I posted I had a random idea that it would have to be based on radioactive decay process
 
Old 08-16-2006, 04:44 AM   #6
TheBrick
Member
 
Registered: Mar 2006
Location: London
Distribution: SUSE 10.0 Home soon to go (no internet conection), gentoo laptop, slack on development box
Posts: 81

Original Poster
Rep: Reputation: 15
thanks for the replies guys.

asgeirss:

1. We have linux / unix clusters but these cost more money to the deparment to buy hours on. Really my terminology was wrong. All of the windows machines have a small program to do distributed computing just like the gene folding screen saver or climate change screen savers you can download and help people out. As I understand it jobs are cued up to be sent to these machines when not busy. This windows "cluster" is very under used and hence easy to get time on for cheap.

2. Does anyone know any kind of windows scrips with similar functionality to bash?



michaelk:

You are correct there are no computer generated random numbers, I use

Code:
wget "www.random.org/cgi-bin/randnum?num=1&min=1000&max=9999&col=1"
In a bash script each time I re run my fortran code.

www.random.org uses atmospheric data to create their random numbers pretty dam close.
asgeirss: I know radioactive decay is what you really need but this is pretty good and easy to use in this form with wget

Apiologies I was using shell scrip and bash interchangably as bash is the only shell I use. Yes I meant recompile fortran. End of the day when I wrote this last post and hence my brain had already gone home!

So from these post it seems like my best bet is to find a windows shell script with similar functionality. Any sugestion please?
 
Old 08-16-2006, 06:55 AM   #7
richardash1981
LQ Newbie
 
Registered: Aug 2006
Posts: 25
Blog Entries: 1

Rep: Reputation: 18
In general terms you can run bash under windows using cygwin, but for what you are describing that's overkill.

To make distributing the program you really want it to be a single binary. If all you are doing in bash is the wget invocation, then you could replace it with any of the C URL libraries - curl comes to mind.

Write a simple C wrapper round it to do what you need, all of whose arguments are pointers, and then you can call that as a function/subroutine from Fortran. The easiest way to build the binaries is probably to install cycgwin on a windows host, complete with gcc and your fortran compiler of choice. Just compile the c code to .o, and link it in with the fortran as normal, adding a -l flag to static link libcurl as well, and you should be away.
 
Old 08-16-2006, 07:07 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Well windows batch files do not have the same functionality of a shell script but still may be possible. There are other windows scripting stuff like VB but I'm unfamilar with them like http://www.winguides.com/article.php...uide=scripting.

Last edited by michaelk; 08-16-2006 at 07:09 AM.
 
Old 08-17-2006, 05:16 AM   #9
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
AFAIR the GNU tools are mostly ported to Win. So there should be a "native" bash for Win. Perhaps google can help .
 
Old 08-17-2006, 10:28 PM   #10
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Cygwin provides a nearly complete bash implementation. I use it all the time.

You can invoke bash from Windows when cygwin is present like this:

start c:\cygwin\bin\bash.exe -l myscript

As I understand what OP is doing, he is invoking bash from a fortran program. In this event, the fortran would be changed to support the syntax I describe here and it will work fine.
 
Old 10-03-2006, 06:35 PM   #11
Pingus
Member
 
Registered: Nov 2004
Location: Canada
Distribution: SuSE 9.1 pro/Debian Sarge
Posts: 61

Rep: Reputation: 15
You can execute your Linux bash script as-is from within the MinGW (www.mingw.org). It features a native port of g77, and versions of g95 and gfortran are available off the web (see, e.g., www.g95.org, which I recommend over gfortran).

Good luck.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortran 90/95 compiler for linux, to output .exe? Lordandmaker General 4 10-04-2006 06:12 AM
need xfoil..for which i need fortran compiler to work flipwhy Linux - Newbie 2 08-16-2006 06:57 AM
How do i call bash command from exe in wine jacktheripperis Programming 1 04-12-2006 03:06 AM
bash.exe command Karthikeyan Gurusamy Linux - Newbie 2 02-03-2006 09:21 AM
does linux fortran compiler in fedora 4 support VAX FORTRAN? terrence Programming 17 08-31-2005 08:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration