[532] | 1 | MODULE cpl_oasis3 |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE cpl_oasis *** |
---|
[4990] | 4 | !! Coupled O/A : coupled ocean-atmosphere case using OASIS3-MCT |
---|
[532] | 5 | !!===================================================================== |
---|
[5836] | 6 | !! History : 1.0 ! 2004-06 (R. Redler, NEC Laboratories Europe, Germany) Original code |
---|
| 7 | !! - ! 2004-11 (R. Redler, NEC Laboratories Europe; N. Keenlyside, W. Park, IFM-GEOMAR, Germany) revision |
---|
| 8 | !! - ! 2004-11 (V. Gayler, MPI M&D) Grid writing |
---|
| 9 | !! 2.0 ! 2005-08 (R. Redler, W. Park) frld initialization, paral(2) revision |
---|
| 10 | !! - ! 2005-09 (R. Redler) extended to allow for communication over root only |
---|
| 11 | !! - ! 2006-01 (W. Park) modification of physical part |
---|
| 12 | !! - ! 2006-02 (R. Redler, W. Park) buffer array fix for root exchange |
---|
| 13 | !! 3.4 ! 2011-11 (C. Harris) Changes to allow mutiple category fields |
---|
| 14 | !! 3.6 ! 2014-11 (S. Masson) OASIS3-MCT |
---|
[532] | 15 | !!---------------------------------------------------------------------- |
---|
[14072] | 16 | |
---|
[532] | 17 | !!---------------------------------------------------------------------- |
---|
[5407] | 18 | !! 'key_oasis3' coupled Ocean/Atmosphere via OASIS3-MCT |
---|
| 19 | !! 'key_oa3mct_v3' to be added for OASIS3-MCT version 3 |
---|
[532] | 20 | !!---------------------------------------------------------------------- |
---|
[4990] | 21 | !! cpl_init : initialization of coupled mode communication |
---|
| 22 | !! cpl_define : definition of grid and fields |
---|
[5836] | 23 | !! cpl_snd : snd out fields in coupled mode |
---|
| 24 | !! cpl_rcv : receive fields in coupled mode |
---|
[4990] | 25 | !! cpl_finalize : finalize the coupled mode communication |
---|
[532] | 26 | !!---------------------------------------------------------------------- |
---|
[4990] | 27 | #if defined key_oasis3 |
---|
| 28 | USE mod_oasis ! OASIS3-MCT module |
---|
| 29 | #endif |
---|
[1218] | 30 | USE par_oce ! ocean parameters |
---|
[532] | 31 | USE dom_oce ! ocean space and time domain |
---|
| 32 | USE in_out_manager ! I/O manager |
---|
[2715] | 33 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
| 34 | |
---|
[532] | 35 | IMPLICIT NONE |
---|
[1218] | 36 | PRIVATE |
---|
[532] | 37 | |
---|
[4990] | 38 | PUBLIC cpl_init |
---|
| 39 | PUBLIC cpl_define |
---|
| 40 | PUBLIC cpl_snd |
---|
| 41 | PUBLIC cpl_rcv |
---|
| 42 | PUBLIC cpl_freq |
---|
| 43 | PUBLIC cpl_finalize |
---|
[2715] | 44 | |
---|
| 45 | INTEGER, PUBLIC :: OASIS_Rcv = 1 !: return code if received field |
---|
| 46 | INTEGER, PUBLIC :: OASIS_idle = 0 !: return code if nothing done by oasis |
---|
[4990] | 47 | INTEGER :: ncomp_id ! id returned by oasis_init_comp |
---|
[2715] | 48 | INTEGER :: nerror ! return error code |
---|
[4990] | 49 | #if ! defined key_oasis3 |
---|
| 50 | ! OASIS Variables not used. defined only for compilation purpose |
---|
| 51 | INTEGER :: OASIS_Out = -1 |
---|
| 52 | INTEGER :: OASIS_REAL = -1 |
---|
| 53 | INTEGER :: OASIS_Ok = -1 |
---|
| 54 | INTEGER :: OASIS_In = -1 |
---|
| 55 | INTEGER :: OASIS_Sent = -1 |
---|
| 56 | INTEGER :: OASIS_SentOut = -1 |
---|
| 57 | INTEGER :: OASIS_ToRest = -1 |
---|
| 58 | INTEGER :: OASIS_ToRestOut = -1 |
---|
| 59 | INTEGER :: OASIS_Recvd = -1 |
---|
| 60 | INTEGER :: OASIS_RecvOut = -1 |
---|
| 61 | INTEGER :: OASIS_FromRest = -1 |
---|
| 62 | INTEGER :: OASIS_FromRestOut = -1 |
---|
| 63 | #endif |
---|
[2715] | 64 | |
---|
[14072] | 65 | INTEGER :: nrcv ! total number of fields received |
---|
| 66 | INTEGER :: nsnd ! total number of fields sent |
---|
[5407] | 67 | INTEGER :: ncplmodel ! Maximum number of models to/from which NEMO is potentialy sending/receiving data |
---|
[14007] | 68 | INTEGER, PUBLIC, PARAMETER :: nmaxfld=62 ! Maximum number of coupling fields |
---|
[4990] | 69 | INTEGER, PUBLIC, PARAMETER :: nmaxcat=5 ! Maximum number of coupling fields |
---|
| 70 | INTEGER, PUBLIC, PARAMETER :: nmaxcpl=5 ! Maximum number of coupling fields |
---|
[14072] | 71 | |
---|
[3294] | 72 | TYPE, PUBLIC :: FLD_CPL !: Type for coupling field information |
---|
| 73 | LOGICAL :: laction ! To be coupled or not |
---|
[14072] | 74 | CHARACTER(len = 8) :: clname ! Name of the coupling field |
---|
| 75 | CHARACTER(len = 1) :: clgrid ! Grid type |
---|
[3294] | 76 | REAL(wp) :: nsgn ! Control of the sign change |
---|
[4990] | 77 | INTEGER, DIMENSION(nmaxcat,nmaxcpl) :: nid ! Id of the field (no more than 9 categories and 9 extrena models) |
---|
[3294] | 78 | INTEGER :: nct ! Number of categories in field |
---|
[4990] | 79 | INTEGER :: ncplmodel ! Maximum number of models to/from which this variable may be sent/received |
---|
[1218] | 80 | END TYPE FLD_CPL |
---|
[532] | 81 | |
---|
[2715] | 82 | TYPE(FLD_CPL), DIMENSION(nmaxfld), PUBLIC :: srcv, ssnd !: Coupling fields |
---|
[532] | 83 | |
---|
[2715] | 84 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: exfld ! Temporary buffer for receiving |
---|
[532] | 85 | |
---|
| 86 | !!---------------------------------------------------------------------- |
---|
[9598] | 87 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
[2528] | 88 | !! $Id$ |
---|
[10068] | 89 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
[532] | 90 | !!---------------------------------------------------------------------- |
---|
| 91 | CONTAINS |
---|
| 92 | |
---|
[5407] | 93 | SUBROUTINE cpl_init( cd_modname, kl_comm ) |
---|
[532] | 94 | !!------------------------------------------------------------------- |
---|
[4990] | 95 | !! *** ROUTINE cpl_init *** |
---|
[532] | 96 | !! |
---|
| 97 | !! ** Purpose : Initialize coupled mode communication for ocean |
---|
| 98 | !! exchange between AGCM, OGCM and COUPLER. (OASIS3 software) |
---|
| 99 | !! |
---|
[14072] | 100 | !! ** Method : OASIS3 MPI communication |
---|
[532] | 101 | !!-------------------------------------------------------------------- |
---|
[5836] | 102 | CHARACTER(len = *), INTENT(in ) :: cd_modname ! model name as set in namcouple file |
---|
| 103 | INTEGER , INTENT( out) :: kl_comm ! local communicator of the model |
---|
[1226] | 104 | !!-------------------------------------------------------------------- |
---|
[1218] | 105 | |
---|
[1579] | 106 | ! WARNING: No write in numout in this routine |
---|
| 107 | !============================================ |
---|
| 108 | |
---|
[532] | 109 | !------------------------------------------------------------------ |
---|
[4990] | 110 | ! 1st Initialize the OASIS system for the application |
---|
[532] | 111 | !------------------------------------------------------------------ |
---|
[5407] | 112 | CALL oasis_init_comp ( ncomp_id, TRIM(cd_modname), nerror ) |
---|
[12377] | 113 | IF( nerror /= OASIS_Ok ) & |
---|
[4990] | 114 | CALL oasis_abort (ncomp_id, 'cpl_init', 'Failure in oasis_init_comp') |
---|
[532] | 115 | |
---|
| 116 | !------------------------------------------------------------------ |
---|
[14227] | 117 | ! 3rd Get an MPI communicator for OCE local communication |
---|
[532] | 118 | !------------------------------------------------------------------ |
---|
| 119 | |
---|
[4990] | 120 | CALL oasis_get_localcomm ( kl_comm, nerror ) |
---|
[12377] | 121 | IF( nerror /= OASIS_Ok ) & |
---|
[4990] | 122 | CALL oasis_abort (ncomp_id, 'cpl_init','Failure in oasis_get_localcomm' ) |
---|
[2715] | 123 | ! |
---|
[4990] | 124 | END SUBROUTINE cpl_init |
---|
[532] | 125 | |
---|
| 126 | |
---|
[4990] | 127 | SUBROUTINE cpl_define( krcv, ksnd, kcplmodel ) |
---|
[532] | 128 | !!------------------------------------------------------------------- |
---|
[4990] | 129 | !! *** ROUTINE cpl_define *** |
---|
[532] | 130 | !! |
---|
| 131 | !! ** Purpose : Define grid and field information for ocean |
---|
| 132 | !! exchange between AGCM, OGCM and COUPLER. (OASIS3 software) |
---|
| 133 | !! |
---|
[14072] | 134 | !! ** Method : OASIS3 MPI communication |
---|
[532] | 135 | !!-------------------------------------------------------------------- |
---|
[2715] | 136 | INTEGER, INTENT(in) :: krcv, ksnd ! Number of received and sent coupling fields |
---|
[4990] | 137 | INTEGER, INTENT(in) :: kcplmodel ! Maximum number of models to/from which NEMO is potentialy sending/receiving data |
---|
[1226] | 138 | ! |
---|
[2715] | 139 | INTEGER :: id_part |
---|
| 140 | INTEGER :: paral(5) ! OASIS3 box partition |
---|
[10404] | 141 | INTEGER :: ishape(4) ! shape of arrays passed to PSMILe |
---|
[4990] | 142 | INTEGER :: ji,jc,jm ! local loop indicees |
---|
| 143 | CHARACTER(LEN=64) :: zclname |
---|
| 144 | CHARACTER(LEN=2) :: cli2 |
---|
[532] | 145 | !!-------------------------------------------------------------------- |
---|
[1218] | 146 | |
---|
[532] | 147 | IF(lwp) WRITE(numout,*) |
---|
[4990] | 148 | IF(lwp) WRITE(numout,*) 'cpl_define : initialization in coupled ocean/atmosphere case' |
---|
[532] | 149 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~' |
---|
| 150 | IF(lwp) WRITE(numout,*) |
---|
| 151 | |
---|
[5407] | 152 | ncplmodel = kcplmodel |
---|
[4990] | 153 | IF( kcplmodel > nmaxcpl ) THEN |
---|
[5407] | 154 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'ncplmodel is larger than nmaxcpl, increase nmaxcpl') ; RETURN |
---|
[4990] | 155 | ENDIF |
---|
[5407] | 156 | |
---|
| 157 | nrcv = krcv |
---|
| 158 | IF( nrcv > nmaxfld ) THEN |
---|
| 159 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'nrcv is larger than nmaxfld, increase nmaxfld') ; RETURN |
---|
| 160 | ENDIF |
---|
| 161 | |
---|
| 162 | nsnd = ksnd |
---|
| 163 | IF( nsnd > nmaxfld ) THEN |
---|
| 164 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'nsnd is larger than nmaxfld, increase nmaxfld') ; RETURN |
---|
| 165 | ENDIF |
---|
[532] | 166 | ! |
---|
[13414] | 167 | ! ... Define the shape for the area that excludes the halo as we don't want them to be "seen" by oasis |
---|
[532] | 168 | ! |
---|
[10404] | 169 | ishape(1) = 1 |
---|
[13286] | 170 | ishape(2) = Ni_0 |
---|
[10404] | 171 | ishape(3) = 1 |
---|
[13286] | 172 | ishape(4) = Nj_0 |
---|
[532] | 173 | ! |
---|
| 174 | ! ... Allocate memory for data exchange |
---|
| 175 | ! |
---|
[13414] | 176 | ALLOCATE(exfld(Ni_0, Nj_0), stat = nerror) ! allocate only inner domain (without halos) |
---|
[2715] | 177 | IF( nerror > 0 ) THEN |
---|
[4990] | 178 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in allocating exfld') ; RETURN |
---|
[532] | 179 | ENDIF |
---|
| 180 | ! |
---|
[1218] | 181 | ! ----------------------------------------------------------------- |
---|
[14072] | 182 | ! ... Define the partition, excluding halos as we don't want them to be "seen" by oasis |
---|
[1218] | 183 | ! ----------------------------------------------------------------- |
---|
[14072] | 184 | |
---|
[13414] | 185 | paral(1) = 2 ! box partitioning |
---|
[14072] | 186 | paral(2) = Ni0glo * mjg0(nn_hls) + mig0(nn_hls) ! NEMO lower left corner global offset, without halos |
---|
[13414] | 187 | paral(3) = Ni_0 ! local extent in i, excluding halos |
---|
| 188 | paral(4) = Nj_0 ! local extent in j, excluding halos |
---|
| 189 | paral(5) = Ni0glo ! global extent in x, excluding halos |
---|
[14072] | 190 | |
---|
[12377] | 191 | IF( sn_cfctl%l_oasout ) THEN |
---|
[1218] | 192 | WRITE(numout,*) ' multiexchg: paral (1:5)', paral |
---|
[13414] | 193 | WRITE(numout,*) ' multiexchg: Ni_0, Nj_0 =', Ni_0, Nj_0 |
---|
[13286] | 194 | WRITE(numout,*) ' multiexchg: Nis0, Nie0, nimpp =', Nis0, Nie0, nimpp |
---|
| 195 | WRITE(numout,*) ' multiexchg: Njs0, Nje0, njmpp =', Njs0, Nje0, njmpp |
---|
[1218] | 196 | ENDIF |
---|
[14072] | 197 | |
---|
[13414] | 198 | CALL oasis_def_partition ( id_part, paral, nerror, Ni0glo*Nj0glo ) ! global number of points, excluding halos |
---|
[532] | 199 | ! |
---|
[14072] | 200 | ! ... Announce send variables. |
---|
[532] | 201 | ! |
---|
[4990] | 202 | ssnd(:)%ncplmodel = kcplmodel |
---|
| 203 | ! |
---|
[1226] | 204 | DO ji = 1, ksnd |
---|
[12377] | 205 | IF( ssnd(ji)%laction ) THEN |
---|
[4990] | 206 | |
---|
| 207 | IF( ssnd(ji)%nct > nmaxcat ) THEN |
---|
| 208 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'Number of categories of '// & |
---|
| 209 | & TRIM(ssnd(ji)%clname)//' is larger than nmaxcat, increase nmaxcat' ) |
---|
| 210 | RETURN |
---|
| 211 | ENDIF |
---|
[14072] | 212 | |
---|
[3294] | 213 | DO jc = 1, ssnd(ji)%nct |
---|
[4990] | 214 | DO jm = 1, kcplmodel |
---|
| 215 | |
---|
[12377] | 216 | IF( ssnd(ji)%nct .GT. 1 ) THEN |
---|
[4990] | 217 | WRITE(cli2,'(i2.2)') jc |
---|
| 218 | zclname = TRIM(ssnd(ji)%clname)//'_cat'//cli2 |
---|
| 219 | ELSE |
---|
| 220 | zclname = ssnd(ji)%clname |
---|
| 221 | ENDIF |
---|
[12377] | 222 | IF( kcplmodel > 1 ) THEN |
---|
[4990] | 223 | WRITE(cli2,'(i2.2)') jm |
---|
| 224 | zclname = 'model'//cli2//'_'//TRIM(zclname) |
---|
| 225 | ENDIF |
---|
| 226 | #if defined key_agrif |
---|
[14072] | 227 | IF( agrif_fixed() /= 0 ) THEN |
---|
[4990] | 228 | zclname=TRIM(Agrif_CFixed())//'_'//TRIM(zclname) |
---|
[12377] | 229 | ENDIF |
---|
[4990] | 230 | #endif |
---|
[12377] | 231 | IF( sn_cfctl%l_oasout ) WRITE(numout,*) "Define", ji, jc, jm, " "//TRIM(zclname), " for ", OASIS_Out |
---|
[10404] | 232 | CALL oasis_def_var (ssnd(ji)%nid(jc,jm), zclname, id_part , (/ 2, 1 /), & |
---|
[4990] | 233 | & OASIS_Out , ishape , OASIS_REAL, nerror ) |
---|
[12377] | 234 | IF( nerror /= OASIS_Ok ) THEN |
---|
[4990] | 235 | WRITE(numout,*) 'Failed to define transient ', ji, jc, jm, " "//TRIM(zclname) |
---|
| 236 | CALL oasis_abort ( ssnd(ji)%nid(jc,jm), 'cpl_define', 'Failure in oasis_def_var' ) |
---|
| 237 | ENDIF |
---|
[12377] | 238 | IF( sn_cfctl%l_oasout .AND. ssnd(ji)%nid(jc,jm) /= -1 ) WRITE(numout,*) "variable defined in the namcouple" |
---|
| 239 | IF( sn_cfctl%l_oasout .AND. ssnd(ji)%nid(jc,jm) == -1 ) WRITE(numout,*) "variable NOT defined in the namcouple" |
---|
[4990] | 240 | END DO |
---|
[3294] | 241 | END DO |
---|
[1218] | 242 | ENDIF |
---|
| 243 | END DO |
---|
| 244 | ! |
---|
[14072] | 245 | ! ... Announce received variables. |
---|
[1218] | 246 | ! |
---|
[4990] | 247 | srcv(:)%ncplmodel = kcplmodel |
---|
| 248 | ! |
---|
[1226] | 249 | DO ji = 1, krcv |
---|
[14072] | 250 | IF( srcv(ji)%laction ) THEN |
---|
| 251 | |
---|
[4990] | 252 | IF( srcv(ji)%nct > nmaxcat ) THEN |
---|
| 253 | CALL oasis_abort ( ncomp_id, 'cpl_define', 'Number of categories of '// & |
---|
| 254 | & TRIM(srcv(ji)%clname)//' is larger than nmaxcat, increase nmaxcat' ) |
---|
| 255 | RETURN |
---|
| 256 | ENDIF |
---|
[14072] | 257 | |
---|
[3294] | 258 | DO jc = 1, srcv(ji)%nct |
---|
[4990] | 259 | DO jm = 1, kcplmodel |
---|
[14072] | 260 | |
---|
[12377] | 261 | IF( srcv(ji)%nct .GT. 1 ) THEN |
---|
[4990] | 262 | WRITE(cli2,'(i2.2)') jc |
---|
| 263 | zclname = TRIM(srcv(ji)%clname)//'_cat'//cli2 |
---|
| 264 | ELSE |
---|
| 265 | zclname = srcv(ji)%clname |
---|
| 266 | ENDIF |
---|
[12377] | 267 | IF( kcplmodel > 1 ) THEN |
---|
[4990] | 268 | WRITE(cli2,'(i2.2)') jm |
---|
| 269 | zclname = 'model'//cli2//'_'//TRIM(zclname) |
---|
| 270 | ENDIF |
---|
| 271 | #if defined key_agrif |
---|
[14072] | 272 | IF( agrif_fixed() /= 0 ) THEN |
---|
[4990] | 273 | zclname=TRIM(Agrif_CFixed())//'_'//TRIM(zclname) |
---|
[12377] | 274 | ENDIF |
---|
[4990] | 275 | #endif |
---|
[12377] | 276 | IF( sn_cfctl%l_oasout ) WRITE(numout,*) "Define", ji, jc, jm, " "//TRIM(zclname), " for ", OASIS_In |
---|
[10404] | 277 | CALL oasis_def_var (srcv(ji)%nid(jc,jm), zclname, id_part , (/ 2, 1 /), & |
---|
[4990] | 278 | & OASIS_In , ishape , OASIS_REAL, nerror ) |
---|
[12377] | 279 | IF( nerror /= OASIS_Ok ) THEN |
---|
[4990] | 280 | WRITE(numout,*) 'Failed to define transient ', ji, jc, jm, " "//TRIM(zclname) |
---|
| 281 | CALL oasis_abort ( srcv(ji)%nid(jc,jm), 'cpl_define', 'Failure in oasis_def_var' ) |
---|
| 282 | ENDIF |
---|
[12377] | 283 | IF( sn_cfctl%l_oasout .AND. srcv(ji)%nid(jc,jm) /= -1 ) WRITE(numout,*) "variable defined in the namcouple" |
---|
| 284 | IF( sn_cfctl%l_oasout .AND. srcv(ji)%nid(jc,jm) == -1 ) WRITE(numout,*) "variable NOT defined in the namcouple" |
---|
[4990] | 285 | |
---|
| 286 | END DO |
---|
[3294] | 287 | END DO |
---|
[1218] | 288 | ENDIF |
---|
| 289 | END DO |
---|
[14072] | 290 | |
---|
[532] | 291 | !------------------------------------------------------------------ |
---|
[1218] | 292 | ! End of definition phase |
---|
[532] | 293 | !------------------------------------------------------------------ |
---|
[14072] | 294 | ! |
---|
[12132] | 295 | #if defined key_agrif |
---|
[14434] | 296 | ! Warning: Agrif_Nb_Fine_Grids not yet defined at this stage for Agrif_Root -> must use Agrif_Root_Only() |
---|
| 297 | IF( Agrif_Root_Only() .OR. agrif_fixed() == Agrif_Nb_Fine_Grids() ) THEN |
---|
[12132] | 298 | #endif |
---|
[4990] | 299 | CALL oasis_enddef(nerror) |
---|
| 300 | IF( nerror /= OASIS_Ok ) CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef') |
---|
[12132] | 301 | #if defined key_agrif |
---|
| 302 | ENDIF |
---|
| 303 | #endif |
---|
[2715] | 304 | ! |
---|
[4990] | 305 | END SUBROUTINE cpl_define |
---|
[14072] | 306 | |
---|
| 307 | |
---|
[4990] | 308 | SUBROUTINE cpl_snd( kid, kstep, pdata, kinfo ) |
---|
[532] | 309 | !!--------------------------------------------------------------------- |
---|
[4990] | 310 | !! *** ROUTINE cpl_snd *** |
---|
[532] | 311 | !! |
---|
| 312 | !! ** Purpose : - At each coupling time-step,this routine sends fields |
---|
| 313 | !! like sst or ice cover to the coupler or remote application. |
---|
| 314 | !!---------------------------------------------------------------------- |
---|
[3294] | 315 | INTEGER , INTENT(in ) :: kid ! variable index in the array |
---|
| 316 | INTEGER , INTENT( out) :: kinfo ! OASIS3 info argument |
---|
| 317 | INTEGER , INTENT(in ) :: kstep ! ocean time-step in seconds |
---|
| 318 | REAL(wp), DIMENSION(:,:,:), INTENT(in ) :: pdata |
---|
| 319 | !! |
---|
[4990] | 320 | INTEGER :: jc,jm ! local loop index |
---|
[532] | 321 | !!-------------------------------------------------------------------- |
---|
| 322 | ! |
---|
[1218] | 323 | ! snd data to OASIS3 |
---|
[532] | 324 | ! |
---|
[3294] | 325 | DO jc = 1, ssnd(kid)%nct |
---|
[4990] | 326 | DO jm = 1, ssnd(kid)%ncplmodel |
---|
[14072] | 327 | |
---|
[13414] | 328 | IF( ssnd(kid)%nid(jc,jm) /= -1 ) THEN ! exclude halos from data sent to oasis |
---|
[13286] | 329 | CALL oasis_put ( ssnd(kid)%nid(jc,jm), kstep, pdata(Nis0:Nie0, Njs0:Nje0,jc), kinfo ) |
---|
[14072] | 330 | |
---|
| 331 | IF ( sn_cfctl%l_oasout ) THEN |
---|
[4990] | 332 | IF ( kinfo == OASIS_Sent .OR. kinfo == OASIS_ToRest .OR. & |
---|
| 333 | & kinfo == OASIS_SentOut .OR. kinfo == OASIS_ToRestOut ) THEN |
---|
| 334 | WRITE(numout,*) '****************' |
---|
| 335 | WRITE(numout,*) 'oasis_put: Outgoing ', ssnd(kid)%clname |
---|
| 336 | WRITE(numout,*) 'oasis_put: ivarid ', ssnd(kid)%nid(jc,jm) |
---|
| 337 | WRITE(numout,*) 'oasis_put: kstep ', kstep |
---|
| 338 | WRITE(numout,*) 'oasis_put: info ', kinfo |
---|
[13286] | 339 | WRITE(numout,*) ' - Minimum value is ', MINVAL(pdata(Nis0:Nie0,Njs0:Nje0,jc)) |
---|
| 340 | WRITE(numout,*) ' - Maximum value is ', MAXVAL(pdata(Nis0:Nie0,Njs0:Nje0,jc)) |
---|
| 341 | WRITE(numout,*) ' - Sum value is ', SUM(pdata(Nis0:Nie0,Njs0:Nje0,jc)) |
---|
[4990] | 342 | WRITE(numout,*) '****************' |
---|
| 343 | ENDIF |
---|
| 344 | ENDIF |
---|
[14072] | 345 | |
---|
[3294] | 346 | ENDIF |
---|
[14072] | 347 | |
---|
[4990] | 348 | ENDDO |
---|
[3294] | 349 | ENDDO |
---|
[2715] | 350 | ! |
---|
[4990] | 351 | END SUBROUTINE cpl_snd |
---|
[532] | 352 | |
---|
| 353 | |
---|
[4990] | 354 | SUBROUTINE cpl_rcv( kid, kstep, pdata, pmask, kinfo ) |
---|
[532] | 355 | !!--------------------------------------------------------------------- |
---|
[4990] | 356 | !! *** ROUTINE cpl_rcv *** |
---|
[532] | 357 | !! |
---|
| 358 | !! ** Purpose : - At each coupling time-step,this routine receives fields |
---|
| 359 | !! like stresses and fluxes from the coupler or remote application. |
---|
| 360 | !!---------------------------------------------------------------------- |
---|
[3294] | 361 | INTEGER , INTENT(in ) :: kid ! variable index in the array |
---|
| 362 | INTEGER , INTENT(in ) :: kstep ! ocean time-step in seconds |
---|
| 363 | REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: pdata ! IN to keep the value if nothing is done |
---|
[4990] | 364 | REAL(wp), DIMENSION(:,:,:), INTENT(in ) :: pmask ! coupling mask |
---|
[3294] | 365 | INTEGER , INTENT( out) :: kinfo ! OASIS3 info argument |
---|
[532] | 366 | !! |
---|
[4990] | 367 | INTEGER :: jc,jm ! local loop index |
---|
[13286] | 368 | LOGICAL :: llaction, ll_1st |
---|
[1218] | 369 | !!-------------------------------------------------------------------- |
---|
[532] | 370 | ! |
---|
[1218] | 371 | ! receive local data from OASIS3 on every process |
---|
| 372 | ! |
---|
[4990] | 373 | kinfo = OASIS_idle |
---|
| 374 | ! |
---|
[3294] | 375 | DO jc = 1, srcv(kid)%nct |
---|
[13286] | 376 | ll_1st = .TRUE. |
---|
[532] | 377 | |
---|
[4990] | 378 | DO jm = 1, srcv(kid)%ncplmodel |
---|
| 379 | |
---|
| 380 | IF( srcv(kid)%nid(jc,jm) /= -1 ) THEN |
---|
| 381 | |
---|
[14072] | 382 | CALL oasis_get ( srcv(kid)%nid(jc,jm), kstep, exfld, kinfo ) |
---|
| 383 | |
---|
[4990] | 384 | llaction = kinfo == OASIS_Recvd .OR. kinfo == OASIS_FromRest .OR. & |
---|
| 385 | & kinfo == OASIS_RecvOut .OR. kinfo == OASIS_FromRestOut |
---|
[14072] | 386 | |
---|
[13415] | 387 | IF ( sn_cfctl%l_oasout ) & |
---|
| 388 | & WRITE(numout,*) "llaction, kinfo, kstep, ivarid: " , llaction, kinfo, kstep, srcv(kid)%nid(jc,jm) |
---|
[14072] | 389 | |
---|
[13414] | 390 | IF( llaction ) THEN ! data received from oasis do not include halos |
---|
[14072] | 391 | |
---|
[4990] | 392 | kinfo = OASIS_Rcv |
---|
[14072] | 393 | IF( ll_1st ) THEN |
---|
[13286] | 394 | pdata(Nis0:Nie0,Njs0:Nje0,jc) = exfld(:,:) * pmask(Nis0:Nie0,Njs0:Nje0,jm) |
---|
| 395 | ll_1st = .FALSE. |
---|
[4990] | 396 | ELSE |
---|
[13286] | 397 | pdata(Nis0:Nie0,Njs0:Nje0,jc) = pdata(Nis0:Nie0,Njs0:Nje0,jc) & |
---|
| 398 | & + exfld(:,:) * pmask(Nis0:Nie0,Njs0:Nje0,jm) |
---|
[4990] | 399 | ENDIF |
---|
[14072] | 400 | |
---|
| 401 | IF ( sn_cfctl%l_oasout ) THEN |
---|
[4990] | 402 | WRITE(numout,*) '****************' |
---|
| 403 | WRITE(numout,*) 'oasis_get: Incoming ', srcv(kid)%clname |
---|
| 404 | WRITE(numout,*) 'oasis_get: ivarid ' , srcv(kid)%nid(jc,jm) |
---|
| 405 | WRITE(numout,*) 'oasis_get: kstep', kstep |
---|
| 406 | WRITE(numout,*) 'oasis_get: info ', kinfo |
---|
[13286] | 407 | WRITE(numout,*) ' - Minimum value is ', MINVAL(pdata(Nis0:Nie0,Njs0:Nje0,jc)) |
---|
| 408 | WRITE(numout,*) ' - Maximum value is ', MAXVAL(pdata(Nis0:Nie0,Njs0:Nje0,jc)) |
---|
| 409 | WRITE(numout,*) ' - Sum value is ', SUM(pdata(Nis0:Nie0,Njs0:Nje0,jc)) |
---|
[4990] | 410 | WRITE(numout,*) '****************' |
---|
| 411 | ENDIF |
---|
[14072] | 412 | |
---|
[4990] | 413 | ENDIF |
---|
[14072] | 414 | |
---|
[4990] | 415 | ENDIF |
---|
[14072] | 416 | |
---|
[4990] | 417 | ENDDO |
---|
[4806] | 418 | |
---|
[13414] | 419 | !--- we must call lbc_lnk to fill the halos that where not received. |
---|
[13286] | 420 | IF( .NOT. ll_1st ) THEN |
---|
[14072] | 421 | CALL lbc_lnk( 'cpl_oasis3', pdata(:,:,jc), srcv(kid)%clgrid, srcv(kid)%nsgn ) |
---|
[10425] | 422 | ENDIF |
---|
[14072] | 423 | |
---|
[3294] | 424 | ENDDO |
---|
[2715] | 425 | ! |
---|
[4990] | 426 | END SUBROUTINE cpl_rcv |
---|
[532] | 427 | |
---|
| 428 | |
---|
[14072] | 429 | INTEGER FUNCTION cpl_freq( cdfieldname ) |
---|
[2528] | 430 | !!--------------------------------------------------------------------- |
---|
[4990] | 431 | !! *** ROUTINE cpl_freq *** |
---|
[2528] | 432 | !! |
---|
| 433 | !! ** Purpose : - send back the coupling frequency for a particular field |
---|
| 434 | !!---------------------------------------------------------------------- |
---|
[5407] | 435 | CHARACTER(len = *), INTENT(in) :: cdfieldname ! field name as set in namcouple file |
---|
[4990] | 436 | !! |
---|
[5407] | 437 | INTEGER :: id |
---|
[4990] | 438 | INTEGER :: info |
---|
| 439 | INTEGER, DIMENSION(1) :: itmp |
---|
[5407] | 440 | INTEGER :: ji,jm ! local loop index |
---|
| 441 | INTEGER :: mop |
---|
[2715] | 442 | !!---------------------------------------------------------------------- |
---|
[5407] | 443 | cpl_freq = 0 ! defaut definition |
---|
| 444 | id = -1 ! defaut definition |
---|
[2715] | 445 | ! |
---|
[5407] | 446 | DO ji = 1, nsnd |
---|
[12377] | 447 | IF(ssnd(ji)%laction ) THEN |
---|
[5407] | 448 | DO jm = 1, ncplmodel |
---|
| 449 | IF( ssnd(ji)%nid(1,jm) /= -1 ) THEN |
---|
| 450 | IF( TRIM(cdfieldname) == TRIM(ssnd(ji)%clname) ) THEN |
---|
| 451 | id = ssnd(ji)%nid(1,jm) |
---|
| 452 | mop = OASIS_Out |
---|
| 453 | ENDIF |
---|
| 454 | ENDIF |
---|
| 455 | ENDDO |
---|
| 456 | ENDIF |
---|
| 457 | ENDDO |
---|
| 458 | DO ji = 1, nrcv |
---|
[12377] | 459 | IF(srcv(ji)%laction ) THEN |
---|
[5407] | 460 | DO jm = 1, ncplmodel |
---|
| 461 | IF( srcv(ji)%nid(1,jm) /= -1 ) THEN |
---|
| 462 | IF( TRIM(cdfieldname) == TRIM(srcv(ji)%clname) ) THEN |
---|
| 463 | id = srcv(ji)%nid(1,jm) |
---|
| 464 | mop = OASIS_In |
---|
| 465 | ENDIF |
---|
| 466 | ENDIF |
---|
| 467 | ENDDO |
---|
| 468 | ENDIF |
---|
| 469 | ENDDO |
---|
| 470 | ! |
---|
| 471 | IF( id /= -1 ) THEN |
---|
[10577] | 472 | #if ! defined key_oa3mct_v1v2 |
---|
[5407] | 473 | CALL oasis_get_freqs(id, mop, 1, itmp, info) |
---|
| 474 | #else |
---|
| 475 | CALL oasis_get_freqs(id, 1, itmp, info) |
---|
| 476 | #endif |
---|
| 477 | cpl_freq = itmp(1) |
---|
| 478 | ENDIF |
---|
| 479 | ! |
---|
[4990] | 480 | END FUNCTION cpl_freq |
---|
[2528] | 481 | |
---|
| 482 | |
---|
[4990] | 483 | SUBROUTINE cpl_finalize |
---|
[532] | 484 | !!--------------------------------------------------------------------- |
---|
[4990] | 485 | !! *** ROUTINE cpl_finalize *** |
---|
[532] | 486 | !! |
---|
| 487 | !! ** Purpose : - Finalizes the coupling. If MPI_init has not been |
---|
[4990] | 488 | !! called explicitly before cpl_init it will also close |
---|
[532] | 489 | !! MPI communication. |
---|
| 490 | !!---------------------------------------------------------------------- |
---|
[2715] | 491 | ! |
---|
| 492 | DEALLOCATE( exfld ) |
---|
[12377] | 493 | IF(nstop == 0) THEN |
---|
[14072] | 494 | CALL oasis_terminate( nerror ) |
---|
[4990] | 495 | ELSE |
---|
| 496 | CALL oasis_abort( ncomp_id, "cpl_finalize", "NEMO ABORT STOP" ) |
---|
[14072] | 497 | ENDIF |
---|
[2715] | 498 | ! |
---|
[4990] | 499 | END SUBROUTINE cpl_finalize |
---|
[532] | 500 | |
---|
[4990] | 501 | #if ! defined key_oasis3 |
---|
| 502 | |
---|
[1218] | 503 | !!---------------------------------------------------------------------- |
---|
[4990] | 504 | !! No OASIS Library OASIS3 Dummy module... |
---|
[1218] | 505 | !!---------------------------------------------------------------------- |
---|
[4990] | 506 | |
---|
| 507 | SUBROUTINE oasis_init_comp(k1,cd1,k2) |
---|
| 508 | CHARACTER(*), INTENT(in ) :: cd1 |
---|
| 509 | INTEGER , INTENT( out) :: k1,k2 |
---|
| 510 | k1 = -1 ; k2 = -1 |
---|
| 511 | WRITE(numout,*) 'oasis_init_comp: Error you sould not be there...', cd1 |
---|
| 512 | END SUBROUTINE oasis_init_comp |
---|
| 513 | |
---|
| 514 | SUBROUTINE oasis_abort(k1,cd1,cd2) |
---|
| 515 | INTEGER , INTENT(in ) :: k1 |
---|
| 516 | CHARACTER(*), INTENT(in ) :: cd1,cd2 |
---|
| 517 | WRITE(numout,*) 'oasis_abort: Error you sould not be there...', cd1, cd2 |
---|
| 518 | END SUBROUTINE oasis_abort |
---|
| 519 | |
---|
| 520 | SUBROUTINE oasis_get_localcomm(k1,k2) |
---|
| 521 | INTEGER , INTENT( out) :: k1,k2 |
---|
| 522 | k1 = -1 ; k2 = -1 |
---|
| 523 | WRITE(numout,*) 'oasis_get_localcomm: Error you sould not be there...' |
---|
| 524 | END SUBROUTINE oasis_get_localcomm |
---|
| 525 | |
---|
[7851] | 526 | SUBROUTINE oasis_def_partition(k1,k2,k3,k4) |
---|
[4990] | 527 | INTEGER , INTENT( out) :: k1,k3 |
---|
| 528 | INTEGER , INTENT(in ) :: k2(5) |
---|
[7851] | 529 | INTEGER , INTENT(in ) :: k4 |
---|
| 530 | k1 = k2(1) ; k3 = k2(5)+k4 |
---|
[4990] | 531 | WRITE(numout,*) 'oasis_def_partition: Error you sould not be there...' |
---|
| 532 | END SUBROUTINE oasis_def_partition |
---|
| 533 | |
---|
| 534 | SUBROUTINE oasis_def_var(k1,cd1,k2,k3,k4,k5,k6,k7) |
---|
| 535 | CHARACTER(*), INTENT(in ) :: cd1 |
---|
| 536 | INTEGER , INTENT(in ) :: k2,k3(2),k4,k5(2,2),k6 |
---|
| 537 | INTEGER , INTENT( out) :: k1,k7 |
---|
| 538 | k1 = -1 ; k7 = -1 |
---|
| 539 | WRITE(numout,*) 'oasis_def_var: Error you sould not be there...', cd1 |
---|
| 540 | END SUBROUTINE oasis_def_var |
---|
| 541 | |
---|
| 542 | SUBROUTINE oasis_enddef(k1) |
---|
| 543 | INTEGER , INTENT( out) :: k1 |
---|
| 544 | k1 = -1 |
---|
| 545 | WRITE(numout,*) 'oasis_enddef: Error you sould not be there...' |
---|
| 546 | END SUBROUTINE oasis_enddef |
---|
[14072] | 547 | |
---|
[4990] | 548 | SUBROUTINE oasis_put(k1,k2,p1,k3) |
---|
| 549 | REAL(wp), DIMENSION(:,:), INTENT(in ) :: p1 |
---|
| 550 | INTEGER , INTENT(in ) :: k1,k2 |
---|
| 551 | INTEGER , INTENT( out) :: k3 |
---|
| 552 | k3 = -1 |
---|
| 553 | WRITE(numout,*) 'oasis_put: Error you sould not be there...' |
---|
| 554 | END SUBROUTINE oasis_put |
---|
| 555 | |
---|
| 556 | SUBROUTINE oasis_get(k1,k2,p1,k3) |
---|
| 557 | REAL(wp), DIMENSION(:,:), INTENT( out) :: p1 |
---|
| 558 | INTEGER , INTENT(in ) :: k1,k2 |
---|
| 559 | INTEGER , INTENT( out) :: k3 |
---|
| 560 | p1(1,1) = -1. ; k3 = -1 |
---|
| 561 | WRITE(numout,*) 'oasis_get: Error you sould not be there...' |
---|
| 562 | END SUBROUTINE oasis_get |
---|
| 563 | |
---|
[10582] | 564 | SUBROUTINE oasis_get_freqs(k1,k5,k2,k3,k4) |
---|
[4990] | 565 | INTEGER , INTENT(in ) :: k1,k2 |
---|
| 566 | INTEGER, DIMENSION(1), INTENT( out) :: k3 |
---|
[10582] | 567 | INTEGER , INTENT( out) :: k4,k5 |
---|
| 568 | k3(1) = k1 ; k4 = k2 ; k5 = k2 |
---|
[4990] | 569 | WRITE(numout,*) 'oasis_get_freqs: Error you sould not be there...' |
---|
| 570 | END SUBROUTINE oasis_get_freqs |
---|
| 571 | |
---|
| 572 | SUBROUTINE oasis_terminate(k1) |
---|
| 573 | INTEGER , INTENT( out) :: k1 |
---|
| 574 | k1 = -1 |
---|
| 575 | WRITE(numout,*) 'oasis_terminate: Error you sould not be there...' |
---|
| 576 | END SUBROUTINE oasis_terminate |
---|
[14072] | 577 | |
---|
[532] | 578 | #endif |
---|
| 579 | |
---|
[2715] | 580 | !!===================================================================== |
---|
[532] | 581 | END MODULE cpl_oasis3 |
---|