Changeset 105 for LMDZ.3.3/branches/rel-LF/libf/phylmd/oasis.F
- Timestamp:
- Jul 21, 2000, 10:28:19 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ.3.3/branches/rel-LF/libf/phylmd/oasis.F
r101 r105 1 c 1 C $Id$ 2 2 C**** 3 C *****************4 C * OASIS ROUTINE *5 C * ------------- *6 C *****************7 3 C 8 4 C**** *INICMA* - Initialize coupled mode communication for atmosphere 9 C 10 C Purpose: 11 C ------- 12 C Exchange process identifiers and timestep information 13 C between AGCM, OGCM and COUPLER. 5 C and exchange some initial information with Oasis 14 6 C 15 7 C Input: … … 17 9 C KASTP : total number of timesteps in atmospheric model 18 10 C KEXCH : frequency of exchange (in time steps) 19 C KSTEP : timestep value (in seconds) 20 C 21 C Method: 22 C ------ 23 C Use named pipes(FIFO) to exchange process identifiers 24 C between the programs 25 C 26 C Externals: 27 C --------- 28 C GETPID, MKNOD 29 C 30 C Reference: 31 C --------- 32 C See Epicoa 0803 (1992) 33 C 34 C Author: 35 C ------- 36 C Laurent Terray 92-09-01 11 C KSTEP : length of timestep (in seconds) 37 12 C 38 13 C ----------------------------------------------------------- … … 40 15 SUBROUTINE inicma(kastp,kexch,kstep) 41 16 c 17 INCLUDE 'param.h' 18 c 42 19 INTEGER kastp, kexch, kstep 43 c44 INTEGER ime45 PARAMETER (ime = 1)46 47 20 INTEGER iparal(3) 48 INTEGER ifcpl, idt, info, imxtag, istep 49 c 50 #include "dimensions.h" 51 #include "dimphy.h" 52 #include "oasis.h" 53 #include "clim.h" 54 c 55 c Addition for SIPC CASE 56 #include "param_sipc.h" 57 #include "param_cou.h" 58 #include "inc_sipc.h" 59 #include "inc_cpl.h" 60 CHARACTER*9 clpoolnam 61 INTEGER ipoolhandle, imrc, ipoolsize, index, jf 21 INTEGER ifcpl, idt, info, imxtag, istep, jf 22 c 23 INCLUDE 'param_cou.h' 24 INCLUDE 'inc_cpl.h' 62 25 CHARACTER*3 cljobnam ! experiment name 63 26 CHARACTER*6 clmodnam ! model name 27 c EM: not used by Oasis2.4 28 CEM CHARACTER*6 clbid(2) ! for CLIM_Init call (not used) 29 CEM ! must be dimensioned by the number of models 30 CEM INTEGER nbid(2) ! for CLIM_Init call (not used) 31 CEM ! must be dimensioned by the number of models 64 32 CHARACTER*5 cloasis ! coupler name (Oasis) 65 INTEGER imess(4), imesso(4) 66 INTEGER getpid, mknod ! system functions 67 CHARACTER*80 clcmd 68 CHARACTER*8 pipnom, fldnom 69 INTEGER ierror, iretcode 70 C 33 INTEGER imess(4) 34 INTEGER getpid ! system functions 71 35 INTEGER nuout 36 CEM LOGICAL llmodel 72 37 PARAMETER (nuout = 6) 73 38 c 74 C 75 c 76 39 INCLUDE 'clim.h' 40 INCLUDE 'mpiclim.h' 41 c 42 INCLUDE 'oasis.h' ! contains the name of communication technique. Here 43 ! cchan=CLIM only is possible. 44 c ! ctype=MPI2 45 c 77 46 C ----------------------------------------------------------- 78 47 C … … 87 56 WRITE(nuout,*) ' ' 88 57 c 89 c 1.2.1-Define the model name90 c 91 clmodnam = ' lmd.xx' ! as $NBMODEL in namcouple92 c 93 c 1.2.2-Define the coupler name94 c 95 cloasis = 'Oasis' ! a s incoupler96 c 97 c 98 c 1.3.1-Define symbolic name for fields exchanged from atmos to coupler,58 c Define the model name 59 c 60 clmodnam = 'toyatm' ! as in $NBMODEL in Cpl/Nam/namcouple.tmp 61 c 62 c Define the coupler name 63 c 64 cloasis = 'Oasis' ! always 'Oasis' as in the coupler 65 c 66 c 67 c Define symbolic name for fields exchanged from atmos to coupler, 99 68 c must be the same as (1) of the field definition in namcouple: 100 69 c 101 cl_writ(1)='CONSFTOT' 102 cl_writ(2)='COSHFTOT' 103 cl_writ(3)='COTOPRSU' 104 cl_writ(4)='COTFSHSU' 105 cl_writ(5)='CORUNCOA' 106 cl_writ(6)='CORIVFLU' 107 cl_writ(7)='COZOTAUX' 108 cl_writ(8)='COZOTAU2' 109 cl_writ(9)='COMETAUY' 110 cl_writ(10)='COMETAU2' 111 c 112 c 1.3.2-Define files name for fields exchanged from atmos to coupler, 70 cl_writ(1)='COSHFICE' 71 cl_writ(2)='COSHFOCE' 72 cl_writ(3)='CONSFICE' 73 cl_writ(4)='CONSFOCE' 74 cl_writ(5)='CODFLXDT' 75 c cl_writ(6)='COICTEMP' 76 cl_writ(6)='COTFSICE' 77 cl_writ(7)='COTFSOCE' 78 cl_writ(8)='COTOLPSU' 79 cl_writ(9)='COTOSPSU' 80 cl_writ(10)='CORUNCOA' 81 cl_writ(11)='CORIVFLU' 82 cl_writ(12)='COZOTAUX' 83 cl_writ(13)='COZOTAUV' 84 cl_writ(14)='COMETAUY' 85 cl_writ(15)='COMETAUU' 86 c 87 c Define files name for fields exchanged from atmos to coupler, 113 88 c must be the same as (6) of the field definition in namcouple: 114 89 c 115 cl_f_writ(1)='atmflx' 116 cl_f_writ(2)='atmflx' 117 cl_f_writ(3)='atmflx' 118 cl_f_writ(4)='atmflx' 119 cl_f_writ(5)='atmflx' 120 cl_f_writ(6)='atmflx' 121 cl_f_writ(7)='atmtau' 122 cl_f_writ(8)='atmtau' 123 cl_f_writ(9)='atmtau' 124 cl_f_writ(10)='atmtau' 125 c 126 c 127 c 1.4.1-Define symbolic name for fields exchanged from coupler to atmosphere, 90 cl_f_writ(1)='flxatmos' 91 cl_f_writ(2)='flxatmos' 92 cl_f_writ(3)='flxatmos' 93 cl_f_writ(4)='flxatmos' 94 cl_f_writ(5)='flxatmos' 95 cl_f_writ(6)='flxatmos' 96 cl_f_writ(7)='flxatmos' 97 cl_f_writ(8)='flxatmos' 98 cl_f_writ(9)='flxatmos' 99 cl_f_writ(10)='flxatmos' 100 cl_f_writ(11)='flxatmos' 101 cl_f_writ(12)='flxatmos' 102 cl_f_writ(13)='flxatmos' 103 cl_f_writ(14)='flxatmos' 104 cl_f_writ(15)='flxatmos' 105 c cl_f_writ(16)='flxatmos' 106 c 107 c 108 c Define symbolic name for fields exchanged from coupler to atmosphere, 128 109 c must be the same as (2) of the field definition in namcouple: 129 110 c 130 cl_read(1)='SISUTES U'111 cl_read(1)='SISUTESW' 131 112 cl_read(2)='SIICECOV' 132 c 133 c 1.4.2-Define files names for fields exchanged from coupler to atmosphere, 113 cl_read(3)='SIICEALW' 114 cl_read(4)='SIICTEMW' 115 c 116 c Define files names for fields exchanged from coupler to atmosphere, 134 117 c must be the same as (7) of the field definition in namcouple: 135 118 c 136 cl_f_read(1)='atmsst' 137 cl_f_read(2)='atmice' 138 c 139 c 1.5-Define infos for sending to oasis 140 c 141 imess(1) = kastp 142 imess(2) = kexch 143 imess(3) = kstep 144 imess(4) = getpid() 145 146 c 147 c 148 IF (cchan.eq.'PIPE') THEN 149 c 150 ierror=0 151 c 152 c 153 WRITE(nuout,*) ' ' 154 WRITE(nuout,*) 'Making pipes for fields to receive from CPL' 155 WRITE(nuout,*) ' ' 156 c 157 c loop to define pipes (ocean=CPL to atmos) 158 c 159 DO jf=1, jpfldo2a 160 CALL PIPE_Model_Define(nuout, cl_read(jf), jpread, iretcode) 161 IF (iretcode.ne.0) ierror=ierror+1 162 END DO 163 c 164 WRITE(nuout,*) ' ' 165 WRITE(nuout,*) 'Making pipes for fields to send to CPL' 166 WRITE(nuout,*) ' ' 167 c 168 c loop to define pipes (atmos to ocean=CPL) 169 c 170 DO jf=1, jpflda2o 171 CALL PIPE_Model_Define(nuout, cl_writ(jf), jpwrit, iretcode) 172 IF (iretcode.ne.0) ierror=ierror+1 173 END DO 174 c 175 IF (ierror.ne.0) THEN 176 WRITE (nuout,*) 'Error in pipes definitions' 177 WRITE (nuout,*) 'STOP inicma' 178 CALL abort 179 END IF 180 c 181 WRITE(nuout,*) ' ' 182 WRITE(nuout,*) 'All pipes have been made' 183 WRITE(nuout,*) ' ' 184 c 185 WRITE(nuout,*) ' ' 186 WRITE(nuout,*) 'Communication test between ATM and CPL' 187 WRITE(nuout,*) ' ' 188 CALL flush(nuout) 189 c 190 CALL PIPE_Model_Stepi(nuout, imess, ime, imesso, ierror) 191 c 192 IF (ierror.ne.0) THEN 193 WRITE (nuout,*) 194 $ 'Error in exchange first informations with Oasis' 195 WRITE (nuout,*) 'STOP inicma' 196 CALL abort 197 END IF 198 c 199 WRITE(nuout,*) ' ' 200 WRITE(nuout,*) 'Communication test between ATM and CPL is OK' 201 WRITE(nuout,*) ' total simulation time in oasis = ', imesso(1) 202 WRITE(nuout,*) ' total number of iterations is = ', imesso(2) 203 WRITE(nuout,*) ' value of oasis timestep is = ', imesso(3) 204 WRITE(nuout,*) ' process id for oasis is = ', imesso(4) 205 WRITE(nuout,*) ' ' 206 CALL flush(nuout) 207 c 208 ELSE IF (cchan.eq.'SIPC') THEN 209 c 210 c debug for more information 211 c 212 c CALL SVIPC_debug(1) 213 c 214 c 215 c 1.1-Define the experiment name : 216 c 217 cljobnam = 'IPC' ! as $JOBNAM in namcouple 218 c 219 c 3-Attach to shared memory pool used to exchange initial infos 220 c 221 imrc = 0 222 CALL SIPC_Init_Model (cljobnam, clmodnam, 1, imrc) 223 IF (imrc .NE. 0) THEN 224 WRITE (nuout,*)' ' 225 WRITE (nuout,*)'WARNING: Problem with attachement to', imrc 226 WRITE (nuout,*)' initial memory pool(s) in atmos' 227 WRITE (nuout,*)' ' 228 CALL ABORT('STOP in atmos') 229 ENDIF 230 c 231 c 4-Attach to pools used to exchange fields from atmos to coupler 232 c 233 DO jf = 1, jpflda2o 234 c 235 C 236 c Pool name: 237 clpoolnam = 'P'//cl_writ(jf) 238 C 239 CALL SIPC_Attach(clpoolnam, ipoolhandle) 240 c 241 c Resulting pool handle: 242 mpoolwrit(jf) = ipoolhandle 243 C 244 END DO 245 C 246 c 5-Attach to pools used to exchange fields from coupler to atmos 247 c 248 DO jf = 1, jpfldo2a 249 c 250 c Pool name: 251 clpoolnam = 'P'//cl_read(jf) 252 c 253 CALL SIPC_Attach(clpoolnam, ipoolhandle) 254 c 255 c Resulting pool handle: 256 mpoolread(jf) = ipoolhandle 257 c 258 END DO 259 c 260 c 6-Exchange of initial infos 261 c 262 c Write data array isend to pool READ by Oasis 263 c 264 imrc = 0 265 ipoolsize = 4*jpbyteint 266 CALL SVIPC_Write(mpoolinitr, imess, ipoolsize, imrc) 267 C 268 C Find error if any 269 C 270 IF (imrc .LT. 0) THEN 271 WRITE (nuout,*) ' ' 272 WRITE (nuout,*) 'Problem in atmos in writing initial' 273 WRITE (nuout,*) 'infos to the shared memory segment(s)' 274 WRITE (nuout,*) ' ' 275 ELSE 276 WRITE (nuout,*) ' ' 277 WRITE (nuout,*) 'Initial infos written in atmos' 278 WRITE (nuout,*) 'to the shared memory segment(s)' 279 WRITE (nuout,*) ' ' 280 ENDIF 281 C 282 C Read data array irecv from pool written by Oasis 283 C 284 imrc = 0 285 ipoolsize = 4*jpbyteint 286 CALL SVIPC_Read(mpoolinitw, imesso, ipoolsize, imrc) 287 C 288 C* Find error if any 289 C 290 IF (imrc .LT. 0) THEN 291 WRITE (nuout,*) ' ' 292 WRITE (nuout,*) 'Problem in atmos in reading initial' 293 WRITE (nuout,*) 'infos from the shared memory segment(s)' 294 WRITE (nuout,*) ' ' 295 ELSE 296 WRITE (nuout,*) ' ' 297 WRITE (nuout,*) 'Initial infos read by atmos' 298 WRITE (nuout,*) 'from the shared memory segment(s)' 299 WRITE (nuout,*) ' ' 300 WRITE(*,*) ' ntime, niter, nstep, Oasis pid:' 301 WRITE(*,*) imesso(1), imesso(2), imesso(3), imesso(4) 302 ENDIF 303 C 304 C Detach from shared memory segment(s) 305 C 306 imrc = 0 307 CALL SVIPC_close(mpoolinitw, 0, imrc) 308 C 309 C Find error if any 310 C 311 IF (imrc .LT. 0) THEN 312 WRITE (nuout,*) 313 $ 'Problem in detaching from shared memory segment(s)' 314 WRITE (nuout,*) 315 $ 'used by atmos to read initial infos' 316 ENDIF 317 c 318 c 319 ELSE IF (cchan.eq.'CLIM') THEN 320 321 c 322 c 1.1-Define the experiment name : 119 cl_f_read(1)='sstatmos' 120 cl_f_read(2)='sstatmos' 121 cl_f_read(3)='sstatmos' 122 cl_f_read(4)='sstatmos' 123 c 124 c 125 c Define the number of processors involved in the coupling for 126 c Oasis (=1) and each model (as last two INTEGER on $CHATYPE line 127 c in the namcouple); they will be stored in a COMMON in mpiclim.h 128 c (used for CLIM/MPI2 only) 129 mpi_nproc(0)=1 130 mpi_nproc(1)=1 131 mpi_nproc(2)=1 132 c 133 c Define infos to be sent initially to oasis 134 c 135 imess(1) = kastp ! total number of timesteps in atmospheric model 136 imess(2) = kexch ! period of exchange (in time steps) 137 imess(3) = kstep ! length of atmospheric timestep (in seconds) 138 imess(4) = getpid() ! PID of atmospheric model 139 c 140 c Initialization and exchange of initial info in the CLIM technique 141 c 142 IF (cchan.eq.'CLIM') THEN 143 c 144 c Define the experiment name : 323 145 c 324 146 cljobnam = 'CLI' ! as $JOBNAM in namcouple 325 326 OPEN ( UNIT = 7, FILE = 'trace', STATUS = 'unknown', 327 $ FORM = 'formatted') 147 c 148 c Start the coupling 149 c (see lib/clim/src/CLIM_Init for the definition of input parameters) 150 c 151 cEM clbid(1)=' ' 152 cEM clbid(2)=' ' 153 cEM nbid(1)=0 154 cEM nbid(2)=0 155 CEM llmodel=.true. 156 c 157 c Define the number of processors used by each model as in 158 c $CHATYPE line of namcouple (used for CLIM/MPI2 only) 159 mpi_totproc(1)=1 160 mpi_totproc(2)=1 161 c 162 c Define names of each model as in $NBMODEL line of namcouple 163 c (used for CLIM/MPI2 only) 164 cmpi_modnam(1)='toyatm' 165 cmpi_modnam(2)='toyoce' 166 c Start the coupling 167 c 328 168 CALL CLIM_Init ( cljobnam, clmodnam, 3, 7, 329 169 * kastp, kexch, kstep, 330 170 * 5, 3600, 3600, info ) 331 171 c 332 IF (info.ne. clim_ok) THEN172 IF (info.ne.CLIM_Ok) THEN 333 173 WRITE ( nuout, *) ' inicma : pb init clim ' 334 174 WRITE ( nuout, *) ' error code is = ', info 335 CALL abort('STOP in inicma')175 CALL halte('STOP in inicma') 336 176 ELSE 337 177 WRITE(nuout,*) 'inicma : init clim ok ' 338 178 ENDIF 339 179 c 340 iparal ( clim_strategy ) = clim_serial 341 iparal ( clim_length ) = iim*(jjm+1) 180 c For each coupling field, association of a port to its symbolic name 181 c 182 c -Define the parallel decomposition associated to the port of each 183 c field; here no decomposition for all ports. 184 iparal ( clim_strategy ) = clim_serial 185 iparal ( clim_length ) = imjm 342 186 iparal ( clim_offset ) = 0 343 187 c 344 c loop to define messages (CPL=ocean to atmos)345 c 188 c -Loop on total number of coupler-to-atmosphere fields 189 c (see lib/clim/src/CLIM_Define for the definition of input parameters) 346 190 DO jf=1, jpfldo2a 347 191 CALL CLIM_Define (cl_read(jf), clim_in , clim_double, iparal 348 192 $ , info ) 349 193 END DO 350 351 c 352 c loop to define messages (atmos to ocean=CPL) 353 c 354 DO jf=1, jpflda2o 194 c 195 c -Loop on total number of atmosphere-to-coupler fields 196 c (see lib/clim/src/CLIM_Define for the definition of input parameters) 197 DO jf=1, jpflda2o1+jpflda2o2 355 198 CALL CLIM_Define (cl_writ(jf), clim_out , clim_double, 356 199 $ iparal, info ) 357 200 END DO 358 201 c 359 202 WRITE(nuout,*) 'inicma : clim_define ok ' 203 c 204 c -Join a pvm group, wait for other programs and broadcast usefull 205 c informations to Oasis and to the ocean (see lib/clim/src/CLIM_Start) 360 206 CALL CLIM_Start ( imxtag, info ) 361 207 IF (info.ne.clim_ok) THEN 362 208 WRITE ( nuout, *) 'inicma : pb start clim ' 363 209 WRITE ( nuout, *) ' error code is = ', info 364 CALL abort('stop in inicma')210 CALL halte('stop in inicma') 365 211 ELSE 366 212 WRITE ( nuout, *) 'inicma : start clim ok ' 367 213 ENDIF 368 214 c 215 c -Get initial information from Oasis 216 c (see lib/clim/src/CLIM_Stepi) 369 217 CALL CLIM_Stepi (cloasis, istep, ifcpl, idt, info) 370 218 IF (info .NE. clim_ok) THEN … … 386 234 END 387 235 388 SUBROUTINE fromcpl(kt, imjm, sst,sic, alb_sst, alb_sic ) 236 c $Id$ 237 SUBROUTINE fromcpl(kt, imjm, sst, gla, tice, albedo) 238 c ====================================================================== 239 c S. Valcke (02/99) adapted From L.Z.X Li: this subroutine reads the SST 240 c and Sea-Ice provided by the coupler with the CLIM (PVM exchange messages) 241 c technique. 242 c====================================================================== 389 243 IMPLICIT none 390 c391 c Laurent Z.X Li (Feb. 10, 1997): It reads the SST and Sea-Ice392 c provided by the coupler. Of course, it waits until it receives393 c the signal from the corresponding pipes.394 c 3 techniques:395 c - pipes and signals (only on Cray C90 and Cray J90)396 c - CLIM (PVM exchange messages)397 c - SVIPC shared memory segments and semaphores398 c399 244 INTEGER imjm, kt 400 245 REAL sst(imjm) ! sea-surface-temperature 401 REAL alb_sst(imjm) ! open sea albedo 402 REAL sic(imjm) ! sea ice cover 403 REAL alb_sic(imjm) ! sea ice albedo 404 246 REAL gla(imjm) ! sea-ice 247 REAL tice(imjm) ! temp glace 248 REAL albedo(imjm) ! albedo glace 405 249 c 406 250 INTEGER nuout ! listing output unit … … 408 252 c 409 253 INTEGER nuread, ios, iflag, icpliter 410 CHARACTER*8 pipnom ! name for the pipe411 CHARACTER*8 fldnom ! name for the field412 CHARACTER*8 filnom ! name for the data file413 414 254 INTEGER info, jf 415 416 c 417 #include "oasis.h" 418 #include "clim.h" 419 c 420 #include "param_cou.h" 421 c 422 #include "inc_sipc.h" 423 #include "inc_cpl.h" 424 c 425 c Addition for SIPC CASE 426 INTEGER index 427 CHARACTER*3 cmodinf ! Header or not 428 CHARACTER*3 cljobnam_r ! Experiment name in the field brick, if any 429 INTEGER infos(3) ! infos in the field brick, if any 255 c 256 INCLUDE 'clim.h' 257 c 258 INCLUDE 'oasis.h' 259 INCLUDE 'param_cou.h' 260 c 261 INCLUDE 'inc_cpl.h' 430 262 c 431 263 c 432 264 WRITE (nuout,*) ' ' 433 WRITE (nuout,*) 'Fromcpl: Read fields from CPL, kt=',kt265 WRITE (nuout,*) 'Fromcpl: Reading fields from CPL, kt=',kt 434 266 WRITE (nuout,*) ' ' 435 267 CALL flush (nuout) 436 268 437 IF (cchan.eq.'PIPE') THEN 438 c 439 c UNIT number for fields 440 c 441 nuread = 99 442 c 443 c exchanges from ocean=CPL to atmosphere 269 270 IF (cchan.eq.'CLIM') THEN 271 272 c 273 c -Get interpolated oceanic fields from Oasis 444 274 c 445 275 DO jf=1,jpfldo2a 446 CALL PIPE_Model_Recv(cl_read(jf), icpliter, nuout) 447 OPEN (nuread, FILE=cl_f_read(jf), FORM='UNFORMATTED') 448 IF (jf.eq.1) 449 $ CALL locread(cl_read(jf), sst, imjm, nuread, iflag, 450 $ nuout) 451 IF (jf.eq.2) 452 $ CALL locread(cl_read(jf), sic, imjm, nuread, iflag, 453 $ nuout) 454 IF (jf.eq.3) 455 $ CALL locread(cl_read(jf), alb_sst, imjm, nuread, iflag, 456 $ nuout) 457 IF (jf.eq.4) 458 $ CALL locread(cl_read(jf), alb_sic, imjm, nuread, iflag, 459 $ nuout) 460 CLOSE (nuread) 461 END DO 462 463 c 464 ELSE IF (cchan.eq.'SIPC') THEN 465 c 466 c Define IF a header must be encapsulated within the field brick : 467 cmodinf = 'NOT' ! as $MODINFO in namcouple 468 c 469 c reading of input field sea-surface-temperature SISUTESU 470 c 471 c 472 c Index of sst in total number of fields jpfldo2a: 473 index = 1 474 c 475 CALL SIPC_Read_Model(index, imjm, cmodinf, 476 $ cljobnam_r,infos, sst) 477 c 478 c reading of input field sea-ice SIICECOV 479 c 480 c 481 c Index of sea-ice in total number of fields jpfldo2a: 482 index = 2 483 c 484 CALL SIPC_Read_Model(index, imjm, cmodinf, 485 $ cljobnam_r,infos, sic) 486 c Index of open sea albedo in total number of fields jpfldo2a: 487 index = 3 488 c 489 CALL SIPC_Read_Model(index, imjm, cmodinf, 490 $ cljobnam_r,infos, alb_sst) 491 c Index of sea-ice albedo in total number of fields jpfldo2a: 492 index = 4 493 c 494 CALL SIPC_Read_Model(index, imjm, cmodinf, 495 $ cljobnam_r,infos, alb_sic) 496 c 497 c 498 ELSE IF (cchan.eq.'CLIM') THEN 499 500 c 501 c exchanges from ocean=CPL to atmosphere 502 c 503 DO jf=1,jpfldo2a 504 IF (jf.eq.1) CALL CLIM_Import (cl_read(jf) , kt, sst, info) 505 IF (jf.eq.2) CALL CLIM_Import (cl_read(jf) , kt, sic, info) 506 IF (jf.eq.3) CALL CLIM_Import (cl_read(jf) , kt, alb_sst, info) 507 IF (jf.eq.4) CALL CLIM_Import (cl_read(jf) , kt, alb_sic, info) 508 IF ( info .NE. CLIM_Ok) THEN 276 IF (jf.eq.1) CALL CLIM_Import (cl_read(jf) , kt, sst, info) 277 IF (jf.eq.2) CALL CLIM_Import (cl_read(jf) , kt, gla, info) 278 IF (jf.eq.3) CALL CLIM_Import (cl_read(jf), kt,albedo, info) 279 IF (jf.eq.4) CALL CLIM_Import (cl_read(jf) , kt, tice, info) 280 IF ( info .NE. CLIM_Ok) THEN 509 281 WRITE(nuout,*)'Pb in reading ', cl_read(jf), jf 510 282 WRITE(nuout,*)'Couplage kt is = ',kt 511 283 WRITE(nuout,*)'CLIM error code is = ', info 512 WRITE(nuout,*)'STOP in Fromcpl' 513 STOP 'Fromcpl' 284 CALL halte('STOP in fromcpl.F') 514 285 ENDIF 515 286 END DO … … 520 291 END 521 292 522 523 SUBROUTINE intocpl(kt,imjm, 524 . fsol, fnsol, 525 . rain, snow, evap, ruisoce, ruisriv, 526 . taux, tauy, last) 293 c $Id$ 294 SUBROUTINE intocpl(kt, imjm, fsolice, fsolwat, fnsolice, fnsolwat, 295 $ fnsicedt, evice, evwat, lpre, spre, dirunoff, rivrunoff, 296 $ tauxu, tauxv, tauyv, tauyu, last) 297 c ====================================================================== 298 c S. Valcke (02/99) adapted From L.Z.X Li: this subroutine provides the 299 c atmospheric coupling fields to the coupler with the CLIM (PVM exchange 300 c messages) technique. 301 c IF last time step, writes output fields to binary files. 302 c ====================================================================== 527 303 IMPLICIT NONE 528 c529 c Laurent Z.X Li (Feb. 10, 1997): It provides several fields to the530 c coupler. Of course, it sends a message to the corresponding pipes531 c after the writting.532 c 3 techniques : pipes533 c clim534 c svipc535 c IF last time step WRITE output files anway536 c537 #include "oasis.h"538 539 304 INTEGER kt, imjm 540 305 c 541 REAL fsol(imjm) 542 REAL fnsol(imjm) 543 REAL rain(imjm) 544 REAL snow(imjm) 545 REAL evap(imjm) 546 REAL ruisoce(imjm) 547 REAL ruisriv(imjm) 548 REAL taux(imjm) 549 REAL tauy(imjm) 306 REAL fsolice(imjm) 307 REAL fsolwat(imjm) 308 REAL fnsolice(imjm) 309 REAL fnsolwat(imjm) 310 REAL fnsicedt(imjm) 311 REAL ictemp(imjm) 312 REAL evice(imjm) 313 REAL evwat(imjm) 314 REAL lpre(imjm) 315 REAL spre(imjm) 316 REAL dirunoff(imjm) 317 REAL rivrunoff(imjm) 318 REAL tauxu(imjm) 319 REAL tauxv(imjm) 320 REAL tauyu(imjm) 321 REAL tauyv(imjm) 550 322 LOGICAL last 551 323 c … … 553 325 PARAMETER (nuout = 6) 554 326 c 555 c Additions for SVIPC 556 c 557 INTEGER index 558 INTEGER infos(3) 559 CHARACTER*3 cmodinf ! Header or not 560 CHARACTER*3 cljobnam ! experiment name 561 c 562 #include "clim.h" 563 c 564 #include "param_cou.h" 565 c 566 #include "inc_sipc.h" 567 #include "inc_cpl.h" 568 c 569 C 570 INTEGER nuwrit, ios 571 CHARACTER*8 pipnom 572 CHARACTER*8 fldnom 573 CHARACTER*6 file_name(jpmaxfld) 327 INCLUDE 'clim.h' 328 INCLUDE 'param_cou.h' 329 INCLUDE 'inc_cpl.h' 330 c 331 CHARACTER*8 file_name(jpmaxfld) 574 332 INTEGER max_file 575 333 INTEGER file_unit_max, file_unit(jpmaxfld), … … 579 337 LOGICAL trouve 580 338 c 339 INCLUDE 'oasis.h' 581 340 c 582 341 icstep=kt 583 342 c 584 343 WRITE(nuout,*) ' ' 585 WRITE(nuout,*) 'Intocpl: send fields to CPL, kt= ', kt344 WRITE(nuout,*) 'Intocpl: sending fields to CPL, kt= ', kt 586 345 WRITE(nuout,*) ' ' 587 346 588 IF (last.or.(cchan.eq.'PIPE')) THEN 589 c 590 c 591 c WRITE fields for coupler with pipe technique or for last time step 592 c 593 c initialisation 347 IF (last) THEN 348 c 349 c -WRITE fields to binary files for coupler restart at last time step 350 c 351 c -initialisation and files opening 594 352 c 595 353 max_file=1 596 354 file_unit_max=99 597 c keeps first file name355 c -keeps first file name 598 356 file_name(max_file)=cl_f_writ(max_file) 599 c keeps first file unit357 c -keeps first file unit 600 358 file_unit(max_file)=file_unit_max 601 c decrements file unit maximum359 c -decrements file unit maximum 602 360 file_unit_max=file_unit_max-1 603 c keeps file unit for field361 c -keeps file unit for field 604 362 file_unit_field(1)=file_unit(max_file) 605 363 c 606 c different files names counter 607 c 608 609 DO jf= 2, jpflda2o 364 c -different files names counter 365 c 366 DO jf= 2, jpflda2o1 + jpflda2o2 610 367 trouve=.false. 611 368 DO jn= 1, max_file 612 369 IF (.not.trouve) THEN 613 370 IF (cl_f_writ(jf).EQ.file_name(jn)) THEN 614 c keep file unit for field371 c -keep file unit for field 615 372 file_unit_field(jf)=file_unit(jn) 616 373 trouve=.true. … … 619 376 END DO 620 377 IF (.not.trouve) then 621 c increment the number of different files378 c -increment the number of different files 622 379 max_file=max_file+1 623 c keep file name380 c -keep file name 624 381 file_name(max_file)=cl_f_writ(jf) 625 c keep file unit for file382 c -keep file unit for file 626 383 file_unit(max_file)=file_unit_max 627 c keep file unit for field384 c -keep file unit for field 628 385 file_unit_field(jf)=file_unit(max_file) 629 c decrement unit maximum number from 99 to 98, ...386 c -decrement unit maximum number from 99 to 98, ... 630 387 file_unit_max=file_unit_max-1 631 388 END IF 632 389 END DO 633 390 c 634 391 DO jn=1, max_file 635 392 OPEN (file_unit(jn), FILE=file_name(jn), FORM='UNFORMATTED') 636 END DO 637 638 DO jf=1, jpflda2o 393 END DO 394 c 395 c WRITE fields to files 396 DO jf=1, jpflda2o1 + jpflda2o2 639 397 IF (jf.eq.1) 640 $ CALL locwrite(cl_writ(jf),f nsol, imjm,398 $ CALL locwrite(cl_writ(jf),fsolice, imjm, 641 399 $ file_unit_field(jf), ierror, nuout) 642 400 IF (jf.eq.2) 643 $ CALL locwrite(cl_writ(jf),fsol , imjm,401 $ CALL locwrite(cl_writ(jf),fsolwat, imjm, 644 402 $ file_unit_field(jf), ierror, nuout) 645 403 IF (jf.eq.3) 646 $ CALL locwrite(cl_writ(jf), rain, imjm,404 $ CALL locwrite(cl_writ(jf),fnsolice, imjm, 647 405 $ file_unit_field(jf), ierror, nuout) 648 406 IF (jf.eq.4) 649 $ CALL locwrite(cl_writ(jf), evap, imjm,407 $ CALL locwrite(cl_writ(jf),fnsolwat, imjm, 650 408 $ file_unit_field(jf), ierror, nuout) 651 409 IF (jf.eq.5) 652 $ CALL locwrite(cl_writ(jf),ruisoce, imjm, 410 $ CALL locwrite(cl_writ(jf),fnsicedt, imjm, 411 $ file_unit_field(jf), ierror, nuout) 412 c IF (jf.eq.6) 413 c $ CALL locwrite(cl_writ(jf),ictemp, imjm, 414 c $ file_unit_field(jf), ierror, nuout) 415 IF (jf.eq.6) 416 $ CALL locwrite(cl_writ(jf),evice, imjm, 417 $ file_unit_field(jf), ierror, nuout) 418 IF (jf.eq.7) 419 $ CALL locwrite(cl_writ(jf),evwat, imjm, 420 $ file_unit_field(jf), ierror, nuout) 421 IF (jf.eq.8) 422 $ CALL locwrite(cl_writ(jf),lpre, imjm, 423 $ file_unit_field(jf), ierror, nuout) 424 IF (jf.eq.9) 425 $ CALL locwrite(cl_writ(jf),spre, imjm, 426 $ file_unit_field(jf), ierror, nuout) 427 IF (jf.eq.10) 428 $ CALL locwrite(cl_writ(jf),dirunoff, imjm, 429 $ file_unit_field(jf), ierror, nuout) 430 IF (jf.eq.11) 431 $ CALL locwrite(cl_writ(jf),rivrunoff, imjm, 432 $ file_unit_field(jf), ierror, nuout) 433 IF (jf.eq.12) 434 $ CALL locwrite(cl_writ(jf),tauxu, imjm, 653 435 $ file_unit_field(jf),ierror, nuout) 654 IF (jf.eq. 6)655 $ CALL locwrite(cl_writ(jf), ruisriv, imjm,436 IF (jf.eq.13) 437 $ CALL locwrite(cl_writ(jf),tauxv, imjm, 656 438 $ file_unit_field(jf),ierror, nuout) 657 IF (jf.eq.7) 658 $ CALL locwrite(cl_writ(jf),taux, imjm, 659 $ file_unit_field(jf), ierror, nuout) 660 IF (jf.eq.8) 661 $ CALL locwrite(cl_writ(jf),taux, imjm, 662 $ file_unit_field(jf), ierror, nuout) 663 IF (jf.eq.9) 664 $ CALL locwrite(cl_writ(jf),tauy, imjm, 665 $ file_unit_field(jf), ierror, nuout) 666 IF (jf.eq.10) 667 $ CALL locwrite(cl_writ(jf),tauy, imjm, 668 $ file_unit_field(jf), ierror, nuout) 669 END DO 670 C 671 C simulate a FLUSH 439 IF (jf.eq.14) 440 $ CALL locwrite(cl_writ(jf),tauyv, imjm, 441 $ file_unit_field(jf),ierror, nuout) 442 IF (jf.eq.15) 443 $ CALL locwrite(cl_writ(jf),tauyu, imjm, 444 $ file_unit_field(jf), ierror, nuout) 445 END DO 446 C 447 C -simulate a FLUSH 672 448 C 673 449 DO jn=1, max_file 674 450 CLOSE (file_unit(jn)) 675 451 END DO 676 c 677 c 678 c 452 C 453 C 679 454 IF(cchan.eq.'CLIM') THEN 680 c 681 c inform PVM daemon, I havefinished682 c 455 C 456 C -inform PVM daemon that message exchange is finished 457 C 683 458 CALL CLIM_Quit (CLIM_ContPvm, info) 684 459 IF (info .NE. CLIM_Ok) THEN … … 687 462 $ info 688 463 ENDIF 689 690 464 END IF 465 RETURN 466 END IF 467 C 468 IF(cchan.eq.'CLIM') THEN 469 C 470 C -Give atmospheric fields to Oasis 471 C 472 DO jn=1, jpflda2o1 + jpflda2o2 473 C 474 IF (jn.eq.1) CALL CLIM_Export(cl_writ(jn), kt, fsolice, info) 475 IF (jn.eq.2) CALL CLIM_Export(cl_writ(jn), kt, fsolwat, info) 476 IF (jn.eq.3) CALL CLIM_Export(cl_writ(jn), kt, fnsolice, info) 477 IF (jn.eq.4) CALL CLIM_Export(cl_writ(jn), kt, fnsolwat, info) 478 IF (jn.eq.5) CALL CLIM_Export(cl_writ(jn), kt, fnsicedt, info) 479 c IF (jn.eq.6) CALL CLIM_Export(cl_writ(jn), kt, ictemp, info) 480 IF (jn.eq.6) CALL CLIM_Export(cl_writ(jn), kt, evice, info) 481 IF (jn.eq.7) CALL CLIM_Export(cl_writ(jn), kt, evwat, info) 482 IF (jn.eq.8) CALL CLIM_Export(cl_writ(jn), kt, lpre, info) 483 IF (jn.eq.9) CALL CLIM_Export(cl_writ(jn), kt, spre, info) 484 IF (jn.eq.10) CALL CLIM_Export(cl_writ(jn),kt,dirunoff, info) 485 IF (jn.eq.11) CALL CLIM_Export(cl_writ(jn),kt,rivrunoff,info) 486 IF (jn.eq.12) CALL CLIM_Export(cl_writ(jn), kt, tauxu, info) 487 IF (jn.eq.13) CALL CLIM_Export(cl_writ(jn), kt, tauxv, info) 488 IF (jn.eq.14) CALL CLIM_Export(cl_writ(jn), kt, tauyv, info) 489 IF (jn.eq.15) CALL CLIM_Export(cl_writ(jn), kt, tauyu, info) 691 490 692 END IF693 694 c695 c IF last we have finished696 c697 IF (last) RETURN698 699 IF (cchan.eq.'PIPE') THEN700 c701 c Send message to pipes for CPL=ocean702 c703 DO jf=1, jpflda2o704 CALL PIPE_Model_Send(cl_writ(jf), kt, nuout)705 END DO706 c707 c708 c709 ELSE IF(cchan.eq.'SIPC') THEN710 c711 c Define IF a header must be encapsulated within the field brick :712 cmodinf = 'NOT' ! as $MODINFO in namcouple713 c714 c IF cmodinf = 'YES', define encapsulated infos to be exchanged715 c infos(1) = initial date716 c infos(2) = timestep717 c infos(3) = actual time718 c719 c Writing of output field non solar heat flux CONSFTOT720 c721 c Index of non solar heat flux in total number of fields jpflda2o:722 index = 1723 c724 CALL SIPC_Write_Model(index, imjm, cmodinf,725 $ cljobnam,infos,fnsol)726 c727 c728 c Writing of output field solar heat flux COSHFTOT729 c730 c Index of solar heat flux in total number of fields jpflda2o:731 index = 2732 c733 CALL SIPC_Write_Model(index, imjm, cmodinf,734 $ cljobnam,infos,fsol)735 c736 c Writing of output field rain COTOPRSU737 c738 c Index of rain in total number of fields jpflda2o:739 index = 3740 c741 CALL SIPC_Write_Model(index, imjm, cmodinf,742 $ cljobnam,infos, rain)743 c744 c Writing of output field evap COTFSHSU745 c746 c Index of evap in total number of fields jpflda2o:747 index = 4748 c749 CALL SIPC_Write_Model(index, imjm, cmodinf,750 $ cljobnam,infos, evap)751 c752 c Writing of output field ruisoce CORUNCOA753 c754 c Index of ruisoce in total number of fields jpflda2o:755 index = 5756 c757 CALL SIPC_Write_Model(index, imjm, cmodinf,758 $ cljobnam,infos, ruisoce)759 c760 c761 c Writing of output field ruisriv CORIVFLU762 c763 c Index of ruisriv in total number of fields jpflda2o:764 index = 6765 c766 CALL SIPC_Write_Model(index, imjm, cmodinf,767 $ cljobnam,infos, ruisriv)768 c769 c770 c Writing of output field zonal wind stress COZOTAUX771 c772 c Index of runoff in total number of fields jpflda2o:773 index = 7774 c775 CALL SIPC_Write_Model(index, imjm, cmodinf,776 $ cljobnam,infos, taux)777 c778 c Writing of output field meridional wind stress COMETAUY779 c780 c Index of runoff in total number of fields jpflda2o:781 index = 8782 c783 CALL SIPC_Write_Model(index, imjm, cmodinf,784 $ cljobnam,infos, taux)785 c786 c787 c Writing of output field zonal wind stress COMETAU2 (at v point)788 c789 c Index of runoff in total number of fields jpflda2o:790 index = 9791 c792 CALL SIPC_Write_Model(index, imjm, cmodinf,793 $ cljobnam,infos, tauy)794 c795 c Writing of output field meridional wind stress COMETAU2796 c797 c Index of runoff in total number of fields jpflda2o:798 index = 10799 c800 CALL SIPC_Write_Model(index, imjm, cmodinf,801 $ cljobnam,infos, tauy)802 c803 c804 ELSE IF(cchan.eq.'CLIM') THEN805 806 DO jn=1, jpflda2o807 808 IF (jn.eq.1) CALL CLIM_Export(cl_writ(jn), kt, fnsol, info)809 IF (jn.eq.2) CALL CLIM_Export(cl_writ(jn), kt, fsol, info)810 IF (jn.eq.3) CALL CLIM_Export(cl_writ(jn), kt, rain, info)811 IF (jn.eq.4) CALL CLIM_Export(cl_writ(jn), kt, evap, info)812 IF (jn.eq.5) CALL CLIM_Export(cl_writ(jn), kt, ruisoce, info813 $ )814 IF (jn.eq.6) CALL CLIM_Export(cl_writ(jn), kt, ruisriv, info815 $ )816 IF (jn.eq.7) CALL CLIM_Export(cl_writ(jn), kt, taux, info)817 IF (jn.eq.8) CALL CLIM_Export(cl_writ(jn), kt, taux, info)818 IF (jn.eq.9) CALL CLIM_Export(cl_writ(jn), kt, tauy, info)819 IF (jn.eq.10) CALL CLIM_Export(cl_writ(jn), kt, tauy, info)820 821 491 IF (info .NE. CLIM_Ok) THEN 822 492 WRITE (nuout,*) 'STEP : Pb giving ',cl_writ(jn), ':',jn 823 493 WRITE (nuout,*) ' at timestep = ', icstep,'kt = ',kt 824 494 WRITE (nuout,*) 'Clim error code is = ',info 825 WRITE (nuout,*) 'STOP in intocpl ' 826 CALL abort(' intocpl ') 495 CALL halte('STOP in intocpl ') 827 496 ENDIF 828 829 END DO 830 497 END DO 831 498 ENDIF 832 c 499 C 833 500 RETURN 834 501 END 835 502 836 SUBROUTINE locread837 print *, 'Attention dans oasis.F, locread est non defini'838 RETURN839 END840 841 SUBROUTINE locwrite842 print *, 'Attention dans oasis.F, locwrite est non defini'843 RETURN844 END845 846 SUBROUTINE pipe_model_define847 print*,'Attention dans oasis.F, pipe_model_define est non defini'848 RETURN849 END850 851 SUBROUTINE pipe_model_stepi852 print*,'Attention dans oasis.F, pipe_model_stepi est non defini'853 RETURN854 END855 856 SUBROUTINE pipe_model_recv857 print *, 'Attention dans oasis.F, pipe_model_recv est non defini'858 RETURN859 END860 861 SUBROUTINE pipe_model_send862 print *, 'Attention dans oasis.F, pipe_model_send est non defini'863 RETURN864 END865 866 867 SUBROUTINE sipc_init_model868 print *, 'Attention dans oasis.F, sipc_init_model est non defini'869 RETURN870 END871 872 SUBROUTINE svipc_write873 print *, 'Attention dans oasis.F, svipc_write est non defini'874 RETURN875 END876 877 SUBROUTINE clim_export878 print *, 'Attention dans oasis.F, clim_export est non defini'879 RETURN880 END881 882 SUBROUTINE clim_init883 print *, 'Attention dans oasis.F, clim_init est non defini'884 RETURN885 END886 887 SUBROUTINE sipc_write_model888 print *, 'Attention dans oasis.F, sipc_write_model est non defini'889 RETURN890 END891 892 SUBROUTINE clim_start893 print *, 'Attention dans oasis.F, clim_start est non defini'894 RETURN895 END896 897 SUBROUTINE clim_define898 print *, 'Attention dans oasis.F, clim_define est non defini'899 RETURN900 END901 902 SUBROUTINE sipc_attach903 print *, 'Attention dans oasis.F, sipc_attach est non defini'904 RETURN905 END906 907 SUBROUTINE clim_import908 print *, 'Attention dans oasis.F, clim_import est non defini'909 RETURN910 END911 912 SUBROUTINE svipc_read913 print *, 'Attention dans oasis.F, svipc_read est non defini'914 RETURN915 END916 917 SUBROUTINE clim_stepi918 print *, 'Attention dans oasis.F, clim_stepi est non defini'919 RETURN920 END921 922 SUBROUTINE sipc_read_model923 print *, 'Attention dans oasis.F, sipc_read_model est non defini'924 RETURN925 END926 927 SUBROUTINE svipc_close928 print *, 'Attention dans oasis.F, svipc_close est non defini'929 RETURN930 END931 932 SUBROUTINE clim_quit933 print *, 'Attention dans oasis.F, clim_quit est non defini'934 RETURN935 END936
Note: See TracChangeset
for help on using the changeset viewer.