Hello folks,
I'm trying to write a program that will store data in various folders so that in my post-processing stages I can easily access the relevant data. I am using the windows xp operating system. I want my program to be portable so i thought I'd try to make use of the 'call system' functions to change the current directory. Rather than specifying all the file locations manually I thought the call system commands might make life a bit easier.
As far as I'm aware, the place where the executable is stored (or compiled?) is the 'root' folder and a section of code:
OPEN(UNIT=10,FILE=myfile.dat)
READ(10,*) mydata
CLOSE(UNIT=10)
will cause the program to look in the root folder for a file called 'myfile.dat' and read the data stored therein.
I am trying to change the current directory so that rather than reading from the root folder it reads data from another folder - which I want to specify in the code. I want to give the location of the new folder in relation to the executable rather than giving the full pathname of each data file. I thought an easy (and portable) way to do this was to use the 'call system' function:
call system('cd folder#2')
for example. This was intended to change the current directory to 'folder#2' so that any data stored/read would default to this folder.
I can's seem to get this working and wondered if anyone could point out where I'm going wrong (or perhaps mention a better wat to solve this problem)? I don't want to prescribe all the file locations as I want to give my executable file to my colleagues and have it work on their computers without them having to edit the .f90 code or re-organise their hard-disks to that they have the same layout as mine.
I'd be very grateful for any advice, Bren