New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
cpl_rnf_1d.F90 in branches/UKMO/dev_r5518_new_runoff_coupling/NEMOGCM/NEMO/OPA_SRC/SBC – NEMO

source: branches/UKMO/dev_r5518_new_runoff_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_rnf_1d.F90 @ 9515

Last change on this file since 9515 was 9515, checked in by dancopsey, 4 years ago

Do not use halos in area calculations.

File size: 8.4 KB
Line 
1MODULE 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   
25   IMPLICIT NONE
26   PRIVATE
27   
28   PUBLIC   cpl_rnf_1d_init     ! routine called in nemo_init
29   PUBLIC   cpl_rnf_1d_rcv      ! routine called in sbccpl.F90
30   
31   TYPE, PUBLIC ::   RIVERS_DATA     !: Storage for river outflow data
32      INTEGER, POINTER, DIMENSION(:,:)    ::   river_number       !: River outflow number
33      REAL(wp), POINTER, DIMENSION(:)     ::   river_area         ! 1D array listing areas of each river outflow (m2)
34   END TYPE RIVERS_DATA
35   
36   TYPE(RIVERS_DATA), PUBLIC, TARGET :: rivers  !: River data
37   
38   INTEGER, PUBLIC            :: nn_cpl_river   ! Maximum number of rivers being passed through the coupler
39   INTEGER, PUBLIC            :: runoff_id      ! OASIS coupling id used in oasis_get command
40   LOGICAL                    :: ln_print_river_info  ! Diagnostic prints of river coupling information
41   
42CONTAINS
43
44   SUBROUTINE cpl_rnf_1d_init
45      !!----------------------------------------------------------------------
46      !!                    ***  SUBROUTINE cpl_rnf_1d_init  ***
47      !!                     
48      !! ** Purpose : - Read in file for river outflow numbers.
49      !!                Calculate 2D area of river outflow points.
50      !!                Called from nemo_init (nemogcm.F90).
51      !!
52      !!----------------------------------------------------------------------
53      !! namelist variables
54      !!-------------------
55      CHARACTER(len=80)                         ::   file_riv_number             !: Filename for river numbers
56      INTEGER                                   ::   ios                 ! Local integer output status for namelist read
57      INTEGER                                   ::   inum
58      INTEGER                                   ::   ii, jj              !: Loop indices
59      INTEGER                                   ::   max_river
60      REAL(wp), POINTER, DIMENSION(:,:)         ::   river_number        ! 2D array containing the river outflow numbers
61     
62      NAMELIST/nam_cpl_rnf_1d/file_riv_number, nn_cpl_river, ln_print_river_info
63      !!----------------------------------------------------------------------
64
65      IF( nn_timing == 1 ) CALL timing_start('cpl_rnf_1d_init')
66     
67      IF(lwp) WRITE(numout,*)
68      IF(lwp) WRITE(numout,*) 'cpl_rnf_1d_init : initialization of river runoff coupling'
69      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
70     
71      REWIND(numnam_cfg)
72     
73      ! Read the namelist
74      READ  ( numnam_ref, nam_cpl_rnf_1d, IOSTAT = ios, ERR = 901)
75901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_cpl_rnf_1d in reference namelist', lwp )
76      READ  ( numnam_cfg, nam_cpl_rnf_1d, IOSTAT = ios, ERR = 902 )
77902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_cpl_rnf_1d in configuration namelist', lwp )
78      IF(lwm) WRITE ( numond, nam_cpl_rnf_1d )
79
80      !                                               ! Parameter control and print
81      IF(lwp) WRITE(numout,*) '  '
82      IF(lwp) WRITE(numout,*) '          Namelist nam_cpl_rnf_1d : Coupled runoff using 1D array'
83      IF(lwp) WRITE(numout,*) '             Input file that contains river numbers = ',file_riv_number
84      IF(lwp) WRITE(numout,*) '             Maximum number of rivers to couple = ',nn_cpl_river
85      IF(lwp) WRITE(numout,*) '             Print river information = ',ln_print_river_info
86      IF(lwp) WRITE(numout,*) ' '
87     
88      ! Assign space for river numbers
89      ALLOCATE( rivers%river_number( jpi, jpj ) )
90      CALL wrk_alloc( jpi, jpj, river_number )
91     
92      ! Read the river numbers from netcdf file
93      CALL iom_open (file_riv_number , inum )
94      CALL iom_get  ( inum, jpdom_data, 'river_number', river_number )
95      CALL iom_close( inum )
96     
97      ! Convert from a real array to an integer array
98      max_river=0
99      DO ii = 1, jpi
100        DO jj = 1, jpj
101          rivers%river_number(ii,jj) = INT(river_number(ii,jj))
102          IF ( rivers%river_number(ii,jj) > max_river ) THEN
103            max_river = rivers%river_number(ii,jj)
104          END IF
105        END DO
106      END DO
107     
108      ! Print out the largest river number
109      WRITE(numout,*) 'Maximum river number in input file = ',max_river
110     
111      ! Get the area of each river outflow
112      ALLOCATE( rivers%river_area( nn_cpl_river ) )
113      rivers%river_area(:) = 0.0
114      DO ii = nldi, nlei     
115        DO jj = nldj, nlej
116          IF ( rivers%river_number(ii,jj) > 0 .AND. rivers%river_number(ii,jj) <= nn_cpl_river ) THEN
117            rivers%river_area(rivers%river_number(ii,jj)) = rivers%river_area(rivers%river_number(ii,jj)) + e1e2t(ii,jj)
118          END IF
119        END DO
120      END DO
121     
122      ! Use mpp_sum to add together river areas on other processors
123      CALL mpp_sum( rivers%river_area, nn_cpl_river )
124      IF ( ln_print_river_info ) THEN
125        WRITE(numout,*) 'Area of rivers 1 to 10 are ',rivers%river_area(1:10)
126      END IF
127     
128   END SUBROUTINE cpl_rnf_1d_init
129   
130   SUBROUTINE cpl_rnf_1d_rcv( kstep)
131   
132      !!----------------------------------------------------------------------
133      !!                    ***  SUBROUTINE cpl_rnf_1d_rcv  ***
134      !!                     
135      !! ** Purpose : - Get river outflow from 1D array (passed from the
136      !!                atmosphere) and transfer it to the 2D NEMO runoff
137      !!                field.
138      !!                Called from sbc_cpl_rcv (sbccpl.F90).
139      !!
140      !!----------------------------------------------------------------------
141     
142      INTEGER                   , INTENT(in   ) ::   kstep     ! ocean time-step in seconds
143     
144      INTEGER  ::   kinfo                  ! OASIS3 info argument   
145      REAL(wp) ::   runoff_1d(nn_cpl_river)    ! River runoff. One value per river.
146      INTEGER  ::   ii, jj                 ! Loop indices
147      LOGICAL  ::   llaction               ! Has the get worked?
148     
149      IF ( ln_print_river_info ) THEN
150         WRITE(numout,*)' Getting data from 1D river runoff coupling '
151      ENDIF
152   
153      ! Get the river runoff sent by the atmosphere
154      CALL oasis_get ( runoff_id, kstep, runoff_1d, kinfo )
155      llaction =  kinfo == OASIS_Recvd   .OR. kinfo == OASIS_FromRest .OR.   &
156                  &        kinfo == OASIS_RecvOut .OR. kinfo == OASIS_FromRestOut
157                 
158      ! Output coupling info
159      IF ( ln_print_river_info ) THEN
160         WRITE(numout,*)' narea = ', narea
161         WRITE(numout,*)' kstep = ', kstep
162         WRITE(numout,*)' River runoff = ', runoff_1d(1:10)
163         WRITE(numout,*)' kinfo = ', kinfo
164         WRITE(numout,*)' llaction = ', llaction
165         WRITE(numout,*)' OASIS_Recvd = ',OASIS_Recvd
166         WRITE(numout,*)' OASIS_FromRest = ',OASIS_FromRest
167         WRITE(numout,*)' OASIS_RecvOut = ',OASIS_RecvOut
168         WRITE(numout,*)' OASIS_FromRestOut = ',OASIS_FromRestOut
169         WRITE(numout,*)'-------'
170      ENDIF
171     
172      IF ( llaction ) THEN
173     
174        ! Convert the 1D total runoff per river to 2D runoff flux by
175        ! dividing by the area of each runoff zone.
176        DO ii = 1, jpi
177          DO jj = 1, jpj
178            IF ( rivers%river_number(ii,jj) > 0 .AND. rivers%river_number(ii,jj) <= nn_cpl_river ) THEN
179              rnf(ii,jj) = runoff_1d(rivers%river_number(ii,jj)) / rivers%river_area(rivers%river_number(ii,jj))
180            ELSE
181              rnf(ii,jj) = 0.0
182            END IF
183           
184          END DO
185        END DO
186         
187      END IF
188     
189      IF ( ln_print_river_info ) WRITE(numout,*)' River runoff flux of AMAZON (pe 351) is ', rnf(59,29)         
190   
191   END SUBROUTINE cpl_rnf_1d_rcv
192
193END MODULE cpl_rnf_1d
Note: See TracBrowser for help on using the repository browser.