-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: Use environment variables at load time in f2py
code
#24974
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
Comments
I skimmed the linked thread, but I don't really understand what the idea is here. It seems to have to do with |
Sorry yeah this was not well phrased. The discussion on #24974 was about build systems. The last comment by @2sn as I understood it was related to a more fundamental problem, using environment variables in Though I'll close this since it is already supported ! env_module.f90
MODULE env_module
IMPLICIT NONE
CONTAINS
SUBROUTINE get_env_value(varname, value)
CHARACTER(LEN=*), INTENT(IN) :: varname
CHARACTER(LEN=100), INTENT(OUT) :: value
CHARACTER(LEN=100) :: buffer
INTEGER :: status
CALL GET_ENVIRONMENT_VARIABLE(varname, buffer, STATUS=status)
IF (status == 0) THEN
value = buffer
ELSE
value = 'NOT FOUND'
END IF
END SUBROUTINE get_env_value
END MODULE env_module With In [1]: import envlib
...: import os
...:
...: # Set an environment variable for testing
...: os.environ["TEST_VAR"] = "Hello, Fortran!"
...:
...: # Retrieve the value using the Fortran subroutine
...: value = envlib.env_module.get_env_value("TEST_VAR")
...: print(f"Value of TEST_VAR: {value}")
...:
...: value_not_found = envlib.env_module.get_env_value("NON_EXISTENT_VAR")
...: print(f"Value of NON_EXISTENT_VAR: {value_not_found}")
Value of TEST_VAR: b'Hello, Fortran!'
Value of NON_EXISTENT_VAR: b'NOT FOUND' @2sn let me know if there was something else w.r.t. |
@HaoZeke I may have been using some different compatibility library with F77 at the time I tested it, Ila few yea s Back, but that should not matter. |
...
@HaoZeke wanted to use environment variables in a different way, access them in a library compiled/linked with f2py and these set before loading the module - or used on the module in general. I had not found a way to change that in this case.
...
Originally posted by @2sn in #24874 (comment)
The text was updated successfully, but these errors were encountered: