Skip to content

Procedure to query version of json-fortran #505

New issue

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

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

Already on GitHub? # to your account

Closed
awvwgk opened this issue Jan 20, 2022 · 7 comments
Closed

Procedure to query version of json-fortran #505

awvwgk opened this issue Jan 20, 2022 · 7 comments

Comments

@awvwgk
Copy link
Contributor

awvwgk commented Jan 20, 2022

Is there a way to query the version of json-fortran at runtime? Something along the lines of

use json_..._module, only : get_json_fortran_version
implicit none
character(len=:), allocatable :: version_string
call get_json_fortran_version(version_string)
print '(a)', version_string
end

Would be useful for projects which depend on json-fortran and want to report which version they are using at runtime.

@jacobwilliams
Copy link
Owner

No we don't currently have that. We could add it though. I do like the idea.

Currently the .VERSION file has the version number. That is mainly used for the doc deployment and isn't read by the code.

@jacobwilliams
Copy link
Owner

Maybe we can use preprocessing to include that file in a string parameter?

@awvwgk
Copy link
Contributor Author

awvwgk commented Apr 2, 2022

Note that module variables are accessed at compile time not at runtime. Using the version support from 8a33d9b allows to check which version of json-fortran a project was compiled against, however not which version is currently used. For static linking those cases are identical, for dynamic linking those don't have to match.

@jacobwilliams
Copy link
Owner

I don't fully understand the concern. Are you saying somebody might use a newer shared lib with an older set of the .mod files? I would say they shouldn't do that.

@awvwgk
Copy link
Contributor Author

awvwgk commented Apr 2, 2022

Indeed, this is a realistic application as long as you allow setting BUILD_SHARED_LIBS=ON for CMake. Obviously, one has to be careful about compatible versions, but I'm basically using most Fortran libraries via dynamic linking and tight version pins without much problems so far. Having the possibility to query which actual version is used is useful in this scenario.

jacobwilliams added a commit that referenced this issue Apr 3, 2022
@jacobwilliams
Copy link
Owner

I'm still not sure I get it. If you use a fortran library that is exporting modules, you need the library and the mod files. There's no guarantee that using a newer library with old mod files is going to work at all. Is this what you are doing? I would not recommend it!

In any event, what about the function version I just committed?

@awvwgk
Copy link
Contributor Author

awvwgk commented Apr 3, 2022

Thanks, looks great.

There's no guarantee that using a newer library with old mod files is going to work at all. Is this what you are doing? I would not recommend it!

Got it, I'll be careful ;). I'm mostly using dynamic linking in package manager or environment manager controlled setups to avoid hours of recompiling dozens of interdependent libraries and executables. Of course I'm going for static linking if I can't have a package manager handling the version constraints and ensuring compatibility.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants