Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.fortran

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-03-2005, 08:18 AM
Alexander Slanina
Guest
 
Posts: n/a
Default copying files

Hi folks !

End of my wits

My fortran program produces 4 log-files. After these files are closed
i want them to have other filenames, like old_name + date + time +
".log".

A simple copy would suffice, imho.

How can i do that ?
And how do i "connect" two strings with each other ?

thanks
and best regards

Alex.
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 11-03-2005, 08:43 AM
Jan Vorbrüggen
Guest
 
Posts: n/a
Default Re: copying files

Use the FILENAME functionality of the OPEN statement to give the "proper"
names to those files from the start. There is no (portable) mechanism
within a Fortran program to rename a file. If you don't or can't go this
way, what you need is a rename at the OS level - i.e., the "mv" command
under Unix/Linux or the "ren" command under Windows.

Jan
Reply With Quote
  #3 (permalink)  
Old 11-03-2005, 11:25 AM
[JvO]
Guest
 
Posts: n/a
Default Re: copying files

A possibility:

Character(len=40) :: filename
character(len=10) :: date, time
integer :: ios

call date_and_time(date, time)
filename = "Whatever" // trim(date) // time
Open(unit = 17, file = filename, iostat = ios)

! etc. [JvO]

Reply With Quote
  #4 (permalink)  
Old 11-03-2005, 12:18 PM
meek@skyway.usask.ca
Guest
 
Posts: n/a
Default RE: copying files

In a previous article, =?ISO-8859-1?Q?Jan_Vorbr=FCggen?= <jvorbrueggen-not@mediasec.de> wrote:
>Use the FILENAME functionality of the OPEN statement to give the "proper"
>names to those files from the start. There is no (portable) mechanism
>within a Fortran program to rename a file. If you don't or can't go this
>way, what you need is a rename at the OS level - i.e., the "mv" command
>under Unix/Linux or the "ren" command under Windows.
>
> Jan

... which can be done with a system call.
Chris
Reply With Quote
  #5 (permalink)  
Old 11-03-2005, 12:21 PM
Jan Vorbrüggen
Guest
 
Posts: n/a
Default Re: copying files

> ... which can be done with a system call.

Sure - but that isn't portable, either.

Jan
Reply With Quote
  #6 (permalink)  
Old 11-03-2005, 01:33 PM
meek@skyway.usask.ca
Guest
 
Posts: n/a
Default RE: copying files

In a previous article, =?ISO-8859-1?Q?Jan_Vorbr=FCggen?= <jvorbrueggen-not@mediasec.de> wrote:
>> ... which can be done with a system call.

>
>Sure - but that isn't portable, either.
>
> Jan

I think the capability is portable these days. Unless you
are writing commercial programs, portable
capability is what's important.
(but we do have to know what compiler before we can be
specific about the call format)
Chris
Reply With Quote
  #7 (permalink)  
Old 11-03-2005, 02:57 PM
aca parmakovic
Guest
 
Posts: n/a
Default Re: copying files

Alexander Slanina wrote:
> Hi folks !
>
> End of my wits
>
> My fortran program produces 4 log-files. After these files are closed
> i want them to have other filenames, like old_name + date + time +
> ".log".



Call this subroutine ('filename_date_time ') for your log-files (after
log-files are closed):

subroutine filename_date_time (NameFile, ierr)
use dfwin, only: MoveFile
implicit none
character(*), intent(in):: NameFile !log file name - without '.log'
integer, intent(out):: ierr
character(8):: date
character(10):: time
call date_and_time(date, time)
ierr=
MoveFile(NameFile//'.log.'//char(0),NameFile//date//time//'.log'//char(0))
endsubroutine

It will work under Windows. For Unix, you write own MoveFile wrapper
function (use 'rename').

--
Aca.


Reply With Quote
  #8 (permalink)  
Old 11-03-2005, 04:29 PM
Richard E Maine
Guest
 
Posts: n/a
Default Re: copying files

<meek@skyway.usask.ca> wrote:

> In a previous article, =?ISO-8859-1?Q?Jan_Vorbr=FCggen?=

<jvorbrueggen-not@mediasec.de> wrote:
> >> ... which can be done with a system call.

> >Sure - but that isn't portable, either.

> I think the capability is portable these days. Unless you
> are writing commercial programs, portable
> capability is what's important.


Portability of the capability is certainly the most basic thing, but it
is far from the only one - commercial application or not. In particular,
I think it highly important to document and isolate the use of practices
that require changes when porting from one system to another. In order
to document and isolate them, you first need to know what they are. Thus
I think it important to point them out, as Jan did.

That doesn't mean not to do it - just to make sure that you be aware of
the dependency.

For the case in question, I suspect that opening the file with the
appropriate name is the better choice, as mentioned elsewhere. I can't
tell for sure, though.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to change .xls files into .txt files in SAS Alan Churchill Newsgroup comp.soft-sys.sas 0 06-23-2006 08:20 PM
Re: How to change .xls files into .txt files in SAS SUBSCRIBE SAS-L Chandra Gadde Newsgroup comp.soft-sys.sas 0 06-23-2006 07:18 PM
Re: How to change .xls files into .txt files in SAS Terjeson, Mark Newsgroup comp.soft-sys.sas 0 06-23-2006 07:11 PM
Re: Processing multiple CSV files from a directory David L. Cassell Newsgroup comp.soft-sys.sas 0 05-09-2005 10:56 PM



All times are GMT. The time now is 12:22 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.