diff --git a/src/offline/cable_driver_common.F90 b/src/offline/cable_driver_common.F90 index c76336a7a..a8ad98b58 100644 --- a/src/offline/cable_driver_common.F90 +++ b/src/offline/cable_driver_common.F90 @@ -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 @@ -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) diff --git a/src/offline/cable_mpimaster.F90 b/src/offline/cable_mpimaster.F90 index 00be9085b..6c51099ff 100644 --- a/src/offline/cable_mpimaster.F90 +++ b/src/offline/cable_mpimaster.F90 @@ -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 @@ -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 @@ -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 *, & @@ -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 diff --git a/src/offline/cable_offline_driver.F90 b/src/offline/cable_offline_driver.F90 index d5e5d0f5f..b1497413a 100644 --- a/src/offline/cable_offline_driver.F90 +++ b/src/offline/cable_offline_driver.F90 @@ -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 diff --git a/src/offline/cable_serial.F90 b/src/offline/cable_serial.F90 index 90e27e5fb..2b3b4559d 100644 --- a/src/offline/cable_serial.F90 +++ b/src/offline/cable_serial.F90 @@ -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 @@ -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 @@ -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 *, & @@ -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