- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I have read forums on string concatenation in fortran 90 such as http://software.intel.com/en-us/forums/showthread.php?t=51416&o=a&s=lr&wapkw=%28atom%29 but I couldn't find the solution to my problem. A portion of my code which concatenates the file name and its path is as follows:
character*255 :: ifilename, ipath, ifull
ifilename='test.dat'
ipath='c:\\data\'
ifull=ipath//ifilename
open (unit = 1 , file = ifull , form='formatted', status = "old", iostat = status)
But ifull does not have the full path of the file and contains only the value of ipath and therefore OPEN statement cannot find the file. I build my code by ifort command in windows. I appreciate any help.
I have read forums on string concatenation in fortran 90 such as http://software.intel.com/en-us/forums/showthread.php?t=51416&o=a&s=lr&wapkw=%28atom%29 but I couldn't find the solution to my problem. A portion of my code which concatenates the file name and its path is as follows:
character*255 :: ifilename, ipath, ifull
ifilename='test.dat'
ipath='c:\\data\'
ifull=ipath//ifilename
open (unit = 1 , file = ifull , form='formatted', status = "old", iostat = status)
But ifull does not have the full path of the file and contains only the value of ipath and therefore OPEN statement cannot find the file. I build my code by ifort command in windows. I appreciate any help.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The thing you overlook is that in Fortran a string is padded with blanks. So:
ipath = 'c:\data' is actually ipath = 'c:\data... blanks until position 255 ...'
So: ifull = ipath // ifilename puts 255 characters into ifull, followed by another 255 characters.
But then the result has to be truncated to 255 characters again, thus the concatenation has no effect.
Use:
ifull = trim(ipath) // ifilename
instead - trim() removes the trailing blanks.
Regards,
Arjen
ipath = 'c:\data' is actually ipath = 'c:\data... blanks until position 255 ...'
So: ifull = ipath // ifilename puts 255 characters into ifull, followed by another 255 characters.
But then the result has to be truncated to 255 characters again, thus the concatenation has no effect.
Use:
ifull = trim(ipath) // ifilename
instead - trim() removes the trailing blanks.
Regards,
Arjen
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The thing you overlook is that in Fortran a string is padded with blanks. So:
ipath = 'c:\data' is actually ipath = 'c:\data... blanks until position 255 ...'
So: ifull = ipath // ifilename puts 255 characters into ifull, followed by another 255 characters.
But then the result has to be truncated to 255 characters again, thus the concatenation has no effect.
Use:
ifull = trim(ipath) // ifilename
instead - trim() removes the trailing blanks.
Regards,
Arjen
ipath = 'c:\data' is actually ipath = 'c:\data... blanks until position 255 ...'
So: ifull = ipath // ifilename puts 255 characters into ifull, followed by another 255 characters.
But then the result has to be truncated to 255 characters again, thus the concatenation has no effect.
Use:
ifull = trim(ipath) // ifilename
instead - trim() removes the trailing blanks.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to trim the trailing spaces from ipath before concatenating it with the file name.
ifull = ipath(:len_trim(ipath))//ifilename
Les
ifull = ipath(:len_trim(ipath))//ifilename
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page