How can I get the value from a reference in fortran?












2















I am attempting to update a piece of fortran code that makes a calculation based on inputs from an IDL routine. When the IDL routine makes a call to fortran, it passes along the reference for each variable (IDL CALL_EXTERNAL documentation). The fortran code currently attempts to pass along each reference in the input array to a different subroutine along with the %VAL() tags.



subroutine full_calc(argc, argv)

implicit none

integer*8 :: argc
integer*8, dimension(24) :: argv

call map_gen(%VAL(argv(1)), %VAL(argv(2)), ...)

end subroutine full_calc


This worked fine with the previous code, as it was compiled in such a way as for this to be useful; however, the new compiler gives a warning that I am passing an INTEGER(8) instead of the correct type of the variables. Also, according to this, using %VAL is somewhat dubious.



If this might cause problems, what can I use to get at the values that won't throw warnings everywhere, doesn't require me to have a routine simply for passing along the references, or will at least work on any compiler?



Also, if anyone can just clarify what is really going on here or why, I would appreciate that too.










share|improve this question























  • "Gives a warning" -- does it work? If yes, do you have a need to fix it? INTEGER*8 is not standard conform any more. What I'd do is to use iso_fortran_env, only: int64 and then replace the INTEGER*8 with INTEGER(KIND=int64). As for the %VAL I have no idea.

    – chw21
    Nov 28 '18 at 4:17






  • 2





    Integer*8 was NEVER standard conforming

    – Ian Bush
    Nov 28 '18 at 4:33






  • 4





    I'd make the functions c-interoperable, double-check the compatibility of types, use value keyword instead of %val, check if the calling convention match, update my compiler version, look for related compiler options, look for the text of the warning on internet, check to see if the results are correct, then decide if I can live with the warnings or not

    – Rodrigo Rodrigues
    Nov 28 '18 at 4:39






  • 1





    You haven't provided necessary details on the IDL call; the documentation you link to shows many variations. %VAL is a DEC extension (also supported by Intel compilers). If argv contains addresses of other things, then I could see this working but only on a 64-bit system. I'll note that @RodrigoRodrigues suggestion of value only works if you have an explicit interface for map_gen that gives the procedure the bind(C) attribute. A lot more info is needed to provide a useful answer for you.

    – Steve Lionel
    Nov 28 '18 at 17:23
















2















I am attempting to update a piece of fortran code that makes a calculation based on inputs from an IDL routine. When the IDL routine makes a call to fortran, it passes along the reference for each variable (IDL CALL_EXTERNAL documentation). The fortran code currently attempts to pass along each reference in the input array to a different subroutine along with the %VAL() tags.



subroutine full_calc(argc, argv)

implicit none

integer*8 :: argc
integer*8, dimension(24) :: argv

call map_gen(%VAL(argv(1)), %VAL(argv(2)), ...)

end subroutine full_calc


This worked fine with the previous code, as it was compiled in such a way as for this to be useful; however, the new compiler gives a warning that I am passing an INTEGER(8) instead of the correct type of the variables. Also, according to this, using %VAL is somewhat dubious.



If this might cause problems, what can I use to get at the values that won't throw warnings everywhere, doesn't require me to have a routine simply for passing along the references, or will at least work on any compiler?



Also, if anyone can just clarify what is really going on here or why, I would appreciate that too.










