40 | | INTEGER , INTENT(in ) :: kt ! ocean time-step index |
41 | | CHARACTER(len=3), INTENT(in ) :: cdtype ! =TRA or TRC (tracer indicator) |
42 | | REAL(wp) , INTENT(in ), DIMENSION(:,:,: ) :: pun, pvn, pwn ! 3 ocean transport components |
43 | | REAL(wp) , INTENT(in ), DIMENSION(:,:,:,:) :: ptrab, ptran ! before and now tracer fields |
44 | | REAL(wp) , INTENT(inout), DIMENSION(:,:,:,:) :: ptraa ! tracer trend |
45 | | }}} |
46 | | [[BR]] |
47 | | |
48 | | '''(2)''' Test for T & S 3D arrays by using the fortran '''''RESHAPE''''' function [[BR]][[BR]] |
49 | | |
50 | | In order to test the new tra... modules without changing the temperature and salinity field every where in the code, we use the RESHAPE function in the call of the new routine. For example the call in tra_adv becomes : |
| 40 | INTEGER , INTENT(in ) :: kt ! ocean time-step index |
| 41 | CHARACTER(len=3), INTENT(in ) :: cdtype ! =TRA or TRC (tracer indicator) |
| 42 | INTEGER , INTENT(in ) :: kjpt ! number of tracers |
| 43 | REAL(wp) , INTENT(in ), DIMENSION(jpi,jpj,jpk ) :: pun, pvn, pwn ! 3 ocean transport components |
| 44 | REAL(wp) , INTENT(in ), DIMENSION(jpi,jpj,jpk,kjpt) :: ptrab, ptran ! before and now tracer fields |
| 45 | REAL(wp) , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt) :: ptraa ! tracer trend |
| 46 | |
| 47 | }}} |
| 48 | [[BR]] |
| 49 | |
| 50 | '''(2)''' Test for T & S 3D arrays [[BR]][[BR]] |
| 51 | |
| 52 | In order to test the new tra... modules without changing the temperature and salinity field every where in the code, we replace T and S 3D arrays by 4D array just within the TRA modules in the call of the new routine. For example, in the step rotuin |
| 53 | |
| 54 | {{{ |
| 55 | SUBROUTINE stp( kstp ) |
| 56 | INTEGER, INTENT(in) :: kstp ! ocean time-step index |
| 57 | |
| 58 | bla bla bla bla bla bla |
| 59 | bla bla bla bla bla bla |
| 60 | |
| 61 | !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
| 62 | ! Active tracers (ua, va used as workspace) |
| 63 | !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
| 64 | ta(:,:,:) = 0.e0 ! set tracer trends to zero |
| 65 | sa(:,:,:) = 0.e0 |
| 66 | |
| 67 | CALL tra_swap |
| 68 | CALL tra_sbc ( kstp ) ! surface boundary condition |
| 69 | IF( ln_traqsr ) CALL tra_qsr ( kstp ) ! penetrative solar radiation qsr |
| 70 | IF( lk_trabbc ) CALL tra_bbc ( kstp ) ! bottom heat flux |
| 71 | IF( lk_trabbl ) CALL tra_bbl ( kstp ) ! advective (and/or diffusive) bottom boundary layer scheme |
| 72 | IF( lk_tradmp ) CALL tra_dmp ( kstp ) ! internal damping trends |
| 73 | CALL tra_adv ( kstp ) ! horizontal & vertical advection |
| 74 | IF( n_cla == 1 ) CALL tra_cla ( kstp ) ! Cross Land Advection (Update Hor. advection) |
| 75 | IF( lk_zdfkpp ) CALL tra_kpp ( kstp ) ! KPP non-local tracer fluxes |
| 76 | CALL tra_ldf ( kstp ) ! lateral mixing |
| 77 | #if defined key_agrif |
| 78 | CALL tra_unswap |
| 79 | IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra ! tracers sponge |
| 80 | CALL tra_swap |
| 81 | #endif |
| 82 | CALL tra_zdf ( kstp ) ! vertical mixing and after tracer fields |
| 83 | |
| 84 | IF( ln_dynhpg_imp ) THEN ! semi-implicit hpg (time stepping then eos) |
| 85 | IF( ln_zdfnpc ) CALL tra_npc ( kstp ) ! update after fields by non-penetrative convection |
| 86 | CALL tra_nxt ( kstp ) ! tracer fields at next time step |
| 87 | CALL tra_unswap |
| 88 | CALL eos( ta, sa, rhd, rhop ) ! Time-filtered in situ density for hpg computation |
| 89 | IF( ln_zps ) CALL zps_hde( kstp, ta, sa, rhd, & ! Partial steps: time filtered hor. derivative |
| 90 | & gtu, gsu, gru, & ! of t, s, rd at the bottom ocean level |
| 91 | & gtv, gsv, grv ) |
| 92 | |
| 93 | ELSE ! centered hpg (eos then time stepping) |
| 94 | CALL tra_unswap |
| 95 | CALL eos( tn, sn, rhd, rhop ) ! now in situ density for hpg computation |
| 96 | IF( ln_zps ) CALL zps_hde( kstp, tn, sn, rhd, & ! Partial steps: now horizontal derivative |
| 97 | & gtu, gsu, gru, & ! of t, s, rd at the bottom ocean level |
| 98 | & gtv, gsv, grv ) |
| 99 | CALL tra_swap |
| 100 | IF( ln_zdfnpc ) CALL tra_npc ( kstp ) ! update after fields by non-penetrative convection |
| 101 | CALL tra_nxt ( kstp ) ! tracer fields at next time step |
| 102 | CALL tra_unswap |
| 103 | ENDIF |
| 104 | |
| 105 | bla bla bla bla bla bla |
| 106 | bla bla bla bla bla bla |
| 107 | }}} |
| 108 | |
| 109 | {{{ |
| 110 | MODULE traswp |
| 111 | !!============================================================================== |
| 112 | !! *** MODULE traswp *** |
| 113 | !! Ocean active tracers: swapping array |
| 114 | !!============================================================================== |
| 115 | USE par_oce |
| 116 | USE oce ! ocean dynamics and active tracers |
| 117 | |
| 118 | IMPLICIT NONE |
| 119 | PRIVATE |
| 120 | |
| 121 | PUBLIC tra_swap ! routine called by step.F90 |
| 122 | PUBLIC tra_unswap ! routine called by step.F90 |
| 123 | |
| 124 | |
| 125 | CONTAINS |
| 126 | |
| 127 | SUBROUTINE tra_swap |
| 128 | !!---------------------------------------------------------------------- |
| 129 | !! *** ROUTINE tra_swp *** |
| 130 | !! |
| 131 | !! ** Purpose : Store temperature and salinity aaray into a 4D array |
| 132 | !! |
| 133 | !!---------------------------------------------------------------------- |
| 134 | |
| 135 | tsn(:,:,:,jp_tem) = tn(:,:,:) ; tsn(:,:,:,jp_sal) = sn(:,:,:) |
| 136 | tsb(:,:,:,jp_tem) = tb(:,:,:) ; tsb(:,:,:,jp_sal) = sb(:,:,:) |
| 137 | tsa(:,:,:,jp_tem) = ta(:,:,:) ; tsa(:,:,:,jp_sal) = sa(:,:,:) |
| 138 | |
| 139 | END SUBROUTINE tra_swap |
| 140 | |
| 141 | SUBROUTINE tra_unswap |
| 142 | !!---------------------------------------------------------------------- |
| 143 | !! *** ROUTINE tra_unswap *** |
| 144 | !! |
| 145 | !! ** Purpose : Store temperature and salinity aaray into a 4D array |
| 146 | !! |
| 147 | !!---------------------------------------------------------------------- |
| 148 | |
| 149 | tn(:,:,:) = tsn(:,:,:,jp_tem) ; sn(:,:,:) = tsn(:,:,:,jp_sal) |
| 150 | tb(:,:,:) = tsb(:,:,:,jp_tem) ; sb(:,:,:) = tsb(:,:,:,jp_sal) |
| 151 | ta(:,:,:) = tsa(:,:,:,jp_tem) ; sa(:,:,:) = tsa(:,:,:,jp_sal) |
| 152 | |
| 153 | END SUBROUTINE tra_unswap |
| 154 | |
| 155 | !!====================================================================== |
| 156 | END MODULE traswp |
| 157 | }}} |
| 158 | |
| 159 | |
| 160 | For example the call in tra_adv becomes : |