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.
Changeset 10176 for branches/UKMO/dev_r5518_GO6_new_runoff_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90 – NEMO

Ignore:
Timestamp:
2018-10-05T17:57:31+02:00 (6 years ago)
Author:
dancopsey
Message:

Merged in dev_r5518_cleanup_1d_cpl branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/dev_r5518_GO6_new_runoff_coupling/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90

    r9321 r10176  
    4646   USE eosbn2 
    4747   USE sbcrnf   , ONLY : l_rnfcpl 
     48   USE cpl_rnf_1d, ONLY: nn_cpl_river, cpl_rnf_1d_init, cpl_rnf_1d_to_2d   ! Variables used in 1D river outflow 
    4849#if defined key_cpl_carbon_cycle 
    4950   USE p4zflx, ONLY : oce_co2 
     
    111112   INTEGER, PARAMETER ::   jpr_atm_pco2 = 46          ! Incoming atm CO2 flux 
    112113   INTEGER, PARAMETER ::   jpr_atm_dust = 47          ! Incoming atm aggregate dust  
    113    INTEGER, PARAMETER ::   jprcv      = 47            ! total number of fields received 
     114   INTEGER, PARAMETER ::   jpr_rnf_1d = 48            ! 1D river runoff 
     115   INTEGER, PARAMETER ::   jprcv      = 48            ! total number of fields received 
    114116 
    115117   INTEGER, PARAMETER ::   jps_fice   =  1            ! ice fraction sent to the atmosphere 
     
    175177   LOGICAL     ::   ln_usecplmask          !  use a coupling mask file to merge data received from several models 
    176178                                           !   -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel) 
     179 
    177180   TYPE ::   DYNARR      
    178181      REAL(wp), POINTER, DIMENSION(:,:,:)    ::   z3    
     
    253256      NAMELIST/namsbc_cpl/  sn_snd_bio_co2, sn_snd_bio_dms, sn_snd_bio_chloro,                        & 
    254257         &                  sn_rcv_atm_pco2, sn_rcv_atm_dust 
     258 
    255259 
    256260      !!--------------------------------------------------------------------- 
     
    324328         WRITE(numout,*)'  rn_antarctica_calving_fraction      = ', rn_antarctica_calving_fraction 
    325329         WRITE(numout,*)'  rn_iceshelf_fluxes_tolerance        = ', rn_iceshelf_fluxes_tolerance 
     330 
    326331      ENDIF 
    327332 
     
    339344 
    340345      ! default definitions of srcv 
    341       srcv(:)%laction = .FALSE.   ;   srcv(:)%clgrid = 'T'   ;   srcv(:)%nsgn = 1.   ;   srcv(:)%nct = 1 
     346      srcv(:)%laction = .FALSE.   ;   srcv(:)%clgrid = 'T'   ;   srcv(:)%nsgn = 1.   ;   srcv(:)%nct = 1 ; srcv(:)%dimensions = 2 
    342347 
    343348      !                                                      ! ------------------------- ! 
     
    460465      !                                                      ! ------------------------- ! 
    461466      srcv(jpr_rnf   )%clname = 'O_Runoff' 
    462       IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' ) THEN 
    463          srcv(jpr_rnf)%laction = .TRUE. 
     467      srcv(jpr_rnf_1d   )%clname = 'runoffo' 
     468      IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' .OR. TRIM( sn_rcv_rnf%cldes ) == 'coupled1d' ) THEN  
     469         IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled' ) srcv(jpr_rnf)%laction = .TRUE. 
     470         IF( TRIM( sn_rcv_rnf%cldes ) == 'coupled1d' ) THEN 
     471            srcv(jpr_rnf_1d)%laction = .TRUE. 
     472            srcv(jpr_rnf_1d)%dimensions = 1 ! 1D field passed through coupler 
     473         END IF 
    464474         l_rnfcpl              = .TRUE.                      ! -> no need to read runoffs in sbcrnf 
    465475         ln_rnf                = nn_components /= jp_iam_sas ! -> force to go through sbcrnf if not sas 
     
    468478      ENDIF 
    469479      ! 
    470       srcv(jpr_cal   )%clname = 'OCalving'   ;   IF( TRIM( sn_rcv_cal%cldes ) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE. 
    471       srcv(jpr_grnm  )%clname = 'OGrnmass'   ;   IF( TRIM( sn_rcv_grnm%cldes ) == 'coupled' )   srcv(jpr_grnm)%laction = .TRUE. 
    472       srcv(jpr_antm  )%clname = 'OAntmass'   ;   IF( TRIM( sn_rcv_antm%cldes ) == 'coupled' )   srcv(jpr_antm)%laction = .TRUE. 
     480      srcv(jpr_cal   )%clname = 'OCalving'    
     481      IF( TRIM( sn_rcv_cal%cldes ) == 'coupled' )   srcv(jpr_cal)%laction = .TRUE.      
     482 
     483      srcv(jpr_grnm  )%clname = 'OGrnmass'  
     484      IF( TRIM( sn_rcv_grnm%cldes ) == 'coupled' .OR. TRIM( sn_rcv_grnm%cldes ) == 'coupled0d' ) srcv(jpr_grnm)%laction = .TRUE.         
     485      IF( TRIM( sn_rcv_grnm%cldes ) == 'coupled0d' ) srcv(jpr_grnm  )%dimensions = 0 ! Scalar field 
     486       
     487      srcv(jpr_antm  )%clname = 'OAntmass' 
     488      IF( TRIM( sn_rcv_antm%cldes ) == 'coupled' .OR. TRIM( sn_rcv_antm%cldes ) == 'coupled0d' )  srcv(jpr_antm)%laction = .TRUE. 
     489      IF( TRIM( sn_rcv_antm%cldes ) == 'coupled0d' ) srcv(jpr_antm  )%dimensions = 0 ! Scalar field    
     490       
    473491 
    474492 
     
    657675         ENDIF 
    658676      ENDIF 
    659        
    660       ! =================================================== ! 
    661       ! Allocate all parts of frcv used for received fields ! 
    662       ! =================================================== ! 
    663       DO jn = 1, jprcv 
    664          IF ( srcv(jn)%laction ) ALLOCATE( frcv(jn)%z3(jpi,jpj,srcv(jn)%nct) ) 
    665       END DO 
    666       ! Allocate taum part of frcv which is used even when not received as coupling field 
    667       IF ( .NOT. srcv(jpr_taum)%laction ) ALLOCATE( frcv(jpr_taum)%z3(jpi,jpj,srcv(jpr_taum)%nct) ) 
    668       ! Allocate w10m part of frcv which is used even when not received as coupling field 
    669       IF ( .NOT. srcv(jpr_w10m)%laction ) ALLOCATE( frcv(jpr_w10m)%z3(jpi,jpj,srcv(jpr_w10m)%nct) ) 
    670       ! Allocate jpr_otx1 part of frcv which is used even when not received as coupling field 
    671       IF ( .NOT. srcv(jpr_otx1)%laction ) ALLOCATE( frcv(jpr_otx1)%z3(jpi,jpj,srcv(jpr_otx1)%nct) ) 
    672       IF ( .NOT. srcv(jpr_oty1)%laction ) ALLOCATE( frcv(jpr_oty1)%z3(jpi,jpj,srcv(jpr_oty1)%nct) ) 
    673       ! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE. 
    674       IF( k_ice /= 0 ) THEN 
    675          IF ( .NOT. srcv(jpr_itx1)%laction ) ALLOCATE( frcv(jpr_itx1)%z3(jpi,jpj,srcv(jpr_itx1)%nct) ) 
    676          IF ( .NOT. srcv(jpr_ity1)%laction ) ALLOCATE( frcv(jpr_ity1)%z3(jpi,jpj,srcv(jpr_ity1)%nct) ) 
    677       END IF 
    678677 
    679678      ! ================================ ! 
     
    685684       
    686685      ! default definitions of nsnd 
    687       ssnd(:)%laction = .FALSE.   ;   ssnd(:)%clgrid = 'T'   ;   ssnd(:)%nsgn = 1.  ; ssnd(:)%nct = 1 
     686      ssnd(:)%laction = .FALSE.   ;   ssnd(:)%clgrid = 'T'   ;   ssnd(:)%nsgn = 1.  ; ssnd(:)%nct = 1 ; ssnd(:)%dimensions = 2 
    688687          
    689688      !                                                      ! ------------------------- ! 
     
    942941         ENDIF 
    943942      ENDIF 
     943       
     944      ! Initialise 1D river outflow scheme  
     945      nn_cpl_river = 1  
     946      IF ( TRIM( sn_rcv_rnf%cldes ) == 'coupled1d' ) CALL cpl_rnf_1d_init   ! Coupled runoff using 1D array 
     947 
     948      ! =================================================== ! 
     949      ! Allocate all parts of frcv used for received fields ! 
     950      ! =================================================== ! 
     951      DO jn = 1, jprcv 
     952 
     953         IF ( srcv(jn)%laction ) THEN  
     954            SELECT CASE( srcv(jn)%dimensions ) 
     955            ! 
     956            CASE( 0 )   ! Scalar field 
     957               ALLOCATE( frcv(jn)%z3(1,1,1) ) 
     958                
     959            CASE( 1 )   ! 1D field 
     960               ALLOCATE( frcv(jn)%z3(nn_cpl_river,1,1) ) 
     961                
     962            CASE DEFAULT  ! 2D (or pseudo 3D) field. 
     963               ALLOCATE( frcv(jn)%z3(jpi,jpj,srcv(jn)%nct) ) 
     964                
     965            END SELECT 
     966         END IF 
     967 
     968      END DO 
     969      ! Allocate taum part of frcv which is used even when not received as coupling field 
     970      IF ( .NOT. srcv(jpr_taum)%laction ) ALLOCATE( frcv(jpr_taum)%z3(jpi,jpj,srcv(jpr_taum)%nct) ) 
     971      ! Allocate w10m part of frcv which is used even when not received as coupling field 
     972      IF ( .NOT. srcv(jpr_w10m)%laction ) ALLOCATE( frcv(jpr_w10m)%z3(jpi,jpj,srcv(jpr_w10m)%nct) ) 
     973      ! Allocate jpr_otx1 part of frcv which is used even when not received as coupling field 
     974      IF ( .NOT. srcv(jpr_otx1)%laction ) ALLOCATE( frcv(jpr_otx1)%z3(jpi,jpj,srcv(jpr_otx1)%nct) ) 
     975      IF ( .NOT. srcv(jpr_oty1)%laction ) ALLOCATE( frcv(jpr_oty1)%z3(jpi,jpj,srcv(jpr_oty1)%nct) ) 
     976      ! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE. 
     977      IF( k_ice /= 0 ) THEN 
     978         IF ( .NOT. srcv(jpr_itx1)%laction ) ALLOCATE( frcv(jpr_itx1)%z3(jpi,jpj,srcv(jpr_itx1)%nct) ) 
     979         IF ( .NOT. srcv(jpr_ity1)%laction ) ALLOCATE( frcv(jpr_ity1)%z3(jpi,jpj,srcv(jpr_ity1)%nct) ) 
     980      END IF 
    944981 
    945982      ! 
     
    10731110      isec = ( kt - nit000 ) * NINT( rdttra(1) )                ! date of exchanges 
    10741111      DO jn = 1, jprcv                                          ! received fields sent by the atmosphere 
    1075          IF( srcv(jn)%laction )   CALL cpl_rcv( jn, isec, frcv(jn)%z3, xcplmask(:,:,1:nn_cplmodel), nrcvinfo(jn) ) 
     1112         IF( srcv(jn)%laction ) THEN  
     1113 
     1114            IF ( srcv(jn)%dimensions <= 1 ) THEN 
     1115               CALL cpl_rcv_1d( jn, isec, frcv(jn)%z3, SIZE(frcv(jn)%z3), nrcvinfo(jn) ) 
     1116            ELSE 
     1117               CALL cpl_rcv( jn, isec, frcv(jn)%z3, xcplmask(:,:,1:nn_cplmodel), nrcvinfo(jn) ) 
     1118            END IF 
     1119 
     1120         END IF 
    10761121      END DO 
    1077  
    10781122      !                                                      ! ========================= ! 
    10791123      IF( srcv(jpr_otx1)%laction ) THEN                      !  ocean stress components  ! 
     
    13781422 
    13791423      IF( srcv(jpr_grnm)%laction .AND. nn_coupled_iceshelf_fluxes == 1 ) THEN 
    1380          greenland_icesheet_mass_array(:,:) = frcv(jpr_grnm)%z3(:,:,1) 
    1381          ! take average over ocean points of input array to avoid cumulative error over time 
    1382          ! The following must be bit reproducible over different PE decompositions 
    1383          zgreenland_icesheet_mass_in = glob_sum( greenland_icesheet_mass_array(:,:) * tmask(:,:,1) ) 
    1384  
    1385          zgreenland_icesheet_mass_in = zgreenland_icesheet_mass_in / zmask_sum 
     1424          
     1425         IF( srcv(jpr_grnm)%dimensions == 0 ) THEN 
     1426       
     1427           ! This is a zero dimensional, single value field.  
     1428           zgreenland_icesheet_mass_in =  frcv(jpr_grnm)%z3(1,1,1) 
     1429            
     1430         ELSE 
     1431          
     1432           greenland_icesheet_mass_array(:,:) = frcv(jpr_grnm)%z3(:,:,1)  
     1433           ! take average over ocean points of input array to avoid cumulative error over time  
     1434           ! The following must be bit reproducible over different PE decompositions  
     1435           zgreenland_icesheet_mass_in = glob_sum( greenland_icesheet_mass_array(:,:) * tmask(:,:,1) )   
     1436           zgreenland_icesheet_mass_in = zgreenland_icesheet_mass_in / zmask_sum  
     1437            
     1438         END IF 
     1439 
    13861440         greenland_icesheet_timelapsed = greenland_icesheet_timelapsed + rdt          
    13871441 
     
    14151469      !                                                        ! land ice masses : Antarctica 
    14161470      IF( srcv(jpr_antm)%laction .AND. nn_coupled_iceshelf_fluxes == 1 ) THEN 
    1417          antarctica_icesheet_mass_array(:,:) = frcv(jpr_antm)%z3(:,:,1) 
    1418          ! take average over ocean points of input array to avoid cumulative error from rounding errors over time 
    1419          ! The following must be bit reproducible over different PE decompositions 
    1420          zantarctica_icesheet_mass_in = glob_sum( antarctica_icesheet_mass_array(:,:) * tmask(:,:,1) ) 
    1421  
    1422          zantarctica_icesheet_mass_in = zantarctica_icesheet_mass_in / zmask_sum 
     1471       
     1472         IF( srcv(jpr_antm)%dimensions == 0 ) THEN 
     1473          
     1474           ! This is a zero dimensional, single value field.  
     1475           zantarctica_icesheet_mass_in = frcv(jpr_antm)%z3(1,1,1) 
     1476            
     1477         ELSE 
     1478          
     1479           antarctica_icesheet_mass_array(:,:) = frcv(jpr_antm)%z3(:,:,1)  
     1480           ! take average over ocean points of input array to avoid cumulative error from rounding errors over time  
     1481           ! The following must be bit reproducible over different PE decompositions  
     1482           zantarctica_icesheet_mass_in = glob_sum( antarctica_icesheet_mass_array(:,:) * tmask(:,:,1) )   
     1483           zantarctica_icesheet_mass_in = zantarctica_icesheet_mass_in / zmask_sum  
     1484            
     1485         END IF 
     1486 
    14231487         antarctica_icesheet_timelapsed = antarctica_icesheet_timelapsed + rdt          
    14241488 
     
    18211885      ! --- runoffs (included in emp later on) --- ! 
    18221886      IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1) 
     1887      IF( srcv(jpr_rnf_1d)%laction )   CALL cpl_rnf_1d_to_2d(frcv(jpr_rnf_1d)%z3(:,:,:)) 
    18231888 
    18241889      ! --- calving (put in emp_tot and emp_oce) --- ! 
     
    18581923      ! runoffs and calving (put in emp_tot) 
    18591924      IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1) 
     1925      IF( srcv(jpr_rnf_1d)%laction )   CALL cpl_rnf_1d_to_2d(frcv(jpr_rnf_1d)%z3(:,:,:)) 
    18601926      IF( iom_use('hflx_rnf_cea') )   & 
    18611927         CALL iom_put( 'hflx_rnf_cea' , rnf(:,:) * zcptn(:,:) ) 
Note: See TracChangeset for help on using the changeset viewer.