Skip to content

Commit

Permalink
Merge pull request #374 from joakim-hove/windows-transform-restart-kw
Browse files Browse the repository at this point in the history
Windows transform restart kw
  • Loading branch information
joakim-hove authored Apr 12, 2018
2 parents cab388b + 9fd1215 commit b31b055
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/ecl/ecl_smspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,14 +1038,33 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi
char * restart_base;
int i;
tmp_base[0] = '\0';
for (i=0; i < ecl_kw_get_size( restart_kw ); i++)
for (i=0; i < ecl_kw_get_size( restart_kw ); i++)
strcat( tmp_base , ecl_kw_iget_ptr( restart_kw , i ));

restart_base = util_alloc_strip_copy( tmp_base );
if (strlen(restart_base)) { /* We ignore the empty ones. */
char * path;
char * smspec_header;

/*
The conditional block here is to support the following situation:
1. A simulation with a restart has been performed on Posix with path
separator '/'.
2. The simulation is loaded on windows, where the native path
separator is '\'.
This code block will translate '/' -> '\' in the restart keyword which
is read from the summary file.
*/
#ifdef ERT_WINDOWS
for (int i=0; i < strlen(restart_base); i++) {
if (restart_base[i] == UTIL_POSIX_PATH_SEP_CHAR)
restart_base[i] = UTIL_PATH_SEP_CHAR;
}
#endif

util_alloc_file_components( ecl_smspec->header_file , &path , NULL , NULL );
smspec_header = ecl_util_alloc_exfilename( path , restart_base , ECL_SUMMARY_HEADER_FILE , ecl_smspec->formatted , 0);
if (!util_same_file(smspec_header , ecl_smspec->header_file)) /* Restart from the current case is ignored. */ {
Expand Down
3 changes: 3 additions & 0 deletions lib/include/ert/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#define UTIL_PATH_SEP_CHAR '/' /* A simple character used when we want an actual char instance (i.e. not a pointer). */
#endif

#define UTIL_WINDOWS_PATH_SEP_CHAR '\\'
#define UTIL_POSIX_PATH_SEP_CHAR '/'

#define UTIL_NEWLINE_STRING " \n"
#define UTIL_DEFAULT_MKDIR_MODE 0777 /* Directories are by default created with mode a+rwx - and then comes the umask ... */

Expand Down

0 comments on commit b31b055

Please sign in to comment.