ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: SUSE 10.0 Home soon to go (no internet conection), gentoo laptop, slack on development box
Posts: 81
Rep:
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)
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.
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.
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
Distribution: SUSE 10.0 Home soon to go (no internet conection), gentoo laptop, slack on development box
Posts: 81
Original Poster
Rep:
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
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?
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.
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.