Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scr: update docs to document return value in Fortran failure case #291

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/rst/users/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ the call allocates and returns a pointer to a string holding the value of the pa
The caller is responsible for calling :code:`free` to release the returned string.
If the parameter has not been set, :code:`NULL` is returned.
For Fortran applications, the value is returned as a string in the :code:`VAL` argument.
If the parameter has not been set, :code:`IERROR` is set to :code:`SCR_FAILURE` in Fortran.

To unset a value, one specifies the parameter name with an empty value
in the form of a :code:`key=` string as the :code:`config` argument.
Expand Down
1 change: 1 addition & 0 deletions src/scr.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern "C" {

/* constants returned from SCR functions for success and failure */
#define SCR_SUCCESS (0)
#define SCR_FAILURE (1)

/* maximum characters in a filename returned by SCR */
#define SCR_MAX_FILENAME 1024
Expand Down
2 changes: 0 additions & 2 deletions src/scr_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#ifndef SCR_UTIL_H
#define SCR_UTIL_H

#define SCR_FAILURE (1)

#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
Expand Down
22 changes: 11 additions & 11 deletions src/scrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ FORTRAN_API void FORT_CALL scr_config_(char* cfg FORT_MIXED_LEN(cfg_len),
/* convert name from a Fortran string to C string */
char cfg_tmp[SCR_MAX_FILENAME];
if (scr_fstr2cstr(cfg, cfg_len, cfg_tmp, sizeof(cfg_tmp)) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAILURE;
return;
}

const char *val_tmp = SCR_Config(cfg_tmp);
if (!val_tmp) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAILURE;
return;
}
/* TODO: there is a memory leak here. scr_config, when called to get a value
Expand All @@ -179,7 +179,7 @@ FORTRAN_API void FORT_CALL scr_config_(char* cfg FORT_MIXED_LEN(cfg_len),

/* convert val to Fortran string */
if (scr_cstr2fstr(val_tmp, val, val_len) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAILURE;
return;
}

Expand All @@ -200,7 +200,7 @@ FORTRAN_API void FORT_CALL scr_have_restart_(int* flag, char* name FORT_MIXED_LE
if (*flag) {
/* convert name to Fortran string */
if (scr_cstr2fstr(name_tmp, name, name_len) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAIULRE;
return;
}
}
Expand All @@ -216,7 +216,7 @@ FORTRAN_API void FORT_CALL scr_start_restart_(char* name FORT_MIXED_LEN(name_len

/* convert name to Fortran string */
if (scr_cstr2fstr(name_tmp, name, name_len) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAIULRE;
return;
}

Expand Down Expand Up @@ -262,7 +262,7 @@ FORTRAN_API void FORT_CALL scr_start_output_(char* name FORT_MIXED_LEN(name_len)
/* convert name from a Fortran string to C string */
char name_tmp[SCR_MAX_FILENAME];
if (scr_fstr2cstr(name, name_len, name_tmp, sizeof(name_tmp)) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAIULRE;
return;
}

Expand Down Expand Up @@ -290,7 +290,7 @@ FORTRAN_API void FORT_CALL scr_route_file_(char* name FORT_MIXED_LEN(name_len),
/* convert filename from a Fortran string to C string */
char name_tmp[SCR_MAX_FILENAME];
if (scr_fstr2cstr(name, name_len, name_tmp, sizeof(name_tmp)) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAIULRE;
return;
}

Expand All @@ -300,7 +300,7 @@ FORTRAN_API void FORT_CALL scr_route_file_(char* name FORT_MIXED_LEN(name_len),

/* convert filename from C to Fortran string */
if (scr_cstr2fstr(file_tmp, file, file_len) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAIULRE;
return;
}

Expand All @@ -316,7 +316,7 @@ FORTRAN_API void FORT_CALL scr_current_(char* name FORT_MIXED_LEN(name_len), int
/* convert name from a Fortran string to C string */
char name_tmp[SCR_MAX_FILENAME];
if (scr_fstr2cstr(name, name_len, name_tmp, sizeof(name_tmp)) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAIULRE;
return;
}

Expand All @@ -330,7 +330,7 @@ FORTRAN_API void FORT_CALL scr_drop_(char* name FORT_MIXED_LEN(name_len), int* i
/* convert name from a Fortran string to C string */
char name_tmp[SCR_MAX_FILENAME];
if (scr_fstr2cstr(name, name_len, name_tmp, sizeof(name_tmp)) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAIULRE;
return;
}

Expand All @@ -344,7 +344,7 @@ FORTRAN_API void FORT_CALL scr_delete_(char* name FORT_MIXED_LEN(name_len), int*
/* convert name from a Fortran string to C string */
char name_tmp[SCR_MAX_FILENAME];
if (scr_fstr2cstr(name, name_len, name_tmp, sizeof(name_tmp)) != 0) {
*ierror = !SCR_SUCCESS;
*ierror = SCR_FAIULRE;
return;
}

Expand Down