Skip to content

Commit

Permalink
(#359) - Removing wlogn, using logn instead for workers and master
Browse files Browse the repository at this point in the history
  • Loading branch information
C. Carouge committed Aug 6, 2024
1 parent 93b16a1 commit 335aa6f
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 105 deletions.
3 changes: 1 addition & 2 deletions src/offline/cable_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,8 @@ PROGRAM cable_offline_driver
NRRRR, & !
ctime, & ! day count for casacnp
LOY, & ! days in year
count_sum_casa, & ! number of time steps over which casa pools &
count_sum_casa ! number of time steps over which casa pools &
!and fluxes are aggregated (for output)
wlogn = 10001

REAL :: dels ! time step size in seconds

Expand Down
2 changes: 0 additions & 2 deletions src/offline/cable_iovars.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ MODULE cable_IO_vars_module

PUBLIC
PRIVATE r_2, mvtype, mstype
!mrd561 debug
INTEGER :: wlogn

! ============ Timing variables =====================
REAL :: shod ! start time hour-of-day
Expand Down
106 changes: 52 additions & 54 deletions src/offline/cable_mpiworker.F90
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ MODULE cable_mpiworker
INTEGER :: restart_t

! worker's logfile unit
!INTEGER :: wlogn
!INTEGER :: logn
!debug moved to iovars -- easy to pass around

PUBLIC :: mpidrv_worker
Expand All @@ -127,7 +127,7 @@ SUBROUTINE mpidrv_worker (comm)
USE cable_IO_vars_module, ONLY: logn,gswpfile,ncciy,leaps, globalMetfile, &
verbose, fixedCO2,output,check,patchout, &
patch_type,soilparmnew,&
defaultLAI, wlogn, NO_CHECK
defaultLAI, NO_CHECK
USE cable_common_module, ONLY: ktau_gl, kend_gl, knode_gl, cable_user, &
cable_runtime, filename, myhome, &
redistrb, wiltParam, satuParam, CurYear, &
Expand Down Expand Up @@ -319,13 +319,11 @@ SUBROUTINE mpidrv_worker (comm)
IF ( CABLE_USER%LogWorker ) THEN
CALL MPI_Comm_rank (comm, rank, ierr)
WRITE(cRank,FMT='(I4.4)')rank
wlogn = 1000+rank
OPEN(wlogn,FILE="cable_log_"//cRank,STATUS="REPLACE")
logn = wlogn
write(wlogn,*) 'ccc logn, wlogn values: ', logn, wlogn
logn = 1000+rank
OPEN(logn,FILE="cable_log_"//cRank,STATUS="REPLACE")
ELSE
wlogn = 1000
OPEN(wlogn, FILE="/dev/null")
logn = 1000
OPEN(logn, FILE="/dev/null")
ENDIF

! INITIALISATION depending on nml settings
Expand Down Expand Up @@ -461,13 +459,13 @@ SUBROUTINE mpidrv_worker (comm)
& rough,rad,sum_flux,bal)

!mrd561 debug
WRITE(wlogn,*) ' ssat_vec min',MINVAL(soil%ssat_vec),MINLOC(soil%ssat_vec)
WRITE(wlogn,*) ' sfc_vec min',MINVAL(soil%sfc_vec),MINLOC(soil%sfc_vec)
WRITE(wlogn,*) ' wb min',MINVAL(ssnow%wb),MINLOC(ssnow%wb)
CALL flush(wlogn)
WRITE(logn,*) ' ssat_vec min',MINVAL(soil%ssat_vec),MINLOC(soil%ssat_vec)
WRITE(logn,*) ' sfc_vec min',MINVAL(soil%sfc_vec),MINLOC(soil%sfc_vec)
WRITE(logn,*) ' wb min',MINVAL(ssnow%wb),MINLOC(ssnow%wb)
CALL flush(logn)

IF (check%ranges /= NO_CHECK) THEN
WRITE (wlogn, *) "Checking parameter ranges"
WRITE (logn, *) "Checking parameter ranges"
CALL constant_check_range(soil, veg, 0, met)
END IF

Expand Down Expand Up @@ -509,9 +507,9 @@ SUBROUTINE mpidrv_worker (comm)

IF ( CABLE_USER%CASA_DUMP_READ .OR. CABLE_USER%CASA_DUMP_WRITE ) &
CALL worker_casa_dump_types(comm, casamet, casaflux, phen, climate)
WRITE(wlogn,*) 'cable_mpiworker, POPLUC: ', CABLE_USER%POPLUC
WRITE(logn,*) 'cable_mpiworker, POPLUC: ', CABLE_USER%POPLUC
WRITE(*,*) 'cable_mpiworker, POPLUC: ', CABLE_USER%POPLUC
CALL flush(wlogn)
CALL flush(logn)
IF ( CABLE_USER%POPLUC ) &
CALL worker_casa_LUC_types( comm, casapool, casabal)

Expand Down Expand Up @@ -544,7 +542,7 @@ SUBROUTINE mpidrv_worker (comm)


IF( icycle>0 .AND. spincasa) THEN
WRITE(wlogn,*) 'EXT spincasacnp enabled with mloop= ', mloop
WRITE(logn,*) 'EXT spincasacnp enabled with mloop= ', mloop
CALL worker_spincasacnp(dels,kstart,kend,mloop,veg,soil,casabiome,casapool, &
casaflux,casamet,casabal,phen,POP,climate,LALLOC, icomm, ocomm)
SPINconv = .FALSE.
Expand Down Expand Up @@ -599,8 +597,8 @@ SUBROUTINE mpidrv_worker (comm)
! increment total timstep counter
ktau_tot = ktau_tot + 1

WRITE(wlogn,*) 'ktau -',ktau_tot
CALL flush(wlogn)
WRITE(logn,*) 'ktau -',ktau_tot
CALL flush(logn)

! globally (WRT code) accessible kend through USE cable_common_module
ktau_gl = ktau_gl + 1
Expand Down Expand Up @@ -639,7 +637,7 @@ SUBROUTINE mpidrv_worker (comm)

! MPI: receive casa_dump_data for this step from the master
ELSEIF ( IS_CASA_TIME("dread", yyyy, ktau, kstart, koffset, &
kend, ktauday, wlogn) ) THEN
kend, ktauday, logn) ) THEN
CALL MPI_Recv (MPI_BOTTOM, 1, casa_dump_t, 0, ktau_gl, icomm, stat, ierr)
END IF

Expand Down Expand Up @@ -689,8 +687,8 @@ SUBROUTINE mpidrv_worker (comm)
! ENDIF

IF ( IS_CASA_TIME("write", yyyy, ktau, kstart, &
koffset, kend, ktauday, wlogn) ) THEN
! write(wlogn,*), 'IN IS_CASA', casapool%cplant(:,1)
koffset, kend, ktauday, logn) ) THEN
! write(logn,*), 'IN IS_CASA', casapool%cplant(:,1)
! CALL MPI_Send (MPI_BOTTOM,1, casa_t,0,ktau_gl,ocomm,ierr)
ENDIF

Expand Down Expand Up @@ -730,15 +728,15 @@ SUBROUTINE mpidrv_worker (comm)
! ENDIF


CALL flush(wlogn)
CALL flush(logn)
IF (icycle >0 .AND. cable_user%CALL_POP) THEN

IF (CABLE_USER%POPLUC) THEN

WRITE(wlogn,*), 'before MPI_Send casa_LUC'
WRITE(logn,*), 'before MPI_Send casa_LUC'
! worker sends casa updates required for LUC calculations here
CALL MPI_Send (MPI_BOTTOM, 1, casa_LUC_t, 0, 0, ocomm, ierr)
WRITE(wlogn,*), 'after MPI_Send casa_LUC'
WRITE(logn,*), 'after MPI_Send casa_LUC'
! master calls LUCDriver here
! worker receives casa and POP updates
CALL MPI_Recv( POP%pop_grid(1), POP%np, pop_t, 0, 0, icomm, stat, ierr )
Expand Down Expand Up @@ -790,7 +788,7 @@ SUBROUTINE mpidrv_worker (comm)
! ! Write to screen and log file:
! WRITE(*,'(A18,I3,A24)') ' Spinning up: run ',INT(ktau_tot/kend), &
! ' of data set complete...'
! WRITE(wlogn,'(A18,I3,A24)') ' Spinning up: run ',INT(ktau_tot/kend), &
! WRITE(logn,'(A18,I3,A24)') ' Spinning up: run ',INT(ktau_tot/kend), &
! ' of data set complete...'
!
! ! IF not 1st run through whole dataset:
Expand Down Expand Up @@ -885,7 +883,7 @@ SUBROUTINE mpidrv_worker (comm)

