Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Manuel on July 06, 2019, 01:38:55 am

Title: How to initialize all local variables to zero in fortran
Post by: Manuel on July 06, 2019, 01:38:55 am
Hello, I'm trying to convert an old program from fortran 77  to fortran 90, but the program has a lot of nested subroutines, I changed the way local and global variables worked but the problem is that while calling a subroutine some variables could contain massive numbers like 2.0155e+285 it could be a scalar double precision or an array. I could identify the local variables and initialize it to zero, but this program contains more than 60 subroutines, so I was thinking if there is a way to initialize automatically those local variables to zero. I quick search send me to this link: https://www.cleancss.com/explain-command/gfortran/82451 (https://www.cleancss.com/explain-command/gfortran/82451), but I dont know how to insert this command
Code
-finit-local-zero
into code blocks. Any help would be appreciated!!
Title: Re: How to initialize all local variables to zero in fortran
Post by: gd_on on July 06, 2019, 10:37:41 am
add your option in the project build option.
To do that, right clic in the workspace arrea on the name of your project (so you must use a project to generate your code).
Chhose Build Option... in the menu, you should see a window with your fortran compiler seeting (GNU fortran for me), select "Other options" at general level (or debug or relaease depending how your project is set), then add your option.

gd_on
Title: Re: How to initialize all local variables to zero in fortran
Post by: Manuel on July 06, 2019, 08:36:49 pm
Thnks a lot gd_on!! it worked!