Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using uninitialised trunk_sumbal #568

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/offline/cable_driver_common.F90
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ MODULE cable_driver_common_mod
SUBROUTINE cable_driver_init(mpi_grp, trunk_sumbal, NRRRR)
!! Model initialisation routine for the CABLE offline driver.
TYPE(mpi_grp_t), INTENT(IN) :: mpi_grp !! MPI group to use
DOUBLE PRECISION, INTENT(OUT) :: trunk_sumbal
DOUBLE PRECISION, ALLOCATABLE, INTENT(OUT) :: trunk_sumbal
!! Reference value for quasi-bitwise reproducibility checks.
INTEGER, INTENT(OUT) :: NRRRR !! Number of repeated spin-up cycles

Expand Down Expand Up @@ -141,6 +141,7 @@ SUBROUTINE cable_driver_init(mpi_grp, trunk_sumbal, NRRRR)
IF (mpi_grp%rank == 0 .AND. cable_user%consistency_check) THEN
OPEN(NEWUNIT=unit, FILE=filename%trunk_sumbal, STATUS='old', ACTION='READ', IOSTAT=ioerror)
IF(ioerror == 0) THEN
ALLOCATE(trunk_sumbal)
READ(unit, *) trunk_sumbal ! written by previous trunk version
END IF
CLOSE(unit)
Expand Down
12 changes: 6 additions & 6 deletions src/offline/cable_mpimaster.F90
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ SUBROUTINE mpidrv_master (comm, trunk_sumbal, dels, koffset, kend, PLUME, CRU)

! MPI:
INTEGER :: comm ! MPI communicator for comms with the workers
DOUBLE PRECISION, INTENT(IN) :: trunk_sumbal
DOUBLE PRECISION, ALLOCATABLE, INTENT(IN) :: trunk_sumbal
!! Reference value for quasi-bitwise reproducibility checks.
REAL, INTENT(INOUT) :: dels !! Time step size in seconds
INTEGER, INTENT(INOUT) :: koffset !! Timestep to start at
Expand Down Expand Up @@ -315,6 +315,7 @@ SUBROUTINE mpidrv_master (comm, trunk_sumbal, dels, koffset, kend, PLUME, CRU)

INTEGER :: count_bal = 0
INTEGER :: nkend=0
INTEGER :: unit

INTEGER :: kk,m,np,ivt
INTEGER, PARAMETER :: mloop = 30 ! CASA-CNP PreSpinup loops
Expand Down Expand Up @@ -900,7 +901,7 @@ SUBROUTINE mpidrv_master (comm, trunk_sumbal, dels, koffset, kend, PLUME, CRU)
IF(ktau==(kend-1)) THEN

nkend = nkend+1
IF( ABS(new_sumbal-trunk_sumbal) < 1.e-7) THEN
IF(ALLOCATED(trunk_sumbal) .AND. ABS(new_sumbal-trunk_sumbal) < 1.e-7) THEN

PRINT *, ""
PRINT *, &
Expand All @@ -915,13 +916,12 @@ SUBROUTINE mpidrv_master (comm, trunk_sumbal, dels, koffset, kend, PLUME, CRU)
"NB. Offline-parallel runs spinup cycles:", nkend
PRINT *, &
"Internal check shows in this version new_sumbal != trunk sumbal"
PRINT *, "The difference is: ", new_sumbal - trunk_sumbal
PRINT *, &
"Writing new_sumbal to the file:", TRIM(filename%new_sumbal)

!CLN OPEN( 12, FILE = filename%new_sumbal )
!CLN WRITE( 12, '(F20.7)' ) new_sumbal ! written by previous trunk version
!CLN CLOSE(12)
OPEN(newunit=unit, file=filename%new_sumbal)
WRITE(unit, '(F20.7)') new_sumbal ! written by previous trunk version
CLOSE(unit)

ENDIF

Expand Down
2 changes: 1 addition & 1 deletion src/offline/cable_offline_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PROGRAM cable_offline_driver

REAL :: etime ! Declare the type of etime()
TYPE(mpi_grp_t) :: mpi_grp
DOUBLE PRECISION :: trunk_sumbal
DOUBLE PRECISION, ALLOCATABLE :: trunk_sumbal
!! Reference value for quasi-bitwise reproducibility checks.
INTEGER :: NRRRR !! Number of repeated spin-up cycles
REAL :: dels !! Time step size in seconds
Expand Down
11 changes: 6 additions & 5 deletions src/offline/cable_serial.F90
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ MODULE cable_serial

SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME, CRU, site)
!! Offline serial driver.
DOUBLE PRECISION, INTENT(IN) :: trunk_sumbal
DOUBLE PRECISION, ALLOCATABLE, INTENT(IN) :: trunk_sumbal
!! Reference value for quasi-bitwise reproducibility checks.
INTEGER, INTENT(IN) :: NRRRR !! Number of repeated spin-up cycles
REAL, INTENT(INOUT) :: dels !! Time step size in seconds
Expand Down Expand Up @@ -258,6 +258,7 @@ SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME,

INTEGER :: nkend=0
INTEGER :: count_bal = 0
INTEGER :: unit

! for landuse
integer mlon,mlat, mpx
Expand Down Expand Up @@ -766,7 +767,7 @@ SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME,
IF( ktau == kend ) THEN
nkend = nkend+1

IF( ABS(new_sumbal-trunk_sumbal) < 1.e-7) THEN
IF(ALLOCATED(trunk_sumbal) .AND. ABS(new_sumbal-trunk_sumbal) < 1.e-7) THEN

PRINT *, ""
PRINT *, &
Expand All @@ -784,9 +785,9 @@ SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME,
PRINT *, &
"Writing new_sumbal to the file:", TRIM(filename%new_sumbal)

OPEN( 12, FILE = filename%new_sumbal )
WRITE( 12, '(F20.7)' ) new_sumbal ! written by previous trunk version
CLOSE(12)
OPEN(newunit=unit, file=filename%new_sumbal)
WRITE(unit, '(F20.7)') new_sumbal ! written by previous trunk version
CLOSE(unit)

ENDIF
ENDIF
Expand Down