Author Topic: How to initialize all local variables to zero in fortran  (Read 3232 times)

Offline Manuel

  • Single posting newcomer
  • *
  • Posts: 7
How to initialize all local variables to zero in fortran
« 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, but I dont know how to insert this command
Code
-finit-local-zero
into code blocks. Any help would be appreciated!!

Offline gd_on

  • Lives here!
  • ****
  • Posts: 797
Re: How to initialize all local variables to zero in fortran
« Reply #1 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
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline Manuel

  • Single posting newcomer
  • *
  • Posts: 7
Re: How to initialize all local variables to zero in fortran
« Reply #2 on: July 06, 2019, 08:36:49 pm »
Thnks a lot gd_on!! it worked!