| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| INQUIRE(FILE='some directory specification',EXIST=ex) correctly tests for the existence of a directory with all my Windows compilers (g95,gfortran,lf95) except IVF. Does anybody know the reason for this and what the standard says if anything? Al Greynolds www.ruda.com |
|
#2
| |||
| |||
| Al Greynolds wrote: > INQUIRE(FILE='some directory specification',EXIST=ex) correctly tests > for the existence of a directory with all my Windows compilers > (g95,gfortran,lf95) except IVF. Does anybody know the reason for this > and what the standard says if anything? it would be ambiguous? On some systems, there isn't even a concept of a directory. There may be a "qualifier/account number" associated, but nothing like a directory, so the standard shouldn't really say that a "file" and a "directory" should be detected portably across OS'. There are situations when you actually want to differentiate between a file and a directory, and you can't using this syntax without prior knowledge. Didn't IVF add some extensions specifically for querying directories? CVF does handle directories with the above inquire statement. > > Al Greynolds > www.ruda.com > > -- Gary Scott mailto:garylscott@sbcglobal dot net Fortran Library: http://www.fortranlib.com Support the Original G95 Project: http://www.g95.org -OR- Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html If you want to do the impossible, don't hire an expert because he knows it can't be done. -- Henry Ford |
|
#3
| |||
| |||
| On Aug 21, 2:31*pm, Gary Scott <garylsc...@sbcglobal.net> wrote: > Didn't IVF add some extensions specifically for querying > directories? Yes they did, but I was looking for something that is portable (at least among the compilers I use). Its interesting that they changed the default behavior from CVF to IVF. Anyway its not a big deal just a curiosity. Al |
|
#4
| |||
| |||
| Al Greynolds <awgreynolds@earthlink.net> wrote: > INQUIRE(FILE='some directory specification',EXIST=ex) correctly tests > for the existence of a directory with all my Windows compilers > (g95,gfortran,lf95) except IVF. Does anybody know the reason for this > and what the standard says if anything? The Fortran standard does not even have the concept of a directory (and Fortran has been implemented on systems that don't have such a thing), so it says nothing about it. As I recall, the C standard is actually quite simillar in not having such a concept. Sure there are widely used C libraries that do, but I don't recall that it was directly in the C standard. -- Richard Maine | Good judgement comes from experience; email: last name at domain . net | experience comes from bad judgement. domain: summertriangle | -- Mark Twain |
|
#5
| |||
| |||
| Al Greynolds wrote: > On Aug 21, 2:31 pm, Gary Scott <garylsc...@sbcglobal.net> wrote: > >>Didn't IVF add some extensions specifically for querying >>directories? > > > Yes they did, but I was looking for something that is portable (at > least among the compilers I use). Its interesting that they changed > the default behavior from CVF to IVF. I'm pretty sure I was one that complained about the way DVF or CVF implemented this. I had a specific situation where I needed to differentiate a directory from a file (file names don't have to have extensions/types suffixed to them). So I may or may not have had some tiny influence on it being changed (don't know, assume it would take lots of complaints or some other serious reason to change it). > > Anyway its not a big deal just a curiosity. > > Al -- Gary Scott mailto:garylscott@sbcglobal dot net Fortran Library: http://www.fortranlib.com Support the Original G95 Project: http://www.g95.org -OR- Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html If you want to do the impossible, don't hire an expert because he knows it can't be done. -- Henry Ford |
|
#6
| |||
| |||
| I heard that one trick is to quote the directory name followed by ".nul' as the filename to test for. This was supposed to return a .TRUE. response if the directory existed. But this may be platform dependent. Note: this is a memory, which may be wrong. I personally use non-portable methods myself.. |
|
#7
| |||
| |||
| On 21 aug, 23:18, Al Greynolds <awgreyno...@earthlink.net> wrote: > INQUIRE(FILE='some directory specification',EXIST=ex) correctly tests > for the existence of a directory with all my Windows compilers > (g95,gfortran,lf95) except IVF. *Does anybody know the reason for this > and what the standard says if anything? > > Al Greynoldswww.ruda.com On Windows and Linux/UNIX/OSX a directory contains a special file named ".". You might try: INQUIRE( FILE = 'mydirectory/.', EXIST = exists ) Regards, Arjen |
|
#8
| |||
| |||
| On 22 août, 08:51, Arjen Markus <arjen.mar...@wldelft.nl> wrote: > On 21 aug, 23:18, Al Greynolds <awgreyno...@earthlink.net> wrote: > > > INQUIRE(FILE='some directory specification',EXIST=ex) correctly tests > > for the existence of a directory with all my Windows compilers > > (g95,gfortran,lf95) except IVF. Does anybody know the reason for this > > and what the standard says if anything? > > > Al Greynoldswww.ruda.com > > On Windows and Linux/UNIX/OSX a directory contains a special > file named ".". You might try: > > INQUIRE( FILE = 'mydirectory/.', EXIST = exists ) > > Regards, > > Arjen To be a little bit more portable, I also use an environment variable called for instance DELIMITER which is equals to "\" on Windows and "/" on unix : CHARACTER :: delimiter ... CALL get_environment_variable('DELIMITER',delimiter) INQUIRE(file='mydirectory'//delimiter//'.',EXIST=exist) |
|
#9
| |||
| |||
| On 22 aug, 13:38, fj <francois.j...@irsn.fr> wrote: > On 22 août, 08:51, Arjen Markus <arjen.mar...@wldelft.nl> wrote: > > > > > > > On 21 aug, 23:18, Al Greynolds <awgreyno...@earthlink.net> wrote: > > > > INQUIRE(FILE='some directory specification',EXIST=ex) correctly tests > > > for the existence of a directory with all my Windows compilers > > > (g95,gfortran,lf95) except IVF. *Does anybody know the reason for this > > > and what the standard says if anything? > > > > Al Greynoldswww.ruda.com > > > On Windows and Linux/UNIX/OSX a directory contains a special > > file named ".". You might try: > > > INQUIRE( FILE = 'mydirectory/.', EXIST = exists ) > > > Regards, > > > Arjen > > To be a little bit more portable, I also use an environment variable > called for instance DELIMITER which is equals to "\" on Windows and > "/" on unix : > > CHARACTER :: delimiter > ... > CALL get_environment_variable('DELIMITER',delimiter) > INQUIRE(file='mydirectory'//delimiter//'.',EXIST=exist)- Tekst uit oorspronkelijk bericht niet weergeven - > > - Tekst uit oorspronkelijk bericht weergeven - Of course , though I recently tried to see if a forward slashwould be acceptable on Windows (I used three different compilers) and they all accepted both a / and a \ as a directory delimiter. Regards, Arjen |
|
#10
| |||
| |||
| On 22 août, 14:07, Arjen Markus <arjen.mar...@wldelft.nl> wrote: > On 22 aug, 13:38, fj <francois.j...@irsn.fr> wrote: > > > > > On 22 août, 08:51, Arjen Markus <arjen.mar...@wldelft.nl> wrote: > > > > On 21 aug, 23:18, Al Greynolds <awgreyno...@earthlink.net> wrote: > > > > > INQUIRE(FILE='some directory specification',EXIST=ex) correctlytests > > > > for the existence of a directory with all my Windows compilers > > > > (g95,gfortran,lf95) except IVF. Does anybody know the reason for this > > > > and what the standard says if anything? > > > > > Al Greynoldswww.ruda.com > > > > On Windows and Linux/UNIX/OSX a directory contains a special > > > file named ".". You might try: > > > > INQUIRE( FILE = 'mydirectory/.', EXIST = exists ) > > > > Regards, > > > > Arjen > > > To be a little bit more portable, I also use an environment variable > > called for instance DELIMITER which is equals to "\" on Windows and > > "/" on unix : > > > CHARACTER :: delimiter > > ... > > CALL get_environment_variable('DELIMITER',delimiter) > > INQUIRE(file='mydirectory'//delimiter//'.',EXIST=exist)- Tekst uit oorspronkelijk bericht niet weergeven - > > > - Tekst uit oorspronkelijk bericht weergeven - > > Of course , though I recently tried to see if a forward slash> would be acceptable on Windows (I used three different compilers) > and they all accepted both a / and a \ as a directory delimiter. > > Regards, > > Arjen Even a microsoft compiler ? |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.