On Fri, 04 Nov 2011 13:28:29 +0800, Jinsong Zhao <>
wrote:
>On 2011-11-4 12:32, Geoff wrote:
>> On Fri, 04 Nov 2011 08:19:27 +0800, Jinsong Zhao<>
>> wrote:
>>
>>> On 2011-11-4 5:52, Geoff wrote:
>>>> On Wed, 02 Nov 2011 00:01:58 +0800, Jinsong Zhao<>
>>>> wrote:
>>>>
>>>>> Is it possible to compile the code on Windows? If yes, how to change the
>>>>> code?
>>>>
>>>> Yes.
>>>>
>>>> Delete this line (line 5):
>>>> # include<unistd.h>
>>>> It's for POSIX and it's not needed for Windows and you won't need the
>>>> link and unlink POSIXisms below.
>>>>
>>>> Instead of (line 563):
>>>>
>>>> if ( unlink(file_out_name),link(file_temp_name, file_out_name) == -1
>>>> ||
>>>> unlink(file_temp_name) == -1)
>>>> {
>>>>
>>>> write:
>>>>
>>>> if ( rename(file_temp_name, file_out_name) == -1 )
>>>> {
>>>>
>>>> Instead of (line 606):
>>>>
>>>> if ( unlink ( file_temp_name ) == -1)
>>>> {
>>>>
>>>> write:
>>>>
>>>> if ( remove ( file_temp_name ) == -1)
>>>> {
>>>>
>>>
>>> Thank you very much. it now could be compiled without any error.
>>>
>>> However, it does not work as expected. It gave the following error message:
>>>
>>> E:\f77split>a f77split_prb.f
>>> Splitting f77split_prb.f.
>>>
>>> F77SPLIT: Error!
>>> Cannot move "fsplit.XXXXX" to "alpha.f".
>>>
>>> Regards,
>>> Jinsong
>>
>> Amend line 563 to read:
>> if ( remove(file_out_name), rename(file_temp_name, file_out_name)
>> == -1 )
>
>Sorry for the previous incomplete post...
>
>Thnaks! I have tried this way, the same error message appears.
>
>Regards,
>Jinsong
I see it works perfectly in a *nix environment but fails in Windows.
Windows won't allow you to rename an open file. You will have to
change the order of events in the split_file function to write the
contents and close file_temp before the rename. Sorry not to have seen
this earlier.
|