- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hi!
I need to tell my fortran program which directory to find all the files it will work with. To accomplish this, I use a text parameter through CALL GETARG().
I then
filename = workingdirectory // 'filename.dat'
OPEN(50,FILE=filename,FORM='FORMATTED')
Unfortunately, this leads to the following content in filename:
c:directory1 est svd2b.dat
I need a way to remove all the spaces. Any advice is greatly appreciated!
Thanks!
-- Kai
- Balises:
- Intel® Fortran Compiler
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Use TRIM(workingdirectory)//trim(filename)
Linda
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Thanks! That helps a lot. Unfortunately, that seems to remove spaces from anywhere in the string (since I'm dealing with directory names, it removes some crucial spaces). Is there any way to remove only trailing spaces?
-- Kai :-)
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
TRIM( ) only removes trailing blanks. Standard Fortran since "forever".
It is best you read the manual, or type "trim fortran" into Google .
David
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Thanks David!
You are right, of course, and I did actually google the problem before asking. I just realized that TRIM was not my problem.
As I mentioned above, I use GETARG() to get the directory name as a command line parameter. Unfortunately, it turns out that when the directory name contains spaces, these are treated as different parameters. Arg(h)...
I guess my question is whether there is a way to cap a string so that GETARG understands that it is one string rather than two (or 3,4,5,6)? I've tried Google with no luck, and my guesses of "c:dir 1" and 'c:dir 1' don't work.
Kai :-)
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Use double quotes ( application.exe "here is the argument")and it will work fine.
Just to prove it, here is a simple Fortran console .EXE which I copied to the root directory c: and then ran from the Start..Run...command line as
c:getargument "here is an argument"
which gave the console output shown in the screenshot.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
If you don't want to do this, you can add a space between each argument you retrieve with GETARG.
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable