[10042] | 1 | MODULE cpl_rnf_1d |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE cpl_rnf_1d *** |
---|
| 4 | !! Ocean forcing: River runoff passed from the atmosphere using |
---|
| 5 | !! 1D array. One value per river. |
---|
| 6 | !!===================================================================== |
---|
| 7 | !! History : ?.? ! 2018-01 (D. Copsey) Initial setup |
---|
| 8 | !!---------------------------------------------------------------------- |
---|
| 9 | |
---|
| 10 | !!---------------------------------------------------------------------- |
---|
| 11 | !! cpl_rnf_1d_init : runoffs initialisation |
---|
| 12 | !!---------------------------------------------------------------------- |
---|
| 13 | |
---|
| 14 | #if defined key_oasis3 |
---|
| 15 | USE mod_oasis ! OASIS3-MCT module |
---|
| 16 | #endif |
---|
| 17 | USE timing ! Timing |
---|
| 18 | USE in_out_manager ! I/O units |
---|
| 19 | USE lib_mpp ! MPP library |
---|
| 20 | USE iom |
---|
| 21 | USE wrk_nemo ! Memory allocation |
---|
| 22 | USE dom_oce ! Domain sizes (for grid box area e1e2t) |
---|
| 23 | USE sbc_oce ! Surface boundary condition: ocean fields |
---|
| 24 | USE lib_fortran, ONLY: DDPDD |
---|
| 25 | |
---|
| 26 | IMPLICIT NONE |
---|
| 27 | PRIVATE |
---|
| 28 | |
---|
| 29 | PUBLIC cpl_rnf_1d_init ! routine called in nemo_init |
---|
| 30 | PUBLIC cpl_rnf_1d_to_2d ! routine called in sbccpl.F90 |
---|
| 31 | |
---|
| 32 | TYPE, PUBLIC :: RIVERS_DATA !: Storage for river outflow data |
---|
| 33 | INTEGER, POINTER, DIMENSION(:,:) :: river_number !: River outflow number |
---|
| 34 | REAL(wp), POINTER, DIMENSION(:) :: river_area ! 1D array listing areas of each river outflow (m2) |
---|
| 35 | COMPLEX(wp), POINTER, DIMENSION(:) :: river_area_c ! Comlex version of river_area for use in bit reproducible sums (m2) |
---|
| 36 | END TYPE RIVERS_DATA |
---|
| 37 | |
---|
| 38 | TYPE(RIVERS_DATA), PUBLIC, TARGET :: rivers !: River data |
---|
| 39 | |
---|
| 40 | INTEGER, PUBLIC :: nn_cpl_river ! Maximum number of rivers being passed through the coupler |
---|
| 41 | INTEGER, PUBLIC :: runoff_id ! OASIS coupling id used in oasis_get command |
---|
| 42 | LOGICAL :: ln_print_river_info ! Diagnostic prints of river coupling information |
---|
| 43 | |
---|
| 44 | CONTAINS |
---|
| 45 | |
---|
| 46 | SUBROUTINE cpl_rnf_1d_init |
---|
| 47 | !!---------------------------------------------------------------------- |
---|
| 48 | !! *** SUBROUTINE cpl_rnf_1d_init *** |
---|
| 49 | !! |
---|
| 50 | !! ** Purpose : - Read in file for river outflow numbers. |
---|
| 51 | !! Calculate 2D area of river outflow points. |
---|
| 52 | !! Called from nemo_init (nemogcm.F90). |
---|
| 53 | !! |
---|
| 54 | !!---------------------------------------------------------------------- |
---|
| 55 | !! namelist variables |
---|
| 56 | !!------------------- |
---|
| 57 | CHARACTER(len=80) :: file_riv_number !: Filename for river numbers |
---|
| 58 | INTEGER :: ios ! Local integer output status for namelist read |
---|
| 59 | INTEGER :: inum |
---|
| 60 | INTEGER :: ii, jj, rr !: Loop indices |
---|
| 61 | INTEGER :: max_river |
---|
| 62 | REAL(wp), POINTER, DIMENSION(:,:) :: river_number ! 2D array containing the river outflow numbers |
---|
| 63 | |
---|
| 64 | NAMELIST/nam_cpl_rnf_1d/file_riv_number, nn_cpl_river, ln_print_river_info |
---|
| 65 | !!---------------------------------------------------------------------- |
---|
| 66 | |
---|
| 67 | IF( nn_timing == 1 ) CALL timing_start('cpl_rnf_1d_init') |
---|
| 68 | |
---|
| 69 | IF(lwp) WRITE(numout,*) |
---|
| 70 | IF(lwp) WRITE(numout,*) 'cpl_rnf_1d_init : initialization of river runoff coupling' |
---|
| 71 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~' |
---|
[10774] | 72 | IF(lwp .AND. lflush) CALL flush(numout) |
---|
[10042] | 73 | |
---|
| 74 | REWIND(numnam_cfg) |
---|
| 75 | |
---|
| 76 | ! Read the namelist |
---|
| 77 | READ ( numnam_ref, nam_cpl_rnf_1d, IOSTAT = ios, ERR = 901) |
---|
| 78 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_cpl_rnf_1d in reference namelist', lwp ) |
---|
| 79 | READ ( numnam_cfg, nam_cpl_rnf_1d, IOSTAT = ios, ERR = 902 ) |
---|
| 80 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_cpl_rnf_1d in configuration namelist', lwp ) |
---|
[10759] | 81 | IF(lwm .AND. nprint > 2) WRITE ( numond, nam_cpl_rnf_1d ) |
---|
[10042] | 82 | |
---|
| 83 | ! ! Parameter control and print |
---|
| 84 | IF(lwp) WRITE(numout,*) ' ' |
---|
| 85 | IF(lwp) WRITE(numout,*) ' Namelist nam_cpl_rnf_1d : Coupled runoff using 1D array' |
---|
| 86 | IF(lwp) WRITE(numout,*) ' Input file that contains river numbers = ',file_riv_number |
---|
| 87 | IF(lwp) WRITE(numout,*) ' Maximum number of rivers to couple = ',nn_cpl_river |
---|
| 88 | IF(lwp) WRITE(numout,*) ' Print river information = ',ln_print_river_info |
---|
| 89 | IF(lwp) WRITE(numout,*) ' ' |
---|
[10774] | 90 | IF(lwp .AND. lflush) CALL flush(numout) |
---|
[10042] | 91 | |
---|
| 92 | ! Assign space for river numbers |
---|
| 93 | ALLOCATE( rivers%river_number( jpi, jpj ) ) |
---|
| 94 | CALL wrk_alloc( jpi, jpj, river_number ) |
---|
| 95 | |
---|
| 96 | ! Read the river numbers from netcdf file |
---|
| 97 | CALL iom_open (file_riv_number , inum ) |
---|
| 98 | CALL iom_get ( inum, jpdom_data, 'river_number', river_number ) |
---|
| 99 | CALL iom_close( inum ) |
---|
| 100 | |
---|
| 101 | ! Convert from a real array to an integer array |
---|
| 102 | max_river=0 |
---|
| 103 | DO ii = 1, jpi |
---|
| 104 | DO jj = 1, jpj |
---|
| 105 | rivers%river_number(ii,jj) = INT(river_number(ii,jj)) |
---|
| 106 | IF ( rivers%river_number(ii,jj) > max_river ) THEN |
---|
| 107 | max_river = rivers%river_number(ii,jj) |
---|
| 108 | END IF |
---|
| 109 | END DO |
---|
| 110 | END DO |
---|
| 111 | |
---|
| 112 | ! Print out the largest river number |
---|
[10774] | 113 | IF ( ln_print_river_info .AND. lwp) THEN |
---|
[10042] | 114 | WRITE(numout,*) 'Maximum river number in input file = ',max_river |
---|
[10774] | 115 | IF(lflush) CALL flush(numout) |
---|
[10042] | 116 | END IF |
---|
| 117 | |
---|
| 118 | ! Get the area of each river outflow |
---|
| 119 | ALLOCATE( rivers%river_area( nn_cpl_river ) ) |
---|
| 120 | ALLOCATE( rivers%river_area_c( nn_cpl_river ) ) |
---|
| 121 | rivers%river_area_c(:) = CMPLX( 0.e0, 0.e0, wp ) |
---|
| 122 | DO ii = nldi, nlei |
---|
| 123 | DO jj = nldj, nlej |
---|
| 124 | IF ( tmask_i(ii,jj) > 0.5 ) THEN ! This makes sure we are not at a duplicated point (at north fold or east-west cyclic point) |
---|
| 125 | IF ( rivers%river_number(ii,jj) > 0 .AND. rivers%river_number(ii,jj) <= nn_cpl_river ) THEN |
---|
| 126 | ! Add the area of each grid box (e1e2t) into river_area_c using DDPDD which should maintain bit reproducibility (needs to be checked) |
---|
| 127 | CALL DDPDD( CMPLX( e1e2t(ii,jj), 0.e0, wp ), rivers%river_area_c(rivers%river_number(ii,jj) ) ) |
---|
| 128 | END IF |
---|
| 129 | END IF |
---|
| 130 | END DO |
---|
| 131 | END DO |
---|
| 132 | |
---|
| 133 | ! Use mpp_sum to add together river areas on other processors |
---|
| 134 | CALL mpp_sum( rivers%river_area_c, nn_cpl_river ) |
---|
| 135 | |
---|
| 136 | ! Convert from complex number to real |
---|
| 137 | ! DO rr = 1, nn_cpl_river |
---|
| 138 | ! rivers%river_area(rr) = rivers%river_area_c(rr) |
---|
| 139 | ! END DO |
---|
| 140 | rivers%river_area(:) = REAL(rivers%river_area_c(:),wp) |
---|
| 141 | |
---|
[10774] | 142 | IF ( ln_print_river_info .AND. lwp) THEN |
---|
[10042] | 143 | WRITE(numout,*) 'Area of rivers 1 to 10 are ',rivers%river_area(1:10) |
---|
[10774] | 144 | IF(lflush) CALL flush(numout) |
---|
[10042] | 145 | END IF |
---|
| 146 | |
---|
| 147 | END SUBROUTINE cpl_rnf_1d_init |
---|
| 148 | |
---|
| 149 | SUBROUTINE cpl_rnf_1d_to_2d( runoff_1d ) |
---|
| 150 | |
---|
| 151 | !!---------------------------------------------------------------------- |
---|
| 152 | !! *** SUBROUTINE cpl_rnf_1d_to_2d *** |
---|
| 153 | !! |
---|
| 154 | !! ** Purpose : - Convert river outflow from 1D array (passed from the |
---|
| 155 | !! atmosphere) to the 2D NEMO runoff field. |
---|
| 156 | !! Called from sbc_cpl_ice_flx (sbccpl.F90). |
---|
| 157 | !! |
---|
| 158 | !!---------------------------------------------------------------------- |
---|
| 159 | |
---|
| 160 | REAL , INTENT(in ) :: runoff_1d(nn_cpl_river) ! River runoff. One value per river. |
---|
| 161 | |
---|
| 162 | INTEGER :: ii, jj ! Loop indices |
---|
| 163 | |
---|
| 164 | ! Convert the 1D total runoff per river to 2D runoff flux by |
---|
| 165 | ! dividing by the area of each runoff zone. |
---|
| 166 | DO ii = 1, jpi |
---|
| 167 | DO jj = 1, jpj |
---|
| 168 | IF ( rivers%river_number(ii,jj) > 0 .AND. rivers%river_number(ii,jj) <= nn_cpl_river ) THEN |
---|
| 169 | rnf(ii,jj) = runoff_1d(rivers%river_number(ii,jj)) / rivers%river_area(rivers%river_number(ii,jj)) |
---|
| 170 | ELSE |
---|
| 171 | rnf(ii,jj) = 0.0 |
---|
| 172 | END IF |
---|
| 173 | |
---|
| 174 | END DO |
---|
| 175 | END DO |
---|
| 176 | |
---|
| 177 | END SUBROUTINE cpl_rnf_1d_to_2d |
---|
| 178 | |
---|
| 179 | END MODULE cpl_rnf_1d |
---|