Author Topic: How to initialize all local variables to zero in fortran  (Read 374 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: [Select]
-finit-local-zero into code blocks. Any help would be appreciated!!

Offline gd_on

  • Regular
  • ***
  • Posts: 471
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 10 or 7, svn C::B (last version or almost!), WxWidgets 3.1.2, Compilers 8.1.0, 32 bits (sjlj, posix : gcc and gfortran installed in C:\MinGW32) or 64 bits by Compilers 8.1.0 (seh, posix : in C:\MinGW64).

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!