share|improve this question























  • "Gives a warning" -- does it work? If yes, do you have a need to fix it? INTEGER*8 is not standard conform any more. What I'd do is to use iso_fortran_env, only: int64 and then replace the INTEGER*8 with INTEGER(KIND=int64). As for the %VAL I have no idea.

    – chw21
    Nov 28 '18 at 4:17






  • 2





    Integer*8 was NEVER standard conforming

    – Ian Bush
    Nov 28 '18 at 4:33






  • 4





    I'd make the functions c-interoperable, double-check the compatibility of types, use value keyword instead of %val, check if the calling convention match, update my compiler version, look for related compiler options, look for the text of the warning on internet, check to see if the results are correct, then decide if I can live with the warnings or not

    – Rodrigo Rodrigues
    Nov 28 '18 at 4:39






  • 1





    You haven't provided necessary details on the IDL call; the documentation you link to shows many variations. %VAL is a DEC extension (also supported by Intel compilers). If argv contains addresses of other things, then I could see this working but only on a 64-bit system. I'll note that @RodrigoRodrigues suggestion of value only works if you have an explicit interface for map_gen that gives the procedure the bind(C) attribute. A lot more info is needed to provide a useful answer for you.

    – Steve Lionel
    Nov 28 '18 at 17:23














2












2








2








I am attempting to update a piece of fortran code that makes a calculation based on inputs from an IDL routine. When the IDL routine makes a call to fortran, it passes along the reference for each variable (IDL CALL_EXTERNAL documentation). The fortran code currently attempts to pass along each reference in the input array to a different subroutine along with the %VAL() tags.



subroutine full_calc(argc, argv)

implicit none

integer*8 :: argc
integer*8, dimension(24) :: argv

call map_gen(%VAL(argv(1)), %VAL(argv(2)), ...)

end subroutine full_calc


This worked fine with the previous code, as it was compiled in such a way as for this to be useful; however, the new compiler gives a warning that I am passing an INTEGER(8) instead of the correct type of the variables. Also, according to this, using %VAL is somewhat dubious.



If this might cause problems, what can I use to get at the values that won't throw warnings everywhere, doesn't require me to have a routine simply for passing along the references, or will at least work on any compiler?



Also, if anyone can just clarify what is really going on here or why, I would appreciate that too.










share|improve this question














I am attempting to update a piece of fortran code that makes a calculation based on inputs from an IDL routine. When the IDL routine makes a call to fortran, it passes along the reference for each variable (IDL CALL_EXTERNAL documentation). The fortran code currently attempts to pass along each reference in the input array to a different subroutine along with the %VAL() tags.



subroutine full_calc(argc, argv)

implicit none

integer*8 :: argc
integer*8, dimension(24) :: argv

call map_gen(%VAL(argv(1)), %VAL(argv(2)), ...)

end subroutine full_calc


This worked fine with the previous code, as it was compiled in such a way as for this to be useful; however, the new compiler gives a warning that I am passing an INTEGER(8) instead of the correct type of the variables. Also, according to this, using %VAL is somewhat dubious.



If this might cause problems, what can I use to get at the values that won't throw warnings everywhere, doesn't require me to have a routine simply for passing along the references, or will at least work on any compiler?



Also, if anyone can just clarify what is really going on here or why, I would appreciate that too.







reference fortran






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 0:22









kgagekgage

111