! Close log file
! MPI: closes handle to /dev/null in workers
CLOSE(wlogn)
CLOSE(logn)


RETURN
Expand Down Expand Up @@ -6800,7 +6798,7 @@ SUBROUTINE worker_restart_type (comm, canopy, air)
!mcd287 CALL MPI_Reduce (tsize, tsize, 1, MPI_INTEGER, MPI_SUM, 0, comm, ierr)
WRITE(*,*) 'b4 reduce wk', tsize, MPI_DATATYPE_NULL, 1, MPI_INTEGER, MPI_SUM, 0, comm, ierr
CALL flush(6)
!call flush(wlogn)
!call flush(logn)
CALL MPI_Reduce (tsize, MPI_DATATYPE_NULL, 1, MPI_INTEGER, MPI_SUM, 0, comm, ierr)

DEALLOCATE(types)
Expand Down Expand Up @@ -7234,7 +7232,7 @@ SUBROUTINE worker_spincasacnp( dels,kstart,kend,mloop,veg,soil,casabiome,casapoo
USE biogeochem_mod, ONLY : biogeochem

!mrd561 debug
USE cable_IO_vars_module, ONLY: wlogn
USE cable_IO_vars_module, ONLY: logn

IMPLICIT NONE
!CLN CHARACTER(LEN=99), INTENT(IN) :: fcnpspin
Expand Down Expand Up @@ -7576,11 +7574,11 @@ SUBROUTINE worker_spincasacnp( dels,kstart,kend,mloop,veg,soil,casabiome,casapoo
ENDDO ! end of nyear

ENDDO ! end of nloop
WRITE(wlogn,*) 'b4 MPI_SEND'
WRITE(logn,*) 'b4 MPI_SEND'
CALL MPI_Send (MPI_BOTTOM, 1, casa_t, 0, 0, ocomm, ierr)
WRITE(wlogn,*) 'after MPI_SEND'
WRITE(logn,*) 'after MPI_SEND'
IF(CABLE_USER%CALL_POP) CALL worker_send_pop (POP, ocomm)
WRITE(wlogn,*) 'cplant', casapool%cplant
WRITE(logn,*) 'cplant', casapool%cplant

END SUBROUTINE worker_spincasacnp

Expand All @@ -7604,7 +7602,7 @@ SUBROUTINE worker_CASAONLY_LUC( dels,kstart,kend,veg,soil,casabiome,casapool, &
USE biogeochem_mod, ONLY : biogeochem

!mrd561 debug
USE cable_IO_vars_module, ONLY: wlogn
USE cable_IO_vars_module, ONLY: logn

IMPLICIT NONE
!CLN CHARACTER(LEN=99), INTENT(IN) :: fcnpspin
Expand Down Expand Up @@ -7703,45 +7701,45 @@ SUBROUTINE worker_CASAONLY_LUC( dels,kstart,kend,veg,soil,casabiome,casapool, &
ENDIF

IF(idoy==mdyear) THEN ! end of year
WRITE(wlogn,*) 'b4 MPI_SEND,casa_LUC_t', casapool%cplant(:,2)
CALL flush(wlogn)
WRITE(logn,*) 'b4 MPI_SEND,casa_LUC_t', casapool%cplant(:,2)
CALL flush(logn)
CALL MPI_Send (MPI_BOTTOM, 1, casa_LUC_t, 0, 0, ocomm, ierr)
WRITE(wlogn,*) 'after MPI_SEND,casa_LUC_t', casapool%cplant(:,2)
CALL flush(wlogn)
WRITE(logn,*) 'after MPI_SEND,casa_LUC_t', casapool%cplant(:,2)
CALL flush(logn)
StemNPP(:,1) = casaflux%stemnpp
StemNPP(:,2) = 0.0

CALL MPI_Comm_rank (icomm, rank, ierr)
WRITE(wlogn,*)
WRITE(wlogn,*),'rank receiving pop_grid from master', rank
!$ write(wlogn,*) 'b4 MPI_Recv, pop_t cmass: ', POP%pop_grid%cmass_sum
!$ write(wlogn,*) 'b4 MPI_Recv, pop_t LU: ', POP%pop_grid%LU
WRITE(logn,*)
WRITE(logn,*),'rank receiving pop_grid from master', rank
!$ write(logn,*) 'b4 MPI_Recv, pop_t cmass: ', POP%pop_grid%cmass_sum
!$ write(logn,*) 'b4 MPI_Recv, pop_t LU: ', POP%pop_grid%LU
CALL MPI_Recv( POP%pop_grid(1), POP%np, pop_t, 0, 0, icomm, stat, ierr )
!$ write(wlogn,*)
!$ write(wlogn,*) 'after MPI_Recv, pop_t cmass: ', POP%pop_grid%cmass_sum
WRITE(wlogn,*) 'after MPI_Recv, pop_t '
CALL flush(wlogn)
!$ write(logn,*)
!$ write(logn,*) 'after MPI_Recv, pop_t cmass: ', POP%pop_grid%cmass_sum
WRITE(logn,*) 'after MPI_Recv, pop_t '
CALL flush(logn)
IF (cable_user%CALL_POP .AND. POP%np.GT.0) THEN ! CALL_POP
WRITE(wlogn,*), 'b4 POPdriver', POP%pop_grid%cmass_sum
WRITE(logn,*), 'b4 POPdriver', POP%pop_grid%cmass_sum
CALL POPdriver(casaflux,casabal,veg, POP)

ENDIF
!$ write(wlogn,*)
!$ write(wlogn,*) 'after POPstep cmass: ', POP%pop_grid%cmass_sum
WRITE(wlogn,*) 'after POPstep ', POP%pop_grid%cmass_sum
CALL flush(wlogn)
!$ write(logn,*)
!$ write(logn,*) 'after POPstep cmass: ', POP%pop_grid%cmass_sum
WRITE(logn,*) 'after POPstep ', POP%pop_grid%cmass_sum
CALL flush(logn)
CALL worker_send_pop (POP, ocomm)
WRITE(wlogn,*) 'after worker_send_pop'
CALL flush(wlogn)
WRITE(logn,*) 'after worker_send_pop'
CALL flush(logn)
ENDIF


ENDDO
! receive updates to CASA pools resulting from LUC
WRITE(wlogn,*)
WRITE(wlogn,*) 'b4 mpi_recv casa_LUC_t '
WRITE(logn,*)
WRITE(logn,*) 'b4 mpi_recv casa_LUC_t '
CALL MPI_Recv (MPI_BOTTOM, 1, casa_LUC_t, 0, nyear, icomm, stat, ierr)
WRITE(wlogn,*) 'after mpi_recv casa_LUC_t: '
WRITE(logn,*) 'after mpi_recv casa_LUC_t: '
ENDDO

END SUBROUTINE WORKER_CASAONLY_LUC
Expand Down
3 changes: 0 additions & 3 deletions src/offline/casa_cable.F90
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ SUBROUTINE POPdriver(casaflux,casabal,veg, POP)
!! vh_js !!
INTEGER, allocatable :: Iw(:) ! array of indices corresponding to woody (shrub or forest) tiles

! INTEGER, INTENT(IN) :: wlogn
INTEGER , parameter :: wlogn=6

if (.NOT.Allocated(LAIMax)) allocate(LAIMax(mp))
if (.NOT.Allocated(Cleafmean)) allocate(Cleafmean(mp))
if (.NOT.Allocated(Crootmean)) allocate(Crootmean(mp))
Expand Down
2 changes: 0 additions & 2 deletions src/science/casa-cnp/bgcdriver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ SUBROUTINE bgcdriver(ktau,kstart,kend,dels,met,ssnow,canopy,veg,soil, &
CHARACTER :: cyear*4
CHARACTER :: ncfile*99

INTEGER , parameter :: wlogn=6

IF ( .NOT. dump_read ) THEN ! construct casa met and flux inputs from current CABLE run

IF ( TRIM(cable_user%MetType) .EQ. 'cru' ) THEN
Expand Down
5 changes: 2 additions & 3 deletions src/science/gw_hydro/cable_gw_hydro.F90
Original file line number Diff line number Diff line change
Expand Up @@ -910,10 +910,9 @@ END SUBROUTINE smoistgw
! Output
! ssnow
SUBROUTINE soil_snow_gw(dels, soil, ssnow, canopy, met, bal, veg)
USE cable_IO_vars_module, ONLY: wlogn

USE cable_common_module
USE snow_processes_soil_thermal_mod, ONLY : snow_processes_soil_thermal
USE snow_processes_soil_thermal_mod, ONLY : snow_processes_soil_thermal

REAL , INTENT(IN) :: dels ! integration time step (s)
TYPE(soil_parameter_type), INTENT(INOUT) :: soil
TYPE(soil_snow_type) , INTENT(INOUT) :: ssnow
Expand Down
2 changes: 0 additions & 2 deletions src/science/pop/POP.F90
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ SUBROUTINE POPStep(POP, StemNPP, disturbance_interval, disturbance_intensity,LAI
INTEGER(i4b), ALLOCATABLE :: it(:)
REAL(dp):: dallocW

!INTEGER, INTENT(IN) :: wlogn
pop%it_pop = pop%it_pop + 1

!it = pop%it_pop(1)
Expand All @@ -373,7 +372,6 @@ SUBROUTINE POPStep(POP, StemNPP, disturbance_interval, disturbance_intensity,LAI
!$
!$ CALL GetPatchFrequencies(POP,it)

!call flush(wlogn)
IF (PRESENT(precip)) THEN
IF(PRESENT(StemNPP_av)) THEN
CALL PatchAnnualDynamics(POP, StemNPP,NPPtoGPP,disturbance_interval, it, precip=precip,StemNPP_av=StemNPP_av)
Expand Down
4 changes: 1 addition & 3 deletions src/science/sli/cable_sli_main.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ SUBROUTINE sli_main(ktau, dt, veg, soil, ssnow, met, canopy, air, rad, SEB_only)
USE sli_roots, ONLY: setroots, getrex
USE sli_solve, ONLY: solve

USE cable_IO_vars_module, ONLY: wlogn, verbose
USE cable_IO_vars_module, ONLY: verbose

IMPLICIT NONE
!INTEGER, INTENT(IN) :: wlogn
!INTEGER :: wlogn = 10001 !use correct value from io_vars module
REAL, INTENT(IN) :: dt
TYPE(veg_parameter_type), INTENT(INOUT) :: veg ! all r_1
TYPE(soil_parameter_type), INTENT(INOUT) :: soil ! all r_1
Expand Down
Loading

0 comments on commit 335aa6f

Please sign in to comment.