[782] | 1 | MODULE oasis |
---|
[5099] | 2 | |
---|
[5111] | 3 | ! This module contains subroutines for initialization, sending and receiving |
---|
| 4 | ! towards the coupler OASIS3. It also contains some parameters for the coupling. |
---|
[5099] | 5 | |
---|
[5111] | 6 | ! This module should always be compiled. With the coupler OASIS3 available the cpp key |
---|
| 7 | ! CPP_COUPLE should be set and the entier of this file will then be compiled. |
---|
| 8 | ! In a forced mode CPP_COUPLE should not be defined and the compilation ends before |
---|
| 9 | ! the CONTAINS, without compiling the subroutines. |
---|
[5099] | 10 | |
---|
[5111] | 11 | USE dimphy |
---|
[5110] | 12 | USE lmdz_phys_para |
---|
[5133] | 13 | USE lmdz_writefield_phy |
---|
[782] | 14 | |
---|
| 15 | #ifdef CPP_COUPLE |
---|
[1965] | 16 | ! Use of Oasis-MCT coupler |
---|
| 17 | #if defined CPP_OMCT |
---|
| 18 | USE mod_prism |
---|
| 19 | ! Use of Oasis3 coupler |
---|
| 20 | #else |
---|
[782] | 21 | USE mod_prism_proto |
---|
| 22 | USE mod_prism_def_partition_proto |
---|
| 23 | USE mod_prism_get_proto |
---|
| 24 | USE mod_prism_put_proto |
---|
| 25 | #endif |
---|
[1965] | 26 | #endif |
---|
[5111] | 27 | |
---|
[782] | 28 | IMPLICIT NONE |
---|
[5111] | 29 | |
---|
[1279] | 30 | ! Id for fields sent to ocean |
---|
| 31 | INTEGER, PARAMETER :: ids_tauxxu = 1 |
---|
| 32 | INTEGER, PARAMETER :: ids_tauyyu = 2 |
---|
| 33 | INTEGER, PARAMETER :: ids_tauzzu = 3 |
---|
| 34 | INTEGER, PARAMETER :: ids_tauxxv = 4 |
---|
| 35 | INTEGER, PARAMETER :: ids_tauyyv = 5 |
---|
| 36 | INTEGER, PARAMETER :: ids_tauzzv = 6 |
---|
| 37 | INTEGER, PARAMETER :: ids_windsp = 7 |
---|
| 38 | INTEGER, PARAMETER :: ids_shfice = 8 |
---|
| 39 | INTEGER, PARAMETER :: ids_shfoce = 9 |
---|
| 40 | INTEGER, PARAMETER :: ids_shftot = 10 |
---|
| 41 | INTEGER, PARAMETER :: ids_nsfice = 11 |
---|
| 42 | INTEGER, PARAMETER :: ids_nsfoce = 12 |
---|
| 43 | INTEGER, PARAMETER :: ids_nsftot = 13 |
---|
| 44 | INTEGER, PARAMETER :: ids_dflxdt = 14 |
---|
| 45 | INTEGER, PARAMETER :: ids_totrai = 15 |
---|
| 46 | INTEGER, PARAMETER :: ids_totsno = 16 |
---|
| 47 | INTEGER, PARAMETER :: ids_toteva = 17 |
---|
| 48 | INTEGER, PARAMETER :: ids_icevap = 18 |
---|
| 49 | INTEGER, PARAMETER :: ids_ocevap = 19 |
---|
| 50 | INTEGER, PARAMETER :: ids_calvin = 20 |
---|
| 51 | INTEGER, PARAMETER :: ids_liqrun = 21 |
---|
| 52 | INTEGER, PARAMETER :: ids_runcoa = 22 |
---|
| 53 | INTEGER, PARAMETER :: ids_rivflu = 23 |
---|
| 54 | INTEGER, PARAMETER :: ids_atmco2 = 24 |
---|
| 55 | INTEGER, PARAMETER :: ids_taumod = 25 |
---|
[2872] | 56 | INTEGER, PARAMETER :: ids_qraioc = 26 |
---|
| 57 | INTEGER, PARAMETER :: ids_qsnooc = 27 |
---|
| 58 | INTEGER, PARAMETER :: ids_qraiic = 28 |
---|
| 59 | INTEGER, PARAMETER :: ids_qsnoic = 29 |
---|
[4370] | 60 | INTEGER, PARAMETER :: ids_delta_sst = 30, ids_delta_sal = 31, ids_dter = 32, & |
---|
[5111] | 61 | ids_dser = 33, ids_dt_ds = 34 |
---|
| 62 | |
---|
| 63 | INTEGER, PARAMETER :: maxsend = 34 ! Maximum number of fields to send |
---|
| 64 | |
---|
[1279] | 65 | ! Id for fields received from ocean |
---|
[3815] | 66 | |
---|
[1279] | 67 | INTEGER, PARAMETER :: idr_sisutw = 1 |
---|
| 68 | INTEGER, PARAMETER :: idr_icecov = 2 |
---|
| 69 | INTEGER, PARAMETER :: idr_icealw = 3 |
---|
| 70 | INTEGER, PARAMETER :: idr_icetem = 4 |
---|
| 71 | INTEGER, PARAMETER :: idr_curenx = 5 |
---|
| 72 | INTEGER, PARAMETER :: idr_cureny = 6 |
---|
| 73 | INTEGER, PARAMETER :: idr_curenz = 7 |
---|
| 74 | INTEGER, PARAMETER :: idr_oceco2 = 8 |
---|
[4640] | 75 | ! bulk salinity of the surface layer of the ocean, in ppt |
---|
[3815] | 76 | INTEGER, PARAMETER :: idr_sss = 9 |
---|
[4640] | 77 | INTEGER, PARAMETER :: idr_ocedms = 10 |
---|
[4754] | 78 | INTEGER, PARAMETER :: idr_ocen2o = 11 |
---|
[3815] | 79 | |
---|
[5111] | 80 | INTEGER, PARAMETER :: maxrecv = 11 ! Maximum number of fields to receive |
---|
[4640] | 81 | INTEGER, PARAMETER :: maxrecv_phys = 9 ! Maximum number of fields to receive in physiq (without fields received in INCA model ) |
---|
[5111] | 82 | ! will be changed in next version - INCA fields will be received in LMDZ (like for ORCHIDEE fields) |
---|
| 83 | ! and then send by routine in INCA model |
---|
[782] | 84 | |
---|
[5111] | 85 | TYPE, PUBLIC :: FLD_CPL ! Type for coupling field information |
---|
| 86 | CHARACTER(len = 8) :: name ! Name of the coupling field |
---|
| 87 | LOGICAL :: action ! To be exchanged or not |
---|
| 88 | INTEGER :: nid ! Id of the field |
---|
[1279] | 89 | END TYPE FLD_CPL |
---|
[782] | 90 | |
---|
[1279] | 91 | TYPE(FLD_CPL), DIMENSION(maxsend), SAVE, PUBLIC :: infosend ! Information for sending coupling fields |
---|
[5111] | 92 | !$OMP THREADPRIVATE(infosend) |
---|
[1279] | 93 | TYPE(FLD_CPL), DIMENSION(maxrecv), SAVE, PUBLIC :: inforecv ! Information for receiving coupling fields |
---|
[5111] | 94 | !$OMP THREADPRIVATE(inforecv) |
---|
[782] | 95 | |
---|
[5111] | 96 | LOGICAL, SAVE :: cpl_current |
---|
| 97 | !$OMP THREADPRIVATE(cpl_current) |
---|
| 98 | |
---|
[782] | 99 | #ifdef CPP_COUPLE |
---|
| 100 | |
---|
| 101 | CONTAINS |
---|
| 102 | |
---|
| 103 | SUBROUTINE inicma |
---|
| 104 | !************************************************************************************ |
---|
| 105 | !**** *INICMA* - Initialize coupled mode communication for atmosphere |
---|
| 106 | ! and exchange some initial information with Oasis |
---|
[5099] | 107 | |
---|
[782] | 108 | ! Rewrite to take the PRISM/psmile library into account |
---|
| 109 | ! LF 09/2003 |
---|
[5099] | 110 | |
---|
[1067] | 111 | USE IOIPSL |
---|
[5101] | 112 | USE surface_data, ONLY: version_ocean |
---|
| 113 | USE carbon_cycle_mod, ONLY: carbon_cycle_cpl |
---|
[5117] | 114 | USE lmdz_wxios, ONLY: wxios_context_init |
---|
[5101] | 115 | USE chemistry_cycle_mod, ONLY: dms_cycle_cpl, n2o_cycle_cpl |
---|
[4619] | 116 | USE lmdz_xios |
---|
[5112] | 117 | USE lmdz_print_control, ONLY: lunout |
---|
[5110] | 118 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat, grid_type, unstructured, regular_lonlat |
---|
[5112] | 119 | USE lmdz_geometry, ONLY: ind_cell_glo |
---|
[5110] | 120 | USE lmdz_phys_mpi_data, ONLY: klon_mpi_para_nb |
---|
[5111] | 121 | USE config_ocean_skin_m, ONLY: activate_ocean_skin |
---|
| 122 | USE lmdz_abort_physic, ONLY: abort_physic |
---|
[1279] | 123 | |
---|
[782] | 124 | ! Local variables |
---|
| 125 | !************************************************************************************ |
---|
| 126 | INTEGER :: comp_id |
---|
| 127 | INTEGER :: ierror, il_commlocal |
---|
| 128 | INTEGER :: il_part_id |
---|
[3465] | 129 | INTEGER, ALLOCATABLE :: ig_paral(:) |
---|
[782] | 130 | INTEGER, DIMENSION(2) :: il_var_nodims |
---|
| 131 | INTEGER, DIMENSION(4) :: il_var_actual_shape |
---|
| 132 | INTEGER :: il_var_type |
---|
| 133 | INTEGER :: jf |
---|
| 134 | CHARACTER (len = 6) :: clmodnam |
---|
| 135 | CHARACTER (len = 20) :: modname = 'inicma' |
---|
| 136 | CHARACTER (len = 80) :: abort_message |
---|
[1997] | 137 | LOGICAL, SAVE :: cpl_current_omp |
---|
[4596] | 138 | INTEGER, DIMENSION(klon_mpi) :: ind_cell_glo_mpi |
---|
[782] | 139 | |
---|
| 140 | !* 1. Initializations |
---|
| 141 | ! --------------- |
---|
| 142 | !************************************************************************************ |
---|
[1279] | 143 | WRITE(lunout,*) ' ' |
---|
| 144 | WRITE(lunout,*) ' ' |
---|
| 145 | WRITE(lunout,*) ' ROUTINE INICMA' |
---|
| 146 | WRITE(lunout,*) ' **************' |
---|
| 147 | WRITE(lunout,*) ' ' |
---|
| 148 | WRITE(lunout,*) ' ' |
---|
[782] | 149 | |
---|
| 150 | ! Define the model name |
---|
[5099] | 151 | |
---|
[3465] | 152 | IF (grid_type==unstructured) THEN |
---|
| 153 | clmodnam = 'icosa' ! as in $NBMODEL in Cpl/Nam/namcouple.tmp |
---|
| 154 | ELSE IF (grid_type==regular_lonlat) THEN |
---|
| 155 | clmodnam = 'LMDZ' ! as in $NBMODEL in Cpl/Nam/namcouple.tmp |
---|
| 156 | ELSE |
---|
[5158] | 157 | abort_message='Pb : type of grid unknown' |
---|
| 158 | CALL abort_physic(modname,abort_message,1) |
---|
[3465] | 159 | ENDIF |
---|
[1067] | 160 | |
---|
[1279] | 161 | |
---|
[782] | 162 | !************************************************************************************ |
---|
[1067] | 163 | ! Define if coupling ocean currents or not |
---|
| 164 | !************************************************************************************ |
---|
| 165 | !$OMP MASTER |
---|
| 166 | cpl_current_omp = .FALSE. |
---|
| 167 | CALL getin('cpl_current', cpl_current_omp) |
---|
| 168 | !$OMP END MASTER |
---|
| 169 | !$OMP BARRIER |
---|
| 170 | cpl_current = cpl_current_omp |
---|
[1279] | 171 | WRITE(lunout,*) 'Couple ocean currents, cpl_current = ',cpl_current |
---|
[1067] | 172 | |
---|
| 173 | !************************************************************************************ |
---|
[4596] | 174 | ! Gather global index to be used for oasis decomposition |
---|
| 175 | !************************************************************************************ |
---|
| 176 | CALL gather_omp(ind_cell_glo,ind_cell_glo_mpi) |
---|
| 177 | |
---|
| 178 | !************************************************************************************ |
---|
[1279] | 179 | ! Define coupling variables |
---|
| 180 | !************************************************************************************ |
---|
| 181 | |
---|
| 182 | ! Atmospheric variables to send |
---|
| 183 | |
---|
| 184 | !$OMP MASTER |
---|
| 185 | infosend(:)%action = .FALSE. |
---|
| 186 | |
---|
| 187 | infosend(ids_tauxxu)%action = .TRUE. ; infosend(ids_tauxxu)%name = 'COTAUXXU' |
---|
| 188 | infosend(ids_tauyyu)%action = .TRUE. ; infosend(ids_tauyyu)%name = 'COTAUYYU' |
---|
| 189 | infosend(ids_tauzzu)%action = .TRUE. ; infosend(ids_tauzzu)%name = 'COTAUZZU' |
---|
| 190 | infosend(ids_tauxxv)%action = .TRUE. ; infosend(ids_tauxxv)%name = 'COTAUXXV' |
---|
| 191 | infosend(ids_tauyyv)%action = .TRUE. ; infosend(ids_tauyyv)%name = 'COTAUYYV' |
---|
| 192 | infosend(ids_tauzzv)%action = .TRUE. ; infosend(ids_tauzzv)%name = 'COTAUZZV' |
---|
| 193 | infosend(ids_windsp)%action = .TRUE. ; infosend(ids_windsp)%name = 'COWINDSP' |
---|
| 194 | infosend(ids_shfice)%action = .TRUE. ; infosend(ids_shfice)%name = 'COSHFICE' |
---|
| 195 | infosend(ids_nsfice)%action = .TRUE. ; infosend(ids_nsfice)%name = 'CONSFICE' |
---|
| 196 | infosend(ids_dflxdt)%action = .TRUE. ; infosend(ids_dflxdt)%name = 'CODFLXDT' |
---|
| 197 | infosend(ids_calvin)%action = .TRUE. ; infosend(ids_calvin)%name = 'COCALVIN' |
---|
| 198 | |
---|
[5117] | 199 | IF (activate_ocean_skin == 2) THEN |
---|
[3815] | 200 | infosend(ids_delta_sst)%action = .TRUE. |
---|
| 201 | infosend(ids_delta_sst)%name = 'CODELSST' |
---|
| 202 | infosend(ids_delta_sal)%action = .TRUE. |
---|
| 203 | infosend(ids_delta_sal)%name = 'CODELSSS' |
---|
[4370] | 204 | infosend(ids_dter)%action = .TRUE. |
---|
| 205 | infosend(ids_dter)%name = 'CODELTER' |
---|
| 206 | infosend(ids_dser)%action = .TRUE. |
---|
| 207 | infosend(ids_dser)%name = 'CODELSER' |
---|
| 208 | infosend(ids_dt_ds)%action = .TRUE. |
---|
| 209 | infosend(ids_dt_ds)%name = 'CODTDS' |
---|
[3815] | 210 | end if |
---|
| 211 | |
---|
[1279] | 212 | IF (version_ocean=='nemo') THEN |
---|
| 213 | infosend(ids_shftot)%action = .TRUE. ; infosend(ids_shftot)%name = 'COQSRMIX' |
---|
| 214 | infosend(ids_nsftot)%action = .TRUE. ; infosend(ids_nsftot)%name = 'COQNSMIX' |
---|
| 215 | infosend(ids_totrai)%action = .TRUE. ; infosend(ids_totrai)%name = 'COTOTRAI' |
---|
| 216 | infosend(ids_totsno)%action = .TRUE. ; infosend(ids_totsno)%name = 'COTOTSNO' |
---|
| 217 | infosend(ids_toteva)%action = .TRUE. ; infosend(ids_toteva)%name = 'COTOTEVA' |
---|
| 218 | infosend(ids_icevap)%action = .TRUE. ; infosend(ids_icevap)%name = 'COICEVAP' |
---|
| 219 | infosend(ids_liqrun)%action = .TRUE. ; infosend(ids_liqrun)%name = 'COLIQRUN' |
---|
| 220 | infosend(ids_taumod)%action = .TRUE. ; infosend(ids_taumod)%name = 'COTAUMOD' |
---|
| 221 | IF (carbon_cycle_cpl) THEN |
---|
| 222 | infosend(ids_atmco2)%action = .TRUE. ; infosend(ids_atmco2)%name = 'COATMCO2' |
---|
| 223 | ENDIF |
---|
[2872] | 224 | infosend(ids_qraioc)%action = .TRUE. ; infosend(ids_qraioc)%name = 'COQRAIOC' |
---|
| 225 | infosend(ids_qsnooc)%action = .TRUE. ; infosend(ids_qsnooc)%name = 'COQSNOOC' |
---|
| 226 | infosend(ids_qraiic)%action = .TRUE. ; infosend(ids_qraiic)%name = 'COQRAIIC' |
---|
| 227 | infosend(ids_qsnoic)%action = .TRUE. ; infosend(ids_qsnoic)%name = 'COQSNOIC' |
---|
[1279] | 228 | |
---|
| 229 | ELSE IF (version_ocean=='opa8') THEN |
---|
| 230 | infosend(ids_shfoce)%action = .TRUE. ; infosend(ids_shfoce)%name = 'COSHFOCE' |
---|
| 231 | infosend(ids_nsfoce)%action = .TRUE. ; infosend(ids_nsfoce)%name = 'CONSFOCE' |
---|
| 232 | infosend(ids_icevap)%action = .TRUE. ; infosend(ids_icevap)%name = 'COTFSICE' |
---|
| 233 | infosend(ids_ocevap)%action = .TRUE. ; infosend(ids_ocevap)%name = 'COTFSOCE' |
---|
| 234 | infosend(ids_totrai)%action = .TRUE. ; infosend(ids_totrai)%name = 'COTOLPSU' |
---|
| 235 | infosend(ids_totsno)%action = .TRUE. ; infosend(ids_totsno)%name = 'COTOSPSU' |
---|
| 236 | infosend(ids_runcoa)%action = .TRUE. ; infosend(ids_runcoa)%name = 'CORUNCOA' |
---|
| 237 | infosend(ids_rivflu)%action = .TRUE. ; infosend(ids_rivflu)%name = 'CORIVFLU' |
---|
| 238 | ENDIF |
---|
| 239 | |
---|
| 240 | ! Oceanic variables to receive |
---|
| 241 | |
---|
| 242 | inforecv(:)%action = .FALSE. |
---|
| 243 | |
---|
| 244 | inforecv(idr_sisutw)%action = .TRUE. ; inforecv(idr_sisutw)%name = 'SISUTESW' |
---|
| 245 | inforecv(idr_icecov)%action = .TRUE. ; inforecv(idr_icecov)%name = 'SIICECOV' |
---|
| 246 | inforecv(idr_icealw)%action = .TRUE. ; inforecv(idr_icealw)%name = 'SIICEALW' |
---|
| 247 | inforecv(idr_icetem)%action = .TRUE. ; inforecv(idr_icetem)%name = 'SIICTEMW' |
---|
[3815] | 248 | |
---|
[5117] | 249 | IF (activate_ocean_skin >= 1) THEN |
---|
[3815] | 250 | inforecv(idr_sss)%action = .TRUE. |
---|
| 251 | inforecv(idr_sss)%name = 'SISUSALW' |
---|
| 252 | end if |
---|
[1279] | 253 | |
---|
| 254 | IF (cpl_current ) THEN |
---|
| 255 | inforecv(idr_curenx)%action = .TRUE. ; inforecv(idr_curenx)%name = 'CURRENTX' |
---|
| 256 | inforecv(idr_cureny)%action = .TRUE. ; inforecv(idr_cureny)%name = 'CURRENTY' |
---|
| 257 | inforecv(idr_curenz)%action = .TRUE. ; inforecv(idr_curenz)%name = 'CURRENTZ' |
---|
| 258 | ENDIF |
---|
| 259 | |
---|
| 260 | IF (carbon_cycle_cpl ) THEN |
---|
| 261 | inforecv(idr_oceco2)%action = .TRUE. ; inforecv(idr_oceco2)%name = 'SICO2FLX' |
---|
| 262 | ENDIF |
---|
[4640] | 263 | IF (dms_cycle_cpl) THEN |
---|
| 264 | inforecv(idr_ocedms)%action = .TRUE. ; inforecv(idr_ocedms)%name = 'SIDMSFLX' |
---|
| 265 | ENDIF |
---|
[4754] | 266 | IF (n2o_cycle_cpl) THEN |
---|
| 267 | inforecv(idr_ocen2o)%action = .TRUE. ; inforecv(idr_ocen2o)%name = 'SIN2OFLX' |
---|
| 268 | ENDIF |
---|
[4640] | 269 | |
---|
[1279] | 270 | |
---|
| 271 | !************************************************************************************ |
---|
[782] | 272 | ! Here we go: psmile initialisation |
---|
| 273 | !************************************************************************************ |
---|
| 274 | IF (is_sequential) THEN |
---|
| 275 | CALL prism_init_comp_proto (comp_id, clmodnam, ierror) |
---|
| 276 | |
---|
| 277 | IF (ierror .NE. PRISM_Ok) THEN |
---|
| 278 | abort_message=' Probleme init dans prism_init_comp ' |
---|
[2311] | 279 | CALL abort_physic(modname,abort_message,1) |
---|
[782] | 280 | ELSE |
---|
[1279] | 281 | WRITE(lunout,*) 'inicma : init psmile ok ' |
---|
[782] | 282 | ENDIF |
---|
| 283 | ENDIF |
---|
| 284 | |
---|
| 285 | CALL prism_get_localcomm_proto (il_commlocal, ierror) |
---|
| 286 | !************************************************************************************ |
---|
| 287 | ! Domain decomposition |
---|
| 288 | !************************************************************************************ |
---|
[3465] | 289 | IF (grid_type==unstructured) THEN |
---|
[782] | 290 | |
---|
[3465] | 291 | ALLOCATE( ig_paral(klon_mpi_para_nb(mpi_rank) + 2) ) |
---|
| 292 | |
---|
| 293 | ig_paral(1) = 4 ! points partition for // |
---|
| 294 | ig_paral(2) = klon_mpi_para_nb(mpi_rank) ! nb of local cells |
---|
| 295 | |
---|
| 296 | DO jf=1, klon_mpi_para_nb(mpi_rank) |
---|
[4596] | 297 | ig_paral(2+jf) = ind_cell_glo_mpi(jf) |
---|
[3465] | 298 | ENDDO |
---|
| 299 | |
---|
| 300 | ELSE IF (grid_type==regular_lonlat) THEN |
---|
| 301 | |
---|
| 302 | ALLOCATE( ig_paral(3) ) |
---|
| 303 | |
---|
| 304 | ig_paral(1) = 1 ! apple partition for // |
---|
| 305 | ig_paral(2) = (jj_begin-1)*nbp_lon+ii_begin-1 ! offset |
---|
| 306 | ig_paral(3) = (jj_end*nbp_lon+ii_end) - (jj_begin*nbp_lon+ii_begin) + 1 |
---|
| 307 | |
---|
| 308 | IF (mpi_rank==mpi_size-1) ig_paral(3)=ig_paral(3)+nbp_lon-1 |
---|
| 309 | ELSE |
---|
| 310 | abort_message='Pb : type of grid unknown' |
---|
| 311 | CALL abort_physic(modname,abort_message,1) |
---|
| 312 | ENDIF |
---|
| 313 | |
---|
| 314 | |
---|
[1279] | 315 | WRITE(lunout,*) mpi_rank,'ig_paral--->',ig_paral(2),ig_paral(3) |
---|
[782] | 316 | |
---|
| 317 | ierror=PRISM_Ok |
---|
| 318 | CALL prism_def_partition_proto (il_part_id, ig_paral, ierror) |
---|
| 319 | |
---|
| 320 | IF (ierror .NE. PRISM_Ok) THEN |
---|
| 321 | abort_message=' Probleme dans prism_def_partition ' |
---|
[2311] | 322 | CALL abort_physic(modname,abort_message,1) |
---|
[782] | 323 | ELSE |
---|
[1279] | 324 | WRITE(lunout,*) 'inicma : decomposition domaine psmile ok ' |
---|
[782] | 325 | ENDIF |
---|
| 326 | |
---|
[3465] | 327 | il_var_nodims(1) = 2 ! rank of field array (1d or 2d) |
---|
| 328 | il_var_nodims(2) = 1 ! always 1 in current oasis version" doc oasis3mct p18 |
---|
[782] | 329 | |
---|
[3465] | 330 | il_var_actual_shape(1) = 1 ! min of 1st dimension (always 1) |
---|
| 331 | il_var_actual_shape(2) = nbp_lon ! max of 1st dimension |
---|
| 332 | il_var_actual_shape(3) = 1 ! min of 2nd dimension (always 1) |
---|
| 333 | il_var_actual_shape(4) = nbp_lat ! max of 2nd dimension |
---|
[782] | 334 | |
---|
| 335 | il_var_type = PRISM_Real |
---|
| 336 | |
---|
| 337 | !************************************************************************************ |
---|
[1279] | 338 | ! Oceanic Fields to receive |
---|
| 339 | ! Loop over all possible variables |
---|
[782] | 340 | !************************************************************************************ |
---|
[1279] | 341 | DO jf=1, maxrecv |
---|
| 342 | IF (inforecv(jf)%action) THEN |
---|
| 343 | CALL prism_def_var_proto(inforecv(jf)%nid, inforecv(jf)%name, il_part_id, & |
---|
| 344 | il_var_nodims, PRISM_In, il_var_actual_shape, il_var_type, & |
---|
| 345 | ierror) |
---|
| 346 | IF (ierror .NE. PRISM_Ok) THEN |
---|
| 347 | WRITE(lunout,*) 'inicma : Problem with prism_def_var_proto for field : ',& |
---|
| 348 | inforecv(jf)%name |
---|
[5103] | 349 | abort_message=' Problem in CALL to prism_def_var_proto for fields to receive' |
---|
[2311] | 350 | CALL abort_physic(modname,abort_message,1) |
---|
[1279] | 351 | ENDIF |
---|
[782] | 352 | ENDIF |
---|
| 353 | END DO |
---|
[4247] | 354 | |
---|
[4640] | 355 | |
---|
[4754] | 356 | IF (dms_cycle_cpl .OR. n2o_cycle_cpl) THEN |
---|
| 357 | CALL init_inca_oasis(inforecv(idr_ocedms:idr_ocen2o)) |
---|
[4640] | 358 | ENDIF |
---|
[5103] | 359 | |
---|
[782] | 360 | !************************************************************************************ |
---|
[1279] | 361 | ! Atmospheric Fields to send |
---|
| 362 | ! Loop over all possible variables |
---|
[782] | 363 | !************************************************************************************ |
---|
[1279] | 364 | DO jf=1,maxsend |
---|
| 365 | IF (infosend(jf)%action) THEN |
---|
| 366 | CALL prism_def_var_proto(infosend(jf)%nid, infosend(jf)%name, il_part_id, & |
---|
| 367 | il_var_nodims, PRISM_Out, il_var_actual_shape, il_var_type, & |
---|
| 368 | ierror) |
---|
| 369 | IF (ierror .NE. PRISM_Ok) THEN |
---|
| 370 | WRITE(lunout,*) 'inicma : Problem with prism_def_var_proto for field : ',& |
---|
| 371 | infosend(jf)%name |
---|
[5103] | 372 | abort_message=' Problem in CALL to prism_def_var_proto for fields to send' |
---|
[2311] | 373 | CALL abort_physic(modname,abort_message,1) |
---|
[1279] | 374 | ENDIF |
---|
[782] | 375 | ENDIF |
---|
| 376 | END DO |
---|
[1279] | 377 | |
---|
[782] | 378 | !************************************************************************************ |
---|
| 379 | ! End definition |
---|
| 380 | !************************************************************************************ |
---|
[4619] | 381 | |
---|
| 382 | IF (using_xios) CALL xios_oasis_enddef() |
---|
| 383 | |
---|
[782] | 384 | CALL prism_enddef_proto(ierror) |
---|
| 385 | IF (ierror .NE. PRISM_Ok) THEN |
---|
[5103] | 386 | abort_message=' Problem in CALL to prism_endef_proto' |
---|
[2311] | 387 | CALL abort_physic(modname,abort_message,1) |
---|
[782] | 388 | ELSE |
---|
[1279] | 389 | WRITE(lunout,*) 'inicma : endef psmile ok ' |
---|
[782] | 390 | ENDIF |
---|
[1279] | 391 | |
---|
[4642] | 392 | !$OMP END MASTER |
---|
[782] | 393 | |
---|
| 394 | END SUBROUTINE inicma |
---|
| 395 | |
---|
| 396 | !************************************************************************************ |
---|
| 397 | |
---|
| 398 | SUBROUTINE fromcpl(ktime, tab_get) |
---|
| 399 | ! ====================================================================== |
---|
[5103] | 400 | ! L. Fairhead (09/2003) adapted From L.Z.X Li: this SUBROUTINE reads the SST |
---|
[782] | 401 | ! and Sea-Ice provided by the coupler. Adaptation to psmile library |
---|
| 402 | !====================================================================== |
---|
[5099] | 403 | |
---|
[5112] | 404 | USE lmdz_print_control, ONLY: lunout |
---|
[5110] | 405 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[5111] | 406 | USE lmdz_abort_physic, ONLY: abort_physic |
---|
[782] | 407 | ! Input arguments |
---|
| 408 | !************************************************************************************ |
---|
| 409 | INTEGER, INTENT(IN) :: ktime |
---|
| 410 | |
---|
| 411 | ! Output arguments |
---|
| 412 | !************************************************************************************ |
---|
[4640] | 413 | REAL, DIMENSION(nbp_lon, jj_nb,maxrecv_phys), INTENT(OUT) :: tab_get |
---|
[782] | 414 | |
---|
| 415 | ! Local variables |
---|
| 416 | !************************************************************************************ |
---|
| 417 | INTEGER :: ierror, i |
---|
| 418 | INTEGER :: istart,iend |
---|
| 419 | CHARACTER (len = 20) :: modname = 'fromcpl' |
---|
| 420 | CHARACTER (len = 80) :: abort_message |
---|
[2346] | 421 | REAL, DIMENSION(nbp_lon*jj_nb) :: field |
---|
[782] | 422 | |
---|
| 423 | !************************************************************************************ |
---|
[1279] | 424 | WRITE (lunout,*) ' ' |
---|
| 425 | WRITE (lunout,*) 'Fromcpl: Reading fields from CPL, ktime=',ktime |
---|
| 426 | WRITE (lunout,*) ' ' |
---|
[782] | 427 | |
---|
| 428 | istart=ii_begin |
---|
[2429] | 429 | IF (is_south_pole_dyn) THEN |
---|
[2346] | 430 | iend=(jj_end-jj_begin)*nbp_lon+nbp_lon |
---|
[782] | 431 | ELSE |
---|
[2346] | 432 | iend=(jj_end-jj_begin)*nbp_lon+ii_end |
---|
[782] | 433 | ENDIF |
---|
| 434 | |
---|
[4640] | 435 | DO i = 1, maxrecv_phys |
---|
[1965] | 436 | IF (inforecv(i)%action .AND. inforecv(i)%nid .NE. -1) THEN |
---|
[1279] | 437 | field(:) = -99999. |
---|
| 438 | CALL prism_get_proto(inforecv(i)%nid, ktime, field(istart:iend), ierror) |
---|
[2346] | 439 | tab_get(:,:,i) = RESHAPE(field(:),(/nbp_lon,jj_nb/)) |
---|
[782] | 440 | |
---|
[1279] | 441 | IF (ierror .NE. PRISM_Ok .AND. ierror.NE.PRISM_Recvd .AND. & |
---|
| 442 | ierror.NE.PRISM_FromRest & |
---|
| 443 | .AND. ierror.NE.PRISM_Input .AND. ierror.NE.PRISM_RecvOut & |
---|
| 444 | .AND. ierror.NE.PRISM_FromRestOut) THEN |
---|
| 445 | WRITE (lunout,*) 'Error with receiving filed : ', inforecv(i)%name, ktime |
---|
| 446 | abort_message=' Problem in prism_get_proto ' |
---|
[2311] | 447 | CALL abort_physic(modname,abort_message,1) |
---|
[1279] | 448 | ENDIF |
---|
| 449 | ENDIF |
---|
[782] | 450 | END DO |
---|
| 451 | |
---|
| 452 | |
---|
| 453 | END SUBROUTINE fromcpl |
---|
| 454 | |
---|
| 455 | !************************************************************************************ |
---|
| 456 | |
---|
| 457 | SUBROUTINE intocpl(ktime, last, tab_put) |
---|
| 458 | ! ====================================================================== |
---|
[5103] | 459 | ! L. Fairhead (09/2003) adapted From L.Z.X Li: this SUBROUTINE provides the |
---|
[782] | 460 | ! atmospheric coupling fields to the coupler with the psmile library. |
---|
| 461 | ! IF last time step, writes output fields to binary files. |
---|
| 462 | ! ====================================================================== |
---|
[5099] | 463 | |
---|
| 464 | |
---|
[5112] | 465 | USE lmdz_print_control, ONLY: lunout |
---|
[5110] | 466 | USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat |
---|
[5111] | 467 | USE lmdz_abort_physic, ONLY: abort_physic |
---|
[782] | 468 | ! Input arguments |
---|
| 469 | !************************************************************************************ |
---|
[1279] | 470 | INTEGER, INTENT(IN) :: ktime |
---|
| 471 | LOGICAL, INTENT(IN) :: last |
---|
[2346] | 472 | REAL, DIMENSION(nbp_lon, jj_nb, maxsend), INTENT(IN) :: tab_put |
---|
[782] | 473 | |
---|
| 474 | ! Local variables |
---|
| 475 | !************************************************************************************ |
---|
[987] | 476 | LOGICAL :: checkout |
---|
| 477 | INTEGER :: istart,iend |
---|
| 478 | INTEGER :: wstart,wend |
---|
| 479 | INTEGER :: ierror, i |
---|
[2346] | 480 | REAL, DIMENSION(nbp_lon*jj_nb) :: field |
---|
[987] | 481 | CHARACTER (len = 20),PARAMETER :: modname = 'intocpl' |
---|
| 482 | CHARACTER (len = 80) :: abort_message |
---|
[782] | 483 | |
---|
| 484 | !************************************************************************************ |
---|
[987] | 485 | checkout=.FALSE. |
---|
[782] | 486 | |
---|
[1279] | 487 | WRITE(lunout,*) ' ' |
---|
| 488 | WRITE(lunout,*) 'Intocpl: sending fields to CPL, ktime= ', ktime |
---|
| 489 | WRITE(lunout,*) 'last = ', last |
---|
| 490 | WRITE(lunout,*) |
---|
[782] | 491 | |
---|
| 492 | |
---|
| 493 | istart=ii_begin |
---|
[2429] | 494 | IF (is_south_pole_dyn) THEN |
---|
[2346] | 495 | iend=(jj_end-jj_begin)*nbp_lon+nbp_lon |
---|
[782] | 496 | ELSE |
---|
[2346] | 497 | iend=(jj_end-jj_begin)*nbp_lon+ii_end |
---|
[782] | 498 | ENDIF |
---|
| 499 | |
---|
| 500 | IF (checkout) THEN |
---|
| 501 | wstart=istart |
---|
| 502 | wend=iend |
---|
[2429] | 503 | IF (is_north_pole_dyn) wstart=istart+nbp_lon-1 |
---|
| 504 | IF (is_south_pole_dyn) wend=iend-nbp_lon+1 |
---|
[782] | 505 | |
---|
[1279] | 506 | DO i = 1, maxsend |
---|
| 507 | IF (infosend(i)%action) THEN |
---|
[2346] | 508 | field = RESHAPE(tab_put(:,:,i),(/nbp_lon*jj_nb/)) |
---|
[1279] | 509 | CALL writefield_phy(infosend(i)%name,field(wstart:wend),1) |
---|
| 510 | END IF |
---|
| 511 | END DO |
---|
| 512 | END IF |
---|
| 513 | |
---|
[782] | 514 | !************************************************************************************ |
---|
| 515 | ! PRISM_PUT |
---|
| 516 | !************************************************************************************ |
---|
| 517 | |
---|
[1279] | 518 | DO i = 1, maxsend |
---|
[1965] | 519 | IF (infosend(i)%action .AND. infosend(i)%nid .NE. -1 ) THEN |
---|
[2346] | 520 | field = RESHAPE(tab_put(:,:,i),(/nbp_lon*jj_nb/)) |
---|
[1279] | 521 | CALL prism_put_proto(infosend(i)%nid, ktime, field(istart:iend), ierror) |
---|
| 522 | |
---|
| 523 | IF (ierror .NE. PRISM_Ok .AND. ierror.NE.PRISM_Sent .AND. ierror.NE.PRISM_ToRest & |
---|
| 524 | .AND. ierror.NE.PRISM_LocTrans .AND. ierror.NE.PRISM_Output .AND. & |
---|
| 525 | ierror.NE.PRISM_SentOut .AND. ierror.NE.PRISM_ToRestOut) THEN |
---|
| 526 | WRITE (lunout,*) 'Error with sending field :', infosend(i)%name, ktime |
---|
| 527 | abort_message=' Problem in prism_put_proto ' |
---|
[2311] | 528 | CALL abort_physic(modname,abort_message,1) |
---|
[1279] | 529 | ENDIF |
---|
| 530 | ENDIF |
---|
[782] | 531 | END DO |
---|
| 532 | |
---|
| 533 | !************************************************************************************ |
---|
| 534 | ! Finalize PSMILE for the case is_sequential, if parallel finalization is done |
---|
| 535 | ! from Finalize_parallel in dyn3dpar/parallel.F90 |
---|
| 536 | !************************************************************************************ |
---|
| 537 | |
---|
| 538 | IF (last) THEN |
---|
| 539 | IF (is_sequential) THEN |
---|
| 540 | CALL prism_terminate_proto(ierror) |
---|
| 541 | IF (ierror .NE. PRISM_Ok) THEN |
---|
[1279] | 542 | abort_message=' Problem in prism_terminate_proto ' |
---|
[2311] | 543 | CALL abort_physic(modname,abort_message,1) |
---|
[782] | 544 | ENDIF |
---|
| 545 | ENDIF |
---|
| 546 | ENDIF |
---|
| 547 | |
---|
| 548 | |
---|
| 549 | END SUBROUTINE intocpl |
---|
| 550 | |
---|
| 551 | #endif |
---|
[5111] | 552 | |
---|
[782] | 553 | END MODULE oasis |
---|