111













  • "Gives a warning" -- does it work? If yes, do you have a need to fix it? INTEGER*8 is not standard conform any more. What I'd do is to use iso_fortran_env, only: int64 and then replace the INTEGER*8 with INTEGER(KIND=int64). As for the %VAL I have no idea.

    – chw21
    Nov 28 '18 at 4:17






  • 2





    Integer*8 was NEVER standard conforming

    – Ian Bush
    Nov 28 '18 at 4:33






  • 4





    I'd make the functions c-interoperable, double-check the compatibility of types, use value keyword instead of %val, check if the calling convention match, update my compiler version, look for related compiler options, look for the text of the warning on internet, check to see if the results are correct, then decide if I can live with the warnings or not

    – Rodrigo Rodrigues
    Nov 28 '18 at 4:39






  • 1





    You haven't provided necessary details on the IDL call; the documentation you link to shows many variations. %VAL is a DEC extension (also supported by Intel compilers). If argv contains addresses of other things, then I could see this working but only on a 64-bit system. I'll note that @RodrigoRodrigues suggestion of value only works if you have an explicit interface for map_gen that gives the procedure the bind(C) attribute. A lot more info is needed to provide a useful answer for you.

    – Steve Lionel
    Nov 28 '18 at 17:23



















  • "Gives a warning" -- does it work? If yes, do you have a need to fix it? INTEGER*8 is not standard conform any more. What I'd do is to use iso_fortran_env, only: int64 and then replace the INTEGER*8 with INTEGER(KIND=int64). As for the %VAL I have no idea.

    – chw21
    Nov 28 '18 at 4:17






  • 2





    Integer*8 was NEVER standard conforming

    – Ian Bush
    Nov 28 '18 at 4:33






  • 4





    I'd make the functions c-interoperable, double-check the compatibility of types, use value keyword instead of %val, check if the calling convention match, update my compiler version, look for related compiler options, look for the text of the warning on internet, check to see if the results are correct, then decide if I can live with the warnings or not

    – Rodrigo Rodrigues
    Nov 28 '18 at 4:39






  • 1





    You haven't provided necessary details on the IDL call; the documentation you link to shows many variations. %VAL is a DEC extension (also supported by Intel compilers). If argv contains addresses of other things, then I could see this working but only on a 64-bit system. I'll note that @RodrigoRodrigues suggestion of value only works if you have an explicit interface for map_gen that gives the procedure the bind(C) attribute. A lot more info is needed to provide a useful answer for you.

    – Steve Lionel
    Nov 28 '18 at 17:23

















"Gives a warning" -- does it work? If yes, do you have a need to fix it? INTEGER*8 is not standard conform any more. What I'd do is to use iso_fortran_env, only: int64 and then replace the INTEGER*8 with INTEGER(KIND=int64). As for the %VAL I have no idea.

– chw21
Nov 28 '18 at 4:17





"Gives a warning" -- does it work? If yes, do you have a need to fix it? INTEGER*8 is not standard conform any more. What I'd do is to use iso_fortran_env, only: int64 and then replace the INTEGER*8 with INTEGER(KIND=int64). As for the %VAL I have no idea.

– chw21
Nov 28 '18 at 4:17




2




2





Integer*8 was NEVER standard conforming

– Ian Bush
Nov 28 '18 at 4:33





Integer*8 was NEVER standard conforming

– Ian Bush
Nov 28 '18 at 4:33




4




4





I'd make the functions c-interoperable, double-check the compatibility of types, use value keyword instead of %val, check if the calling convention match, update my compiler version, look for related compiler options, look for the text of the warning on internet, check to see if the results are correct, then decide if I can live with the warnings or not

– Rodrigo Rodrigues
Nov 28 '18 at 4:39





I'd make the functions c-interoperable, double-check the compatibility of types, use value keyword instead of %val, check if the calling convention match, update my compiler version, look for related compiler options, look for the text of the warning on internet, check to see if the results are correct, then decide if I can live with the warnings or not

– Rodrigo Rodrigues
Nov 28 '18 at 4:39




1




1





You haven't provided necessary details on the IDL call; the documentation you link to shows many variations. %VAL is a DEC extension (also supported by Intel compilers). If argv contains addresses of other things, then I could see this working but only on a 64-bit system. I'll note that @RodrigoRodrigues suggestion of value only works if you have an explicit interface for map_gen that gives the procedure the bind(C) attribute. A lot more info is needed to provide a useful answer for you.

– Steve Lionel
Nov 28 '18 at 17:23





You haven't provided necessary details on the IDL call; the documentation you link to shows many variations. %VAL is a DEC extension (also supported by Intel compilers). If argv contains addresses of other things, then I could see this working but only on a 64-bit system. I'll note that @RodrigoRodrigues suggestion of value only works if you have an explicit interface for map_gen that gives the procedure the bind(C) attribute. A lot more info is needed to provide a useful answer for you.

– Steve Lionel
Nov 28 '18 at 17:23












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53510277%2fhow-can-i-get-the-value-from-a-reference-in-fortran%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53510277%2fhow-can-i-get-the-value-from-a-reference-in-fortran%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks