Fortran isn't a good language to work with strings, but this is still possible.
You need a variable, where you can store the path. If this path is a constant and already known at compile time, you can simply write
CHARACTER(*), PARAMETER :: fileplace = "/home/vijay/data1/process-folder1/"
The file can then be opened with
OPEN(unit=10, status="old",file=fileplace//"file1.dat")
If you want to change the path during execution time, you have to set a appropriate length for fileplace
and adjust it accordingly, when you want to use it:
CHARACTER(100) :: fileplace
WRITE(fileplace,*) "/home/vijay/data1/process-folder1/"
OPEN(unit=10, status="old", file=TRIM(ADJUSTL(fileplace))//"file1.dat")
The functions ADJUSTL()
and TRIM()
move the content of string to the left to remove any leading whitespace and then cut all trailing whitespace.