Reputation: 59
I know that Fortran 2003 contains the intrinsic subroutine get_environment_variable, but I can't get it to return the variable I want. Here is a test program:
program main
implicit none
character(len=10) :: time
call get_environment_variable("t", time)
write(6,*) time
end program main
I then set t=2010010100 (or something) in the shell, compile and run, and the only thing written is a blank line. I don't understand: I'm using gfortran with the flag -std=f2003, this should be simple, what's being hung up? I suspect it's quite simple and the answer will expose my ignorance....but thank you anyways!
Upvotes: 1
Views: 910
Reputation: 11
In bash you need to export the environment variable, otherwise it won't be passed to the program.
PS you do this using the "export" command, e.g.
export t=2010010100
Upvotes: 1