24 #define _GET_VAR1 get_var1_real 26 #define _GET_VAR1 get_var1_double 149 use fms_mod,
only: file_exist, read_data, field_exist, write_version_number
150 use fms_mod,
only: open_namelist_file, check_nml_error, close_file
151 use fms_mod,
only: get_mosaic_tile_file, read_data, error_mesg
152 use fms_io_mod,
only: get_tile_string, field_size, free_restart_type
153 use fms_io_mod,
only: restart_file_type, register_restart_field
154 use fms_io_mod,
only: save_restart, restore_state
155 use mpp_mod,
only: mpp_error, fatal, note, mpp_pe, mpp_root_pe
156 use mpp_mod,
only: stdlog, input_nml_file
157 use mpp_parameter_mod,
only: agrid_param=>agrid
158 use mpp_domains_mod,
only: mpp_get_tile_id, domain2d, mpp_update_domains, north, east
159 use tracer_manager_mod,
only: get_tracer_names, get_number_tracers, get_tracer_index
160 use tracer_manager_mod,
only: set_tracer_profile
161 use field_manager_mod,
only: model_atmos
163 use constants_mod,
only: pi=>pi_8, omega, grav, kappa, rdgas, rvgas, cp_air
171 use fv_mp_mod,
only:
ng, is_master, fill_corners, ydir, mp_reduce_min, mp_reduce_max
189 use mpp_domains_mod,
only: mpp_get_data_domain, mpp_get_global_domain, mpp_get_compute_domain
198 real,
parameter::
zvir = rvgas/rdgas - 1.
206 #include<file_version.h> 213 type(domain2d),
intent(inout) :: fv_domain
214 logical,
intent(IN) :: cold_start
219 real,
pointer,
dimension(:,:,:) :: grid, agrid
220 real,
pointer,
dimension(:,:) :: fc, f0
222 integer :: is, ie, js, je
223 integer :: isd, ied, jsd, jed
224 integer :: sphum, liq_wat, ice_wat, rainwat, snowwat, graupel
226 integer :: liq_aero, ice_aero
229 integer :: spfo, spfo2, spfo3
243 grid => atm(1)%gridstruct%grid
244 agrid => atm(1)%gridstruct%agrid
246 fc => atm(1)%gridstruct%fC
247 f0 => atm(1)%gridstruct%f0
253 fc(i,j) = 2.*omega*( -1.*cos(grid(i,j,1))*cos(grid(i,j,2))*sin(alpha) + &
254 sin(grid(i,j,2))*cos(alpha) )
260 f0(i,j) = 2.*omega*( -1.*cos(agrid(i,j,1))*cos(agrid(i,j,2))*sin(alpha) + &
261 sin(agrid(i,j,2))*cos(alpha) )
265 call mpp_update_domains( f0, fv_domain )
266 if ( atm(1)%gridstruct%cubed_sphere .and. (.not. (atm(1)%neststruct%nested .or. atm(1)%flagstruct%regional)))
then 267 call fill_corners(f0, atm(1)%npx, atm(1)%npy, ydir)
271 if ( atm(1)%flagstruct%mountain )
then 274 if (.not. atm(1)%neststruct%nested) atm(1)%phis = 0.
278 if ( atm(1)%flagstruct%ncep_ic )
then 284 if (.not. cold_start)
then 286 if(is_master())
write(*,*)
'All tracers except sphum replaced by FV IC' 289 elseif ( atm(1)%flagstruct%nggps_ic )
then 293 elseif ( atm(1)%flagstruct%ecmwf_ic )
then 294 if( is_master() )
write(*,*)
'Calling get_ecmwf_ic' 301 nq =
size(atm(1)%q,4)
305 call prt_maxmin(
'PS', atm(1)%ps, is, ie, js, je,
ng, 1, 0.01)
306 call prt_maxmin(
'T', atm(1)%pt, is, ie, js, je,
ng, atm(1)%npz, 1.)
307 if (.not.atm(1)%flagstruct%hydrostatic)
call prt_maxmin(
'W', atm(1)%w, is, ie, js, je,
ng, atm(1)%npz, 1.)
308 call prt_maxmin(
'SPHUM', atm(1)%q(:,:,:,1), is, ie, js, je,
ng, atm(1)%npz, 1.)
309 if ( atm(1)%flagstruct%nggps_ic )
then 310 call prt_maxmin(
'TS', atm(1)%ts, is, ie, js, je, 0, 1, 1.)
312 if ( atm(1)%flagstruct%nggps_ic .or. atm(1)%flagstruct%ecmwf_ic )
then 313 sphum = get_tracer_index(model_atmos,
'sphum')
314 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
315 ice_wat = get_tracer_index(model_atmos,
'ice_wat')
316 rainwat = get_tracer_index(model_atmos,
'rainwat')
317 snowwat = get_tracer_index(model_atmos,
'snowwat')
318 graupel = get_tracer_index(model_atmos,
'graupel')
320 spfo = get_tracer_index(model_atmos,
'spfo')
321 spfo2 = get_tracer_index(model_atmos,
'spfo2')
322 spfo3 = get_tracer_index(model_atmos,
'spfo3')
324 o3mr = get_tracer_index(model_atmos,
'o3mr')
327 liq_aero = get_tracer_index(model_atmos,
'liq_aero')
328 ice_aero = get_tracer_index(model_atmos,
'ice_aero')
332 call prt_maxmin(
'liq_wat', atm(1)%q(:,:,:,liq_wat), is, ie, js, je,
ng, atm(1)%npz, 1.)
334 call prt_maxmin(
'ice_wat', atm(1)%q(:,:,:,ice_wat), is, ie, js, je,
ng, atm(1)%npz, 1.)
336 call prt_maxmin(
'rainwat', atm(1)%q(:,:,:,rainwat), is, ie, js, je,
ng, atm(1)%npz, 1.)
338 call prt_maxmin(
'snowwat', atm(1)%q(:,:,:,snowwat), is, ie, js, je,
ng, atm(1)%npz, 1.)
340 call prt_maxmin(
'graupel', atm(1)%q(:,:,:,graupel), is, ie, js, je,
ng, atm(1)%npz, 1.)
343 call prt_maxmin(
'SPFO', atm(1)%q(:,:,:,spfo), is, ie, js, je,
ng, atm(1)%npz, 1.)
345 call prt_maxmin(
'SPFO2', atm(1)%q(:,:,:,spfo2), is, ie, js, je,
ng, atm(1)%npz, 1.)
347 call prt_maxmin(
'SPFO3', atm(1)%q(:,:,:,spfo3), is, ie, js, je,
ng, atm(1)%npz, 1.)
350 call prt_maxmin(
'O3MR', atm(1)%q(:,:,:,o3mr), is, ie, js, je,
ng, atm(1)%npz, 1.)
354 call prt_maxmin(
'liq_aero',atm(1)%q(:,:,:,liq_aero),is, ie, js, je,
ng, atm(1)%npz, 1.)
356 call prt_maxmin(
'ice_aero',atm(1)%q(:,:,:,ice_aero),is, ie, js, je,
ng, atm(1)%npz, 1.)
360 call p_var(atm(1)%npz, is, ie, js, je, atm(1)%ak(1),
ptop_min, &
361 atm(1)%delp, atm(1)%delz, atm(1)%pt, atm(1)%ps, &
362 atm(1)%pe, atm(1)%peln, atm(1)%pk, atm(1)%pkz, &
363 kappa, atm(1)%q,
ng, atm(1)%ncnst, atm(1)%gridstruct%area_64, atm(1)%flagstruct%dry_mass, &
364 atm(1)%flagstruct%adjust_dry_mass, atm(1)%flagstruct%mountain, atm(1)%flagstruct%moist_phys, &
365 atm(1)%flagstruct%hydrostatic, atm(1)%flagstruct%nwat, atm(1)%domain, atm(1)%flagstruct%make_nh)
373 type(domain2d),
intent(inout) :: fv_domain
375 integer,
allocatable :: tile_id(:)
376 character(len=64) :: fname
377 character(len=7) :: gn
379 integer :: jbeg, jend
381 real,
allocatable :: g_dat2(:,:,:)
382 real,
allocatable :: pt_coarse(:,:,:)
383 integer isc_p, iec_p, jsc_p, jec_p, isg, ieg, jsg,jeg
385 integer :: is, ie, js, je
386 integer :: isd, ied, jsd, jed
397 if (atm(1)%grid_number > 1)
then 399 write(gn,
'(A5, I2.2)')
".nest", atm(1)%grid_number
404 ntileme =
size(atm(:))
407 allocate( tile_id(ntileme) )
408 tile_id = mpp_get_tile_id( fv_domain )
411 call get_tile_string(fname,
'INPUT/fv_core.res'//trim(gn)//
'.tile', tile_id(n),
'.nc' )
412 if (mpp_pe() == mpp_root_pe()) print*,
'external_ic: looking for ', fname
415 if( file_exist(fname) )
then 416 call read_data(fname,
'phis', atm(n)%phis(is:ie,js:je), &
417 domain=fv_domain, tile_count=n)
419 call surfdrv( atm(n)%npx, atm(n)%npy, atm(n)%gridstruct%grid_64, atm(n)%gridstruct%agrid_64, &
420 atm(n)%gridstruct%area_64, atm(n)%gridstruct%dx, atm(n)%gridstruct%dy, &
421 atm(n)%gridstruct%dxa, atm(n)%gridstruct%dya, &
422 atm(n)%gridstruct%dxc, atm(n)%gridstruct%dyc, atm(n)%gridstruct%sin_sg, &
423 atm(n)%phis, atm(n)%flagstruct%stretch_fac, &
424 atm(n)%neststruct%nested, atm(n)%neststruct%npx_global, atm(n)%domain, &
425 atm(n)%flagstruct%grid_number, atm(n)%bd, atm(n)%flagstruct%regional )
426 call mpp_error(note,
'terrain datasets generated using USGS data')
432 call mpp_update_domains( atm(1)%phis, atm(1)%domain )
433 ftop =
g_sum(atm(1)%domain, atm(1)%phis(is:ie,js:je), is, ie, js, je,
ng, atm(1)%gridstruct%area_64, 1)
435 call prt_maxmin(
'ZS', atm(1)%phis, is, ie, js, je,
ng, 1, 1./grav)
436 if(is_master())
write(*,*)
'mean terrain height (m)=', ftop/grav
438 deallocate( tile_id )
467 use gfs_restart,
only : gfs_restart_type
472 type(fv_atmos_type),
intent(inout) :: Atm(:)
473 type(domain2d),
intent(inout) :: fv_domain
475 real,
dimension(:),
allocatable:: ak, bk
476 real,
dimension(:,:),
allocatable:: wk2, ps, oro_g
477 real,
dimension(:,:,:),
allocatable:: ud, vd, u_w, v_w, u_s, v_s, omga, temp
478 real,
dimension(:,:,:),
allocatable:: zh(:,:,:)
479 real,
dimension(:,:,:,:),
allocatable:: q
480 real,
dimension(:,:),
allocatable :: phis_coarse
481 real rdg, wt, qt, m_fac
482 integer:: n, npx, npy, npz, itoa, nt, ntprog, ntdiag, ntracers, ntrac, iq
483 integer :: is, ie, js, je
484 integer :: isd, ied, jsd, jed
485 integer :: ios, ierr, unit, id_res
486 type(restart_file_type) :: oro_restart, sfc_restart, gfs_restart
487 character(len=6) :: gn, stile_name
488 character(len=64) :: tracer_name
489 character(len=64) :: fn_gfs_ctl =
'gfs_ctrl.nc' 490 character(len=64) :: fn_gfs_ics =
'gfs_data.nc' 491 character(len=64) :: fn_sfc_ics =
'sfc_data.nc' 492 character(len=64) :: fn_oro_ics =
'oro_data.nc' 495 logical :: filtered_terrain = .true.
496 logical :: gfs_dwinds = .true.
498 logical :: checker_tr = .false.
499 integer :: nt_checker = 0
500 real(kind=R_GRID),
dimension(2):: p1, p2, p3
501 real(kind=R_GRID),
dimension(3):: e1, e2, ex, ey
502 integer:: i,j,k,nts, ks
503 integer:: liq_wat, ice_wat, rainwat, snowwat, graupel, ntclamt
504 namelist /external_ic_nml/ filtered_terrain, levp, gfs_dwinds, &
505 checker_tr, nt_checker
507 real,
dimension(65):: ak_sj, bk_sj
508 data ak_sj/20.00000, 68.00000, 137.79000, &
509 221.95800, 318.26600, 428.43400, &
510 554.42400, 698.45700, 863.05803, &
511 1051.07995, 1265.75194, 1510.71101, &
512 1790.05098, 2108.36604, 2470.78817, &
513 2883.03811, 3351.46002, 3883.05187, &
514 4485.49315, 5167.14603, 5937.04991, &
515 6804.87379, 7780.84698, 8875.64338, &
516 9921.40745, 10760.99844, 11417.88354, &
517 11911.61193, 12258.61668, 12472.89642, &
518 12566.58298, 12550.43517, 12434.26075, &
519 12227.27484, 11938.39468, 11576.46910, &
520 11150.43640, 10669.41063, 10142.69482, &
521 9579.72458, 8989.94947, 8382.67090, &
522 7766.85063, 7150.91171, 6542.55077, &
523 5948.57894, 5374.81094, 4825.99383, &
524 4305.79754, 3816.84622, 3360.78848, &
525 2938.39801, 2549.69756, 2194.08449, &
526 1870.45732, 1577.34218, 1313.00028, &
527 1075.52114, 862.90778, 673.13815, &
528 504.22118, 354.22752, 221.32110, &
530 data bk_sj/0.00000, 0.00000, 0.00000, &
531 0.00000, 0.00000, 0.00000, &
532 0.00000, 0.00000, 0.00000, &
533 0.00000, 0.00000, 0.00000, &
534 0.00000, 0.00000, 0.00000, &
535 0.00000, 0.00000, 0.00000, &
536 0.00000, 0.00000, 0.00000, &
537 0.00000, 0.00000, 0.00000, &
538 0.00179, 0.00705, 0.01564, &
539 0.02749, 0.04251, 0.06064, &
540 0.08182, 0.10595, 0.13294, &
541 0.16266, 0.19492, 0.22950, &
542 0.26615, 0.30455, 0.34435, &
543 0.38516, 0.42656, 0.46815, &
544 0.50949, 0.55020, 0.58989, &
545 0.62825, 0.66498, 0.69987, &
546 0.73275, 0.76351, 0.79208, &
547 0.81845, 0.84264, 0.86472, &
548 0.88478, 0.90290, 0.91923, &
549 0.93388, 0.94697, 0.95865, &
550 0.96904, 0.97826, 0.98642, &
554 real,
dimension(64):: ak_sj, bk_sj
555 data ak_sj/64.247, 137.790, 221.958, &
556 318.266, 428.434, 554.424, &
557 698.457, 863.05803, 1051.07995, &
558 1265.75194, 1510.71101, 1790.05098, &
559 2108.36604, 2470.78817, 2883.03811, &
560 3351.46002, 3883.05187, 4485.49315, &
561 5167.14603, 5937.04991, 6804.87379, &
562 7780.84698, 8875.64338, 10100.20534, &
563 11264.35673, 12190.64366, 12905.42546, &
564 13430.87867, 13785.88765, 13986.77987, &
565 14047.96335, 13982.46770, 13802.40331, &
566 13519.33841, 13144.59486, 12689.45608, &
567 12165.28766, 11583.57006, 10955.84778, &
568 10293.60402, 9608.08306, 8910.07678, &
569 8209.70131, 7516.18560, 6837.69250, &
570 6181.19473, 5552.39653, 4955.72632, &
571 4394.37629, 3870.38682, 3384.76586, &
572 2937.63489, 2528.37666, 2155.78385, &
573 1818.20722, 1513.68173, 1240.03585, &
574 994.99144, 776.23591, 581.48797, &
575 408.53400, 255.26520, 119.70243, 0. /
577 data bk_sj/0.00000, 0.00000, 0.00000, &
578 0.00000, 0.00000, 0.00000, &
579 0.00000, 0.00000, 0.00000, &
580 0.00000, 0.00000, 0.00000, &
581 0.00000, 0.00000, 0.00000, &
582 0.00000, 0.00000, 0.00000, &
583 0.00000, 0.00000, 0.00000, &
584 0.00000, 0.00000, 0.00000, &
585 0.00201, 0.00792, 0.01755, &
586 0.03079, 0.04751, 0.06761, &
587 0.09097, 0.11746, 0.14690, &
588 0.17911, 0.21382, 0.25076, &
589 0.28960, 0.32994, 0.37140, &
590 0.41353, 0.45589, 0.49806, &
591 0.53961, 0.58015, 0.61935, &
592 0.65692, 0.69261, 0.72625, &
593 0.75773, 0.78698, 0.81398, &
594 0.83876, 0.86138, 0.88192, &
595 0.90050, 0.91722, 0.93223, &
596 0.94565, 0.95762, 0.96827, &
597 0.97771, 0.98608, 0.99347, 1./
601 real,
dimension(64):: ak_sj, bk_sj
602 data ak_sj/64.247, 137.79, 221.958, &
603 318.266, 428.434, 554.424, &
604 698.457, 863.058, 1051.08, &
605 1265.752, 1510.711, 1790.051, &
606 2108.366, 2470.788, 2883.038, &
607 3351.46, 3883.052, 4485.493, &
608 5167.146, 5937.05, 6804.874, &
609 7777.15, 8832.537, 9936.614, &
610 11054.85, 12152.94, 13197.07, &
611 14154.32, 14993.07, 15683.49, &
612 16197.97, 16511.74, 16611.6, &
613 16503.14, 16197.32, 15708.89, &
614 15056.34, 14261.43, 13348.67, &
615 12344.49, 11276.35, 10171.71, &
616 9057.051, 7956.908, 6893.117, &
617 5884.206, 4945.029, 4086.614, &
618 3316.217, 2637.553, 2051.15, &
619 1554.789, 1143.988, 812.489, &
620 552.72, 356.223, 214.015, &
621 116.899, 55.712, 21.516, &
622 5.741, 0.575, 0., 0. /
624 data bk_sj/0.00000, 0.00000, 0.00000, &
625 0.00000, 0.00000, 0.00000, &
626 0.00000, 0.00000, 0.00000, &
627 0.00000, 0.00000, 0.00000, &
628 0.00000, 0.00000, 0.00000, &
629 0.00000, 0.00000, 0.00000, &
630 0.00000, 0.00000, 0.00000, &
631 0.00003697, 0.00043106, 0.00163591, &
632 0.00410671, 0.00829402, 0.01463712, &
633 0.02355588, 0.03544162, 0.05064684, &
634 0.06947458, 0.09216691, 0.1188122, &
635 0.1492688, 0.1832962, 0.2205702, &
636 0.2606854, 0.3031641, 0.3474685, &
637 0.3930182, 0.4392108, 0.4854433, &
638 0.5311348, 0.5757467, 0.6187996, &
639 0.659887, 0.6986829, 0.7349452, &
640 0.7685147, 0.7993097, 0.8273188, &
641 0.8525907, 0.8752236, 0.895355, &
642 0.913151, 0.9287973, 0.9424911, &
643 0.9544341, 0.9648276, 0.9738676, &
644 0.9817423, 0.9886266, 0.9946712, 1./
647 call mpp_error(note,
'Using external_IC::get_nggps_ic which is valid only for data which has been & 648 &horizontally interpolated to the current cubed-sphere grid')
649 #ifdef INTERNAL_FILE_NML 650 read (input_nml_file,external_ic_nml,iostat=ios)
651 ierr = check_nml_error(ios,
'external_ic_nml')
653 unit=open_namelist_file()
654 read (unit,external_ic_nml,iostat=ios)
655 ierr = check_nml_error(ios,
'external_ic_nml')
656 call close_file(unit)
660 call write_version_number (
'EXTERNAL_IC_mod::get_nggps_ic', version )
661 write(unit, nml=external_ic_nml)
664 if (atm(1)%flagstruct%external_eta)
then 665 if (filtered_terrain)
then 666 call mpp_error(note,
'External_IC::get_nggps_ic - use externally-generated, filtered terrain & 667 &and NCEP pressure levels (no vertical remapping)')
668 else if (.not. filtered_terrain)
then 669 call mpp_error(note,
'External_IC::get_nggps_ic - use externally-generated, raw terrain & 670 &and NCEP pressure levels (no vertical remapping)')
673 if (filtered_terrain)
then 674 call mpp_error(note,
'External_IC::get_nggps_ic - use externally-generated, filtered terrain & 675 &and FV3 pressure levels (vertical remapping)')
676 else if (.not. filtered_terrain)
then 677 call mpp_error(note,
'External_IC::get_nggps_ic - use externally-generated, raw terrain & 678 &and FV3 pressure levels (vertical remapping)')
691 write(*,22001)is,ie,js,je,isd,ied,jsd,jed
692 22001
format(
' enter get_nggps_ic is=',i4,
' ie=',i4,
' js=',i4,
' je=',i4,
' isd=',i4,
' ied=',i4,
' jsd=',i4,
' jed=',i4)
693 call get_number_tracers(model_atmos, num_tracers=ntracers, num_prog=ntprog)
694 ntdiag = ntracers-ntprog
697 if (.not. file_exist(
'INPUT/'//trim(fn_gfs_ctl), no_domain=.true.))
then 698 call mpp_error(fatal,
'==> Error in External_ic::get_nggps_ic: file '//trim(fn_gfs_ctl)//
' for NGGPS IC does not exist')
700 call mpp_error(note,
'==> External_ic::get_nggps_ic: using control file '//trim(fn_gfs_ctl)//
' for NGGPS IC')
703 call read_data (
'INPUT/'//trim(fn_gfs_ctl),
'ntrac', ntrac, no_domain=.true.)
704 if (ntrac > ntracers)
call mpp_error(fatal,
'==> External_ic::get_nggps_ic: more NGGPS tracers & 705 &than defined in field_table '//trim(fn_gfs_ctl)//
' for NGGPS IC')
708 allocate (wk2(levp+1,2))
709 allocate (ak(levp+1))
710 allocate (bk(levp+1))
711 call read_data(
'INPUT/'//trim(fn_gfs_ctl),
'vcoord',wk2, no_domain=.true.)
712 ak(1:levp+1) = wk2(1:levp+1,1)
713 bk(1:levp+1) = wk2(1:levp+1,2)
716 if (.not. file_exist(
'INPUT/'//trim(fn_oro_ics), domain=atm(1)%domain))
then 717 call mpp_error(fatal,
'==> Error in External_ic::get_nggps_ic: tiled file '//trim(fn_oro_ics)//
' for NGGPS IC does not exist')
719 call mpp_error(note,
'==> External_ic::get_nggps_ic: using tiled data file '//trim(fn_oro_ics)//
' for NGGPS IC')
721 if (.not. file_exist(
'INPUT/'//trim(fn_sfc_ics), domain=atm(1)%domain))
then 722 call mpp_error(fatal,
'==> Error in External_ic::get_nggps_ic: tiled file '//trim(fn_sfc_ics)//
' for NGGPS IC does not exist')
724 call mpp_error(note,
'==> External_ic::get_nggps_ic: using tiled data file '//trim(fn_sfc_ics)//
' for NGGPS IC')
726 if (.not. file_exist(
'INPUT/'//trim(fn_gfs_ics), domain=atm(1)%domain))
then 727 call mpp_error(fatal,
'==> Error in External_ic::get_nggps_ic: tiled file '//trim(fn_gfs_ics)//
' for NGGPS IC does not exist')
729 call mpp_error(note,
'==> External_ic::get_nggps_ic: using tiled data file '//trim(fn_gfs_ics)//
' for NGGPS IC')
731 call get_data_source(
source,atm(1)%flagstruct%regional)
733 allocate (zh(is:ie,js:je,levp+1))
734 allocate (ps(is:ie,js:je))
735 allocate (omga(is:ie,js:je,levp))
736 allocate (q(is:ie,js:je,levp,ntracers))
737 allocate ( u_w(is:ie+1, js:je, 1:levp) )
738 allocate ( v_w(is:ie+1, js:je, 1:levp) )
739 allocate ( u_s(is:ie, js:je+1, 1:levp) )
740 allocate ( v_s(is:ie, js:je+1, 1:levp) )
741 allocate (temp(is:ie,js:je,levp))
743 do n = 1,
size(atm(:))
746 if (atm(n)%neststruct%nested)
then 747 allocate(phis_coarse(isd:ied,jsd:jed))
750 phis_coarse(i,j) = atm(n)%phis(i,j)
757 id_res = register_restart_field(sfc_restart, fn_sfc_ics,
'tsea', atm(n)%ts, domain=atm(n)%domain)
760 if (filtered_terrain)
then 761 id_res = register_restart_field(oro_restart, fn_oro_ics,
'orog_filt', atm(n)%phis, domain=atm(n)%domain)
762 elseif (.not. filtered_terrain)
then 763 id_res = register_restart_field(oro_restart, fn_oro_ics,
'orog_raw', atm(n)%phis, domain=atm(n)%domain)
766 if ( atm(n)%flagstruct%full_zs_filter)
then 767 allocate (oro_g(isd:ied,jsd:jed))
770 id_res = register_restart_field(oro_restart, fn_oro_ics,
'land_frac', oro_g, domain=atm(n)%domain)
771 call mpp_update_domains(oro_g, atm(n)%domain)
772 if (atm(n)%neststruct%nested)
then 773 call extrapolation_bc(oro_g, 0, 0, atm(n)%npx, atm(n)%npy, atm(n)%bd, .true.)
777 if ( atm(n)%flagstruct%fv_land )
then 779 id_res = register_restart_field(oro_restart, fn_oro_ics,
'stddev', atm(n)%sgh, domain=atm(n)%domain)
781 id_res = register_restart_field(oro_restart, fn_oro_ics,
'land_frac', atm(n)%oro, domain=atm(n)%domain)
785 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'ps', ps, domain=atm(n)%domain)
788 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'u_w', u_w, domain=atm(n)%domain,position=east)
790 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'v_w', v_w, domain=atm(n)%domain,position=east)
792 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'u_s', u_s, domain=atm(n)%domain,position=north)
794 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'v_s', v_s, domain=atm(n)%domain,position=north)
797 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'w', omga, domain=atm(n)%domain)
799 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'ZH', zh, domain=atm(n)%domain)
801 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
't', temp, mandatory=.false., &
802 domain=atm(n)%domain)
805 call get_tracer_names(model_atmos, nt, tracer_name)
807 id_res = register_restart_field(gfs_restart, fn_gfs_ics, trim(tracer_name), q(:,:,:,nt), &
808 mandatory=.false.,domain=atm(n)%domain)
813 call get_tracer_names(model_atmos, nt, tracer_name)
815 call set_tracer_profile (model_atmos, nt, atm(n)%q(:,:,:,nt) )
817 do nt = ntprog+1, ntracers
818 call get_tracer_names(model_atmos, nt, tracer_name)
820 call set_tracer_profile (model_atmos, nt, atm(n)%qdiag(:,:,:,nt) )
824 call restore_state (oro_restart)
825 call restore_state (sfc_restart)
826 call restore_state (gfs_restart)
829 call free_restart_type(oro_restart)
830 call free_restart_type(sfc_restart)
831 call free_restart_type(gfs_restart)
834 atm(n)%phis = atm(n)%phis*grav
837 if (atm(1)%flagstruct%external_eta)
then 838 itoa = levp - npz + 1
839 atm(n)%ptop = ak(itoa)
840 atm(n)%ak(1:npz+1) = ak(itoa:levp+1)
841 atm(n)%bk(1:npz+1) = bk(itoa:levp+1)
844 if ( npz <= 64 )
then 845 atm(n)%ak(:) = ak_sj(:)
846 atm(n)%bk(:) = bk_sj(:)
847 atm(n)%ptop = atm(n)%ak(1)
849 call set_eta(npz, ks, atm(n)%ptop, atm(n)%ak, atm(n)%bk)
853 if(is_master())
write(*,*)
'GFS ak =', ak,
' FV3 ak=',atm(n)%ak
854 ak(1) = max(1.e-9, ak(1))
862 if (n==1.and.atm(1)%flagstruct%regional)
then 872 call remap_scalar_nggps(atm(n), levp, npz, ntracers, ak, bk, ps, temp, q, omga, zh)
874 allocate ( ud(is:ie, js:je+1, 1:levp) )
875 allocate ( vd(is:ie+1,js:je, 1:levp) )
882 p1(:) = atm(1)%gridstruct%grid(i, j,1:2)
883 p2(:) = atm(1)%gridstruct%grid(i+1,j,1:2)
892 p1(:) = atm(1)%gridstruct%grid(i,j ,1:2)
893 p2(:) = atm(1)%gridstruct%grid(i,j+1,1:2)
906 call remap_dwinds(levp, npz, ak, bk, ps, ud, vd, atm(n))
911 if (atm(n)%neststruct%nested)
then 912 if (is_master())
write(*,*)
'Blending nested and coarse grid topography' 917 wt = max(0.,min(1.,
real(5 - min(i,j,npx-i,npy-j,5))/5. ))
918 atm(n)%phis(i,j) = (1.-wt)*atm(n)%phis(i,j) + wt*phis_coarse(i,j)
925 if ( atm(n)%flagstruct%full_zs_filter )
then 927 call mpp_update_domains(atm(n)%phis, atm(n)%domain)
929 call fv3_zs_filter( atm(n)%bd, isd, ied, jsd, jed, npx, npy, atm(n)%neststruct%npx_global, &
930 atm(n)%flagstruct%stretch_fac, atm(n)%neststruct%nested, atm(n)%domain, &
931 atm(n)%gridstruct%area_64, atm(n)%gridstruct%dxa, atm(n)%gridstruct%dya, &
932 atm(n)%gridstruct%dx, atm(n)%gridstruct%dy, atm(n)%gridstruct%dxc, &
933 atm(n)%gridstruct%dyc, atm(n)%gridstruct%grid_64, atm(n)%gridstruct%agrid_64, &
934 atm(n)%gridstruct%sin_sg, atm(n)%phis, oro_g, atm(n)%flagstruct%regional)
939 if ( atm(n)%flagstruct%n_zs_filter > 0 )
then 941 if ( atm(n)%flagstruct%nord_zs_filter == 2 )
then 943 atm(n)%gridstruct%area_64, atm(n)%gridstruct%dx, atm(n)%gridstruct%dy, &
944 atm(n)%gridstruct%dxc, atm(n)%gridstruct%dyc, atm(n)%gridstruct%sin_sg, &
945 atm(n)%flagstruct%n_zs_filter,
cnst_0p20*atm(n)%gridstruct%da_min, &
946 .false., oro_g, atm(n)%neststruct%nested, atm(n)%domain, atm(n)%bd, atm(n)%flagstruct%regional)
947 if ( is_master() )
write(*,*)
'Warning !!! del-2 terrain filter has been applied ', &
948 atm(n)%flagstruct%n_zs_filter,
' times' 949 else if( atm(n)%flagstruct%nord_zs_filter == 4 )
then 950 call del4_cubed_sphere(atm(n)%npx, atm(n)%npy, atm(n)%phis, atm(n)%gridstruct%area_64, &
951 atm(n)%gridstruct%dx, atm(n)%gridstruct%dy, &
952 atm(n)%gridstruct%dxc, atm(n)%gridstruct%dyc, atm(n)%gridstruct%sin_sg, &
953 atm(n)%flagstruct%n_zs_filter, .false., oro_g, atm(n)%neststruct%nested, &
954 atm(n)%domain, atm(n)%bd, atm(n)%flagstruct%regional)
955 if ( is_master() )
write(*,*)
'Warning !!! del-4 terrain filter has been applied ', &
956 atm(n)%flagstruct%n_zs_filter,
' times' 961 if ( atm(n)%neststruct%nested .and. ( atm(n)%flagstruct%n_zs_filter > 0 .or. atm(n)%flagstruct%full_zs_filter ) )
then 966 wt = max(0.,min(1.,
real(5 - min(i,j,npx-i,npy-j,5))/5. ))
967 atm(n)%phis(i,j) = (1.-wt)*atm(n)%phis(i,j) + wt*phis_coarse(i,j)
970 deallocate(phis_coarse)
973 call mpp_update_domains( atm(n)%phis, atm(n)%domain, complete=.true. )
974 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
975 ice_wat = get_tracer_index(model_atmos,
'ice_wat')
976 rainwat = get_tracer_index(model_atmos,
'rainwat')
977 snowwat = get_tracer_index(model_atmos,
'snowwat')
978 graupel = get_tracer_index(model_atmos,
'graupel')
979 ntclamt = get_tracer_index(model_atmos,
'cld_amt')
980 if (trim(
source) ==
'FV3GFS GAUSSIAN NEMSIO FILE')
then 984 wt = atm(n)%delp(i,j,k)
985 if ( atm(n)%flagstruct%nwat == 6 )
then 986 qt = wt*(1. + atm(n)%q(i,j,k,liq_wat) + &
987 atm(n)%q(i,j,k,ice_wat) + &
988 atm(n)%q(i,j,k,rainwat) + &
989 atm(n)%q(i,j,k,snowwat) + &
990 atm(n)%q(i,j,k,graupel))
992 qt = wt*(1. + sum(atm(n)%q(i,j,k,2:atm(n)%flagstruct%nwat)))
994 atm(n)%delp(i,j,k) = qt
995 if (ntclamt > 0) atm(n)%q(i,j,k,ntclamt) = 0.0
1005 wt = atm(n)%delp(i,j,k)
1006 if ( atm(n)%flagstruct%nwat == 6 )
then 1007 qt = wt*(1. + atm(n)%q(i,j,k,liq_wat) + &
1008 atm(n)%q(i,j,k,ice_wat) + &
1009 atm(n)%q(i,j,k,rainwat) + &
1010 atm(n)%q(i,j,k,snowwat) + &
1011 atm(n)%q(i,j,k,graupel))
1013 qt = wt*(1. + sum(atm(n)%q(i,j,k,2:atm(n)%flagstruct%nwat)))
1017 atm(n)%q(i,j,k,iq) = m_fac * atm(n)%q(i,j,k,iq)
1019 atm(n)%delp(i,j,k) = qt
1020 if (ntclamt > 0) atm(n)%q(i,j,k,ntclamt) = 0.0
1027 if (checker_tr)
then 1028 nts = ntracers - nt_checker+1
1030 npz, atm(n)%q(:,:,:,nts:ntracers), &
1031 atm(n)%gridstruct%agrid_64(is:ie,js:je,1), &
1032 atm(n)%gridstruct%agrid_64(is:ie,js:je,2), 9., 9.)
1036 atm(1)%flagstruct%make_nh = .false.
1050 type(fv_atmos_type),
intent(inout) :: Atm(:)
1051 type(domain2d),
intent(inout) :: fv_domain
1052 integer,
intent(in):: nq
1055 real :: ak_HIWPP(65), bk_HIWPP(65)
1057 0, 0.00064247, 0.0013779, 0.00221958, 0.00318266, 0.00428434, &
1058 0.00554424, 0.00698457, 0.00863058, 0.0105108, 0.01265752, 0.01510711, &
1059 0.01790051, 0.02108366, 0.02470788, 0.02883038, 0.0335146, 0.03883052, &
1060 0.04485493, 0.05167146, 0.0593705, 0.06804874, 0.0777715, 0.08832537, &
1061 0.09936614, 0.1105485, 0.1215294, 0.1319707, 0.1415432, 0.1499307, &
1062 0.1568349, 0.1619797, 0.1651174, 0.166116, 0.1650314, 0.1619731, &
1063 0.1570889, 0.1505634, 0.1426143, 0.1334867, 0.1234449, 0.1127635, &
1064 0.1017171, 0.09057051, 0.07956908, 0.06893117, 0.05884206, 0.04945029, &
1065 0.04086614, 0.03316217, 0.02637553, 0.0205115, 0.01554789, 0.01143988, &
1066 0.00812489, 0.0055272, 0.00356223, 0.00214015, 0.00116899, 0.00055712, &
1067 0.00021516, 5.741e-05, 5.75e-06, 0, 0 /
1070 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &
1071 3.697e-05, 0.00043106, 0.00163591, 0.00410671, 0.00829402, 0.01463712, &
1072 0.02355588, 0.03544162, 0.05064684, 0.06947458, 0.09216691, 0.1188122, &
1073 0.1492688, 0.1832962, 0.2205702, 0.2606854, 0.3031641, 0.3474685, &
1074 0.3930182, 0.4392108, 0.4854433, 0.5311348, 0.5757467, 0.6187996, &
1075 0.659887, 0.6986829, 0.7349452, 0.7685147, 0.7993097, 0.8273188, &
1076 0.8525907, 0.8752236, 0.895355, 0.913151, 0.9287973, 0.9424911, &
1077 0.9544341, 0.9648276, 0.9738676, 0.9817423, 0.9886266, 0.9946712, 1 /
1079 character(len=128) :: fname
1080 real(kind=4),
allocatable:: wk1(:), wk2(:,:), wk3(:,:,:)
1081 real,
allocatable:: tp(:,:,:), qp(:,:,:)
1082 real,
allocatable:: ua(:,:,:), va(:,:,:)
1083 real,
allocatable:: lat(:), lon(:), ak0(:), bk0(:)
1084 real:: s2c(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je,4)
1085 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je):: id1, id2, jdc
1086 real psc(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je)
1087 real gzc(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je)
1089 integer:: i, j, k, im, jm, km, npz, npt
1090 integer:: i1, i2, j1, ncid
1091 integer:: jbeg, jend
1093 logical:: read_ts = .true.
1094 logical:: land_ts = .false.
1096 integer :: is, ie, js, je
1097 integer :: isd, ied, jsd, jed
1116 fname = atm(1)%flagstruct%res_latlon_dynamics
1118 if( file_exist(fname) )
then 1124 im = tsize(1); jm = tsize(2); km = tsize(3)
1126 if(is_master())
write(*,*) fname
1127 if(is_master())
write(*,*)
' NCEP IC dimensions:', tsize
1129 allocate ( lon(im) )
1130 allocate ( lat(jm) )
1132 call _get_var1(ncid,
'lon', im, lon )
1133 call _get_var1(ncid,
'lat', jm, lat )
1143 allocate ( ak0(km+1) )
1144 allocate ( bk0(km+1) )
1149 ak0(k) = ak_hiwpp(k)
1150 bk0(k) = bk_hiwpp(k)
1153 call _get_var1(ncid,
'hyai', km+1, ak0, found )
1154 if ( .not. found ) ak0(:) = 0.
1156 call _get_var1(ncid,
'hybi', km+1, bk0 )
1158 if( is_master() )
then 1160 write(*,*) k, ak0(k), bk0(k)
1165 ak0(:) = ak0(:) * 1.e5
1168 if ( bk0(1) < 1.e-9 ) ak0(1) = max(1.e-9, ak0(1))
1171 call mpp_error(fatal,
'==> Error in get_external_ic: Expected file '//trim(fname)//
' for NCEP IC does not exist')
1175 call remap_coef( is, ie, js, je, isd, ied, jsd, jed, &
1176 im, jm, lon, lat, id1, id2, jdc, s2c , atm(1)%gridstruct%agrid)
1179 jbeg = jm-1; jend = 2
1183 jbeg = min(jbeg, j1)
1184 jend = max(jend, j1+1)
1190 allocate ( wk2(im,jbeg:jend) )
1191 call get_var3_r4( ncid,
'PS', 1,im, jbeg,jend, 1,1, wk2 )
1198 psc(i,j) = s2c(i,j,1)*wk2(i1,j1 ) + s2c(i,j,2)*wk2(i2,j1 ) + &
1199 s2c(i,j,3)*wk2(i2,j1+1) + s2c(i,j,4)*wk2(i1,j1+1)
1203 call get_var3_r4( ncid,
'PHIS', 1,im, jbeg,jend, 1,1, wk2 )
1209 gzc(i,j) = s2c(i,j,1)*wk2(i1,j1 ) + s2c(i,j,2)*wk2(i2,j1 ) + &
1210 s2c(i,j,3)*wk2(i2,j1+1) + s2c(i,j,4)*wk2(i1,j1+1)
1215 allocate ( wk2(im,jm) )
1221 if ( .not. land_ts )
then 1222 allocate ( wk1(im) )
1226 call get_var3_r4( ncid,
'ORO', 1,im, j,j, 1,1, wk1 )
1230 if( abs(wk1(i)-1.) > 0.99 )
then 1231 tmean = tmean + wk2(i,j)
1238 if ( npt /= 0 )
then 1239 tmean= tmean /
real(npt)
1241 if( abs(wk1(i)-1.) <= 0.99 )
then 1244 elseif ( i==im )
then 1249 if ( abs(wk1(i2)-1.)>0.99 )
then 1250 wk2(i,j) = wk2(i2,j)
1251 elseif ( abs(wk1(i1)-1.)>0.99 )
then 1252 wk2(i,j) = wk2(i1,j)
1268 atm(1)%ts(i,j) = s2c(i,j,1)*wk2(i1,j1 ) + s2c(i,j,2)*wk2(i2,j1 ) + &
1269 s2c(i,j,3)*wk2(i2,j1+1) + s2c(i,j,4)*wk2(i1,j1+1)
1272 call prt_maxmin(
'SST_model', atm(1)%ts, is, ie, js, je, 0, 1, 1.)
1276 call ncep2fms(im, jm, lon, lat, wk2)
1277 if( is_master() )
then 1278 write(*,*)
'External_ic_mod: i_sst=', i_sst,
' j_sst=', j_sst
1279 call pmaxmin(
'SST_ncep_fms', sst_ncep, i_sst, j_sst, 1.)
1287 allocate ( wk3(1:im,jbeg:jend, 1:km) )
1288 call get_var3_r4( ncid,
'T', 1,im, jbeg,jend, 1,km, wk3 )
1290 allocate ( tp(is:ie,js:je,km) )
1297 tp(i,j,k) = s2c(i,j,1)*wk3(i1,j1 ,k) + s2c(i,j,2)*wk3(i2,j1 ,k) + &
1298 s2c(i,j,3)*wk3(i2,j1+1,k) + s2c(i,j,4)*wk3(i1,j1+1,k)
1304 call get_var3_r4( ncid,
'Q', 1,im, jbeg,jend, 1,km, wk3 )
1306 allocate ( qp(is:ie,js:je,km) )
1313 qp(i,j,k) = s2c(i,j,1)*wk3(i1,j1 ,k) + s2c(i,j,2)*wk3(i2,j1 ,k) + &
1314 s2c(i,j,3)*wk3(i2,j1+1,k) + s2c(i,j,4)*wk3(i1,j1+1,k)
1319 call remap_scalar(im, jm, km, npz, nq, nq, ak0, bk0, psc, gzc, tp, qp, atm(1))
1324 call get_var3_r4( ncid,
'U', 1,im, jbeg,jend, 1,km, wk3 )
1326 allocate ( ua(is:ie,js:je,km) )
1333 ua(i,j,k) = s2c(i,j,1)*wk3(i1,j1 ,k) + s2c(i,j,2)*wk3(i2,j1 ,k) + &
1334 s2c(i,j,3)*wk3(i2,j1+1,k) + s2c(i,j,4)*wk3(i1,j1+1,k)
1339 call get_var3_r4( ncid,
'V', 1,im, jbeg,jend, 1,km, wk3 )
1342 allocate ( va(is:ie,js:je,km) )
1349 va(i,j,k) = s2c(i,j,1)*wk3(i1,j1 ,k) + s2c(i,j,2)*wk3(i2,j1 ,k) + &
1350 s2c(i,j,3)*wk3(i2,j1+1,k) + s2c(i,j,4)*wk3(i1,j1+1,k)
1355 call remap_winds(im, jm, km, npz, ak0, bk0, psc, ua, va, atm(1))
1373 use gfs_restart,
only : gfs_restart_type
1378 type(fv_atmos_type),
intent(inout) :: Atm(:)
1379 type(domain2d),
intent(inout) :: fv_domain
1381 real :: ak_ec(138), bk_ec(138)
1382 data ak_ec/ 0.000000, 2.000365, 3.102241, 4.666084, 6.827977, 9.746966, &
1383 13.605424, 18.608931, 24.985718, 32.985710, 42.879242, 54.955463, &
1384 69.520576, 86.895882, 107.415741, 131.425507, 159.279404, 191.338562, &
1385 227.968948, 269.539581, 316.420746, 368.982361, 427.592499, 492.616028, &
1386 564.413452, 643.339905, 729.744141, 823.967834, 926.344910, 1037.201172, &
1387 1156.853638, 1285.610352, 1423.770142, 1571.622925, 1729.448975, 1897.519287, &
1388 2076.095947, 2265.431641, 2465.770508, 2677.348145, 2900.391357, 3135.119385, &
1389 3381.743652, 3640.468262, 3911.490479, 4194.930664, 4490.817383, 4799.149414, &
1390 5119.895020, 5452.990723, 5798.344727, 6156.074219, 6526.946777, 6911.870605, &
1391 7311.869141, 7727.412109, 8159.354004, 8608.525391, 9076.400391, 9562.682617, &
1392 10065.978516, 10584.631836, 11116.662109, 11660.067383, 12211.547852, 12766.873047, &
1393 13324.668945, 13881.331055, 14432.139648, 14975.615234, 15508.256836, 16026.115234, &
1394 16527.322266, 17008.789063, 17467.613281, 17901.621094, 18308.433594, 18685.718750, &
1395 19031.289063, 19343.511719, 19620.042969, 19859.390625, 20059.931641, 20219.664063, &
1396 20337.863281, 20412.308594, 20442.078125, 20425.718750, 20361.816406, 20249.511719, &
1397 20087.085938, 19874.025391, 19608.572266, 19290.226563, 18917.460938, 18489.707031, &
1398 18006.925781, 17471.839844, 16888.687500, 16262.046875, 15596.695313, 14898.453125, &
1399 14173.324219, 13427.769531, 12668.257813, 11901.339844, 11133.304688, 10370.175781, &
1400 9617.515625, 8880.453125, 8163.375000, 7470.343750, 6804.421875, 6168.531250, &
1401 5564.382813, 4993.796875, 4457.375000, 3955.960938, 3489.234375, 3057.265625, &
1402 2659.140625, 2294.242188, 1961.500000, 1659.476563, 1387.546875, 1143.250000, &
1403 926.507813, 734.992188, 568.062500, 424.414063, 302.476563, 202.484375, &
1404 122.101563, 62.781250, 22.835938, 3.757813, 0.000000, 0.000000 /
1406 data bk_ec/ 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, &
1407 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, &
1408 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, &
1409 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, &
1410 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, &
1411 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, &
1412 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, &
1413 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, &
1414 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, &
1415 0.000000, 0.000007, 0.000024, 0.000059, 0.000112, 0.000199, &
1416 0.000340, 0.000562, 0.000890, 0.001353, 0.001992, 0.002857, &
1417 0.003971, 0.005378, 0.007133, 0.009261, 0.011806, 0.014816, &
1418 0.018318, 0.022355, 0.026964, 0.032176, 0.038026, 0.044548, &
1419 0.051773, 0.059728, 0.068448, 0.077958, 0.088286, 0.099462, &
1420 0.111505, 0.124448, 0.138313, 0.153125, 0.168910, 0.185689, &
1421 0.203491, 0.222333, 0.242244, 0.263242, 0.285354, 0.308598, &
1422 0.332939, 0.358254, 0.384363, 0.411125, 0.438391, 0.466003, &
1423 0.493800, 0.521619, 0.549301, 0.576692, 0.603648, 0.630036, &
1424 0.655736, 0.680643, 0.704669, 0.727739, 0.749797, 0.770798, &
1425 0.790717, 0.809536, 0.827256, 0.843881, 0.859432, 0.873929, &
1426 0.887408, 0.899900, 0.911448, 0.922096, 0.931881, 0.940860, &
1427 0.949064, 0.956550, 0.963352, 0.969513, 0.975078, 0.980072, &
1428 0.984542, 0.988500, 0.991984, 0.995003, 0.997630, 1.000000 /
1432 real,
dimension(64):: ak_sj, bk_sj
1433 data ak_sj/64.247, 137.790, 221.958, &
1434 318.266, 428.434, 554.424, &
1435 698.457, 863.05803, 1051.07995, &
1436 1265.75194, 1510.71101, 1790.05098, &
1437 2108.36604, 2470.78817, 2883.03811, &
1438 3351.46002, 3883.05187, 4485.49315, &
1439 5167.14603, 5937.04991, 6804.87379, &
1440 7780.84698, 8875.64338, 10100.20534, &
1441 11264.35673, 12190.64366, 12905.42546, &
1442 13430.87867, 13785.88765, 13986.77987, &
1443 14047.96335, 13982.46770, 13802.40331, &
1444 13519.33841, 13144.59486, 12689.45608, &
1445 12165.28766, 11583.57006, 10955.84778, &
1446 10293.60402, 9608.08306, 8910.07678, &
1447 8209.70131, 7516.18560, 6837.69250, &
1448 6181.19473, 5552.39653, 4955.72632, &
1449 4394.37629, 3870.38682, 3384.76586, &
1450 2937.63489, 2528.37666, 2155.78385, &
1451 1818.20722, 1513.68173, 1240.03585, &
1452 994.99144, 776.23591, 581.48797, &
1453 408.53400, 255.26520, 119.70243, 0. /
1455 data bk_sj/0.00000, 0.00000, 0.00000, &
1456 0.00000, 0.00000, 0.00000, &
1457 0.00000, 0.00000, 0.00000, &
1458 0.00000, 0.00000, 0.00000, &
1459 0.00000, 0.00000, 0.00000, &
1460 0.00000, 0.00000, 0.00000, &
1461 0.00000, 0.00000, 0.00000, &
1462 0.00000, 0.00000, 0.00000, &
1463 0.00201, 0.00792, 0.01755, &
1464 0.03079, 0.04751, 0.06761, &
1465 0.09097, 0.11746, 0.14690, &
1466 0.17911, 0.21382, 0.25076, &
1467 0.28960, 0.32994, 0.37140, &
1468 0.41353, 0.45589, 0.49806, &
1469 0.53961, 0.58015, 0.61935, &
1470 0.65692, 0.69261, 0.72625, &
1471 0.75773, 0.78698, 0.81398, &
1472 0.83876, 0.86138, 0.88192, &
1473 0.90050, 0.91722, 0.93223, &
1474 0.94565, 0.95762, 0.96827, &
1475 0.97771, 0.98608, 0.99347, 1./
1477 character(len=128) :: fname
1478 real,
allocatable:: wk2(:,:)
1479 real(kind=4),
allocatable:: wk2_r4(:,:)
1480 real,
dimension(:,:,:),
allocatable:: ud, vd
1481 real,
allocatable:: wc(:,:,:)
1482 real(kind=4),
allocatable:: uec(:,:,:), vec(:,:,:), tec(:,:,:), wec(:,:,:)
1483 real(kind=4),
allocatable:: psec(:,:), zsec(:,:), zhec(:,:,:), qec(:,:,:,:)
1484 real(kind=4),
allocatable:: psc(:,:)
1485 real(kind=4),
allocatable:: sphumec(:,:,:)
1486 real,
allocatable:: psc_r8(:,:), zhc(:,:,:), qc(:,:,:,:)
1487 real,
allocatable:: lat(:), lon(:), ak0(:), bk0(:)
1488 real,
allocatable:: pt_c(:,:,:), pt_d(:,:,:)
1489 real:: s2c(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je,4)
1490 real:: s2c_c(Atm(1)%bd%is:Atm(1)%bd%ie+1,Atm(1)%bd%js:Atm(1)%bd%je,4)
1491 real:: s2c_d(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je+1,4)
1492 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je):: &
1494 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie+1,Atm(1)%bd%js:Atm(1)%bd%je):: &
1496 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je+1):: &
1499 integer:: i, j, k, n, im, jm, km, npz, npt
1500 integer:: i1, i2, j1, ncid
1501 integer:: jbeg, jend, jn
1503 logical:: read_ts = .true.
1504 logical:: land_ts = .false.
1506 integer :: is, ie, js, je
1507 integer :: isd, ied, jsd, jed
1508 integer :: sphum, liq_wat, ice_wat, rainwat, snowwat, graupel
1510 integer :: spfo, spfo2, spfo3
1514 real:: wt, qt, m_fac
1515 real(kind=8) :: scale_value, offset, ptmp
1516 real(kind=R_GRID),
dimension(2):: p1, p2, p3
1517 real(kind=R_GRID),
dimension(3):: e1, e2, ex, ey
1518 real,
allocatable:: ps_gfs(:,:), zh_gfs(:,:,:)
1520 real,
allocatable:: spfo_gfs(:,:,:), spfo2_gfs(:,:,:), spfo3_gfs(:,:,:)
1522 real,
allocatable:: o3mr_gfs(:,:,:)
1524 real,
allocatable:: ak_gfs(:), bk_gfs(:)
1525 integer :: id_res, ntprog, ntracers, ks, iq, nt
1526 character(len=64) :: tracer_name
1527 integer :: levp_gfs = 64
1528 type(restart_file_type) :: oro_restart, gfs_restart
1529 character(len=64) :: fn_oro_ics =
'oro_data.nc' 1530 character(len=64) :: fn_gfs_ics =
'gfs_data.nc' 1531 character(len=64) :: fn_gfs_ctl =
'gfs_ctrl.nc' 1532 logical :: filtered_terrain = .true.
1533 namelist /external_ic_nml/ filtered_terrain
1547 call get_number_tracers(model_atmos, num_tracers=ntracers, num_prog=ntprog)
1548 if(is_master())
write(*,*)
'ntracers = ', ntracers,
'ntprog = ',ntprog
1550 sphum = get_tracer_index(model_atmos,
'sphum')
1551 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
1552 ice_wat = get_tracer_index(model_atmos,
'ice_wat')
1553 rainwat = get_tracer_index(model_atmos,
'rainwat')
1554 snowwat = get_tracer_index(model_atmos,
'snowwat')
1555 graupel = get_tracer_index(model_atmos,
'graupel')
1557 spfo = get_tracer_index(model_atmos,
'spfo')
1558 spfo2 = get_tracer_index(model_atmos,
'spfo2')
1559 spfo3 = get_tracer_index(model_atmos,
'spfo3')
1561 o3mr = get_tracer_index(model_atmos,
'o3mr')
1564 if (is_master())
then 1565 print *,
'sphum = ', sphum
1566 print *,
'liq_wat = ', liq_wat
1567 if ( atm(1)%flagstruct%nwat .eq. 6 )
then 1568 print *,
'rainwat = ', rainwat
1569 print *,
'iec_wat = ', ice_wat
1570 print *,
'snowwat = ', snowwat
1571 print *,
'graupel = ', graupel
1574 print *,
' spfo3 = ', spfo3
1575 print *,
' spfo = ', spfo
1576 print *,
' spfo2 = ', spfo2
1578 print *,
' o3mr = ', o3mr
1584 if ( npz <= 64 )
then 1585 atm(1)%ak(:) = ak_sj(:)
1586 atm(1)%bk(:) = bk_sj(:)
1587 atm(1)%ptop = atm(1)%ak(1)
1589 call set_eta(npz, ks, atm(1)%ptop, atm(1)%ak, atm(1)%bk)
1593 if (filtered_terrain)
then 1594 id_res = register_restart_field(oro_restart, fn_oro_ics,
'orog_filt', atm(1)%phis, domain=atm(1)%domain)
1595 elseif (.not. filtered_terrain)
then 1596 id_res = register_restart_field(oro_restart, fn_oro_ics,
'orog_raw', atm(1)%phis, domain=atm(1)%domain)
1598 call restore_state (oro_restart)
1599 call free_restart_type(oro_restart)
1600 atm(1)%phis = atm(1)%phis*grav
1601 if(is_master())
write(*,*)
'done reading model terrain from oro_data.nc' 1602 call mpp_update_domains( atm(1)%phis, atm(1)%domain )
1606 allocate (spfo3_gfs(is:ie,js:je,levp_gfs))
1607 allocate ( spfo_gfs(is:ie,js:je,levp_gfs))
1608 allocate (spfo2_gfs(is:ie,js:je,levp_gfs))
1610 allocate (o3mr_gfs(is:ie,js:je,levp_gfs))
1612 allocate (ps_gfs(is:ie,js:je))
1613 allocate (zh_gfs(is:ie,js:je,levp_gfs+1))
1616 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'spfo3', spfo3_gfs, &
1617 mandatory=.false.,domain=atm(1)%domain)
1618 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'spfo', spfo_gfs, &
1619 mandatory=.false.,domain=atm(1)%domain)
1620 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'spfo2', spfo2_gfs, &
1621 mandatory=.false.,domain=atm(1)%domain)
1623 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'o3mr', o3mr_gfs, &
1624 mandatory=.false.,domain=atm(1)%domain)
1626 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'ps', ps_gfs, domain=atm(1)%domain)
1627 id_res = register_restart_field(gfs_restart, fn_gfs_ics,
'ZH', zh_gfs, domain=atm(1)%domain)
1628 call restore_state (gfs_restart)
1629 call free_restart_type(gfs_restart)
1633 allocate (wk2(levp_gfs+1,2))
1634 allocate (ak_gfs(levp_gfs+1))
1635 allocate (bk_gfs(levp_gfs+1))
1636 call read_data(
'INPUT/'//trim(fn_gfs_ctl),
'vcoord',wk2, no_domain=.true.)
1637 ak_gfs(1:levp_gfs+1) = wk2(1:levp_gfs+1,1)
1638 bk_gfs(1:levp_gfs+1) = wk2(1:levp_gfs+1,2)
1641 if ( bk_gfs(1) < 1.e-9 ) ak_gfs(1) = max(1.e-9, ak_gfs(1))
1645 if(is_master())
write(*,*)
'Reading spfo3 from GFS_data.nc:' 1646 if(is_master())
write(*,*)
'spfo3 =', iq
1647 call remap_scalar_single(atm(1), levp_gfs, npz, ak_gfs, bk_gfs, ps_gfs, spfo3_gfs, zh_gfs, iq)
1649 if(is_master())
write(*,*)
'Reading spfo from GFS_data.nc:' 1650 if(is_master())
write(*,*)
'spfo =', iq
1651 call remap_scalar_single(atm(1), levp_gfs, npz, ak_gfs, bk_gfs, ps_gfs, spfo_gfs, zh_gfs, iq)
1653 if(is_master())
write(*,*)
'Reading spfo2 from GFS_data.nc:' 1654 if(is_master())
write(*,*)
'spfo2 =', iq
1655 call remap_scalar_single(atm(1), levp_gfs, npz, ak_gfs, bk_gfs, ps_gfs, spfo2_gfs, zh_gfs, iq)
1658 if(is_master())
write(*,*)
'Reading o3mr from GFS_data.nc:' 1659 if(is_master())
write(*,*)
'o3mr =', iq
1660 call remap_scalar_single(atm(1), levp_gfs, npz, ak_gfs, bk_gfs, ps_gfs, o3mr_gfs, zh_gfs, iq)
1663 deallocate (ak_gfs, bk_gfs)
1664 deallocate (ps_gfs, zh_gfs)
1666 deallocate (spfo3_gfs)
1667 deallocate ( spfo_gfs)
1668 deallocate (spfo2_gfs)
1670 deallocate (o3mr_gfs)
1674 fname = atm(1)%flagstruct%res_latlon_dynamics
1676 if( file_exist(fname) )
then 1679 call get_ncdim1( ncid,
'longitude', tsize(1) )
1680 call get_ncdim1( ncid,
'latitude', tsize(2) )
1683 im = tsize(1); jm = tsize(2); km = tsize(3)
1685 if(is_master())
write(*,*) fname
1686 if(is_master())
write(*,*)
' ECMWF IC dimensions:', tsize
1688 allocate ( lon(im) )
1689 allocate ( lat(jm) )
1691 call _get_var1(ncid,
'longitude', im, lon )
1692 call _get_var1(ncid,
'latitude', jm, lat )
1702 allocate ( ak0(km+1) )
1703 allocate ( bk0(km+1) )
1711 if( is_master() )
then 1713 write(*,*) k, ak0(k), bk0(k)
1718 if ( bk0(1) < 1.e-9 ) ak0(1) = max(1.e-9, ak0(1))
1721 call mpp_error(fatal,
'==> Error in get_external_ic: Expected file '//trim(fname)//
' for NCEP IC does not exist')
1725 call remap_coef( is, ie, js, je, isd, ied, jsd, jed, &
1726 im, jm, lon, lat, id1, id2, jdc, s2c , atm(1)%gridstruct%agrid )
1729 jbeg = jm-1; jend = 2
1733 jbeg = min(jbeg, j1)
1734 jend = max(jend, j1+1)
1738 if(is_master())
write(*,*)
'jbeg, jend = ', jbeg, jend
1740 allocate ( psec(im,jbeg:jend) )
1741 allocate ( zsec(im,jbeg:jend) )
1742 allocate ( wk2_r4(im,jbeg:jend) )
1744 call get_var2_r4( ncid,
'lnsp', 1,im, jbeg,jend, wk2_r4 )
1747 psec(:,:) = exp(wk2_r4(:,:)*scale_value + offset)
1748 if(is_master())
write(*,*)
'done reading psec' 1750 call get_var2_r4( ncid,
'z', 1,im, jbeg,jend, wk2_r4 )
1753 zsec(:,:) = (wk2_r4(:,:)*scale_value + offset)/grav
1754 if(is_master())
write(*,*)
'done reading zsec' 1756 deallocate ( wk2_r4 )
1759 allocate ( tec(1:im,jbeg:jend, 1:km) )
1761 call get_var3_r4( ncid,
't', 1,im, jbeg,jend, 1,km, tec )
1764 tec(:,:,:) = tec(:,:,:)*scale_value + offset
1765 if(is_master())
write(*,*)
'done reading tec' 1768 allocate ( sphumec(1:im,jbeg:jend, 1:km) )
1770 call get_var3_r4( ncid,
'q', 1,im, jbeg,jend, 1,km, sphumec(:,:,:) )
1773 sphumec(:,:,:) = sphumec(:,:,:)*scale_value + offset
1774 if(is_master())
write(*,*)
'done reading sphum ec' 1777 allocate ( qec(1:im,jbeg:jend,1:km,5) )
1780 if (n == sphum)
then 1781 qec(:,:,:,sphum) = sphumec(:,:,:)
1782 deallocate ( sphumec )
1783 else if (n == liq_wat)
then 1784 call get_var3_r4( ncid,
'clwc', 1,im, jbeg,jend, 1,km, qec(:,:,:,liq_wat) )
1787 qec(:,:,:,liq_wat) = qec(:,:,:,liq_wat)*scale_value + offset
1788 if(is_master())
write(*,*)
'done reading clwc ec' 1789 else if (n == rainwat)
then 1790 call get_var3_r4( ncid,
'crwc', 1,im, jbeg,jend, 1,km, qec(:,:,:,rainwat) )
1793 qec(:,:,:,rainwat) = qec(:,:,:,rainwat)*scale_value + offset
1794 if(is_master())
write(*,*)
'done reading crwc ec' 1795 else if (n == ice_wat)
then 1796 call get_var3_r4( ncid,
'ciwc', 1,im, jbeg,jend, 1,km, qec(:,:,:,ice_wat) )
1799 qec(:,:,:,ice_wat) = qec(:,:,:,ice_wat)*scale_value + offset
1800 if(is_master())
write(*,*)
'done reading ciwc ec' 1801 else if (n == snowwat)
then 1802 call get_var3_r4( ncid,
'cswc', 1,im, jbeg,jend, 1,km, qec(:,:,:,snowwat) )
1805 qec(:,:,:,snowwat) = qec(:,:,:,snowwat)*scale_value + offset
1806 if(is_master())
write(*,*)
'done reading cswc ec' 1808 if(is_master())
write(*,*)
'nq is more then 5!' 1815 allocate ( zhec(1:im,jbeg:jend, km+1) )
1816 jn = jend - jbeg + 1
1818 call compute_zh(im, jn, km, ak0, bk0, psec, zsec, tec, qec, 5, zhec )
1819 if(is_master())
write(*,*)
'done compute zhec' 1822 allocate (psc(is:ie,js:je))
1823 allocate (psc_r8(is:ie,js:je))
1828 psec(i,j) = log(psec(i,j))
1838 ptmp = s2c(i,j,1)*psec(i1,j1 ) + s2c(i,j,2)*psec(i2,j1 ) + &
1839 s2c(i,j,3)*psec(i2,j1+1) + s2c(i,j,4)*psec(i1,j1+1)
1840 psc(i,j) = exp(ptmp)
1842 psc(i,j) = s2c(i,j,1)*psec(i1,j1 ) + s2c(i,j,2)*psec(i2,j1 ) + &
1843 s2c(i,j,3)*psec(i2,j1+1) + s2c(i,j,4)*psec(i1,j1+1)
1850 allocate (zhc(is:ie,js:je,km+1))
1859 zhc(i,j,k) = s2c(i,j,1)*zhec(i1,j1 ,k) + s2c(i,j,2)*zhec(i2,j1 ,k) + &
1860 s2c(i,j,3)*zhec(i2,j1+1,k) + s2c(i,j,4)*zhec(i1,j1+1,k)
1866 if(is_master())
write(*,*)
'done interpolate psec/zsec/zhec into cubic grid psc/zhc!' 1869 allocate ( qc(is:ie,js:je,km,6) )
1880 qc(i,j,k,n) = s2c(i,j,1)*qec(i1,j1 ,k,n) + s2c(i,j,2)*qec(i2,j1 ,k,n) + &
1881 s2c(i,j,3)*qec(i2,j1+1,k,n) + s2c(i,j,4)*qec(i1,j1+1,k,n)
1887 qc(:,:,:,graupel) = 0.
1890 if(is_master())
write(*,*)
'done interpolate tracers (qec) into cubic (qc)' 1893 allocate ( wec(1:im,jbeg:jend, 1:km) )
1894 allocate ( wc(is:ie,js:je,km))
1896 call get_var3_r4( ncid,
'w', 1,im, jbeg,jend, 1,km, wec )
1899 wec(:,:,:) = wec(:,:,:)*scale_value + offset
1910 wc(i,j,k) = s2c(i,j,1)*wec(i1,j1 ,k) + s2c(i,j,2)*wec(i2,j1 ,k) + &
1911 s2c(i,j,3)*wec(i2,j1+1,k) + s2c(i,j,4)*wec(i1,j1+1,k)
1918 if(is_master())
write(*,*)
'done reading and interpolate vertical wind (w) into cubic' 1921 psc_r8(:,:) = psc(:,:)
1924 call remap_scalar_ec(atm(1), km, npz, 6, ak0, bk0, psc_r8, qc, wc, zhc )
1925 call mpp_update_domains(atm(1)%phis, atm(1)%domain)
1926 if(is_master())
write(*,*)
'done remap_scalar_ec' 1934 allocate (pt_c(isd:ied+1,jsd:jed ,2))
1935 allocate (pt_d(isd:ied ,jsd:jed+1,2))
1936 allocate (ud(is:ie , js:je+1, km))
1937 allocate (vd(is:ie+1, js:je , km))
1940 isd, ied, jsd, jed, &
1941 atm(1)%gridstruct%grid, pt_c, pt_d)
1945 call remap_coef( is, ie+1, js, je, isd, ied+1, jsd, jed, &
1946 im, jm, lon, lat, id1_c, id2_c, jdc_c, s2c_c, pt_c)
1949 jbeg = jm-1; jend = 2
1953 jbeg = min(jbeg, j1)
1954 jend = max(jend, j1+1)
1959 allocate ( uec(1:im,jbeg:jend, 1:km) )
1960 allocate ( vec(1:im,jbeg:jend, 1:km) )
1962 call get_var3_r4( ncid,
'u', 1,im, jbeg,jend, 1,km, uec )
1968 uec(i,j,k) = uec(i,j,k)*scale_value + offset
1972 if(is_master())
write(*,*)
'first time done reading uec' 1974 call get_var3_r4( ncid,
'v', 1,im, jbeg,jend, 1,km, vec )
1980 vec(i,j,k) = vec(i,j,k)*scale_value + offset
1985 if(is_master())
write(*,*)
'first time done reading vec' 1995 p1(:) = atm(1)%gridstruct%grid(i,j ,1:2)
1996 p2(:) = atm(1)%gridstruct%grid(i,j+1,1:2)
2000 utmp = s2c_c(i,j,1)*uec(i1,j1 ,k) + &
2001 s2c_c(i,j,2)*uec(i2,j1 ,k) + &
2002 s2c_c(i,j,3)*uec(i2,j1+1,k) + &
2003 s2c_c(i,j,4)*uec(i1,j1+1,k)
2004 vtmp = s2c_c(i,j,1)*vec(i1,j1 ,k) + &
2005 s2c_c(i,j,2)*vec(i2,j1 ,k) + &
2006 s2c_c(i,j,3)*vec(i2,j1+1,k) + &
2007 s2c_c(i,j,4)*vec(i1,j1+1,k)
2013 deallocate ( uec, vec )
2017 call remap_coef( is, ie, js, je+1, isd, ied, jsd, jed+1, &
2018 im, jm, lon, lat, id1_d, id2_d, jdc_d, s2c_d, pt_d)
2019 deallocate ( pt_c, pt_d )
2022 jbeg = jm-1; jend = 2
2026 jbeg = min(jbeg, j1)
2027 jend = max(jend, j1+1)
2032 allocate ( uec(1:im,jbeg:jend, 1:km) )
2033 allocate ( vec(1:im,jbeg:jend, 1:km) )
2035 call get_var3_r4( ncid,
'u', 1,im, jbeg,jend, 1,km, uec )
2038 uec(:,:,:) = uec(:,:,:)*scale_value + offset
2039 if(is_master())
write(*,*)
'second time done reading uec' 2041 call get_var3_r4( ncid,
'v', 1,im, jbeg,jend, 1,km, vec )
2044 vec(:,:,:) = vec(:,:,:)*scale_value + offset
2045 if(is_master())
write(*,*)
'second time done reading vec' 2055 p1(:) = atm(1)%gridstruct%grid(i, j,1:2)
2056 p2(:) = atm(1)%gridstruct%grid(i+1,j,1:2)
2060 utmp = s2c_d(i,j,1)*uec(i1,j1 ,k) + &
2061 s2c_d(i,j,2)*uec(i2,j1 ,k) + &
2062 s2c_d(i,j,3)*uec(i2,j1+1,k) + &
2063 s2c_d(i,j,4)*uec(i1,j1+1,k)
2064 vtmp = s2c_d(i,j,1)*vec(i1,j1 ,k) + &
2065 s2c_d(i,j,2)*vec(i2,j1 ,k) + &
2066 s2c_d(i,j,3)*vec(i2,j1+1,k) + &
2067 s2c_d(i,j,4)*vec(i1,j1+1,k)
2072 deallocate ( uec, vec )
2074 call remap_dwinds(km, npz, ak0, bk0, psc_r8, ud, vd, atm(1))
2075 deallocate ( ud, vd )
2083 wt = atm(1)%delp(i,j,k)
2084 if ( atm(1)%flagstruct%nwat .eq. 2 )
then 2085 qt = wt*(1.+atm(1)%q(i,j,k,liq_wat))
2086 elseif ( atm(1)%flagstruct%nwat .eq. 6 )
then 2087 qt = wt*(1. + atm(1)%q(i,j,k,liq_wat) + &
2088 atm(1)%q(i,j,k,ice_wat) + &
2089 atm(1)%q(i,j,k,rainwat) + &
2090 atm(1)%q(i,j,k,snowwat) + &
2091 atm(1)%q(i,j,k,graupel))
2095 atm(1)%q(i,j,k,iq) = m_fac * atm(1)%q(i,j,k,iq)
2097 atm(1)%delp(i,j,k) = qt
2103 deallocate ( ak0, bk0 )
2105 deallocate ( psc_r8 )
2106 deallocate ( lat, lon )
2108 atm(1)%flagstruct%make_nh = .false.
2113 subroutine get_fv_ic( Atm, fv_domain, nq )
2114 type(fv_atmos_type),
intent(inout) :: Atm(:)
2115 type(domain2d),
intent(inout) :: fv_domain
2116 integer,
intent(in):: nq
2118 character(len=128) :: fname, tracer_name
2119 real,
allocatable:: ps0(:,:), gz0(:,:), u0(:,:,:), v0(:,:,:), t0(:,:,:), dp0(:,:,:), q0(:,:,:,:)
2120 real,
allocatable:: ua(:,:,:), va(:,:,:)
2121 real,
allocatable:: lat(:), lon(:), ak0(:), bk0(:)
2122 integer :: i, j, k, im, jm, km, npz, tr_ind
2133 fname = atm(1)%flagstruct%res_latlon_dynamics
2135 if( file_exist(fname) )
then 2136 call field_size(fname,
'T', tsize, field_found=found)
2137 if(is_master())
write(*,*)
'Using lat-lon FV restart:', fname
2140 im = tsize(1); jm = tsize(2); km = tsize(3)
2141 if(is_master())
write(*,*)
'External IC dimensions:', tsize
2143 call mpp_error(fatal,
'==> Error in get_external_ic: field not found')
2147 allocate ( lon(im) )
2148 allocate ( lat(jm) )
2151 lon(i) = (0.5 +
real(i-1)) * 2.*pi/
real(im)
2155 lat(j) = -0.5*pi +
real(j-1)*pi/
real(jm-1) 2158 allocate ( ak0(1:km+1) )
2159 allocate ( bk0(1:km+1) )
2160 allocate ( ps0(1:im,1:jm) )
2161 allocate ( gz0(1:im,1:jm) )
2162 allocate ( u0(1:im,1:jm,1:km) )
2163 allocate ( v0(1:im,1:jm,1:km) )
2164 allocate ( t0(1:im,1:jm,1:km) )
2165 allocate ( dp0(1:im,1:jm,1:km) )
2167 call read_data (fname,
'ak', ak0)
2168 call read_data (fname,
'bk', bk0)
2169 call read_data (fname,
'Surface_geopotential', gz0)
2170 call read_data (fname,
'U', u0)
2171 call read_data (fname,
'V', v0)
2172 call read_data (fname,
'T', t0)
2173 call read_data (fname,
'DELP', dp0)
2176 if(is_master())
call pmaxmin(
'ZS_data', gz0, im, jm, 1./grav)
2177 if(mpp_pe()==1)
call pmaxmin(
'U_data', u0, im*jm, km, 1.)
2178 if(mpp_pe()==1)
call pmaxmin(
'V_data', v0, im*jm, km, 1.)
2179 if(mpp_pe()==2)
call pmaxmin(
'T_data', t0, im*jm, km, 1.)
2180 if(mpp_pe()==3)
call pmaxmin(
'DEL-P', dp0, im*jm, km, 0.01)
2184 call mpp_error(fatal,
'==> Error in get_external_ic: Expected file '//trim(fname)//
' for dynamics does not exist')
2188 fname = atm(1)%flagstruct%res_latlon_tracers
2190 if( file_exist(fname) )
then 2191 if(is_master())
write(*,*)
'Using lat-lon tracer restart:', fname
2193 allocate ( q0(im,jm,km,atm(1)%ncnst) )
2197 call get_tracer_names(model_atmos, tr_ind, tracer_name)
2198 if (field_exist(fname,tracer_name))
then 2199 call read_data(fname, tracer_name, q0(1:im,1:jm,1:km,tr_ind))
2200 call mpp_error(note,
'==> Have read tracer '//trim(tracer_name)//
' from '//trim(fname))
2205 call mpp_error(fatal,
'==> Error in get_external_ic: Expected file '//trim(fname)//
' for tracers does not exist')
2209 allocate ( ua(im,jm,km) )
2210 allocate ( va(im,jm,km) )
2212 call d2a3d(u0, v0, ua, va, im, jm, km, lon)
2217 if(mpp_pe()==4)
call pmaxmin(
'UA', ua, im*jm, km, 1.)
2218 if(mpp_pe()==4)
call pmaxmin(
'VA', va, im*jm, km, 1.)
2229 ps0(i,j) = ps0(i,j) + dp0(i,j,k)
2234 if (is_master())
call pmaxmin(
'PS_data (mb)', ps0, im, jm, 0.01)
2239 call remap_xyz( im, 1, jm, jm, km, npz, nq, atm(1)%ncnst, lon, lat, ak0, bk0, &
2240 ps0, gz0, ua, va, t0, q0, atm(1) )
2258 subroutine ncep2fms(im, jm, lon, lat, wk)
2260 integer,
intent(in):: im, jm
2261 real,
intent(in):: lon(im), lat(jm)
2262 real(kind=4),
intent(in):: wk(im,jm)
2269 real:: c1, c2, c3, c4
2270 integer i,j, i1, i2, jc, i0, j0, it, jt
2273 rdlon(i) = 1. / (lon(i+1) - lon(i))
2275 rdlon(im) = 1. / (lon(1) + 2.*pi - lon(im))
2278 rdlat(j) = 1. / (lat(j+1) - lat(j))
2285 delx = 360./
real(i_sst)
2286 dely = 180./
real(j_sst)
2291 yc = (-90. + dely * (0.5+
real(j-1))) * deg2rad
2292 if ( yc<lat(1) )
then 2295 elseif ( yc>lat(jm) )
then 2300 if ( yc>=lat(j0) .and. yc<=lat(j0+1) )
then 2303 b1 = (yc-lat(jc)) * rdlat(jc)
2312 xc = delx * (0.5+
real(i-1)) * deg2rad
2313 if ( xc>lon(im) )
then 2315 a1 = (xc-lon(im)) * rdlon(im)
2316 elseif ( xc<lon(1) )
then 2318 a1 = (xc+2.*pi-lon(im)) * rdlon(im)
2321 if ( xc>=lon(i0) .and. xc<=lon(i0+1) )
then 2324 a1 = (xc-lon(i1)) * rdlon(i0)
2331 if ( a1<0.0 .or. a1>1.0 .or. b1<0.0 .or. b1>1.0 )
then 2332 write(*,*)
'gid=', mpp_pe(), i,j,a1, b1
2335 c1 = (1.-a1) * (1.-b1)
2340 sst_ncep(i,j) = c1*wk(i1,jc ) + c2*wk(i2,jc ) + &
2341 c3*wk(i2,jc+1) + c4*wk(i1,jc+1)
2349 subroutine remap_coef( is, ie, js, je, isd, ied, jsd, jed, &
2350 im, jm, lon, lat, id1, id2, jdc, s2c, agrid )
2352 integer,
intent(in):: is, ie, js, je, isd, ied, jsd, jed
2353 integer,
intent(in):: im, jm
2354 real,
intent(in):: lon(im), lat(jm)
2355 real,
intent(out):: s2c(is:ie,js:je,4)
2356 integer,
intent(out),
dimension(is:ie,js:je):: id1, id2, jdc
2357 real,
intent(in):: agrid(isd:ied,jsd:jed,2)
2362 integer i,j, i1, i2, jc, i0, j0
2365 rdlon(i) = 1. / (lon(i+1) - lon(i))
2367 rdlon(im) = 1. / (lon(1) + 2.*pi - lon(im))
2370 rdlat(j) = 1. / (lat(j+1) - lat(j))
2378 if ( agrid(i,j,1)>lon(im) )
then 2380 a1 = (agrid(i,j,1)-lon(im)) * rdlon(im)
2381 elseif ( agrid(i,j,1)<lon(1) )
then 2383 a1 = (agrid(i,j,1)+2.*pi-lon(im)) * rdlon(im)
2386 if ( agrid(i,j,1)>=lon(i0) .and. agrid(i,j,1)<=lon(i0+1) )
then 2388 a1 = (agrid(i,j,1)-lon(i1)) * rdlon(i0)
2395 if ( agrid(i,j,2)<lat(1) )
then 2398 elseif ( agrid(i,j,2)>lat(jm) )
then 2403 if ( agrid(i,j,2)>=lat(j0) .and. agrid(i,j,2)<=lat(j0+1) )
then 2405 b1 = (agrid(i,j,2)-lat(jc)) * rdlat(jc)
2412 if ( a1<0.0 .or. a1>1.0 .or. b1<0.0 .or. b1>1.0 )
then 2413 write(*,*)
'gid=', mpp_pe(), i,j,a1, b1
2416 s2c(i,j,1) = (1.-a1) * (1.-b1)
2417 s2c(i,j,2) = a1 * (1.-b1)
2418 s2c(i,j,3) = a1 * b1
2419 s2c(i,j,4) = (1.-a1) * b1
2429 subroutine remap_scalar(im, jm, km, npz, nq, ncnst, ak0, bk0, psc, gzc, ta, qa, Atm)
2430 type(fv_atmos_type),
intent(inout) :: Atm
2431 integer,
intent(in):: im, jm, km, npz, nq, ncnst
2432 real,
intent(in):: ak0(km+1), bk0(km+1)
2433 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je):: psc, gzc
2434 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km):: ta
2435 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km,ncnst):: qa
2437 real,
dimension(Atm%bd%is:Atm%bd%ie,km):: tp
2438 real,
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pe0, pn0
2439 real,
dimension(Atm%bd%is:Atm%bd%ie,npz):: qn1
2440 real,
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pe1, pn1
2441 real(kind=R_GRID),
dimension(2*km+1):: gz, pn
2443 real qp(Atm%bd%is:Atm%bd%ie,km,ncnst)
2444 real p1, p2, alpha, rdg
2445 real(kind=R_GRID):: pst, pt0
2447 integer spfo, spfo2, spfo3
2451 integer i,j,k, k2,l, iq
2452 integer sphum, clwmr
2453 integer :: is, ie, js, je
2454 integer :: isd, ied, jsd, jed
2468 sphum = get_tracer_index(model_atmos,
'sphum')
2470 if (mpp_pe()==1)
then 2471 print *,
'sphum = ', sphum,
' ncnst=', ncnst
2472 print *,
'T_is_Tv = ',
t_is_tv,
' zvir=',
zvir,
' kappa=', kappa
2475 if ( sphum/=1 )
then 2476 call mpp_error(fatal,
'SPHUM must be 1st tracer')
2479 call prt_maxmin(
'ZS_FV3', atm%phis, is, ie, js, je, 3, 1, 1./grav)
2480 call prt_maxmin(
'ZS_GFS', gzc, is, ie, js, je, 0, 1, 1./grav)
2481 call prt_maxmin(
'PS_Data', psc, is, ie, js, je, 0, 1, 0.01)
2482 call prt_maxmin(
'T_Data', ta, is, ie, js, je, 0, km, 1.)
2483 call prt_maxmin(
'q_Data', qa(is:ie,js:je,1:km,1), is, ie, js, je, 0, km, 1.)
2491 qp(i,k,iq) = qa(i,j,k,iq)
2504 tp(i,k) = ta(i,j,k)*
virq(qp(i,k,:))
2506 tp(i,k) = ta(i,j,k)*(1.+
zvir*qp(i,k,sphum))
2513 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
2514 pn0(i,k) = log(pe0(i,k))
2515 pk0(k) = pe0(i,k)**kappa
2522 gz(k) = gz(k+1) + rdgas*tp(i,k)*(pn0(i,k+1)-pn0(i,k))
2532 gz(k) = 2.*gz(km+1) - gz(l)
2533 pn(k) = 2.*pn(km+1) - pn(l)
2536 if( atm%phis(i,j).le.gz(k) .and. atm%phis(i,j).ge.gz(k+1) )
then 2537 pst = pn(k) + (pn(k+1)-pn(k))*(gz(k)-atm%phis(i,j))/(gz(k)-gz(k+1))
2541 123 atm%ps(i,j) = exp(pst)
2545 pe1(i,1) = atm%ak(1)
2546 pn1(i,1) = log(pe1(i,1))
2550 pe1(i,k) = atm%ak(k) + atm%bk(k)*atm%ps(i,j)
2551 pn1(i,k) = log(pe1(i,k))
2558 atm%delp(i,j,k) = pe1(i,k+1) - pe1(i,k)
2566 call mappm(km, pe0, qp(is,1,iq), npz, pe1, qn1, is,ie, 0, 11, atm%ptop)
2569 atm%q(i,j,k,iq) = qn1(i,k)
2577 call mappm(km, pn0, tp, npz, pn1, qn1, is,ie, 1, 9, atm%ptop)
2581 atm%pt(i,j,k) = qn1(i,k)/
virq(atm%q(i,j,k,:))
2583 atm%pt(i,j,k) = qn1(i,k)/(1.+
zvir*atm%q(i,j,k,sphum))
2588 if ( .not. atm%flagstruct%hydrostatic .and. atm%flagstruct%ncep_ic )
then 2593 atm%delz(i,j,k) = rdg*qn1(i,k)*(pn1(i,k+1)-pn1(i,k))
2600 call prt_maxmin(
'PS_model', atm%ps(is:ie,js:je), is, ie, js, je, 0, 1, 0.01)
2602 if (is_master())
write(*,*)
'done remap_scalar' 2607 subroutine remap_scalar_nggps(Atm, km, npz, ncnst, ak0, bk0, psc, t_in, qa, omga, zh)
2608 type(fv_atmos_type),
intent(inout) :: Atm
2609 integer,
intent(in):: km, npz, ncnst
2610 real,
intent(in):: ak0(km+1), bk0(km+1)
2611 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je):: psc
2612 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km):: t_in
2613 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km):: omga
2614 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km,ncnst):: qa
2615 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km+1):: zh
2617 real,
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pe0
2618 real,
dimension(Atm%bd%is:Atm%bd%ie,npz):: qn1, dp2
2619 real,
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pe1
2620 real qp(Atm%bd%is:Atm%bd%ie,km)
2621 real wk(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je)
2622 real,
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je):: z500
2624 real(kind=R_GRID),
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pn1
2625 real(kind=R_GRID):: gz_fv(npz+1)
2626 real(kind=R_GRID),
dimension(2*km+1):: gz, pn
2627 real(kind=R_GRID),
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pn0
2628 real(kind=R_GRID):: pst
2630 integer i,j,k,l,m, k2,iq
2631 integer sphum, liq_wat, ice_wat, rainwat, snowwat, graupel, cld_amt, liq_aero, ice_aero
2633 integer spfo, spfo2, spfo3
2637 integer :: is, ie, js, je
2644 sphum = get_tracer_index(model_atmos,
'sphum')
2645 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
2646 ice_wat = get_tracer_index(model_atmos,
'ice_wat')
2647 rainwat = get_tracer_index(model_atmos,
'rainwat')
2648 snowwat = get_tracer_index(model_atmos,
'snowwat')
2649 graupel = get_tracer_index(model_atmos,
'graupel')
2650 cld_amt = get_tracer_index(model_atmos,
'cld_amt')
2652 spfo = get_tracer_index(model_atmos,
'spfo')
2653 spfo2 = get_tracer_index(model_atmos,
'spfo2')
2654 spfo3 = get_tracer_index(model_atmos,
'spfo3')
2656 o3mr = get_tracer_index(model_atmos,
'o3mr')
2658 liq_aero = get_tracer_index(model_atmos,
'liq_aero')
2659 ice_aero = get_tracer_index(model_atmos,
'ice_aero')
2663 if (mpp_pe()==1)
then 2664 print *,
'sphum = ', sphum
2665 print *,
'clwmr = ', liq_wat
2667 print *,
'spfo3 = ', spfo3
2668 print *,
' spfo = ', spfo
2669 print *,
'spfo2 = ', spfo2
2671 print *,
' o3mr = ', o3mr
2673 print *,
'liq_aero = ', liq_aero
2674 print *,
'ice_aero = ', ice_aero
2675 print *,
'ncnst = ', ncnst
2678 if ( sphum/=1 )
then 2679 call mpp_error(fatal,
'SPHUM must be 1st tracer')
2683 atm%phis(is:ie,js:je) = zh(is:ie,js:je,km+1)*grav
2693 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
2694 pn0(i,k) = log(pe0(i,k))
2701 gz(k) = zh(i,j,k)*grav
2707 gz(k) = 2.*gz(km+1) - gz(l)
2708 pn(k) = 2.*pn(km+1) - pn(l)
2712 if( atm%phis(i,j).le.gz(k) .and. atm%phis(i,j).ge.gz(k+1) )
then 2713 pst = pn(k) + (pn(k+1)-pn(k))*(gz(k)-atm%phis(i,j))/(gz(k)-gz(k+1))
2717 123 atm%ps(i,j) = exp(pst)
2724 if( pst.le.pn(k+1) .and. pst.ge.pn(k) )
then 2725 z500(i,j) = (gz(k+1) + (gz(k)-gz(k+1))*(pn(k+1)-pst)/(pn(k+1)-pn(k)))/grav
2734 pe1(i,1) = atm%ak(1)
2735 pn1(i,1) = log(pe1(i,1))
2739 pe1(i,k) = atm%ak(k) + atm%bk(k)*atm%ps(i,j)
2740 pn1(i,k) = log(pe1(i,k))
2747 dp2(i,k) = pe1(i,k+1) - pe1(i,k)
2748 atm%delp(i,j,k) = dp2(i,k)
2756 qp(i,k) = qa(i,j,k,iq)
2759 call mappm(km, pe0, qp, npz, pe1, qn1, is,ie, 0, 8, atm%ptop)
2760 if ( iq==sphum )
then 2761 call fillq(ie-is+1, npz, 1, qn1, dp2)
2763 call fillz(ie-is+1, npz, 1, qn1, dp2)
2768 atm%q(i,j,k,iq) = qn1(i,k)
2778 if ( pn1(i,1) .lt. pn0(i,1) )
then 2779 call mpp_error(fatal,
'FV3 top higher than NCEP/GFS')
2784 gz(k) = zh(i,j,k)*grav
2789 gz(k) = 2.*gz(km+1) - gz(l)
2790 pn(k) = 2.*pn(km+1) - pn(l)
2794 gz_fv(npz+1) = atm%phis(i,j)
2800 #ifdef USE_ISOTHERMO 2802 if ( (pn1(i,k).le.pn(l+1)) .and. (pn1(i,k).ge.pn(l)) )
then 2803 gz_fv(k) = gz(l) + (gz(l+1)-gz(l))*(pn1(i,k)-pn(l))/(pn(l+1)-pn(l))
2805 elseif ( pn1(i,k) .gt. pn(km+1) )
then 2807 gz_fv(k) = gz(km+1) + (gz_fv(npz+1)-gz(km+1))*(pn1(i,k)-pn(km+1))/(pn1(i,npz+1)-pn(km+1))
2813 if ( (pn1(i,k).le.pn(l+1)) .and. (pn1(i,k).ge.pn(l)) )
then 2814 gz_fv(k) = gz(l) + (gz(l+1)-gz(l))*(pn1(i,k)-pn(l))/(pn(l+1)-pn(l))
2823 atm%peln(i,k,j) = pn1(i,k)
2829 if (trim(
source) /=
'FV3GFS GAUSSIAN NEMSIO FILE')
then 2832 atm%pt(i,j,k) = (gz_fv(k)-gz_fv(k+1))/( rdgas*(pn1(i,k+1)-pn1(i,k))*
virq(atm%q(i,j,k,:)) )
2834 atm%pt(i,j,k) = (gz_fv(k)-gz_fv(k+1))/( rdgas*(pn1(i,k+1)-pn1(i,k))*(1.+
zvir*atm%q(i,j,k,sphum)) )
2842 qp(i,k) = t_in(i,j,k)
2845 call mappm(km, pe0, qp, npz, pe1, qn1, is,ie, 2, 4, atm%ptop)
2848 atm%pt(i,j,k) = qn1(i,k)
2852 if ( .not. atm%flagstruct%hydrostatic )
then 2854 atm%delz(i,j,k) = (gz_fv(k+1) - gz_fv(k)) / grav
2864 if (cld_amt .gt. 0) atm%q(:,:,:,cld_amt) = 0.
2865 if (trim(
source) /=
'FV3GFS GAUSSIAN NEMSIO FILE')
then 2866 if ( atm%flagstruct%nwat .eq. 6 )
then 2869 qn1(i,k) = atm%q(i,j,k,liq_wat)
2870 atm%q(i,j,k,rainwat) = 0.
2871 atm%q(i,j,k,snowwat) = 0.
2872 atm%q(i,j,k,graupel) = 0.
2874 if ( atm%pt(i,j,k) > 273.16 )
then 2875 atm%q(i,j,k,liq_wat) = qn1(i,k)
2876 atm%q(i,j,k,ice_wat) = 0.
2877 #ifdef ORIG_CLOUDS_PART 2878 else if ( atm%pt(i,j,k) < 258.16 )
then 2879 atm%q(i,j,k,liq_wat) = 0.
2880 atm%q(i,j,k,ice_wat) = qn1(i,k)
2882 atm%q(i,j,k,liq_wat) = qn1(i,k)*((atm%pt(i,j,k)-258.16)/15.)
2883 atm%q(i,j,k,ice_wat) = qn1(i,k) - atm%q(i,j,k,liq_wat)
2886 else if ( atm%pt(i,j,k) < 233.16 )
then 2887 atm%q(i,j,k,liq_wat) = 0.
2888 atm%q(i,j,k,ice_wat) = qn1(i,k)
2891 atm%q(i,j,k,liq_wat) = qn1(i,k)*((atm%pt(i,j,k)-233.16)/40.)
2892 atm%q(i,j,k,ice_wat) = qn1(i,k) - atm%q(i,j,k,liq_wat)
2894 if (atm%pt(i,j,k)<258.16 .and. atm%q(i,j,k-1,ice_wat)>1.e-5 )
then 2895 atm%q(i,j,k,liq_wat) = 0.
2896 atm%q(i,j,k,ice_wat) = qn1(i,k)
2898 atm%q(i,j,k,liq_wat) = qn1(i,k)*((atm%pt(i,j,k)-233.16)/40.)
2899 atm%q(i,j,k,ice_wat) = qn1(i,k) - atm%q(i,j,k,liq_wat)
2905 atm%q(i,j,k,ice_wat), atm%q(i,j,k,snowwat) )
2917 if ( .not. atm%flagstruct%hydrostatic )
then 2920 qp(i,k) = omga(i,j,k)
2923 call mappm(km, pe0, qp, npz, pe1, qn1, is,ie, -1, 4, atm%ptop)
2924 if (trim(
source) ==
'FV3GFS GAUSSIAN NEMSIO FILE')
then 2927 atm%w(i,j,k) = qn1(i,k)
2934 atm%w(i,j,k) = qn1(i,k)/atm%delp(i,j,k)*atm%delz(i,j,k)
2942 call p_maxmin(
'PS_model (mb)', atm%ps(is:ie,js:je), is, ie, js, je, 1, 0.01)
2943 call p_maxmin(
'PT_model', atm%pt(is:ie,js:je,1:npz), is, ie, js, je, npz, 1.)
2946 wk(i,j) = atm%phis(i,j)/grav - zh(i,j,km+1)
2949 call pmaxmn(
'ZS_diff (m)', wk, is, ie, js, je, 1, 1., atm%gridstruct%area_64, atm%domain)
2951 if (.not.atm%neststruct%nested)
then 2952 call prt_gb_nh_sh(
'GFS_IC Z500', is,ie, js,je, z500, atm%gridstruct%area_64(is:ie,js:je), atm%gridstruct%agrid_64(is:ie,js:je,2))
2953 if ( .not. atm%flagstruct%hydrostatic ) &
2954 call prt_height(
'fv3_IC Z500', is,ie, js,je, 3, npz, 500.e2, atm%phis, atm%delz, atm%peln, &
2955 atm%gridstruct%area_64(is:ie,js:je), atm%gridstruct%agrid_64(is:ie,js:je,2))
2960 wk(i,j) = atm%ps(i,j) - psc(i,j)
2963 call pmaxmn(
'PS_diff (mb)', wk, is, ie, js, je, 1, 0.01, atm%gridstruct%area_64, atm%domain)
2965 if (is_master())
write(*,*)
'done remap_scalar_nggps' 2969 subroutine remap_scalar_ec(Atm, km, npz, ncnst, ak0, bk0, psc, qa, wc, zh)
2970 type(fv_atmos_type),
intent(inout) :: Atm
2971 integer,
intent(in):: km, npz, ncnst
2972 real,
intent(in):: ak0(km+1), bk0(km+1)
2973 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je):: psc
2974 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km):: wc
2975 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km,ncnst):: qa
2976 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km+1):: zh
2978 real,
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pe0
2979 real,
dimension(Atm%bd%is:Atm%bd%ie,npz):: qn1, dp2
2980 real,
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pe1
2981 real qp(Atm%bd%is:Atm%bd%ie,km)
2982 real wk(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je)
2984 real(kind=R_GRID),
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pn1
2985 real(kind=R_GRID):: gz_fv(npz+1)
2986 real(kind=R_GRID),
dimension(2*km+1):: gz, pn
2987 real(kind=R_GRID),
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pn0
2988 real(kind=R_GRID):: pst
2989 real,
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je):: z500
2991 integer:: sphum, liq_wat, ice_wat, rainwat, snowwat, graupel, cld_amt
2993 integer:: spfo, spfo2, spfo3
2997 integer:: i,j,k,l,m,k2, iq
2998 integer:: is, ie, js, je
3005 sphum = get_tracer_index(model_atmos,
'sphum')
3006 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
3008 if ( atm%flagstruct%nwat .eq. 6 )
then 3009 ice_wat = get_tracer_index(model_atmos,
'ice_wat')
3010 rainwat = get_tracer_index(model_atmos,
'rainwat')
3011 snowwat = get_tracer_index(model_atmos,
'snowwat')
3012 graupel = get_tracer_index(model_atmos,
'graupel')
3013 cld_amt = get_tracer_index(model_atmos,
'cld_amt')
3015 if (cld_amt .gt. 0) atm%q(:,:,:,cld_amt) = 0.
3019 if (mpp_pe()==1)
then 3020 print *,
'In remap_scalar_ec:' 3021 print *,
'ncnst = ', ncnst
3022 print *,
'sphum = ', sphum
3023 print *,
'liq_wat = ', liq_wat
3024 if ( atm%flagstruct%nwat .eq. 6 )
then 3025 print *,
'rainwat = ', rainwat
3026 print *,
'ice_wat = ', ice_wat
3027 print *,
'snowwat = ', snowwat
3028 print *,
'graupel = ', graupel
3037 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
3038 pn0(i,k) = log(pe0(i,k))
3045 gz(k) = zh(i,j,k)*grav
3051 gz(k) = 2.*gz(km+1) - gz(l)
3052 pn(k) = 2.*pn(km+1) - pn(l)
3056 if( atm%phis(i,j).le.gz(k) .and. atm%phis(i,j).ge.gz(k+1) )
then 3057 pst = pn(k) + (pn(k+1)-pn(k))*(gz(k)-atm%phis(i,j))/(gz(k)-gz(k+1))
3061 123 atm%ps(i,j) = exp(pst)
3068 if( pst.le.pn(k+1) .and. pst.ge.pn(k) )
then 3069 z500(i,j) = (gz(k+1) + (gz(k)-gz(k+1))*(pn(k+1)-pst)/(pn(k+1)-pn(k)))/grav
3078 pe1(i,1) = atm%ak(1)
3079 pn1(i,1) = log(pe1(i,1))
3083 pe1(i,k) = atm%ak(k) + atm%bk(k)*atm%ps(i,j)
3084 pn1(i,k) = log(pe1(i,k))
3091 dp2(i,k) = pe1(i,k+1) - pe1(i,k)
3092 atm%delp(i,j,k) = dp2(i,k)
3100 qp(i,k) = qa(i,j,k,iq)
3103 call mappm(km, pe0, qp, npz, pe1, qn1, is,ie, 0, 8, atm%ptop)
3105 call fillq(ie-is+1, npz, 1, qn1, dp2)
3107 call fillz(ie-is+1, npz, 1, qn1, dp2)
3112 atm%q(i,j,k,iq) = qn1(i,k)
3121 if ( pn1(i,1) .lt. pn0(i,1) )
then 3122 call mpp_error(fatal,
'FV3 top higher than ECMWF')
3127 gz(k) = zh(i,j,k)*grav
3132 gz(k) = 2.*gz(km+1) - gz(l)
3133 pn(k) = 2.*pn(km+1) - pn(l)
3136 gz_fv(npz+1) = atm%phis(i,j)
3141 #ifdef USE_ISOTHERMO 3143 if ( (pn1(i,k).le.pn(l+1)) .and. (pn1(i,k).ge.pn(l)) )
then 3144 gz_fv(k) = gz(l) + (gz(l+1)-gz(l))*(pn1(i,k)-pn(l))/(pn(l+1)-pn(l))
3146 elseif ( pn1(i,k) .gt. pn(km+1) )
then 3148 gz_fv(k) = gz(km+1) + (gz_fv(npz+1)-gz(km+1))*(pn1(i,k)-pn(km+1))/(pn1(i,npz+1)-pn(km+1))
3154 if ( (pn1(i,k).le.pn(l+1)) .and. (pn1(i,k).ge.pn(l)) )
then 3155 gz_fv(k) = gz(l) + (gz(l+1)-gz(l))*(pn1(i,k)-pn(l))/(pn(l+1)-pn(l))
3164 atm%peln(i,k,j) = pn1(i,k)
3172 atm%pt(i,j,k) = (gz_fv(k)-gz_fv(k+1))/( rdgas*(pn1(i,k+1)-pn1(i,k))*
virq(atm%q(i,j,k,:)) )
3174 atm%pt(i,j,k) = (gz_fv(k)-gz_fv(k+1))/( rdgas*(pn1(i,k+1)-pn1(i,k))*(1.+
zvir*atm%q(i,j,k,sphum)) )
3177 if ( .not. atm%flagstruct%hydrostatic )
then 3179 atm%delz(i,j,k) = (gz_fv(k+1) - gz_fv(k)) / grav
3188 if ( .not. atm%flagstruct%hydrostatic )
then 3194 call mappm(km, pe0, qp, npz, pe1, qn1, is,ie, -1, 4, atm%ptop)
3197 atm%w(i,j,k) = qn1(i,k)/atm%delp(i,j,k)*atm%delz(i,j,k)
3205 call p_maxmin(
'PS_model (mb)', atm%ps(is:ie,js:je), is, ie, js, je, 1, 0.01)
3206 call p_maxmin(
'PT_model', atm%pt(is:ie,js:je,1:npz), is, ie, js, je, npz, 1.)
3207 call pmaxmn(
'ZS_model', atm%phis(is:ie,js:je)/grav, is, ie, js, je, 1, 1., atm%gridstruct%area_64, atm%domain)
3208 call pmaxmn(
'ZS_EC', zh(is:ie,js:je,km+1), is, ie, js, je, 1, 1., atm%gridstruct%area_64, atm%domain)
3211 wk(i,j) = atm%phis(i,j)/grav - zh(i,j,km+1)
3219 call pmaxmn(
'ZS_diff (m)', wk, is, ie, js, je, 1, 1., atm%gridstruct%area_64, atm%domain)
3221 if (.not.atm%neststruct%nested)
then 3222 call prt_gb_nh_sh(
'IFS_IC Z500', is,ie, js,je, z500, atm%gridstruct%area_64(is:ie,js:je), atm%gridstruct%agrid_64(is:ie,js:je,2))
3223 if ( .not. atm%flagstruct%hydrostatic ) &
3224 call prt_height(
'fv3_IC Z500', is,ie, js,je, 3, npz, 500.e2, atm%phis, atm%delz, atm%peln, &
3225 atm%gridstruct%area_64(is:ie,js:je), atm%gridstruct%agrid_64(is:ie,js:je,2))
3230 wk(i,j) = atm%ps(i,j) - psc(i,j)
3233 call pmaxmn(
'PS_diff (mb)', wk, is, ie, js, je, 1, 0.01, atm%gridstruct%area_64, atm%domain)
3238 type(fv_atmos_type),
intent(inout) :: Atm
3239 integer,
intent(in):: km, npz, iq
3240 real,
intent(in):: ak0(km+1), bk0(km+1)
3241 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je):: psc
3242 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km):: qa
3243 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km+1):: zh
3245 real,
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pe0
3246 real,
dimension(Atm%bd%is:Atm%bd%ie,npz):: qn1, dp2
3247 real,
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pe1
3248 real qp(Atm%bd%is:Atm%bd%ie,km)
3249 real wk(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je)
3251 real(kind=R_GRID),
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pn1
3252 real(kind=R_GRID):: gz_fv(npz+1)
3253 real(kind=R_GRID),
dimension(2*km+1):: gz, pn
3254 real(kind=R_GRID),
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pn0
3255 real(kind=R_GRID):: pst
3257 integer i,j,k, k2, l
3258 integer :: is, ie, js, je
3259 real,
allocatable:: ps_temp(:,:)
3268 allocate(ps_temp(is:ie,js:je))
3273 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
3274 pn0(i,k) = log(pe0(i,k))
3281 gz(k) = zh(i,j,k)*grav
3287 gz(k) = 2.*gz(km+1) - gz(l)
3288 pn(k) = 2.*pn(km+1) - pn(l)
3292 if( atm%phis(i,j).le.gz(k) .and. atm%phis(i,j).ge.gz(k+1) )
then 3293 pst = pn(k) + (pn(k+1)-pn(k))*(gz(k)-atm%phis(i,j))/(gz(k)-gz(k+1))
3297 123 ps_temp(i,j) = exp(pst)
3301 pe1(i,1) = atm%ak(1)
3302 pn1(i,1) = log(pe1(i,1))
3306 pe1(i,k) = atm%ak(k) + atm%bk(k)*ps_temp(i,j)
3307 pn1(i,k) = log(pe1(i,k))
3314 dp2(i,k) = pe1(i,k+1) - pe1(i,k)
3324 call mappm(km, pe0, qp, npz, pe1, qn1, is,ie, 0, 8, atm%ptop)
3326 call fillq(ie-is+1, npz, 1, qn1, dp2)
3328 call fillz(ie-is+1, npz, 1, qn1, dp2)
3333 atm%q(i,j,k,iq) = qn1(i,k)
3338 call p_maxmin(
'o3mr remap', atm%q(is:ie,js:je,1:npz,iq), is, ie, js, je, npz, 1.)
3346 real,
intent(inout):: ql, qr, qi, qs
3347 real,
parameter:: qi0_max = 2.0e-3
3348 real,
parameter:: ql0_max = 2.5e-3
3351 if ( ql > ql0_max )
then 3356 if ( qi > qi0_max )
then 3364 subroutine remap_dwinds(km, npz, ak0, bk0, psc, ud, vd, Atm)
3365 type(fv_atmos_type),
intent(inout) :: Atm
3366 integer,
intent(in):: km, npz
3367 real,
intent(in):: ak0(km+1), bk0(km+1)
3368 real,
intent(in):: psc(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je)
3369 real,
intent(in):: ud(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je+1,km)
3370 real,
intent(in):: vd(Atm%bd%is:Atm%bd%ie+1,Atm%bd%js:Atm%bd%je,km)
3372 real,
dimension(Atm%bd%isd:Atm%bd%ied,Atm%bd%jsd:Atm%bd%jed):: psd
3373 real,
dimension(Atm%bd%is:Atm%bd%ie+1, km+1):: pe0
3374 real,
dimension(Atm%bd%is:Atm%bd%ie+1,npz+1):: pe1
3375 real,
dimension(Atm%bd%is:Atm%bd%ie+1,npz):: qn1
3377 integer :: is, ie, js, je
3378 integer :: isd, ied, jsd, jed
3389 if (atm%neststruct%nested .or. atm%flagstruct%regional)
then 3392 psd(i,j) = atm%ps(i,j)
3402 call mpp_update_domains( psd, atm%domain, complete=.false. )
3403 call mpp_update_domains( atm%ps, atm%domain, complete=.true. )
3413 pe0(i,k) = ak0(k) + bk0(k)*0.5*(psd(i,j-1)+psd(i,j))
3418 pe1(i,k) = atm%ak(k) + atm%bk(k)*0.5*(atm%ps(i,j-1)+atm%ps(i,j))
3421 call mappm(km, pe0(is:ie,1:km+1), ud(is:ie,j,1:km), npz, pe1(is:ie,1:npz+1), &
3422 qn1(is:ie,1:npz), is,ie, -1, 8, atm%ptop)
3425 atm%u(i,j,k) = qn1(i,k)
3431 if ( j/=(je+1) )
then 3435 pe0(i,k) = ak0(k) + bk0(k)*0.5*(psd(i-1,j)+psd(i,j))
3440 pe1(i,k) = atm%ak(k) + atm%bk(k)*0.5*(atm%ps(i-1,j)+atm%ps(i,j))
3443 call mappm(km, pe0(is:ie+1,1:km+1), vd(is:ie+1,j,1:km), npz, pe1(is:ie+1,1:npz+1), &
3444 qn1(is:ie+1,1:npz), is,ie+1, -1, 8, atm%ptop)
3447 atm%v(i,j,k) = qn1(i,k)
3455 if (is_master())
write(*,*)
'done remap_dwinds' 3460 subroutine remap_winds(im, jm, km, npz, ak0, bk0, psc, ua, va, Atm)
3461 type(fv_atmos_type),
intent(inout) :: Atm
3462 integer,
intent(in):: im, jm, km, npz
3463 real,
intent(in):: ak0(km+1), bk0(km+1)
3464 real,
intent(in):: psc(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je)
3465 real,
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km):: ua, va
3467 real,
dimension(Atm%bd%isd:Atm%bd%ied,Atm%bd%jsd:Atm%bd%jed,npz):: ut, vt
3468 real,
dimension(Atm%bd%is:Atm%bd%ie, km+1):: pe0
3469 real,
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pe1
3470 real,
dimension(Atm%bd%is:Atm%bd%ie,npz):: qn1
3473 integer :: is, ie, js, je
3474 integer :: isd, ied, jsd, jed
3489 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
3495 pe1(i,k) = atm%ak(k) + atm%bk(k)*atm%ps(i,j)
3502 call mappm(km, pe0, ua(is:ie,j,1:km), npz, pe1, qn1, is,ie, -1, 8, atm%ptop)
3505 ut(i,j,k) = qn1(i,k)
3511 call mappm(km, pe0, va(is:ie,j,1:km), npz, pe1, qn1, is,ie, -1, 8, atm%ptop)
3514 vt(i,j,k) = qn1(i,k)
3522 call prt_maxmin(
'UA_top',ut(:,:,1), is, ie, js, je,
ng, 1, 1.)
3527 call cubed_a2d(atm%npx, atm%npy, npz, ut, vt, atm%u, atm%v, atm%gridstruct, atm%domain, atm%bd )
3529 if (is_master())
write(*,*)
'done remap_winds' 3534 subroutine remap_xyz( im, jbeg, jend, jm, km, npz, nq, ncnst, lon, lat, ak0, bk0, ps0, gz0, &
3535 ua, va, ta, qa, Atm )
3537 type(fv_atmos_type),
intent(inout),
target :: Atm
3538 integer,
intent(in):: im, jm, km, npz, nq, ncnst
3539 integer,
intent(in):: jbeg, jend
3540 real,
intent(in):: lon(im), lat(jm), ak0(km+1), bk0(km+1)
3541 real,
intent(in):: gz0(im,jbeg:jend), ps0(im,jbeg:jend)
3542 real,
intent(in),
dimension(im,jbeg:jend,km):: ua, va, ta
3543 real,
intent(in),
dimension(im,jbeg:jend,km,ncnst):: qa
3545 real,
pointer,
dimension(:,:,:) :: agrid
3548 real,
dimension(Atm%bd%isd:Atm%bd%ied,Atm%bd%jsd:Atm%bd%jed,npz):: ut, vt
3549 real,
dimension(Atm%bd%is:Atm%bd%ie,km):: up, vp, tp
3550 real,
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pe0, pn0
3551 real pt0(km), gz(km+1), pk0(km+1)
3552 real qp(Atm%bd%is:Atm%bd%ie,km,ncnst)
3553 real,
dimension(Atm%bd%is:Atm%bd%ie,npz):: qn1
3554 real,
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pe1, pn1
3557 real:: a1, b1, c1, c2, c3, c4
3558 real:: gzc, psc, pst
3562 integer i,j,k, i1, i2, jc, i0, j0, iq
3565 integer :: is, ie, js, je
3566 integer :: isd, ied, jsd, jed
3578 agrid => atm%gridstruct%agrid
3580 sphum = get_tracer_index(model_atmos,
'sphum')
3582 if ( sphum/=1 )
then 3583 call mpp_error(fatal,
'SPHUM must be 1st tracer')
3586 pk0(1) = ak0(1)**kappa
3589 rdlon(i) = 1. / (lon(i+1) - lon(i))
3591 rdlon(im) = 1. / (lon(1) + 2.*pi - lon(im))
3594 rdlat(j) = 1. / (lat(j+1) - lat(j))
3602 pn0(i,1) = log(ak0(1))
3608 if ( agrid(i,j,1)>lon(im) )
then 3610 a1 = (agrid(i,j,1)-lon(im)) * rdlon(im)
3611 elseif ( agrid(i,j,1)<lon(1) )
then 3613 a1 = (agrid(i,j,1)+2.*pi-lon(im)) * rdlon(im)
3616 if ( agrid(i,j,1)>=lon(i0) .and. agrid(i,j,1)<=lon(i0+1) )
then 3618 a1 = (agrid(i,j,1)-lon(i1)) * rdlon(i0)
3626 if ( agrid(i,j,2)<lat(1) )
then 3629 elseif ( agrid(i,j,2)>lat(jm) )
then 3634 if ( agrid(i,j,2)>=lat(j0) .and. agrid(i,j,2)<=lat(j0+1) )
then 3636 b1 = (agrid(i,j,2)-lat(jc)) * rdlat(jc)
3644 if ( a1<0.0 .or. a1>1.0 .or. b1<0.0 .or. b1>1.0 )
then 3645 write(*,*) i,j,a1, b1
3648 c1 = (1.-a1) * (1.-b1)
3654 psc = c1*ps0(i1,jc ) + c2*ps0(i2,jc ) + &
3655 c3*ps0(i2,jc+1) + c4*ps0(i1,jc+1)
3658 gzc = c1*gz0(i1,jc ) + c2*gz0(i2,jc ) + &
3659 c3*gz0(i2,jc+1) + c4*gz0(i1,jc+1)
3665 qp(i,k,iq) = c1*qa(i1,jc, k,iq) + c2*qa(i2,jc, k,iq) + &
3666 c3*qa(i2,jc+1,k,iq) + c4*qa(i1,jc+1,k,iq)
3672 up(i,k) = c1*ua(i1,jc, k) + c2*ua(i2,jc, k) + &
3673 c3*ua(i2,jc+1,k) + c4*ua(i1,jc+1,k)
3674 vp(i,k) = c1*va(i1,jc, k) + c2*va(i2,jc, k) + &
3675 c3*va(i2,jc+1,k) + c4*va(i1,jc+1,k)
3676 tp(i,k) = c1*ta(i1,jc, k) + c2*ta(i2,jc, k) + &
3677 c3*ta(i2,jc+1,k) + c4*ta(i1,jc+1,k)
3680 tp(i,k) = tp(i,k)*
virq(qp(i,k,:))
3682 tp(i,k) = tp(i,k)*(1.+
zvir*qp(i,k,sphum))
3688 pe0(i,k) = ak0(k) + bk0(k)*psc
3689 pn0(i,k) = log(pe0(i,k))
3690 pk0(k) = pe0(i,k)**kappa
3701 gz(k) = gz(k+1) + rdgas*tp(i,k)*(pn0(i,k+1)-pn0(i,k))
3706 pkx = (pk0(km+1)-pk0(km))*(kappa*(pn0(i,km+1)-pn0(i,km)))
3707 pkx = exp( kappax*log(pkx) )
3708 pt0(km) = tp(i,km)/pkx
3710 pt0(km) = tp(i,km)/(pk0(km+1)-pk0(km))*(kappa*(pn0(i,km+1)-pn0(i,km)))
3712 if( atm%phis(i,j)>gzc )
then 3714 if( atm%phis(i,j) < gz(k) .and. &
3715 atm%phis(i,j) >= gz(k+1) )
then 3716 pst = pk0(k) + (pk0(k+1)-pk0(k))*(gz(k)-atm%phis(i,j))/(gz(k)-gz(k+1))
3723 pst = pk0(km+1) + (gzc-atm%phis(i,j))/(cp_air*pt0(km)*pkx)
3725 pst = pk0(km+1) + (gzc-atm%phis(i,j))/(cp_air*pt0(km))
3730 123 atm%ps(i,j) = pst**(1./(kappa*kappax))
3732 123 atm%ps(i,j) = pst**(1./kappa)
3740 pe1(i,1) = atm%ak(1)
3741 pn1(i,1) = log(pe1(i,1))
3745 pe1(i,k) = atm%ak(k) + atm%bk(k)*atm%ps(i,j)
3746 pn1(i,k) = log(pe1(i,k))
3752 atm%delp(i,j,k) = pe1(i,k+1) - pe1(i,k)
3760 call mappm(km, pe0, up, npz, pe1, qn1, is,ie, -1, 9, atm%ptop)
3763 ut(i,j,k) = qn1(i,k)
3769 call mappm(km, pe0, vp, npz, pe1, qn1, is,ie, -1, 9, atm%ptop)
3772 vt(i,j,k) = qn1(i,k)
3782 call mappm(km, pe0, qp(is,1,iq), npz, pe1, qn1, is,ie, 0, 11, atm%ptop)
3785 atm%q(i,j,k,iq) = qn1(i,k)
3794 call mappm(km, pn0, tp, npz, pn1, qn1, is,ie, 1, 9, atm%ptop)
3798 atm%pt(i,j,k) = qn1(i,k)/
virq(atm%q(i,j,k,:))
3800 atm%pt(i,j,k) = qn1(i,k)/(1.+
zvir*atm%q(i,j,k,sphum))
3807 call prt_maxmin(
'PS_model', atm%ps, is, ie, js, je,
ng, 1, 0.01)
3814 call cubed_a2d(atm%npx, atm%npy, npz, ut, vt, atm%u, atm%v, atm%gridstruct, atm%domain, atm%bd )
3816 if (is_master())
write(*,*)
'done remap_xyz' 3821 subroutine cubed_a2d( npx, npy, npz, ua, va, u, v, gridstruct, fv_domain, bd )
3822 use mpp_domains_mod,
only: mpp_update_domains
3824 type(fv_grid_bounds_type),
intent(IN) :: bd
3825 integer,
intent(in):: npx, npy, npz
3826 real,
intent(inout),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,npz):: ua, va
3827 real,
intent(out):: u(bd%isd:bd%ied, bd%jsd:bd%jed+1,npz)
3828 real,
intent(out):: v(bd%isd:bd%ied+1,bd%jsd:bd%jed ,npz)
3829 type(fv_grid_type),
intent(IN),
target :: gridstruct
3830 type(domain2d),
intent(INOUT) :: fv_domain
3832 real v3(3,bd%is-1:bd%ie+1,bd%js-1:bd%je+1)
3833 real ue(3,bd%is-1:bd%ie+1,bd%js:bd%je+1)
3834 real ve(3,bd%is:bd%ie+1,bd%js-1:bd%je+1)
3835 real,
dimension(bd%is:bd%ie):: ut1, ut2, ut3
3836 real,
dimension(bd%js:bd%je):: vt1, vt2, vt3
3837 integer i, j, k, im2, jm2
3839 real(kind=R_GRID),
pointer,
dimension(:,:,:) :: vlon, vlat
3840 real(kind=R_GRID),
pointer,
dimension(:) :: edge_vect_w, edge_vect_e, edge_vect_s, edge_vect_n
3841 real(kind=R_GRID),
pointer,
dimension(:,:,:,:) :: ew, es
3843 integer :: is, ie, js, je
3844 integer :: isd, ied, jsd, jed
3855 vlon => gridstruct%vlon
3856 vlat => gridstruct%vlat
3858 edge_vect_w => gridstruct%edge_vect_w
3859 edge_vect_e => gridstruct%edge_vect_e
3860 edge_vect_s => gridstruct%edge_vect_s
3861 edge_vect_n => gridstruct%edge_vect_n
3866 call mpp_update_domains(ua, fv_domain, complete=.false.)
3867 call mpp_update_domains(va, fv_domain, complete=.true.)
3876 v3(1,i,j) = ua(i,j,k)*vlon(i,j,1) + va(i,j,k)*vlat(i,j,1)
3877 v3(2,i,j) = ua(i,j,k)*vlon(i,j,2) + va(i,j,k)*vlat(i,j,2)
3878 v3(3,i,j) = ua(i,j,k)*vlon(i,j,3) + va(i,j,k)*vlat(i,j,3)
3886 ue(1,i,j) = 0.5*(v3(1,i,j-1) + v3(1,i,j))
3887 ue(2,i,j) = 0.5*(v3(2,i,j-1) + v3(2,i,j))
3888 ue(3,i,j) = 0.5*(v3(3,i,j-1) + v3(3,i,j))
3894 ve(1,i,j) = 0.5*(v3(1,i-1,j) + v3(1,i,j))
3895 ve(2,i,j) = 0.5*(v3(2,i-1,j) + v3(2,i,j))
3896 ve(3,i,j) = 0.5*(v3(3,i-1,j) + v3(3,i,j))
3901 if (.not. gridstruct%nested)
then 3906 vt1(j) = edge_vect_w(j)*ve(1,i,j-1)+(1.-edge_vect_w(j))*ve(1,i,j)
3907 vt2(j) = edge_vect_w(j)*ve(2,i,j-1)+(1.-edge_vect_w(j))*ve(2,i,j)
3908 vt3(j) = edge_vect_w(j)*ve(3,i,j-1)+(1.-edge_vect_w(j))*ve(3,i,j)
3910 vt1(j) = edge_vect_w(j)*ve(1,i,j+1)+(1.-edge_vect_w(j))*ve(1,i,j)
3911 vt2(j) = edge_vect_w(j)*ve(2,i,j+1)+(1.-edge_vect_w(j))*ve(2,i,j)
3912 vt3(j) = edge_vect_w(j)*ve(3,i,j+1)+(1.-edge_vect_w(j))*ve(3,i,j)
3922 if ( (ie+1)==npx )
then 3926 vt1(j) = edge_vect_e(j)*ve(1,i,j-1)+(1.-edge_vect_e(j))*ve(1,i,j)
3927 vt2(j) = edge_vect_e(j)*ve(2,i,j-1)+(1.-edge_vect_e(j))*ve(2,i,j)
3928 vt3(j) = edge_vect_e(j)*ve(3,i,j-1)+(1.-edge_vect_e(j))*ve(3,i,j)
3930 vt1(j) = edge_vect_e(j)*ve(1,i,j+1)+(1.-edge_vect_e(j))*ve(1,i,j)
3931 vt2(j) = edge_vect_e(j)*ve(2,i,j+1)+(1.-edge_vect_e(j))*ve(2,i,j)
3932 vt3(j) = edge_vect_e(j)*ve(3,i,j+1)+(1.-edge_vect_e(j))*ve(3,i,j)
3947 ut1(i) = edge_vect_s(i)*ue(1,i-1,j)+(1.-edge_vect_s(i))*ue(1,i,j)
3948 ut2(i) = edge_vect_s(i)*ue(2,i-1,j)+(1.-edge_vect_s(i))*ue(2,i,j)
3949 ut3(i) = edge_vect_s(i)*ue(3,i-1,j)+(1.-edge_vect_s(i))*ue(3,i,j)
3951 ut1(i) = edge_vect_s(i)*ue(1,i+1,j)+(1.-edge_vect_s(i))*ue(1,i,j)
3952 ut2(i) = edge_vect_s(i)*ue(2,i+1,j)+(1.-edge_vect_s(i))*ue(2,i,j)
3953 ut3(i) = edge_vect_s(i)*ue(3,i+1,j)+(1.-edge_vect_s(i))*ue(3,i,j)
3963 if ( (je+1)==npy )
then 3967 ut1(i) = edge_vect_n(i)*ue(1,i-1,j)+(1.-edge_vect_n(i))*ue(1,i,j)
3968 ut2(i) = edge_vect_n(i)*ue(2,i-1,j)+(1.-edge_vect_n(i))*ue(2,i,j)
3969 ut3(i) = edge_vect_n(i)*ue(3,i-1,j)+(1.-edge_vect_n(i))*ue(3,i,j)
3971 ut1(i) = edge_vect_n(i)*ue(1,i+1,j)+(1.-edge_vect_n(i))*ue(1,i,j)
3972 ut2(i) = edge_vect_n(i)*ue(2,i+1,j)+(1.-edge_vect_n(i))*ue(2,i,j)
3973 ut3(i) = edge_vect_n(i)*ue(3,i+1,j)+(1.-edge_vect_n(i))*ue(3,i,j)
3987 u(i,j,k) = ue(1,i,j)*es(1,i,j,1) + &
3988 ue(2,i,j)*es(2,i,j,1) + &
3989 ue(3,i,j)*es(3,i,j,1)
3994 v(i,j,k) = ve(1,i,j)*ew(1,i,j,2) + &
3995 ve(2,i,j)*ew(2,i,j,2) + &
3996 ve(3,i,j)*ew(3,i,j,2)
4005 subroutine d2a3d(u, v, ua, va, im, jm, km, lon)
4006 integer,
intent(in):: im, jm, km
4007 real,
intent(in ) :: lon(im)
4008 real,
intent(in ),
dimension(im,jm,km):: u, v
4009 real,
intent(out),
dimension(im,jm,km):: ua, va
4011 real :: coslon(im),sinlon(im)
4021 sinlon(i) = sin(lon(i))
4022 coslon(i) = cos(lon(i))
4028 ua(i,j,k) = 0.5*(u(i,j,k) + u(i,j+1,k))
4034 va(i,j,k) = 0.5*(v(i,j,k) + v(i+1,j,k))
4036 va(im,j,k) = 0.5*(v(im,j,k) + v(1,j,k))
4043 us = us + (ua(i+imh,2,k)-ua(i,2,k))*sinlon(i) &
4044 + (va(i,2,k)-va(i+imh,2,k))*coslon(i)
4045 vs = vs + (ua(i+imh,2,k)-ua(i,2,k))*coslon(i) &
4046 + (va(i+imh,2,k)-va(i,2,k))*sinlon(i)
4051 ua(i,1,k) = -us*sinlon(i) - vs*coslon(i)
4052 va(i,1,k) = us*coslon(i) - vs*sinlon(i)
4053 ua(i+imh,1,k) = -ua(i,1,k)
4054 va(i+imh,1,k) = -va(i,1,k)
4061 un = un + (ua(i+imh,jm-1,k)-ua(i,jm-1,k))*sinlon(i) &
4062 + (va(i+imh,jm-1,k)-va(i,jm-1,k))*coslon(i)
4063 vn = vn + (ua(i,jm-1,k)-ua(i+imh,jm-1,k))*coslon(i) &
4064 + (va(i+imh,jm-1,k)-va(i,jm-1,k))*sinlon(i)
4070 ua(i,jm,k) = -un*sinlon(i) + vn*coslon(i)
4071 va(i,jm,k) = -un*coslon(i) - vn*sinlon(i)
4072 ua(i+imh,jm,k) = -ua(i,jm,k)
4073 va(i+imh,jm,k) = -va(i,jm,k)
4077 end subroutine d2a3d 4080 subroutine pmaxmin( qname, a, im, jm, fac )
4082 integer,
intent(in):: im, jm
4083 character(len=*) :: qname
4087 real qmin(jm), qmax(jm)
4095 pmax = max(pmax, a(i,j))
4096 pmin = min(pmin, a(i,j))
4107 pmax = max(pmax, qmax(j))
4108 pmin = min(pmin, qmin(j))
4111 write(*,*) qname,
' max = ', pmax*fac,
' min = ', pmin*fac
4115 subroutine pmaxmn(qname, q, is, ie, js, je, km, fac, area, domain)
4116 character(len=*),
intent(in):: qname
4117 integer,
intent(in):: is, ie, js, je
4118 integer,
intent(in):: km
4119 real,
intent(in):: q(is:ie, js:je, km)
4120 real,
intent(in):: fac
4121 real(kind=R_GRID),
intent(IN):: area(is-3:ie+3, js-3:je+3)
4122 type(domain2d),
intent(INOUT) :: domain
4124 real qmin, qmax, gmean
4134 if( q(i,j,k) < qmin )
then 4136 elseif( q(i,j,k) > qmax )
then 4143 call mp_reduce_min(qmin)
4144 call mp_reduce_max(qmax)
4146 gmean =
g_sum(domain, q(is,js,km), is, ie, js, je, 3, area, 1, reproduce=.true.)
4147 if(is_master())
write(6,*) qname, qmax*fac, qmin*fac, gmean*fac
4151 subroutine p_maxmin(qname, q, is, ie, js, je, km, fac)
4152 character(len=*),
intent(in):: qname
4153 integer,
intent(in):: is, ie, js, je, km
4154 real,
intent(in):: q(is:ie, js:je, km)
4155 real,
intent(in):: fac
4164 if( q(i,j,k) < qmin )
then 4166 elseif( q(i,j,k) > qmax )
then 4172 call mp_reduce_min(qmin)
4173 call mp_reduce_max(qmax)
4174 if(is_master())
write(6,*) qname, qmax*fac, qmin*fac
4178 subroutine fillq(im, km, nq, q, dp)
4179 integer,
intent(in):: im
4180 integer,
intent(in):: km
4181 integer,
intent(in):: nq
4182 real ,
intent(in):: dp(im,km)
4183 real ,
intent(inout) :: q(im,km,nq)
4185 integer i, k, ic, k1
4192 if( q(i,k,ic) < 0. )
then 4193 q(i,k1,ic) = q(i,k1,ic) + q(i,k,ic)*dp(i,k)/dp(i,k1)
4202 if( q(i,k,ic) < 0. )
then 4203 q(i,k1,ic) = q(i,k1,ic) + q(i,k,ic)*dp(i,k)/dp(i,k1)
4211 end subroutine fillq 4213 subroutine compute_zh(im, jm, levp, ak0, bk0, ps, zs, t, q, nq, zh )
4215 integer,
intent(in):: levp, im,jm, nq
4216 real,
intent(in),
dimension(levp+1):: ak0, bk0
4217 real(kind=4),
intent(in),
dimension(im,jm):: ps, zs
4218 real(kind=4),
intent(in),
dimension(im,jm,levp):: t
4219 real(kind=4),
intent(in),
dimension(im,jm,levp,nq):: q
4220 real(kind=4),
intent(out),
dimension(im,jm,levp+1):: zh
4222 real,
dimension(im,levp+1):: pe0, pn0
4232 pn0(i,1) = log(pe0(i,1))
4233 zh(i,j,levp+1) = zs(i,j)
4238 pe0(i,k) = ak0(k) + bk0(k)*ps(i,j)
4239 pn0(i,k) = log(pe0(i,k))
4246 zh(i,j,k) = zh(i,j,k+1)+(t(i,j,k)*(1.+
zvir*q(i,j,k,1))*(pn0(i,k+1)-pn0(i,k)))*(rdgas/grav)
4255 subroutine get_staggered_grid( is, ie, js, je, isd, ied, jsd, jed, pt_b, pt_c, pt_d)
4256 integer,
intent(in):: is, ie, js, je, isd, ied, jsd, jed
4257 real,
dimension(isd:ied+1,jsd:jed+1,2),
intent(in) :: pt_b
4258 real,
dimension(isd:ied+1,jsd:jed ,2),
intent(out) :: pt_c
4259 real,
dimension(isd:ied ,jsd:jed+1,2),
intent(out) :: pt_d
4261 real(kind=R_GRID),
dimension(2):: p1, p2, p3
4266 p1(:) = pt_b(i, j,1:2)
4267 p2(:) = pt_b(i+1,j,1:2)
4269 pt_d(i,j,1:2) = p3(:)
4275 p1(:) = pt_b(i,j ,1:2)
4276 p2(:) = pt_b(i,j+1,1:2)
4278 pt_c(i,j,1:2) = p3(:)
subroutine remap_dwinds(km, npz, ak0, bk0, psc, ud, vd, Atm)
subroutine, public mid_pt_sphere(p1, p2, pm)
subroutine, public prt_height(qname, is, ie, js, je, ng, km, press, phis, delz, peln, area, lat)
subroutine, public del2_cubed_sphere(npx, npy, q, area, dx, dy, dxc, dyc, sin_sg, nmax, cd, zero_ocean, oro, nested, domain, bd, regional)
pure real function, public vicpqd(q)
subroutine remap_scalar_ec(Atm, km, npz, ncnst, ak0, bk0, psc, qa, wc, zh)
subroutine, public get_var3_r4(ncid, var3_name, is, ie, js, je, ks, ke, var3, time_slice)
The module 'fv_mp_mod' is a single program multiple data (SPMD) parallel decompostion/communication m...
subroutine timing_off(blk_name)
The subroutine 'timing_off' stops a timer.
The type 'fv_grid_type' is made up of grid-dependent information from fv_grid_tools and fv_grid_utils...
integer, parameter, public h_stagger
subroutine, public mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
The subroutine 'mappm' is a general-purpose routine for remapping one set of vertical levels to anoth...
subroutine, public set_eta(km, ks, ptop, ak, bk)
This is the version of set_eta used in fvGFS and AM4.
The module 'multi_gases' peforms multi constitutents computations.
subroutine compute_zh(im, jm, levp, ak0, bk0, ps, zs, t, q, nq, zh)
subroutine, public fv3_zs_filter(bd, isd, ied, jsd, jed, npx, npy, npx_global, stretch_fac, nested, domain, area, dxa, dya, dx, dy, dxc, dyc, grid, agrid, sin_sg, phis, oro, regional)
subroutine, public del4_cubed_sphere(npx, npy, q, area, dx, dy, dxc, dyc, sin_sg, nmax, zero_ocean, oro, nested, domain, bd, regional)
subroutine get_nggps_ic(Atm, fv_domain)
The subroutine 'get_nggps_ic' reads in data after it has been preprocessed with NCEP/EMC orography ma...
real function, public g_sum(domain, p, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce)
The function 'g_sum' is the fast version of 'globalsum'.
real function, public inner_prod(v1, v2)
The module 'fv_io' contains restart facilities for FV core.
subroutine get_staggered_grid(is, ie, js, je, isd, ied, jsd, jed, pt_b, pt_c, pt_d)
subroutine, public get_latlon_vector(pp, elon, elat)
subroutine, public get_unit_vect2(e1, e2, uc)
subroutine remap_xyz(im, jbeg, jend, jm, km, npz, nq, ncnst, lon, lat, ak0, bk0, ps0, gz0, ua, va, ta, qa, Atm)
integer, parameter, public r_grid
pure real function, public virqd(q)
The module fv_nwp_nudge contains routines for nudging to input analyses. note This module is currentl...
real(kind=r_grid), parameter cnst_0p20
subroutine, public get_var1_real(ncid, var1_name, im, var1, var_exist)
The module 'fv_timing' contains FV3 timers.
pure real function, public virq(q)
The module 'boundary' contains utility routines for grid nesting and boundary conditions.
subroutine pmaxmin(qname, a, im, jm, fac)
subroutine, public get_var1_double(ncid, var1_name, im, var1, var_exist)
The 'get_var' subroutines read in variables from netcdf files.
real, parameter, public ptop_min
subroutine, public fv_io_read_tracers(fv_domain, Atm)
The subroutine 'fv_io_read_tracers' reads in only tracers from restart files.
The module 'fv_mapz' contains the vertical mapping routines .
subroutine, public fillz(im, km, nq, q, dp)
The subroutine 'fillz' is for mass-conservative filling of nonphysical negative values in the tracers...
The module 'fv_arrays' contains the 'fv_atmos_type' and associated datatypes.
interface 'nested_grid_BC' includes subroutines 'nested_grid_BC_2d' and 'nested_grid_BC_3d' that fetc...
The module 'sim_nc' is a netcdf file reader.
subroutine ncep2fms(im, jm, lon, lat, wk)
subroutine, public set_external_eta(ak, bk, ptop, ks)
The subroutine 'set_external_eta' sets 'ptop' (model top) and 'ks' (first level of pure pressure coor...
subroutine, public get_var2_real(ncid, var_name, im, jm, var2)
subroutine pmaxmn(qname, q, is, ie, js, je, km, fac, area, domain)
The module 'fv_eta' contains routine to set up the reference (Eulerian) pressure coordinate.
subroutine cubed_a2d(npx, npy, npz, ua, va, u, v, gridstruct, fv_domain, bd)
The subroutine 'cubed_a2d' transforms the wind from the A Grid to the D Grid.
subroutine, public get_var2_r4(ncid, var2_name, is, ie, js, je, var2, time_slice)
The module 'external_ic_mod' contains routines that read in and remap initial conditions.
subroutine d2a3d(u, v, ua, va, im, jm, km, lon)
real, dimension(:,:), allocatable, public sgh_g
subroutine remap_scalar_nggps(Atm, km, npz, ncnst, ak0, bk0, psc, t_in, qa, omga, zh)
subroutine, public open_ncfile(iflnm, ncid)
subroutine remap_coef(is, ie, js, je, isd, ied, jsd, jed, im, jm, lon, lat, id1, id2, jdc, s2c, agrid)
subroutine, public get_data_source(source, regional)
subroutine, public get_var_att_double(ncid, var_name, att_name, value)
subroutine timing_on(blk_name)
The subroutine 'timing_on' starts a timer.
subroutine get_fv_ic(Atm, fv_domain, nq)
subroutine get_ncep_ic(Atm, fv_domain, nq)
The subroutine 'get_ncep_ic' reads in the specified NCEP analysis or reanalysis dataset.
integer, parameter, public ng
subroutine remap_winds(im, jm, km, npz, ak0, bk0, psc, ua, va, Atm)
subroutine, public surfdrv(npx, npy, grid, agrid, area, dx, dy, dxa, dya, dxc, dyc, sin_sg, phis, stretch_fac, nested, npx_global, domain, grid_number, bd, regional)
integer, parameter, public v_stagger
@ The module 'fv_diagnostics' contains routines to compute diagnosic fields.
The module 'fv_grid_utils' contains routines for setting up and computing grid-related quantities...
subroutine, public prt_gb_nh_sh(qname, is, ie, js, je, a2, area, lat)
real, dimension(:,:), allocatable, public oro_g
subroutine, public prt_maxmin(qname, q, is, ie, js, je, n_g, km, fac)
subroutine, public get_cubed_sphere_terrain(Atm, fv_domain)
subroutine, public checker_tracers(i0, i1, j0, j1, ifirst, ilast, jfirst, jlast, nq, km, q, lon, lat, nx, ny, rn)
subroutine mp_auto_conversion(ql, qr, qi, qs)
subroutine remap_scalar_single(Atm, km, npz, ak0, bk0, psc, qa, zh, iq)
subroutine, public get_external_ic(Atm, fv_domain, cold_start)
subroutine remap_scalar(im, jm, km, npz, nq, ncnst, ak0, bk0, psc, gzc, ta, qa, Atm)
subroutine get_ecmwf_ic(Atm, fv_domain)
The subroutine 'get_ecmwf_ic' reads in initial conditions from ECMWF analyses (EXPERIMENTAL: contact ...
subroutine, public get_ncdim1(ncid, var1_name, im)
subroutine, public start_regional_cold_start(Atm, ak, bk, levp, is, ie, js, je, isd, ied, jsd, jed)
subroutine p_maxmin(qname, q, is, ie, js, je, km, fac)
subroutine, public extrapolation_bc(q, istag, jstag, npx, npy, bd, pd_in, debug_in)
The subroutine 'extrapolation_BC' performs linear extrapolation into the halo region.
subroutine fillq(im, km, nq, q, dp)
subroutine, public p_var(km, ifirst, ilast, jfirst, jlast, ptop, ptop_min, delp, delz, pt, ps, pe, peln, pk, pkz, cappa, q, ng, nq, area, dry_mass, adjust_dry_mass, mountain, moist_phys, hydrostatic, nwat, domain, make_nh)
the subroutine 'p_var' computes auxiliary pressure variables for a hydrostatic state.
integer, parameter, public u_stagger
subroutine, public close_ncfile(ncid)