Opened 8 years ago

Closed 8 years ago

#187 closed defect (fixed)

Variables in hydrol.f90 used before initialization

Reported by: ajornet Owned by: somebody
Priority: major Milestone:
Component: Anthropogenic processes Version: trunc
Keywords: profil_froz_hydro, profil_froz_hydro_ns, kk, kk_moy, temp_hydro Cc: fabienne.maignan@…

Description

This part of code is using those variables. They have been allocated but not initilized with a value.

hydrol.f90 -> hydrol_init:
Allocation:

1667	    IF (ok_freeze_cwrr) THEN
1668	       ALLOCATE (profil_froz_hydro(kjpindex, nslm),stat=ier)
1669	       IF (ier /= 0) CALL ipslerr_p(3,'hydrol_init','Problem in allocate of variable profil_froz_hydrol','','')
1670	
1671	       ALLOCATE (profil_froz_hydro_ns(kjpindex, nslm, nstm),stat=ier)
1672	       IF (ier /= 0) CALL ipslerr_p(3,'hydrol_init','Problem in allocate of variable profil_froz_hydro_ns','','')
1673	
1674	       ALLOCATE (temp_hydro(kjpindex, nslm),stat=ier)
1675	       IF (ier /= 0) CALL ipslerr_p(3,'hydrol_init','Problem in allocate of variable temp_hydro','','')
1676	    ENDIF

Next references of this variables, which are used:

1974	       IF (ok_freeze_cwrr) THEN 
1975	          CALL setvar_p (profil_froz_hydro, val_exp, 'NO_KEYWORD', zero)
1976	          CALL setvar_p (profil_froz_hydro_ns, val_exp, 'NO_KEYWORD', zero)
1977	          CALL setvar_p (kk, val_exp, 'NO_KEYWORD', 276.48)
1978	          CALL setvar_p (kk_moy, val_exp, 'NO_KEYWORD', 276.48)
1979	          CALL setvar_p (temp_hydro, val_exp, 'NO_KEYWORD', 280.)
1980	       ENDIF

Valgrind output:

  584 ==13380== Conditional jump or move depends on uninitialised value(s)
  585 ==13380==    at 0x2D4D443: sechiba_io_p_mp_r20setvar_p_ (sechiba_io_p.f90:378)
  586 ==13380==    by 0x2123CDB: hydrol_mp_hydrol_init_ (hydrol.f90:2558)
  587 ==13380==    by 0x20A0F8F: hydrol_mp_hydrol_initialize_ (hydrol.f90:548)
  588 ==13380==    by 0x99F427: sechiba_mp_sechiba_initialize_ (in /home/orchidee04/ajornet/bin/orchidee_ol)
  589 ==13380==    by 0x5C0474: intersurf_mp_intersurf_initialize_2d_ (intersurf.f90:362)
  590 ==13380==    by 0x506BA6: MAIN__ (in /home/orchidee04/ajornet/bin/orchidee_ol)
  591 ==13380==    by 0x43D9BB: main (in /home/orchidee04/ajornet/bin/orchidee_ol)
  592 ==13380==  Uninitialised value was created by a heap allocation
  593 ==13380==    at 0xBAF1A2E: malloc (vg_replace_malloc.c:270)
  594 ==13380==    by 0x391A168: for_alloc_allocatable (in /home/orchidee04/ajornet/bin/orchidee_ol)
  595 ==13380==    by 0x211A73C: hydrol_mp_hydrol_init_ (hydrol.f90:2244)
  596 ==13380==    by 0x20A0F8F: hydrol_mp_hydrol_initialize_ (hydrol.f90:548)
  597 ==13380==    by 0x99F427: sechiba_mp_sechiba_initialize_ (in /home/orchidee04/ajornet/bin/orchidee_ol)
  598 ==13380==    by 0x5C0474: intersurf_mp_intersurf_initialize_2d_ (intersurf.f90:362)
  599 ==13380==    by 0x506BA6: MAIN__ (in /home/orchidee04/ajornet/bin/orchidee_ol)
  600 ==13380==    by 0x43D9BB: main (in /home/orchidee04/ajornet/bin/orchidee_ol)

Change History (2)

comment:1 Changed 8 years ago by ajornet

Add variable initializations at the end of hydrol_var_init. Check commit at r2936.

profil_froz_hydro(:,:) = 0.0 
profil_froz_hydro_ns(:,:,:) = 0.0 
temp_hydro(:,:) = 0.0 

source:/perso/albert.jornet/ORCHIDEE-MICT/src_sechiba/hydrol.f90

comment:2 Changed 8 years ago by jgipsl

  • Resolution set to fixed
  • Status changed from new to closed

Correction done in the trunk rev [2943].

setvar_p is removed and the variables are initialized directly as set above.

Note: See TracTickets for help on using tickets.