forked from GEOS-ESM/FVdycoreCubed_GridComp
-
Notifications
You must be signed in to change notification settings - Fork 5
/
fv_regrid_c2c_bin.F90
2473 lines (2165 loc) · 104 KB
/
fv_regrid_c2c_bin.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module fv_regrid_c2c_bin
#ifdef MAPL_MODE
#define DEALLOCGLOB_(A) if(associated(A)) then;A=0;if(MAPL_ShmInitialized) then; call MAPL_DeAllocNodeArray(A,rc=status);else; deallocate(A);endif;NULLIFY(A);endif
#endif
use fv_arrays_mod, only: REAL4, REAL8, FVPRC
use fms_mod, only: file_exist, read_data, field_exist
use fms_io_mod, only: get_tile_string, field_size
use mpp_mod, only: mpp_error, FATAL, NOTE, mpp_broadcast,mpp_npes
use mpp_parameter_mod, only: AGRID_PARAM=>AGRID
use mpp_domains_mod, only: mpp_get_tile_id, domain2d, mpp_update_domains, mpp_get_boundary, DGRID_NE
use tracer_manager_mod, only: get_tracer_names, get_number_tracers, get_tracer_index
use field_manager_mod, only: MODEL_ATMOS
use MAPL
use gFTL_StringVector
use gFTL_StringIntegerMap
use, intrinsic :: iso_fortran_env, only: REAL64, REAL32
use fv_arrays_mod, only: fv_atmos_type, fv_grid_type, fv_grid_bounds_type, FVPRC, REAL4, REAL8
use fv_diagnostics_mod,only: prt_maxmin
use fv_mp_mod, only: is_master, ng, mp_barrier, mp_gather, mp_bcst, &
is,js,ie,je, isd,jsd,ied,jed, fill_corners, YDir
use fv_grid_utils_mod, only: ptop_min
use fv_grid_utils_mod, only: normalize_vect
use fv_mapz_mod, only: mappm
use fv_surf_map_mod, only: surfdrv
use fv_timing_mod, only: timing_on, timing_off
use init_hydro_mod, only: p_var
use fv_timing_mod, only: timing_on, timing_off
use mpp_mod, only: mpp_pe
use memutils_mod, only: print_memuse_stats
use fv_regridding_utils
use ESMF
implicit none
#include "mpif.h"
private
real(FVPRC), parameter :: PI = MAPL_PI_R8
real(FVPRC), parameter :: OMEGA = MAPL_OMEGA
real(FVPRC), parameter :: GRAV = MAPL_GRAV
real(FVPRC), parameter :: KAPPA = MAPL_KAPPA
real(FVPRC), parameter :: RDGAS = MAPL_RGAS
real(FVPRC), parameter :: RVGAS = MAPL_RVAP
real(FVPRC), parameter :: CP_AIR = MAPL_CP
real(FVPRC), parameter:: zvir = rvgas/rdgas - 1.
public get_geos_ic_bin
integer, SAVE :: tile, npes_x, npes_y
integer :: status
integer :: IUNIT=15
integer :: OUNIT=16
contains
subroutine get_geos_ic_bin( Atm, extra_rst, rstcube, gridOut)
type(fv_atmos_type), intent(inout) :: Atm(:)
type(fv_rst), pointer, intent(inout) :: extra_rst(:)
logical :: rstcube
type(ESMF_Grid), intent(inout) :: gridOut
real(FVPRC):: alpha = 0.
integer i,j
logical :: cubed_sphere,fv_diag_ic
! * Initialize coriolis param:
do j=jsd,jed+1
do i=isd,ied+1
Atm(1)%gridstruct%fc(i,j) = 2.*omega*( -1.*cos(Atm(1)%gridstruct%grid(i,j,1))*cos(Atm(1)%gridstruct%grid(i,j,2))*sin(alpha) + &
sin(Atm(1)%gridstruct%grid(i,j,2))*cos(alpha) )
enddo
enddo
do j=jsd,jed
do i=isd,ied
Atm(1)%gridstruct%f0(i,j) = 2.*omega*( -1.*cos(Atm(1)%gridstruct%agrid(i,j,1))*cos(Atm(1)%gridstruct%agrid(i,j,2))*sin(alpha) + &
sin(Atm(1)%gridstruct%agrid(i,j,2))*cos(alpha) )
enddo
enddo
cubed_sphere=.true.
fv_diag_ic=.false.
call mpp_update_domains( Atm(1)%gridstruct%f0, Atm(1)%domain )
if ( cubed_sphere ) call fill_corners(Atm(1)%gridstruct%f0, Atm(1)%npx, Atm(1)%npy, YDir)
Atm(1)%phis = 0.
do i=1,size(extra_rst)
if (extra_rst(i)%have_descriptor) then
do j=1,size(extra_rst(i)%vars)
if (extra_rst(i)%vars(j)%nLev/=1) then
allocate(extra_rst(i)%vars(j)%ptr3d(isd:ied,jsd:jed,extra_rst(i)%vars(j)%nLev),source=0.0_FVPRC )
else
allocate(extra_rst(i)%vars(j)%ptr2d(isd:ied,jsd:jed), source=0.0_FVPRC )
end if
enddo
else
do j=1,size(extra_rst(i)%vars)
allocate(extra_rst(i)%vars(j)%ptr3d(isd:ied,jsd:jed,extra_rst(i)%vars(j)%nLev),source=0.0_FVPRC )
enddo
end if
enddo
if ( .not.rstCube ) then
if (allocated(Atm(1)%q)) deallocate( Atm(1)%q )
allocate ( Atm(1)%q(isd:ied,jsd:jed,Atm(1)%npz,Atm(1)%ncnst) )
call get_geos_latlon_ic( Atm, extra_rst )
else
if (allocated(Atm(1)%q)) deallocate( Atm(1)%q )
allocate ( Atm(1)%q(isd:ied,jsd:jed,Atm(1)%npz,Atm(1)%ncnst) )
call get_geos_cubed_ic( Atm, extra_rst, gridOut )
endif
call prt_maxmin('T', Atm(1)%pt, is, ie, js, je, ng, Atm(1)%npz, 1.0_FVPRC)
Atm(1)%flagstruct%moist_phys=.false.
call p_var(Atm(1)%npz, is, ie, js, je, Atm(1)%ak(1), ptop_min, &
Atm(1)%delp, Atm(1)%delz, Atm(1)%pt, Atm(1)%ps, &
Atm(1)%pe, Atm(1)%peln, Atm(1)%pk, Atm(1)%pkz, &
kappa, Atm(1)%q, ng, Atm(1)%ncnst, dble(Atm(1)%gridstruct%area),Atm(1)%flagstruct%dry_mass, &
Atm(1)%flagstruct%adjust_dry_mass, Atm(1)%flagstruct%mountain, Atm(1)%flagstruct%moist_phys, &
Atm(1)%flagstruct%hydrostatic, Atm(1)%flagstruct%nwat, Atm(1)%domain,Atm(1)%flagstruct%make_nh, do_pkz=.false.)
end subroutine get_geos_ic_bin
subroutine get_geos_cubed_ic( Atm, extra_rst, gridOut )
use GHOST_CUBSPH_mod, only : A_grid, ghost_cubsph_update
use CUB2CUB_mod, only: get_c2c_weight, &
interpolate_c2c
type(fv_atmos_type), intent(inout) :: Atm(:)
type(fv_rst), pointer, intent(inout) :: extra_rst(:)
type(ESMF_Grid), intent(inout) :: gridOut
character(len=128) :: fname, fname1
real(FVPRC), allocatable:: pkz0(:,:)
real(FVPRC), allocatable:: ps0(:,:), gz0(:,:), t0(:,:,:), q0(:,:,:),qlev(:,:)
real(FVPRC), allocatable:: u0(:,:,:), v0(:,:,:)
real(FVPRC), allocatable:: ak0(:), bk0(:)
integer :: i, j, k, l, iq, im, jm, km, npts, npx, npy, npz
integer :: ntiles=6
integer :: header(6)
character (len=8) :: imc, jmc
real(FVPRC) psc(is:ie,js:je)
real(FVPRC) gzc(is:ie,js:je)
real(FVPRC), allocatable:: tp(:,:,:), qp(:,:,:,:)
real(FVPRC), allocatable:: ua(:,:,:), va(:,:,:)
real(REAL64), allocatable :: akbk_r8(:)
real(REAL64), dimension(:,:,:,:), allocatable :: corner_in, corner_out
integer :: is_i,ie_i, js_i,je_i
integer :: isd_i,ied_i, jsd_i,jed_i
integer :: ng_i = 5
type(domain2d) :: domain_i
real(FVPRC), allocatable :: ebuffer(:,:)
real(FVPRC), allocatable :: nbuffer(:,:)
real(FVPRC), allocatable :: wbuffer(:,:)
real(FVPRC), allocatable :: sbuffer(:,:)
integer (kind=MPI_OFFSET_KIND) :: slice_2d
integer (kind=MPI_OFFSET_KIND) :: offset
integer :: filetype,nqmap
integer :: ivar
character(len=128) :: vname
integer :: ifile,nlev
type(fv_rst), pointer :: tracer_bundles(:) => null()
type(StringIntegerMap) :: moist_tracers
integer, pointer :: iptr
character(len=:), pointer :: cptr
type(StringIntegerMapIterator) :: iter
character(len=128) :: moist_order(9) = (/"Q ","QLLS","QLCN","CLLS","CLCN","QILS","QICN","NCPL","NCPI"/)
type(CubedSphereGridFactory) :: cs_factory
type(ESMF_Grid) :: gridIn
class(AbstractRegridder), pointer :: regridder=>null()
npx = Atm(1)%npx
npy = Atm(1)%npy
npz = Atm(1)%npz
! Zero out all initial tracer fields:
Atm(1)%q = 0.
! Read input FV core restart file
fname = "fvcore_internal_restart_in"
if( file_exist(fname) ) then
open(IUNIT,file=fname ,access='sequential',form='unformatted',status='old')
read (IUNIT, IOSTAT=status) header
if (is_master()) print*, header
read (IUNIT, IOSTAT=status) header(1:5)
if (is_master()) print*, header(1:5)
im=header(1)
jm=header(2)
km=header(3)
if(is_master()) write(*,*) 'Using GEOS restart:', fname
if ( file_exist(fname) ) then
if(is_master()) write(*,*) 'External IC dimensions:', im , jm , km
if(is_master()) write(*,*) 'Interpolating to :', npx-1, (npy-1)*6, npz
else
call mpp_error(FATAL,'==> Error from get_geos_ic: &
& field not found')
endif
cs_factory = CubedSphereGridFactory(nx=Atm(1)%layout(1),ny=Atm(1)%layout(2),im_world=im,lm=km)
gridIn = grid_manager%make_grid(cs_factory,rc=status)
regridder => new_regridder_manager%make_regridder(gridIn,gridOut,REGRID_METHOD_BILINEAR,rc=status)
!--------------------------------------------------------------------!
! setup input cubed-sphere domain !
!--------------------------------------------------------------------!
call mpp_domain_decomp(domain_i,im+1,(jm/ntiles)+1,ntiles,ng_i,ntiles, &
is_i,ie_i,js_i,je_i,isd_i,ied_i,jsd_i,jed_i,tile)
!--------------------------------------------------------------------!
! initialize cubed sphere grid: in !
!--------------------------------------------------------------------!
allocate(corner_in(2,is_i:ie_i+1,js_i:je_i+1,tile:tile))
call init_cubsph_grid(im+1, is_i,ie_i, js_i,je_i, ntiles, corner_in)
call print_memuse_stats('get_geos_cubed_ic: init corner_in')
!--------------------------------------------------------------------!
! initialize cubed sphere grid: out !
!--------------------------------------------------------------------!
allocate(corner_out(2,is:ie+1,js:je+1,tile:tile))
do l=tile,tile
do j=js,je+1
do i=is,ie+1
corner_out(1,i,j,l) = Atm(1)%gridstruct%grid(i,j,1)
corner_out(2,i,j,l) = Atm(1)%gridstruct%grid(i,j,2)
enddo
enddo
enddo
call print_memuse_stats('get_geos_cubed_ic: init corner_out')
npts = im
call print_memuse_stats('get_geos_cubed_ic: get_c2c_weight')
allocate ( ak0(km+1) )
allocate ( bk0(km+1) )
allocate ( akbk_r8(km+1) )
read (IUNIT, IOSTAT=status) akbk_r8
ak0 = akbk_r8
read (IUNIT, IOSTAT=status) akbk_r8
bk0 = akbk_r8
deallocate ( akbk_r8 )
call print_memuse_stats('get_geos_cubed_ic: read ak/bk')
close (IUNIT)
! Read U
allocate ( u0(isd_i:ied_i,jsd_i:jed_i+1,km) )
u0(:,:,:) = 0.0
!offset = sequential access: 4 + INT(6) + 8 + INT(5) + 8 + DBL(NPZ+1) + 8 + DBL(NPZ+1) + 8
offset = 4 + 24 + 8 + 20 + 8 + (km+1)*8 + 8 + (km+1)*8 + 8
if (is_master()) print*, offset
call parallel_read_file_r8(fname, npts, is_i,ie_i, js_i,je_i, km, offset, u0(is_i:ie_i,js_i:je_i,:))
call print_memuse_stats('get_geos_cubed_ic: read U')
! Read V
allocate ( v0(isd_i:ied_i+1,jsd_i:jed_i,km) )
v0(:,:,:) = 0.0
if (is_master()) print*, offset
call parallel_read_file_r8(fname, npts, is_i,ie_i, js_i,je_i, km, offset, v0(is_i:ie_i,js_i:je_i,:))
call print_memuse_stats('get_geos_cubed_ic: read V')
allocate ( sbuffer(is_i:ie_i,km) )
allocate ( wbuffer(js_i:je_i,km) )
allocate ( nbuffer(is_i:ie_i,km) )
allocate ( ebuffer(js_i:je_i,km) )
call mpp_get_boundary(u0, v0, domain_i, &
wbuffery=wbuffer, ebuffery=ebuffer, &
sbufferx=sbuffer, nbufferx=nbuffer, &
gridtype=DGRID_NE )
do k=1,km
do i=is_i,ie_i
u0(i,je_i+1,k) = nbuffer(i,k)
enddo
do j=js_i,je_i
v0(ie_i+1,j,k) = ebuffer(j,k)
enddo
enddo
deallocate ( sbuffer )
deallocate ( wbuffer )
deallocate ( nbuffer )
deallocate ( ebuffer )
call mpp_update_domains( u0, v0, domain_i, gridtype=DGRID_NE, complete=.true. )
call prt_maxmin(' U_geos', u0, is_i, ie_i, js_i, je_i, ng_i, km, 1.0_FVPRC)
call prt_maxmin(' V_geos', v0, is_i, ie_i, js_i, je_i, ng_i, km, 1.0_FVPRC)
allocate ( ua(is:ie,js:je,km) )
allocate ( va(is:ie,js:je,km) )
call interp_c2c_vect(npts, npts, npx-1, npy-1, km, ntiles, domain_i, &
is,ie, js,je, isd_i,ied_i, jsd_i,jed_i, is_i,ie_i, js_i,je_i, &
u0, v0, ua, va, regridder, corner_in(:,is_i:ie_i+1,js_i:je_i+1,tile), corner_out, Atm(1)%gridstruct)
deallocate ( v0 )
deallocate ( u0 )
deallocate ( corner_in )
deallocate ( corner_out )
! Read T
allocate ( t0(isd_i:ied_i,jsd_i:jed_i,km) )
t0(:,:,:) = 0.0
if (is_master()) print*, offset
call parallel_read_file_r8(fname, npts, is_i,ie_i, js_i,je_i, km, offset, t0(is_i:ie_i,js_i:je_i,:))
call print_memuse_stats('get_geos_cubed_ic: read T')
! Read PE at Surface only
allocate ( ps0(isd_i:ied_i,jsd_i:jed_i) )
ps0(:,:) = 0.0
slice_2d = npts*npts*ntiles
do k=1,km
offset = offset + slice_2d*8 + 8 ! skip first KM levels of Edge Pressure to find surface pressure
enddo
if (is_master()) print*, offset, slice_2d
call parallel_read_file_r8(fname, npts, is_i,ie_i, js_i,je_i, 1, offset, ps0(is_i:ie_i,js_i:je_i))
call mpp_update_domains(ps0, domain_i)
! Read PKZ
allocate ( pkz0(isd_i:ied_i,jsd_i:jed_i) )
pkz0(:,:) = 0.0
if (is_master()) print*, offset
do k=1,km
call parallel_read_file_r8(fname, npts, is_i,ie_i, js_i,je_i, 1, offset, pkz0(is_i:ie_i,js_i:je_i))
! t0 need to be just temperature with no virtual effect
t0(is_i:ie_i,js_i:je_i,k) = t0(is_i:ie_i,js_i:je_i,k)*pkz0(is_i:ie_i,js_i:je_i)
enddo
call print_memuse_stats('get_geos_cubed_ic: converted T')
deallocate ( pkz0 )
allocate ( gz0(isd_i:ied_i,jsd_i:jed_i) )
gz0(:,:) = 0.0
write(imc, "(i8)") im
write(jmc, "(i8)") jm
imc = adjustl(imc)
jmc = adjustl(jmc)
write(fname1, "('topo_DYN_ave_',a,'x',a,'.data')") trim(imc), trim(jmc)
if (.not. file_exist(fname1)) then
call mpp_error(FATAL,'get_geos_cubed_ic: cannot find topo_DYN_ave file')
endif
call print_memuse_stats('get_geos_cubed_ic: '//TRIM(fname1)//' being read')
offset = 4
call parallel_read_file_r4(fname1, npts, is_i,ie_i, js_i,je_i, 1, offset, gz0(is_i:ie_i,js_i:je_i))
call mpp_update_domains(gz0, domain_i)
gz0 = gz0*grav
! Read cubed-sphere phis from file since IMPORT is not ready yet
offset = 4
call parallel_read_file_r4('topo_dynave.data', Atm(1)%npx-1, is,ie, js,je, 1, offset, Atm(1)%phis(is:ie,js:je))
call mpp_update_domains(Atm(1)%phis, Atm(1)%domain)
Atm(1)%phis = Atm(1)%phis*grav
call print_memuse_stats('get_geos_cubed_ic: phis')
! Horiz Interp for surface pressure
call prt_maxmin('PS_geos', ps0, is_i, ie_i, js_i, je_i, ng_i, 1, 1.0_FVPRC)
call regridder%regrid(ps0(is_i:ie_i,js_i:je_i),psc(is:ie,js:je),rc=status)
deallocate ( ps0 )
! Horiz Interp for surface height
call prt_maxmin('GZ_geos', gz0, is_i, ie_i, js_i, je_i, ng_i, 1, 1.0/grav)
call regridder%regrid(gz0(is_i:ie_i,js_i:je_i),gzc(is:ie,js:je),rc=status)
deallocate ( gz0 )
! Horiz Interp for Q
allocate ( q0(isd_i:ied_i,jsd_i:jed_i,km) )
allocate ( qp(is:ie,js:je,km,Atm(1)%ncnst) )
q0(:,:,:) = 0.0
qp(:,:,:,:) = 0.0
! Horiz Interp for moist tracers
! is there a moist restart file to interpolate?
! Read in tracers: only sphum at this point
if( file_exist("moist_internal_restart_in") ) then
if (is_master()) print*, 'Trying to interpolate moist_internal_restart_in'
offset=4
do ivar=1,Atm(1)%ncnst
call moist_tracers%insert(trim(moist_order(ivar)),ivar)
iq=ivar
do k=1,km
call parallel_read_file_r4('moist_internal_restart_in', npts, is_i,ie_i, js_i,je_i, 1, offset, q0(is_i:ie_i,js_i:je_i,k))
call mpp_update_domains(q0(:,:,k), domain_i)
call regridder%regrid(q0(is_i:ie_i,js_i:je_i,k),qp(:,:,k,iq),rc=status)
enddo
call prt_maxmin( 'Q_geos_moist', q0, is_i, ie_i, js_i, je_i, ng_i, km, 1._FVPRC)
enddo
end if
! Horiz Interp for extra tracers
! make copy of input on input levs
call copy_fv_rst(extra_rst,tracer_bundles)
do i=1,size(extra_rst)
do j=1,size(extra_rst(i)%vars)
if (extra_rst(i)%have_descriptor) then
if (extra_rst(i)%vars(j)%nLev/=1) then
if (extra_rst(i)%vars(j)%nLev == npz) then
tracer_bundles(i)%vars(j)%nLev=km
allocate(tracer_bundles(i)%vars(j)%ptr3d(is:ie,js:je,km) )
else if (extra_rst(i)%vars(j)%nLev == npz+1) then
tracer_bundles(i)%vars(j)%nLev=km+1
allocate(tracer_bundles(i)%vars(j)%ptr3d(is:ie,js:je,km+1) )
end if
else
allocate(tracer_bundles(i)%vars(j)%ptr2d(is:ie,js:je) )
end if
else
allocate(tracer_bundles(i)%vars(j)%ptr3d(is:ie,js:je,extra_rst(i)%vars(j)%nLev))
end if
enddo
enddo
do ifile=1,size(tracer_bundles)
if (is_master()) print*, 'Trying to interpolate: ',trim(tracer_bundles(ifile)%file_name)
offset=4
allocate ( qlev(isd_i:ied_i,jsd_i:jed_i) )
qlev(:,:) = 0.0
do ivar=1,size(tracer_bundles(ifile)%vars)
nlev=tracer_bundles(ifile)%vars(ivar)%nLev
if (filetype == 0) vname = trim(tracer_bundles(ifile)%vars(ivar)%name)
do k=1,nlev
call parallel_read_file_r4(trim(tracer_bundles(ifile)%file_name), npts, is_i,ie_i, js_i,je_i, 1, offset, qlev(is_i:ie_i,js_i:je_i))
if (tracer_bundles(ifile)%vars(ivar)%nLev/=1) then
call regridder%regrid(qlev(is_i:ie_i,js_i:je_i),tracer_bundles(ifile)%vars(ivar)%ptr3d(is:ie,js:je,k),rc=status)
else
call regridder%regrid(qlev(is_i:ie_i,js_i:je_i),tracer_bundles(ifile)%vars(ivar)%ptr2d(is:ie,js:je),rc=status)
end if
enddo
!call prt_maxmin( 'Q_geos_gocart', q0, is_i, ie_i, js_i, je_i, ng_i, km, 1._FVPRC)
enddo
deallocate(qlev)
enddo
! Horiz Interp for T
deallocate ( q0 )
call mpp_update_domains(t0, domain_i)
call prt_maxmin( 'T_geos', t0, is_i, ie_i, js_i, je_i, ng_i, km, 1.0_FVPRC)
allocate ( tp(is:ie,js:je,km) )
do k=1,km
call regridder%regrid(t0(is_i:ie_i,js_i:je_i,k),tp(:,:,k),rc=status)
enddo
deallocate ( t0 )
! Horz/Vert remap for scalars
nqmap = Atm(1)%ncnst
call remap_scalar(im, jm, km, npz, nqmap, nqmap, ak0, bk0, psc, gzc, tp, qp, Atm(1),tracer_bundles,extra_rst)
deallocate ( tp )
deallocate ( qp )
call print_memuse_stats('get_geos_cubed_ic: remap_scalar')
! Horz/Vert remap for U/V
call remap_winds(im, jm, km, npz, ak0, bk0, psc, ua, va, Atm)
deallocate ( ua )
deallocate ( va )
call print_memuse_stats('get_geos_cubed_ic: remap_winds')
else
call mpp_error(FATAL,'==> Error from get_geos_ic: &
& Expected file '//trim(fname)//' does not exist')
endif
if (allocated(bk0)) deallocate ( bk0 )
if (allocated(ak0)) deallocate ( ak0 )
! Finished, let's check the results !
call prt_maxmin('GZ_model', Atm(1)%phis, is, ie, js, je, ng, 1, 1.0/grav)
call prt_maxmin('PS_model', Atm(1)%ps, is, ie, js, je, ng, 1, 0.01_FVPRC)
call prt_maxmin('DP_model', Atm(1)%delp, is, ie, js, je, ng, npz, 1.0_FVPRC)
call prt_maxmin(' U_model', Atm(1)%u, is, ie, js, je, ng, npz, 1.0_FVPRC)
call prt_maxmin(' V_model', Atm(1)%v, is, ie, js, je, ng, npz, 1.0_FVPRC)
call prt_maxmin('PT_model', Atm(1)%pt, is, ie, js, je, ng, npz, 1.0_FVPRC)
! Range check the MOIST tracers
! Iterate over tracer names
iter = moist_tracers%begin()
do while (iter /= moist_tracers%end())
iptr => iter%value()
cptr => iter%key()
if (.not.match(cptr)) then
do k=1,npz
do j=js,je
do i=is,ie
Atm(1)%q(i,j,k,iptr) = MIN(Atm(1)%q(i,j,k,iptr),1.d0)
Atm(1)%q(i,j,k,iptr) = MAX(Atm(1)%q(i,j,k,iptr),0.d0)
enddo
enddo
enddo
endif
call iter%next()
enddo
do iq=1,Atm(1)%ncnst
call prt_maxmin('QP_model', Atm(1)%q(is:ie,js:je,1:npz,iq), is, ie, js, je, 0, npz, 1._FVPRC)
enddo
do i=1,size(tracer_bundles)
do j=1,size(tracer_bundles(i)%vars)
if (tracer_bundles(i)%vars(j)%nLev/=1) then
deallocate(tracer_bundles(i)%vars(j)%ptr3d )
else
deallocate(tracer_bundles(i)%vars(j)%ptr2d )
end if
enddo
enddo
deallocate(tracer_bundles)
contains
function match(var_name) result(inList)
character(len=*) :: var_name
logical :: inList
integer :: i
character(len=10) :: exclude_vars(3)
exclude_vars(1)="Q"
exclude_vars(2)="NCPL"
exclude_vars(3)="NCPI"
inList = .false.
do i=1,size(exclude_vars)
if (trim(exclude_vars(i))==trim(var_name)) inList = .true.
enddo
end function match
end subroutine get_geos_cubed_ic
subroutine get_geos_latlon_ic( Atm, extra_rst)
type(fv_atmos_type), intent(inout) :: Atm(:)
type(fv_rst), pointer, intent(inout) :: extra_rst(:)
character(len=128) :: fname, fname1
real(FVPRC), allocatable:: pkz0(:,:)
real(FVPRC), allocatable:: ps0(:,:), gz0(:,:), t0(:,:,:), q0(:,:,:)
real(FVPRC), allocatable:: u0(:,:,:), v0(:,:,:), ua0(:,:), va0(:,:)
real(FVPRC), allocatable:: lat(:), lon(:), ak0(:), bk0(:)
integer :: i, j, k, iq, j1, j2, im, jm, km, npz
integer :: header(6)
character (len=8) :: imc, jmc
integer:: i1, i2, nmoist, ngocart, npchem, nqmap, offset
real(FVPRC):: s2c(is:ie,js:je,4)
integer, dimension(is:ie,js:je):: id1, id2, jdc
real(FVPRC) psc(is:ie,js:je)
real(FVPRC) gzc(is:ie,js:je)
real(FVPRC), allocatable:: tp(:,:,:), qp(:,:,:,:)
real(FVPRC), allocatable:: ua(:,:,:), va(:,:,:)
real(REAL4), allocatable :: phis_r4(:,:)
real(REAL64), allocatable :: r8latlon(:,:)
real(REAL4), allocatable :: r4latlon(:,:)
real(REAL64), allocatable :: akbk_r8(:)
integer :: filetype
logical :: isNC4
type(Netcdf4_Fileformatter) :: formatter
type(FileMetadata), allocatable :: cfg(:)
integer :: nDims, nVars, ivar, dimSizes(3)
character(len=128) :: vname
integer :: lvar_cnt
!bma added
character(len=128) :: moist_order(9) = (/"Q ","QLLS","QLCN","CLLS","CLCN","QILS","QICN","NCPL","NCPI"/)
type(fv_rst), pointer :: tracer_bundles(:) => null()
integer :: ifile,nlev
real(FVPRC), allocatable :: gslice_r4(:,:)
npz = Atm(1)%npz
! Zero out all initial tracer fields:
Atm(1)%q = 0.
! Read in lat-lon FV core restart file
fname = "fvcore_internal_restart_in"
if( file_exist(fname) ) then
call MAPL_NCIOGetFileType(fname,filetype)
if (filetype >=0 ) then
isNC4 = .true.
else
isNC4 = .false.
end if
if (isNC4) then
allocate(cfg(1))
call formatter%open(fname,pFIO_READ,rc=status)
cfg(1) = formatter%read(rc=status)
im =cfg(1)%get_dimension('lon',rc=status)
jm =cfg(1)%get_dimension('lat',rc=status)
km =cfg(1)%get_dimension('lev',rc=status)
else
open(IUNIT,file=fname ,access='sequential',form='unformatted',status='old')
read (IUNIT, IOSTAT=status) header
if (is_master()) print*, header
read (IUNIT, IOSTAT=status) header(1:5)
if (is_master()) print*, header(1:5)
im=header(1)
jm=header(2)
km=header(3)
end if
if(is_master()) write(*,*) 'Using GEOS restart:', fname
if(is_master()) write(*,*) 'External IC dimensions:', im, jm, km
allocate ( lon(im) )
do i=1,im
lon(i) = (0.5 + real(i-1)) * 2.*pi/real(im)
enddo
allocate ( lat(jm) )
do j=1,jm
lat(j) = -0.5*pi + real(j-1)*pi/real(jm-1) ! SP to NP
enddo
call remap_coef( im, jm, lon, lat, id1, id2, jdc, s2c , Atm(1)%gridstruct%agrid, Atm(1)%bd)
allocate ( ak0(km+1) )
allocate ( bk0(km+1) )
allocate ( akbk_r8(km+1) )
if (isNC4) then
call MAPL_VarRead(formatter,"AK",akbk_r8)
else
read (IUNIT, IOSTAT=status) akbk_r8
end if
ak0 = akbk_r8
if (isNC4) then
call MAPL_VarRead(formatter,"BK",akbk_r8)
else
read (IUNIT, IOSTAT=status) akbk_r8
end if
bk0 = akbk_r8
deallocate ( akbk_r8 )
call print_memuse_stats('get_geos_latlon_ic: read ak/bk')
allocate ( r8latlon(im,jm) )
! Read U
allocate ( u0(im,jm,km) )
do k=1,km
if (isNC4) then
call MAPL_VarRead(formatter,"U",r8latlon,lev=k)
else
read (IUNIT, IOSTAT=status) r8latlon
end if
! Regrid from -180:180 to 0:360
u0(1 :im/2,:,k) = r8latlon(im/2 + 1 :im , :)
u0(im/2 + 1:im ,:,k) = r8latlon(1 :im/2, :)
enddo
call print_memuse_stats('get_geos_latlon_ic: read u')
! Read V
allocate ( v0(im,jm,km) )
do k=1,km
if (isNC4) then
call MAPL_VarRead(formatter,"V",r8latlon,lev=k)
else
read (IUNIT, IOSTAT=status) r8latlon
end if
! Regrid from -180:180 to 0:360
v0(1 :im/2,:,k) = r8latlon(im/2 + 1 :im , :)
v0(im/2 + 1:im ,:,k) = r8latlon(1 :im/2, :)
enddo
call print_memuse_stats('get_geos_latlon_ic: read v')
if(is_master()) call pmaxmin( 'U_geos', u0(:,2:jm,:), im*(jm-1), km, 1.0_FVPRC)
if(is_master()) call pmaxmin( 'V_geos', v0, im*jm , km, 1.0_FVPRC)
allocate ( ua(is:ie,js:je,km) )
allocate ( va(is:ie,js:je,km) )
allocate ( ua0(im,jm) )
allocate ( va0(im,jm) )
do k=1,km
! Move latlon D winds to cell centers (A-grid)
call d2a3d(u0(:,:,k), v0(:,:,k), ua0(:,:), va0(:,:), im, jm, 1, lon)
! Horiz Interp for U
do j=js,je
do i=is,ie
i1 = id1(i,j)
i2 = id2(i,j)
j1 = jdc(i,j)
ua(i,j,k) = s2c(i,j,1)*ua0(i1,j1 ) + s2c(i,j,2)*ua0(i2,j1 ) + &
s2c(i,j,3)*ua0(i2,j1+1) + s2c(i,j,4)*ua0(i1,j1+1)
enddo
enddo
! Horiz Interp for V
do j=js,je
do i=is,ie
i1 = id1(i,j)
i2 = id2(i,j)
j1 = jdc(i,j)
va(i,j,k) = s2c(i,j,1)*va0(i1,j1 ) + s2c(i,j,2)*va0(i2,j1 ) + &
s2c(i,j,3)*va0(i2,j1+1) + s2c(i,j,4)*va0(i1,j1+1)
enddo
enddo
enddo
call print_memuse_stats('get_geos_latlon_ic: d2a3d')
deallocate ( v0 )
deallocate ( u0 )
deallocate ( ua0 )
deallocate ( va0 )
! Read T
allocate ( t0(im,jm,km) )
do k=1,km
if (isNC4) then
call MAPL_VarRead(formatter,"PT",r8latlon,lev=k)
else
read (IUNIT, IOSTAT=status) r8latlon
end if
! Regrid from -180:180 to 0:360
t0(1 :im/2,:,k) = r8latlon(im/2 + 1 :im , :)
t0(im/2 + 1:im ,:,k) = r8latlon(1 :im/2, :)
enddo
call print_memuse_stats('get_geos_latlon_ic: read t')
! Read PE
do k=1,km+1
if (isNC4) then
call MAPL_VarRead(formatter,"PE",r8latlon,lev=k)
else
read (IUNIT, IOSTAT=status) r8latlon
end if
enddo
! Regrid from -180:180 to 0:360
allocate ( ps0(im,jm) )
ps0(1 :im/2,:) = r8latlon(im/2 + 1 :im , :)
ps0(im/2 + 1:im ,:) = r8latlon(1 :im/2, :)
allocate ( pkz0(im,jm) )
do k=1,km
if (isNC4) then
call MAPL_VarRead(formatter,"PKZ",r8latlon,lev=k)
else
read (IUNIT, IOSTAT=status) r8latlon
end if
! Regrid from -180:180 to 0:360
pkz0(1 :im/2,:) = r8latlon(im/2 + 1 :im , :)
pkz0(im/2 + 1:im ,:) = r8latlon(1 :im/2, :)
! t0 needs to be just temperature with no virtual effect
t0(:,:,k) = t0(:,:,k)*pkz0
enddo
deallocate ( r8latlon )
call print_memuse_stats('get_geos_latlon_ic: converted T')
deallocate ( pkz0 )
if (isNC4) then
call formatter%close()
deallocate(cfg)
else
close (IUNIT)
end if
write(imc, "(i8)") im
write(jmc, "(i8)") jm
imc = adjustl(imc)
jmc = adjustl(jmc)
write(fname1, "('topo_DYN_ave_',a,'x',a,'_DC.data')") trim(imc), trim(jmc)
if (.not. file_exist(fname1)) then
CALL mpp_error(FATAL,'get_geos_latlon_ic: cannot find topo_DYN_ave file')
endif
call print_memuse_stats('get_geos_latlon_ic: '//TRIM(fname1)//' being read')
allocate ( r4latlon(im,jm) )
open(IUNIT,file=fname1,form='unformatted',status='old')
read(IUNIT) r4latlon
close(IUNIT)
! Regrid from -180:180 to 0:360
allocate ( gz0(im,jm) )
gz0(1 :im/2,:) = r4latlon(im/2 + 1 :im , :)
gz0(im/2 + 1:im ,:) = r4latlon(1 :im/2, :)
gz0 = gz0*grav
deallocate ( r4latlon )
! Read cubed-sphere phis from file since IMPORT is not ready yet
write(imc, "(i8)") Atm(1)%npx-1
write(jmc, "(i8)") 6*(Atm(1)%npy-1)
imc = adjustl(imc)
jmc = adjustl(jmc)
write(fname1, "('topo_DYN_ave_',a,'x',a,'.data')") trim(imc), trim(jmc)
if (.not. file_exist(fname1)) then
call mpp_error(FATAL,'get_geos_latlon_ic: cannot find topo_DYN_ave file')
endif
allocate( phis_r4(Atm(1)%npx-1,6*(Atm(1)%npy-1)) )
open(IUNIT,file=fname1,form='unformatted',status='old')
read(IUNIT) phis_r4
close(IUNIT)
Atm(1)%phis(is:ie,js:je) = phis_r4(is:ie,js+(tile-1)*(Atm(1)%npy-1):je+(tile-1)*(Atm(1)%npy-1))*grav
call mpp_update_domains(Atm(1)%phis, Atm(1)%domain)
deallocate( phis_r4 )
call print_memuse_stats('get_geos_latlon_ic: phis')
! Horiz Interp for surface pressure
if(is_master()) call pmaxmin( 'PS_geos', ps0, im, jm, 0.01_FVPRC)
do j=js,je
do i=is,ie
i1 = id1(i,j)
i2 = id2(i,j)
j1 = jdc(i,j)
psc(i,j) = s2c(i,j,1)*ps0(i1,j1 ) + s2c(i,j,2)*ps0(i2,j1 ) + &
s2c(i,j,3)*ps0(i2,j1+1) + s2c(i,j,4)*ps0(i1,j1+1)
enddo
enddo
deallocate ( ps0 )
! Horiz Interp for surface height
if(is_master()) call pmaxmin( 'ZS_geos', gz0, im, jm, 1.0/grav)
do j=js,je
do i=is,ie
i1 = id1(i,j)
i2 = id2(i,j)
j1 = jdc(i,j)
gzc(i,j) = s2c(i,j,1)*gz0(i1,j1 ) + s2c(i,j,2)*gz0(i2,j1 ) + &
s2c(i,j,3)*gz0(i2,j1+1) + s2c(i,j,4)*gz0(i1,j1+1)
enddo
enddo
deallocate ( gz0 )
! Horiz Interp for MOIST
! ----------------------
allocate ( q0(im,jm,km) )
allocate ( qp(is:ie,js:je,km,Atm(1)%ncnst) )
qp = 0.0
! Horiz Interp for moist tracers
! is there a moist restart file to interpolate?
! Read in tracers: only sphum at this point
if( file_exist("moist_internal_restart_in")) then
if (is_master()) print*, 'Trying to interpolate moist_internal_restart_in'
allocate ( r4latlon(im,jm) )
call MAPL_NCIOGetFileType("moist_internal_restart_in",filetype)
if (filetype /= 0) then
open(IUNIT,file="moist_internal_restart_in" ,access='sequential',form='unformatted',status='old')
else
lvar_cnt = 0
call formatter%open("moist_internal_restart_in",pFIO_READ,rc=status)
cfg = formatter%read(rc=status)
call MAPL_IOCountNonDimVars(cfg(1),nvars,rc=status)
if (nVars /= Atm(1)%ncnst) call mpp_error(FATAL,'Wrong number of variables in moist file')
end if
do ivar=1,Atm(1)%ncnst
if (filetype ==0) lvar_cnt=lvar_cnt+1
do k=1,km
if (filetype /= 0) then
read (IUNIT, IOSTAT=status) r4latlon
else
vname = trim(moist_order(lvar_cnt))
call MAPL_VarRead(formatter,vname,r4latlon,lev=k)
end if
q0(1 :im/2,:,k) = r4latlon(im/2 + 1 :im , :) ! Regrid from -180:180 to 0:360
q0(im/2 + 1:im ,:,k) = r4latlon(1 :im/2, :) ! Regrid from -180:180 to 0:360
do j=js,je
do i=is,ie
i1 = id1(i,j)
i2 = id2(i,j)
j1 = jdc(i,j)
qp(i,j,k,ivar) = s2c(i,j,1)*q0(i1,j1 ,k) + s2c(i,j,2)*q0(i2,j1 ,k) + &
s2c(i,j,3)*q0(i2,j1+1,k) + s2c(i,j,4)*q0(i1,j1+1,k)
enddo
enddo
enddo
if (ivar == 1) t0 = (t0/(1.0 + zvir*q0(:,:,:)))
if (is_master()) call pmaxmin( 'MOIST_Q_', q0(:,:,:), im*jm, km, 1.0_FVPRC)
enddo
if (filetype == 0) then
call formatter%close()
deallocate(cfg)
else
close(IUNIT)
end if
deallocate(r4latlon)
end if
! Horiz Interp for extra tracers
! make copy of input on input levs
call copy_fv_rst(extra_rst,tracer_bundles)
do i=1,size(extra_rst)
do j=1,size(extra_rst(i)%vars)
if (extra_rst(i)%have_descriptor) then
if (extra_rst(i)%vars(j)%nLev/=1) then
if (extra_rst(i)%vars(j)%nLev == npz) then
tracer_bundles(i)%vars(j)%nLev=km
allocate(tracer_bundles(i)%vars(j)%ptr3d(is:ie,js:je,km) )
else if (extra_rst(i)%vars(j)%nLev == npz+1) then
tracer_bundles(i)%vars(j)%nLev=km+1
allocate(tracer_bundles(i)%vars(j)%ptr3d(is:ie,js:je,km+1) )
end if
else
allocate(tracer_bundles(i)%vars(j)%ptr2d(is:ie,js:je) )
end if
else
allocate(tracer_bundles(i)%vars(j)%ptr3d(is:ie,js:je,extra_rst(i)%vars(j)%nLev))
end if
enddo
enddo
do ifile=1,size(tracer_bundles)
if (is_master()) print*, 'Trying to interpolate: ',trim(tracer_bundles(ifile)%file_name)
call MAPL_NCIOGetFileType(trim(tracer_bundles(ifile)%file_name),filetype)
allocate(gslice_r4(im,jm))
if (filetype /= 0) then
open(IUNIT,file=triM(tracer_bundles(ifile)%file_name) ,access='sequential',form='unformatted',status='old')
else
call formatter%open(trim(tracer_bundles(ifile)%file_name),pFIO_READ,rc=status)
end if
do ivar=1,size(tracer_bundles(ifile)%vars)
nlev=tracer_bundles(ifile)%vars(ivar)%nLev
if (filetype == 0) vname = trim(tracer_bundles(ifile)%vars(ivar)%name)
do k=1,nlev
if (filetype /= 0) then
read (IUNIT, IOSTAT=status)gslice_r4
else
if (tracer_bundles(ifile)%vars(ivar)%nLev/=1) then
call MAPL_VarRead(formatter,vname,gslice_r4,lev=k)
else
call MAPL_VarRead(formatter,vname,gslice_r4)
end if
end if
q0(1 :im/2,:,k) = gslice_r4(im/2 + 1 :im , :) ! Regrid from -180:180 to 0:360
q0(im/2 + 1:im ,:,k) = gslice_r4(1 :im/2, :) ! Regrid from -180:180 to 0:360
do j=js,je
do i=is,ie
i1 = id1(i,j)
i2 = id2(i,j)
j1 = jdc(i,j)
if (tracer_bundles(ifile)%vars(ivar)%nLev/=1) then
tracer_bundles(ifile)%vars(ivar)%ptr3d(i,j,k) &
=s2c(i,j,1)*q0(i1,j1,k) &
+s2c(i,j,2)*q0(i2,j1,k) &
+s2c(i,j,3)*q0(i2,j1+1,k) &
+s2c(i,j,4)*q0(i1,j1+1,k)
else
tracer_bundles(ifile)%vars(ivar)%ptr2d(i,j) &
=s2c(i,j,1)*q0(i1,j1,k) &
+s2c(i,j,2)*q0(i2,j1,k) &
+s2c(i,j,3)*q0(i2,j1+1,k) &
+s2c(i,j,4)*q0(i1,j1+1,k)
end if
enddo
enddo
enddo
!call prt_maxmin( 'Q_geos_gocart', q0, is_i, ie_i, js_i, je_i, ng_i, km, 1._FVPRC)
enddo
if (filetype == 0) then
call formatter%close()
deallocate(gslice_r4)
end if
enddo
call print_memuse_stats('get_geos_latlon_ic: remap_tracers')
deallocate ( q0 )
! Horiz Interp for T
if(is_master()) call pmaxmin( 'T_geos', t0, im*jm, km, 1.0_FVPRC)
allocate ( tp(is:ie,js:je,km) )
do k=1,km
do j=js,je
do i=is,ie
i1 = id1(i,j)
i2 = id2(i,j)
j1 = jdc(i,j)
tp(i,j,k) = s2c(i,j,1)*t0(i1,j1 ,k) + s2c(i,j,2)*t0(i2,j1 ,k) + &
s2c(i,j,3)*t0(i2,j1+1,k) + s2c(i,j,4)*t0(i1,j1+1,k)
enddo
enddo
enddo
deallocate ( t0 )
call print_memuse_stats('get_geos_latlon_ic: remap_t')
! Horz/Vert remap for MOIST, GOCART, and PCHEM scalars (Assuming Total Number is divisible by KM)
! -----------------------------------------------------------------------------------------------
nqmap = nmoist + ngocart + npchem
call remap_scalar(im, jm, km, npz, nqmap, nqmap, ak0, bk0, psc, gzc, tp, qp, Atm(1), tracer_bundles, extra_rst)
deallocate ( tp )
deallocate ( qp )
call print_memuse_stats('get_geos_latlon_ic: remap_scalar')
! Horz/Vert remap for U/V