Changeset 15454
 Timestamp:
 20211027T20:03:30+02:00 (3 years ago)
 Location:
 NEMO/branches/NERC/dev_release3.4_NEMOTAM_consolidated/NEMOGCM
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

NEMO/branches/NERC/dev_release3.4_NEMOTAM_consolidated/NEMOGCM/CONFIG/ORCA2_TAM/EXP00/namelist
r3797 r15454 994 994 / 995 995 ! 996 &namtst_tam ! NEMOTAM driver ('key_tam') 996 &namtam ! NEMOTAM ('key_tam') 997 ! 998 ln_tam = 0 ! NEMOTAM mode 999 ! nn_tam = 1: Tangentlinear model time stepping 1000 ! nn_tam = 2: Adjoint model time stepping 1001 ! nn_tam = 3: External code 1002 ! nn_tam = 0: NEMOTAM tests 1003 / 1004 ! 1005 &namtst_tam ! NEMOTAM tests ('key_tam') 997 1006 ! 998 1007 ln_swi_opatam = 0 ! Switch for different TAM modes 999 1008 ! = 0 => Routine by routine adjoint test 1000 1009 ! = 1 => Step adjoint test 1001 ! = 2 => Run LT model in standalone1002 1010 / 1003 1011 ! 
NEMO/branches/NERC/dev_release3.4_NEMOTAM_consolidated/NEMOGCM/NEMO/OPATAM_SRC/nemogcm_tam.F90
r4600 r15454 90 90 !USE tamtrj 91 91 USE trj_tam 92 USE iom 93 USE wrk_nemo 92 94 IMPLICIT NONE 93 95 PRIVATE … … 119 121 !! Madec, 2008, internal report, IPSL. 120 122 !! 121 INTEGER :: istp ! time step index122 !!123 123 ! !! 124 124 ! !== Initialisations ==! … … 135 135 ! !== time stepping ==! 136 136 ! !! 137 IF (ln_swi_opatam == 2) THEN 138 istp = nit000  1 139 CALL trj_rea( istp, 1) 140 istp = nit000 141 CALL istate_init_tan 142 DO istp = nit000, nitend, 1 143 CALL stp_tan( istp ) 144 END DO 137 ! 138 ! NEMOTAM options 139 !  140 ! 141 ! nn_tam = 1: Tangentlinear model time stepping 142 ! nn_tam = 2: Adjoint model time stepping 143 ! nn_tam = 3: Call external code (see below) 144 ! nn_tam = 0: Call tam_tst 145 ! 146 ! External NEMOTAM code 147 !  148 ! 149 ! When key_tam_ext is defined, two include files are required (e.g., in 150 ! the MY_SRC directory): tam_ext_subr.h90 and tam_ext_var.h90. All of the 151 ! subroutines listed below have to be provided in include file 152 ! tam_ext_subr.h90 153 ! 154 ! +++++ 155 !  Subroutine  called if nn_tam =  argument  position of call  156 ! +++++ 157 !  tam_ext_tan_init  1   precedes istate_init_tan call  158 !  tam_ext_tan_prestp  1  istp  precedes stp_tan call  159 !  tam_ext_tan_poststp  1  istp  follows stp_tan call  160 !  tam_ext_tan_final  1   follows final time step  161 !  tam_ext_adj_init  2   precedes first time step  162 !  tam_ext_adj_prestp  2  istp  precedes stp_adj call  163 !  tam_ext_adj_poststp  2  istp  follows stp_adj call  164 !  tam_ext_adj_final  2   follows istate_init_adj call  165 !  tam_ext_main  3   n/a  166 ! +++++ 167 ! 168 ! and tam_ext_vars.h90 can be empty or used to declare addtional 169 ! TAMspecific variables (declared in module tamctl). 170 ! 171 IF ( nn_tam == 1 ) THEN ! TL mode 172 173 ! Initialize energy weights 174 CALL par_esp 175 176 ! Timestep loop 177 CALL tam_tsloop_tan 178 179 IF (lwp) THEN 180 WRITE(numout,*) 181 WRITE(numout,*) ' TAM: TL finished' 182 WRITE(numout,*) ' ' 183 WRITE(numout,*) 184 ENDIF 185 CALL flush(numout) 186 187 ELSEIF ( nn_tam == 2 ) THEN ! ADJ mode 188 189 ! Initialize energy weights 190 CALL par_esp 191 192 ! Timestep loop 193 CALL tam_tsloop_adj 194 195 IF (lwp) THEN 196 WRITE(numout,*) 197 WRITE(numout,*) ' TAM: ADJ finished' 198 WRITE(numout,*) ' ' 199 WRITE(numout,*) 200 ENDIF 201 CALL flush(numout) 202 203 ELSEIF ( nn_tam == 3 ) THEN 204 205 ! Initialize energy weights 206 CALL par_esp 207 208 CALL tam_ext_main 209 210 ELSE ! Test mode 211 212 CALL tam_tst 213 145 214 IF (lwp) THEN 146 215 WRITE(numout,*) … … 149 218 WRITE(numout,*) 150 219 ENDIF 151 CALL flush(numout) 152 ELSE 153 CALL tam_tst 220 154 221 ENDIF 155 222 ! !! … … 170 237 END SUBROUTINE nemo_gcm_tam 171 238 239 SUBROUTINE tam_tsloop_tan(ld_input, ld_output) 240 !! 241 !! *** ROUTINE tam_tsloop_tan *** 242 !! 243 !! ** Purpose : Default NEMOTAM tangentlinear timestepping loop 244 !! 245 !! 246 247 LOGICAL, INTENT(in), OPTIONAL :: ld_input, ld_output ! optional arguments (default .TRUE.) 248 LOGICAL :: ll_input, ll_output !  ld_input/ll_input: input of initial state 249 !  ld_output/ll_output: output of final state 250 INTEGER :: istp, inum ! timestep index, file unit 251 REAL(KIND=wp), POINTER, DIMENSION(:,:) :: z2d 252 REAL(KIND=wp), POINTER, DIMENSION(:,:,:) :: z3d 253 254 ! Optional arguments 255 ll_input = .TRUE. ; IF ( PRESENT( ld_input ) ) ll_input = ld_input 256 ll_output = .TRUE. ; IF ( PRESENT( ld_output ) ) ll_output = ld_output 257 258 ! Update trajectory 259 istp = nit000  1 260 CALL trj_rea( istp, 1, .true. ) 261 262 ! Call various initialisation subroutines 263 CALL oce_tam_init( 1 ) 264 CALL sbc_oce_tam_init( 1 ) 265 CALL trc_oce_tam_init( 1 ) 266 CALL sol_oce_tam_init( 1 ) 267 268 ! Initialise tangentlinear state variables 269 un_tl (:,:,:) = 0.0_wp 270 vn_tl (:,:,:) = 0.0_wp 271 tsn_tl (:,:,:,jp_tem) = 0.0_wp 272 tsn_tl (:,:,:,jp_sal) = 0.0_wp 273 sshn_tl( :,:) = 0.0_wp 274 275 ! Load initial tangentlinear state 276 IF ( ll_input ) THEN 277 CALL wrk_alloc( jpi, jpj, z2d ) 278 CALL wrk_alloc( jpi, jpj, jpk, z3d ) 279 CALL iom_open( 'tan_input.nc', inum, kiolib = jprstlib ) 280 CALL iom_get( inum, jpdom_autoglo, 'tn_tl', z3d ) 281 tsn_tl(:,:,:,jp_tem) = z3d 282 CALL iom_get( inum, jpdom_autoglo, 'sn_tl', z3d ) 283 tsn_tl(:,:,:,jp_sal) = z3d 284 CALL iom_get( inum, jpdom_autoglo, 'un_tl', z3d ) 285 un_tl(:,:,:) = z3d 286 CALL iom_get( inum, jpdom_autoglo, 'vn_tl', z3d ) 287 vn_tl(:,:,:) = z3d 288 CALL iom_get( inum, jpdom_autoglo, 'sshn_tl', z2d ) 289 sshn_tl(:,:) = z2d 290 CALL iom_close( inum ) 291 CALL wrk_dealloc( jpi, jpj, z2d ) 292 CALL wrk_dealloc( jpi, jpj, jpk, z3d ) 293 END IF 294 295 CALL tam_ext_tan_init 296 297 ! Tangentlinear version of istate 298 CALL istate_init_tan 299 300 ! Call day_tam, as call to day_init commented out in istate_init_tan 301 CALL day_tam( nit000, 0 ) 302 303 ! Time step 304 DO istp = nit000, nitend, 1 305 306 CALL tam_ext_tan_prestp( istp ) 307 308 CALL stp_tan( istp ) 309 310 CALL tam_ext_tan_poststp( istp ) 311 312 END DO 313 314 CALL tam_ext_tan_final 315 316 ! Output final tangentlinear state 317 IF ( ll_output ) THEN 318 CALL iom_open( 'tan_output.nc', inum, ldwrt = .TRUE., kiolib = jprstlib ) 319 CALL iom_rstput( istp, istp, inum, 'tn_tl', tsn_tl(:,:,:,jp_tem) ) 320 CALL iom_rstput( istp, istp, inum, 'sn_tl', tsn_tl(:,:,:,jp_sal) ) 321 CALL iom_rstput( istp, istp, inum, 'un_tl', un_tl ) 322 CALL iom_rstput( istp, istp, inum, 'vn_tl', vn_tl ) 323 CALL iom_rstput( istp, istp, inum, 'sshn_tl', sshn_tl ) 324 CALL iom_close( inum ) 325 END IF 326 327 END SUBROUTINE tam_tsloop_tan 328 329 SUBROUTINE tam_tsloop_adj(ld_input, ld_output) 330 !! 331 !! *** ROUTINE tam_tsloop_adj *** 332 !! 333 !! ** Purpose : Default NEMOTAM adjoint timestepping loop 334 !! 335 !! 336 337 LOGICAL, INTENT(in), OPTIONAL :: ld_input, ld_output ! optional arguments (default .TRUE.) 338 LOGICAL :: ll_input, ll_output !  ld_input/ll_input: input of initial state 339 !  ld_output/ll_output: output of final state 340 INTEGER :: istp, inum ! timestep index, file unit 341 REAL(KIND=wp), POINTER, DIMENSION(:,:) :: z2d 342 REAL(KIND=wp), POINTER, DIMENSION(:,:,:) :: z3d 343 344 ! Optional arguments 345 ll_input = .TRUE. ; IF ( PRESENT( ld_input ) ) ll_input = ld_input 346 ll_output = .TRUE. ; IF ( PRESENT( ld_output ) ) ll_output = ld_output 347 348 ! Update calendar (go to final time step one at a time: calendar 349 ! is initialised at nit000, and subroutine 'day_tam' only 350 ! increments/decrements one time step each call) 351 DO istp = nit000, nitend 352 CALL day_tam( istp, 0 ) 353 END DO 354 355 ! Update trajectory 356 CALL trj_rea( istp1, 1, .true. ) 357 358 ! Call various initialisation subroutines 359 CALL oce_tam_init(2) 360 CALL sbc_oce_tam_init(2) 361 CALL trc_oce_tam_init(2) 362 CALL sol_oce_tam_init(2) 363 364 ! Initialise adjoint state variables 365 un_ad(:,:,:) = 0.0_wp 366 vn_ad(:,:,:) = 0.0_wp 367 sshn_ad(:,:) = 0.0_wp 368 tsn_ad(:,:,:,:) = 0.0_wp 369 ub_ad(:,:,:) = 0.0_wp 370 vb_ad(:,:,:) = 0.0_wp 371 sshb_ad(:,:) = 0.0_wp 372 tsb_ad(:,:,:,:) = 0.0_wp 373 374 ! Load initial adjoint state and only permit values in interior domain 375 IF ( ll_input ) THEN 376 CALL wrk_alloc( jpi, jpj, z2d ) 377 CALL wrk_alloc( jpi, jpj, jpk, z3d ) 378 CALL iom_open( 'adj_input.nc', inum, kiolib = jprstlib ) 379 CALL iom_get( inum, jpdom_autoglo, 'tn_ad', z3d ) 380 tsn_ad(:,:,:,jp_tem) = z3d * tmsk_i 381 CALL iom_get( inum, jpdom_autoglo, 'sn_ad', z3d ) 382 tsn_ad(:,:,:,jp_sal) = z3d * tmsk_i 383 CALL iom_get( inum, jpdom_autoglo, 'un_ad', z3d ) 384 un_ad(:,:,:) = z3d * umsk_i 385 CALL iom_get( inum, jpdom_autoglo, 'vn_ad', z3d ) 386 vn_ad(:,:,:) = z3d * vmsk_i 387 CALL iom_get( inum, jpdom_autoglo, 'sshn_ad', z2d ) 388 sshn_ad(:,:) = z2d * tmsk_i(:,:,1) 389 CALL iom_close( inum ) 390 CALL wrk_dealloc( jpi, jpj, z2d ) 391 CALL wrk_dealloc( jpi, jpj, jpk, z3d ) 392 END IF 393 394 CALL tam_ext_adj_init 395 396 ! Adjoint time steps (backwards in time) 397 DO istp = nitend, nit000, 1 398 399 CALL tam_ext_adj_prestp( istp ) 400 401 ! Carry out adjoint time step 402 CALL stp_adj( istp ) 403 404 CALL tam_ext_adj_poststp( istp ) 405 406 END DO 407 408 ! Adjoint version of istate 409 CALL istate_init_adj 410 411 ! Output final adjoint state 412 IF ( ll_output ) THEN 413 CALL iom_open( 'adj_output.nc', inum, ldwrt = .TRUE., kiolib = jprstlib ) 414 CALL iom_rstput( istp, istp, inum, 'tn_ad', tsn_ad(:,:,:,jp_tem) ) 415 CALL iom_rstput( istp, istp, inum, 'sn_ad', tsn_ad(:,:,:,jp_sal) ) 416 CALL iom_rstput( istp, istp, inum, 'un_ad', un_ad ) 417 CALL iom_rstput( istp, istp, inum, 'vn_ad', vn_ad ) 418 CALL iom_rstput( istp, istp, inum, 'sshn_ad', sshn_ad ) 419 CALL iom_close( inum ) 420 END IF 421 422 CALL tam_ext_adj_final 423 424 END SUBROUTINE tam_tsloop_adj 425 426 #if defined key_tam_ext 427 #include "tam_ext_subr.h90" 428 #else 429 SUBROUTINE tam_ext_tan_init 430 END SUBROUTINE tam_ext_tan_init 431 SUBROUTINE tam_ext_tan_prestp( kstp ) 432 INTEGER :: kstp 433 END SUBROUTINE tam_ext_tan_prestp 434 SUBROUTINE tam_ext_tan_poststp( kstp ) 435 INTEGER :: kstp 436 END SUBROUTINE tam_ext_tan_poststp 437 SUBROUTINE tam_ext_tan_final 438 END SUBROUTINE tam_ext_tan_final 439 SUBROUTINE tam_ext_adj_init 440 END SUBROUTINE tam_ext_adj_init 441 SUBROUTINE tam_ext_adj_prestp( kstp ) 442 INTEGER :: kstp 443 END SUBROUTINE tam_ext_adj_prestp 444 SUBROUTINE tam_ext_adj_poststp( kstp ) 445 INTEGER :: kstp 446 END SUBROUTINE tam_ext_adj_poststp 447 SUBROUTINE tam_ext_adj_final 448 END SUBROUTINE tam_ext_adj_final 449 SUBROUTINE tam_ext_main 450 END SUBROUTINE tam_ext_main 451 #endif 172 452 173 453 SUBROUTINE nemo_init_tam … … 184 464 & nn_isplt, nn_jsplt, nn_jctls, nn_jctle, & 185 465 & nn_bench, nn_timing 186 !! 466 NAMELIST/namtam/ nn_tam 467 !! 468 ! 469 ! Read 'namtam' namelist 470 nn_tam = 1 ! Default mode (tangentlinear) 471 REWIND( numnam ) 472 READ ( numnam, namtam ) 473 IF (lwp) THEN 474 WRITE(numout,*) 475 WRITE(numout,*) 'tam : NEMOTAM mode' 476 WRITE(numout,*) '~~~' 477 WRITE(numout,*) ' Namelist namtam' 478 WRITE(numout,*) ' tam mode (0  TEST, 1  TL (default), 2  ADJ, 3  external) nn_tam = ', nn_tam 479 END IF 187 480 ! 188 481 IF( ln_rnf ) CALL sbc_rnf_init … … 216 509 CALL sbc_rnf_init_tam 217 510 218 CALL tam_tst_init219 CALL tl_trj_ini511 IF( nn_tam == 0 ) CALL tam_tst_init 512 CALL tl_trj_ini 220 513 END SUBROUTINE nemo_init_tam 221 514 
NEMO/branches/NERC/dev_release3.4_NEMOTAM_consolidated/NEMOGCM/NEMO/OPATAM_SRC/tamctl.F90
r3611 r15454 23 23 24 24 !! * Module variables 25 25 INTEGER :: nn_tam ! TAM mode 26 ! 1 : Tangentlinear model time stepping 27 ! 2 : Adjoint model time stepping 28 ! 3 : External code 29 ! <1 or >3 : NEMOTAM tests 30 #if defined key_tam_ext 31 #include "tam_ext_var.h90" 32 #endif 26 33 27 34 !! namtst: assimilation test parameters
Note: See TracChangeset
for help on using the changeset viewer.