forked from NOAA-GFDL/FMScoupler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flux_exchange.F90
4414 lines (3885 loc) · 203 KB
/
flux_exchange.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
!-----------------------------------------------------------------------
! GNU General Public License !
! This program is free software; you can redistribute it and/or modify it and
! are expected to follow the terms of the GNU General Public License
! as published by the Free Software Foundation; either version 2 of
! the License, or (at your option) any later version.
!
! MOM is distributed in the hope that it will be useful, but WITHOUT
! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
! License for more details.
!
! For the full text of the GNU General Public License,
! write to: Free Software Foundation, Inc.,
! 675 Mass Ave, Cambridge, MA 02139, USA.
! or see: http://www.gnu.org/licenses/gpl.html
!-----------------------------------------------------------------------
!> \author Bruce Wyman <[email protected]>
!! \author V. Balaji <[email protected]>
!! \author Sergey Malyshev <[email protected]>
!!
!! \brief The flux_exchange module provides interfaces to couple the following component
!! models: atmosphere, ocean, land, and ice. All interpolation between physically
!! distinct model grids is handled by the exchange grid (xgrid_mod) with the
!! interpolated quantities being conserved.
!!
!! -# This version of flux_exchange_mod allows the definition of physically independent
!! grids for atmosphere, land and sea ice. Ice and ocean must share the same physical
!! grid (though the domain decomposition on parallel systems may be different).
!! Grid information is input through the grid_spec file (URL). The masked region of the
!! land grid and ice/ocean grid must "tile" each other. The masked region of the ice grid
!! and ocean grid must be identical.
!! <pre>
!! ATMOSPHERE |----|----|----|----|----|----|----|----|
!!
!! LAND |---|---|---|---|xxx|xxx|xxx|xxx|xxx|xxx|
!!
!! ICE |xxx|xxx|xxx|xxx|---|---|---|---|---|---|
!!
!! OCEAN |xxx|xxx|xxx|xxx|---|---|---|---|---|---|
!! </pre>
!!
!! where \c |xxx| represents a masked grid point
!!
!! The atmosphere, land, and ice grids exchange information using the exchange grid xmap_sfc.
!!
!! The land and ice grids exchange runoff data using the exchange grid xmap_runoff.
!!
!! Transfer of data between the ice bottom and ocean does not require an exchange
!! grid as the grids are physically identical. The flux routines will automatically
!! detect and redistribute data if their domain decompositions are different.
!!
!! To get information from the atmosphere to the ocean it must pass through the
!! ice model, first by interpolating from the atmospheric grid to the ice grid,
!! and then transferring from the ice grid to the ocean grid.
!!
!! -# Each component model must have a public defined data type containing specific
!! boundary fields. A list of these quantities is located in the NOTES of this document.
!!
!! -# The surface flux of sensible heat and surface evaporation can be implicit functions
!! of surface temperature. As a consequence, the parts of the land and sea-ice models
!! that update the surface temperature must be called on the atmospheric time step
!!
!! -# The surface fluxes of all other tracers and of momentum are assumed to be explicit
!! functions of all surface parameters
!!
!! -# While no explicit reference is made within this module to the implicit treatment
!! of vertical diffusion in the atmosphere and in the land or sea-ice models, the
!! module is designed to allow for simultaneous implicit time integration on both
!! sides of the surface interface.
!!
!! -# Due to #5, the diffusion part of the land and ice models must be called on the
!! atmospheric time step.
!!
!! -# Any field passed from one component to another may be "faked" to a
!! constant value, or to data acquired from a file, using the
!! data_override feature of FMS. The fields to override are runtime
!! configurable, using the text file <tt>data_table</tt> for input.
!! See the data_override_mod documentation for more details.
!!
!! We DO NOT RECOMMEND exercising the data override capabilities of
!! the FMS coupler until the user has acquired considerable
!! sophistication in running FMS.
!!
!! Here is a listing of the override capabilities of the flux_exchange
!! module:
!!
!! - FROM the atmosphere boundary TO the exchange grid (in sfc_boundary_layer):
!!
!! t_bot, q_bot, z_bot, p_bot, u_bot, v_bot, p_surf, slp, gust
!!
!! - FROM the ice boundary TO the exchange grid (in sfc_boundary_layer):
!!
!! t_surf, rough_mom, rough_heat, rough_moist, albedo, u_surf, v_surf
!!
!! - FROM the land boundary TO the exchange grid (in sfc_boundary_layer):
!!
!! t_surf, t_ca, q_ca, rough_mom, rough_heat, albedo
!!
!! - FROM the exchange grid TO land_ice_atmos_boundary (in
!! sfc_boundary_layer):
!!
!! t, albedo, land_frac, dt_t, dt_q, u_flux, v_flux, dtaudu, dtaudv,
!! u_star, b_star, rough_mom
!!
!! - FROM the atmosphere boundary TO the exchange grid (in
!! flux_down_from_atmos):
!!
!! flux_sw, flux_lw, lprec, fprec, coszen, dtmass, delta_t,
!! delta_q, dflux_t, dflux_q
!!
!! - FROM the exchange grid TO the land boundary (in
!! flux_down_from_atmos):
!!
!! t_flux, q_flux, lw_flux, sw_flux, lprec, fprec, dhdt, dedt, dedq,
!! drdt, drag_q, p_surf
!!
!! - FROM the exchange grid TO the ice boundary (in flux_down_from_atmos):
!!
!! u_flux, v_flux, t_flux, q_flux, lw_flux, lw_flux_dn, sw_flux,
!! sw_flux_dn, lprec, fprec, dhdt, dedt, drdt, coszen, p
!!
!! - FROM the land boundary TO the ice boundary (in flux_land_to_ice):
!!
!! runoff, calving
!!
!! - FROM the ice boundary TO the ocean boundary (in flux_ice_to_ocean):
!!
!! u_flux, v_flux, t_flux, q_flux, salt_flux, lw_flux, sw_flux,
!! lprec, fprec, runoff, calving, p
!!
!! - FROM the ocean boundary TO the ice boundary (in flux_ocean_to_ice):
!!
!! u, v, t, s, frazil, sea_level
!!
!! - FROM the ice boundary TO the atmosphere boundary (in flux_up_to_atmos):
!!
!! t_surf
!!
!! - FROM the land boundary TO the atmosphere boundary (in
!! flux_up_to_atmos):
!!
!! t_ca, t_surf, q_ca
!!
!! See NOTES below for an explanation of the field names.
!!
!! \section diag_fields Diagnostic Fields
!!
!! The table below contains the available diagnostic fields is the `flux` diagnostic module.
!!
!! Field Name | Units | Description
!! ----------- | --------------- | -----------
!! land_mask | none | Fractional amount of land
!! wind | m/s | Wind speed for flux calculations
!! drag_moist | none | Drag coeff for moisture
!! drag_heat | none | Drag coeff for heat
!! drag_mom | none | Drag coeff for momentum
!! rough_moist | m | Surface roughness for moisture
!! rough_heat | m | Surface roughness for heat
!! rough_mom | m | Surface roughness for momentum
!! u_star | m/s | Friction velocity
!! b_star | m/s | Buoyancy scale
!! q_star | kg water/kg air | moisture scale
!! t_atm | deg_k | temperature at btm level
!! u_atm | m/s | u wind component at btm level
!! v_atm | m/s | v wind component at btm level
!! q_atm | kg/kg | specific humidity at btm level
!! p_atm | pa | pressure at btm level
!! z_atm | m | height of btm level
!! gust | m/s | gust scale
!! rh_ref | percent | relative humidity at ref height
!! t_ref | deg_k | temperature at ref height
!! u_ref | m/s | zonal wind component at ref height
!! v_ref | m/s | meridional wind component at ref height
!! del_h | none | ref height interp factor for heat
!! del_m | none | ref height interp factor for momentum
!! del_q | none | ref height interp factor for moisture
!! tau_x | pa | zonal wind stress
!! tau_y | pa | meridional wind stress
!! ice_mask | none | fractional amount of sea ice
!! t_surf | deg_k | surface temperature
!! t_ca | deg_k | canopy air temperature
!! q_surf | kg/kg | surface specific humidity
!! shflx | w/m2 | sensible heat flux
!! evap | kg/m2/s | evaporation rate
!! lwflx | w/m2 | net (down-up) longwave flux
!!
!! \section flux_exchange_config Flux Exchange Configuration
!!
!! flux_exchange_mod is configured via the flux_exchange_nml namelist in the `input.nml` file.
!! The following table are the available namelist variables.
!!
!! | Variable Name | Type | Default Value | Description
!! | --------------------- | ------- | ------------- | -----------
!! | z_ref_heat | real | 2.0 | Reference height (meters) for temperature and relative humidity diagnostics (t_ref, rh_ref, del_h, del_q) |
!! | z_ref_mom | real | 10.0 | Reference height (meters) for mementum diagnostics (u_ref, v_ref, del_m) |
!! | ex_u_start_smooth_bug | logical | .FALSE. | By default, the global exchange grid `u_star` will not be interpolated from atmospheric grid, this is different from Jakarta behavior and will change answers. So to preserve Jakarta behavior and reproduce answers explicitly set this namelist variable to .true. in input.nml. |
!! | sw1way_bug | logical | .FALSE. | |
!! | do_area_weighted_flux | logical | .FALSE. | |
!! | debug_stocks | logical | .FALSE. | |
!! | divert_stocks_report | logical | .FALSE. | |
!! | do_runoff | logical | .TRUE. | Turns on/off the land runoff interpolation to the ocean |
!! | do_forecast | logical | .FALSE. | |
!! | nblocks | integer | 1 | Specify number of blocks that n_xgrid_sfc is divided into. The main purpose is for Openmp implementation. Normally you may set nblocks to be coupler_nml atmos_nthreads. |
!!
!! \section main_example Main Program Example
!!
!! ~~~~~~~~~~{.f90}
!! DO slow time steps (ocean)
!! call flux_ocean_to_ice
!!
!! call ICE_SLOW_UP
!!
!! DO fast time steps (atmos)
!! call sfc_boundary_layer
!!
!! call ATMOS_DOWN
!!
!! call flux_down_from_atmos
!!
!! call LAND_FAST
!!
!! call ICE_FAST
!!
!! call flux_up_to_atmos
!!
!! call ATMOS_UP
!! END DO
!!
!! call ICE_SLOW_DN
!!
!! call flux_ice_to_ocean
!!
!! call OCEAN
!! END DO
!! ~~~~~~~~~~
!!
!! \note LAND_FAST and ICE_FAST must update the surface temperature
!!
!! \section Required Variables In Defined Data Types For Component Models
!!
!! \subsection Atmosphere
!!
!! ~~~~~~~~~~{.f90}
!! type (atmos_boundary_data_type) :: Atm
!!
!! real, dimension(:) :: Atm%lon_bnd & ! longitude axis grid box boundaries in radians
!! ! must be monotonic
!! Atm%lat_bnd ! latitude axis grid box boundaries in radians
!! ! must be monotonic
!! real, dimension(:,:) :: Atm%t_bot & ! temperature at lowest model level
!! Atm%q_bot & ! specific humidity at lowest model level
!! Atm%z_bot & ! height above the surface for the lowest model level (m)
!! Atm%p_bot & ! pressure at lowest model level (pa)
!! Atm%u_bot & ! zonal wind component at lowest model level (m/s)
!! Atm%v_bot & ! meridional wind component at lowest model level (m/s)
!! Atm%p_surf & ! surface pressure (pa)
!! Atm%slp & ! sea level pressure (pa)
!! Atm%gust & ! gustiness factor (m/s)
!! Atm%flux_sw & ! net shortwave flux at the surface
!! Atm%flux_lw & ! downward longwave flux at the surface
!! Atm%lprec & ! liquid precipitation (kg/m2)
!! Atm%fprec & ! water equivalent frozen precipitation (kg/m2)
!! Atm%coszen & ! cosine of the zenith angle
!! integer, dimension(4) :: Atm%axes ! Axis identifiers returned by diag_axis_init for the
!! ! atmospheric model axes: X, Y, Z_full, Z_half.
!! ~~~~~~~~~~
!!
!! The following five fields are gathered into a data type for convenience in passing
!! this information through the different levels of the atmospheric model --
!! these fields are rlated to the simultaneous implicit time steps in the
!! atmosphere and surface models -- they are described more fully in
!! flux_exchange.tech.ps and in the documntation for vert_diff_mod
!!
!! ~~~~~~~~~~{.f90}
!! type (surf_diff_type) :: Atm%Surf_Diff
!!
!! real, dimension(:,:) :: Atm%Surf_Diff%dtmass & ! dt/mass where dt = atmospheric time step ((i+1) = (i-1) for leapfrog) (s)
!! ! mass = mass per unit area of lowest atmosphehic layer (Kg/m2))
!! Atm%Surf_Diff%delta_t & ! increment ((i+1) = (i-1) for leapfrog) in temperature of
!! ! lowest atmospheric layer (K)
!! Atm%Surf_Diff%delta_q & ! increment ((i+1) = (i-1) for leapfrog) in specific humidity of
!! ! lowest atmospheric layer (nondimensional -- Kg/Kg)
!! Atm%Surf_Diff%dflux_t & ! derivative of implicit part of downward temperature flux at top of lowest
!! ! atmospheric layer with respect to temperature
!! ! of lowest atmospheric layer (Kg/(m2 s))
!! Atm%Surf_Diff%dflux_q ! derivative of implicit part of downward moisture flux at top of lowest
!! ! atmospheric layer with respect to specific humidity of
!! ! of lowest atmospheric layer (Kg/(m2 s))
!! ~~~~~~~~~~
!!
!! \subsection Land
!!
!! ~~~~~~~~~~{.f90}
!! type (land_boundary_data_type) :: Land
!!
!! real, dimension(:) :: Land%lon_bnd & ! longitude axis grid box boundaries in radians
!! ! must be monotonic
!! Land%lat_bnd ! latitude axis grid box boundaries in radians
!! ! must be monotonic
!!
!! logical, dimension(:,:,:) :: Land%mask & ! land/sea mask (true for land)
!! Land%glacier ! glacier mask (true for glacier)
!!
!! real, dimension(:,:,:) :: Land%tile_size & ! fractional area of each tile (partition)
!! Land%t_surf & ! surface temperature (deg k)
!! Land%albedo & ! surface albedo (fraction)
!! Land%rough_mom & ! surface roughness for momentum (m)
!! Land%rough_heat & ! surface roughness for heat/moisture (m)
!! Land%stomatal & ! stomatal resistance
!! Land%snow & ! snow depth (water equivalent) (kg/m2)
!! Land%water & ! water depth of the uppermost bucket (kg/m2)
!! Land%max_water ! maximum water depth allowed in the uppermost bucket (kg/m2)
!! ~~~~~~~~~~
!!
!! \subsection Ice
!!
!! ~~~~~~~~~~
!! type (ice_boundary_data_type) :: Ice
!!
!! real, dimension(:) :: Ice%lon_bnd & ! longitude axis grid box boundaries for temperature points
!! ! in radians (must be monotonic)
!! Ice%lat_bnd & ! latitude axis grid box boundaries for temperature points
!! ! in radians (must be monotonic)
!! Ice%lon_bnd_uv & ! longitude axis grid box boundaries for momentum points
!! ! in radians (must be monotonic)
!! Ice%lat_bnd_uv ! latitude axis grid box boundaries for momentum points
!! ! in radians (must be monotonic)
!!
!! logical, dimension(:,:,:) :: Ice%mask & ! ocean/land mask for temperature points
!! ! (true for ocean, with or without ice)
!! Ice%mask_uv & ! ocean/land mask for momentum points
!! ! (true for ocean, with or without ice)
!! Ice%ice_mask ! optional ice mask (true for ice)
!!
!! real, dimension(:,:,:) :: Ice%part_size & ! fractional area of each partition of a temperature grid box
!! Ice%part_size_uv ! fractional area of each partition of a momentum grid box
!! ~~~~~~~~~~
!!
!! The following fields are located on the ice top grid
!!
!! ~~~~~~~~~~{.f90}
!! real, dimension(:,:,:) :: Ice%t_surf & ! surface temperature (deg k)
!! Ice%albedo & ! surface albedo (fraction)
!! Ice%rough_mom & ! surface roughness for momentum (m)
!! Ice%rough_heat & ! surface roughness for heat/moisture (m)
!! Ice%u_surf & ! zonal (ocean/ice) current at the surface (m/s)
!! Ice%v_surf ! meridional (ocean/ice) current at the surface (m/s)
!! ~~~~~~~~~~
!!
!! The following fields are located on the ice bottom grid
!!
!! ~~~~~~~~~~{.f90}
!! real, dimension(:,:,:) :: Ice%flux_u & ! zonal wind stress (Pa)
!! Ice%flux_v & ! meridional wind stress (Pa)
!! Ice%flux_t & ! sensible heat flux (w/m2)
!! Ice%flux_q & ! specific humidity flux (kg/m2/s)
!! Ice%flux_sw & ! net (down-up) shortwave flux (w/m2)
!! Ice%flux_lw & ! net (down-up) longwave flux (w/m2)
!! Ice%lprec & ! mass of liquid precipitation since last time step (Kg/m2)
!! Ice%fprec & ! mass of frozen precipitation since last time step (Kg/m2)
!! Ice%runoff ! mass of runoff water since last time step (Kg/m2)
!! ~~~~~~~~~~
!!
!! \subsection Ocean
!!
!! ~~~~~~~~~~{.f90}
!! type (ocean_boundary_data_type) :: Ocean
!!
!! real, dimension(:) :: Ocean%Data%lon_bnd & ! longitude axis grid box boundaries for temperature
!! ! points on the ocean DATA GRID (radians)
!! Ocean%Data%lat_bnd & ! latitude axis grid box boundaries for temperature
!! ! points on the ocean DATA GRID (radians)
!! Ocean%Data%lon_bnd_uv & ! longitude axis grid box boundaries for momentum
!! ! points on the ocean DATA GRID (radians)
!! Ocean%Data%lat_bnd_uv & ! latitude axis grid box boundaries for momentum
!! ! points on the ocean DATA GRID (radians)
!! Ocean%Ocean%lon_bnd & ! longitude axis grid box boundaries for temperature
!! ! points on the ocean MODEL GRID (radians)
!! Ocean%Ocean%lat_bnd & ! latitude axis grid box boundaries for temperature
!! ! points on the ocean MODEL GRID (radians)
!! Ocean%Ocean%lon_bnd_uv & ! longitude axis grid box boundaries for momentum
!! ! points on the ocean MODEL GRID (radians)
!! Ocean%Ocean%lat_bnd_uv & ! latitude axis grid box boundaries for momentum
!! ! points on the ocean MODEL GRID (radians)
!! ~~~~~~~~~~
!!
!! \note The data values in all longitude and latitude grid box boundary
!! array must be monotonic.
!!
!! ~~~~~~~~~~{.f90}
!! logical, dimension(:,:) :: Ocean%Data%mask & ! ocean/land mask for temperature points on the ocean
!! ! DATA GRID (true for ocean)
!! Ocean%Data%mask_uv & ! ocean/land mask for momentum points on the ocean
!! ! DATA GRID (true for ocean)
!! Ocean%Ocean%mask & ! ocean/land mask for temperature points on the ocean
!! ! MODEL GRID (true for ocean)
!! Ocean%Ocean%mask_uv ! ocean/land mask for momentum points on the ocean
!! ! MODEL GRID (true for ocean)
!! real, dimension(:,:) :: Ocean%t_surf_data & ! surface temperature on the ocean DATA GRID (deg k)
!! Ocean%t_surf & ! surface temperature on the ocean MODEL GRID (deg k)
!! Ocean%u_surf & ! zonal ocean current at the surface on the ocean
!! ! MODEL GRID (m/s)
!! Ocean%v_surf & ! meridional ocean current at the surface on the
!! ! ocean MODEL GRID (m/s)
!! Ocean%frazil ! frazil at temperature points on the ocean MODEL GRID
!! ~~~~~~~~~~
module flux_exchange_mod
use mpp_mod, only: mpp_npes, mpp_pe, mpp_root_pe, &
mpp_error, stderr, stdout, stdlog, FATAL, NOTE, mpp_set_current_pelist, &
mpp_clock_id, mpp_clock_begin, mpp_clock_end, mpp_sum, mpp_max, &
CLOCK_COMPONENT, CLOCK_SUBCOMPONENT, CLOCK_ROUTINE, lowercase, &
input_nml_file
use mpp_domains_mod, only: mpp_get_compute_domain, mpp_get_compute_domains, &
mpp_global_sum, mpp_redistribute, operator(.EQ.)
use mpp_domains_mod, only: mpp_get_global_domain, mpp_get_data_domain
use mpp_domains_mod, only: mpp_set_global_domain, mpp_set_data_domain, mpp_set_compute_domain
use mpp_domains_mod, only: mpp_deallocate_domain, mpp_copy_domain, domain2d, mpp_compute_extent
use mpp_io_mod, only: mpp_close, mpp_open, MPP_MULTI, MPP_SINGLE, MPP_OVERWR
!model_boundary_data_type contains all model fields at the boundary.
!model1_model2_boundary_type contains fields that model2 gets
!from model1, may also include fluxes. These are declared by
!flux_exchange_mod and have private components. All model fields in
!model_boundary_data_type may not be exchanged.
!will support 3 types of flux_exchange:
!REGRID: physically distinct grids, via xgrid
!REDIST: same grid, transfer in index space only
!DIRECT: same grid, same decomp, direct copy
use atmos_model_mod, only: atmos_data_type, land_ice_atmos_boundary_type
use ocean_model_mod, only: ocean_public_type, ice_ocean_boundary_type
use ocean_model_mod, only: ocean_state_type
use ice_model_mod, only: ice_data_type, land_ice_boundary_type, &
ocean_ice_boundary_type, atmos_ice_boundary_type, Ice_stock_pe, &
ice_cell_area => cell_area
use land_model_mod, only: land_data_type, atmos_land_boundary_type
use surface_flux_mod, only: surface_flux
use monin_obukhov_mod, only: mo_profile
use xgrid_mod, only: xmap_type, setup_xmap, set_frac_area, &
put_to_xgrid, get_from_xgrid, &
xgrid_count, some, conservation_check, xgrid_init, &
get_ocean_model_area_elements, stock_integrate_2d, &
stock_move, stock_print
use diag_integral_mod, only: diag_integral_field_init, &
sum_diag_integral_field
use diag_manager_mod, only: register_diag_field, &
register_static_field, send_data, send_tile_averaged_data
use time_manager_mod, only: time_type
use sat_vapor_pres_mod, only: compute_qs
use constants_mod, only: rdgas, rvgas, cp_air, stefan, WTMAIR, HLV, HLF, Radius, PI, CP_OCEAN, &
WTMCO2, WTMC
!Balaji
!utilities stuff into use fms_mod
use fms_mod, only: clock_flag_default, check_nml_error, error_mesg
use fms_mod, only: open_namelist_file, write_version_number
use fms_mod, only: field_exist, field_size, read_data, get_mosaic_tile_grid
use data_override_mod, only: data_override
use coupler_types_mod, only: coupler_1d_bc_type
use atmos_ocean_fluxes_mod, only: atmos_ocean_fluxes_init, atmos_ocean_fluxes_calc
use ocean_model_mod, only: ocean_model_init_sfc, ocean_model_flux_init, ocean_model_data_get
use coupler_types_mod, only: coupler_type_copy
use coupler_types_mod, only: ind_psurf, ind_u10
use atmos_tracer_driver_mod, only: atmos_tracer_flux_init
use field_manager_mod, only: MODEL_ATMOS, MODEL_LAND, MODEL_ICE
use tracer_manager_mod, only: get_tracer_index
use tracer_manager_mod, only: get_tracer_names, get_number_tracers, NO_TRACER
use stock_constants_mod, only: NELEMS, ISTOCK_WATER, ISTOCK_HEAT, ISTOCK_SALT
use stock_constants_mod, only: ISTOCK_SIDE, ISTOCK_TOP, ISTOCK_BOTTOM , STOCK_UNITS, STOCK_NAMES
use stock_constants_mod, only: stocks_file, stocks_report, stocks_report_init
use stock_constants_mod, only: Atm_stock, Ocn_stock, Lnd_stock, Ice_stock
use land_model_mod, only: Lnd_stock_pe
use ocean_model_mod, only: Ocean_stock_pe
use atmos_model_mod, only: Atm_stock_pe
#ifdef SCM
! option to override various surface boundary conditions for SCM
use scm_forc_mod, only: do_specified_flux, scm_surface_flux, &
do_specified_tskin, TSKIN, &
do_specified_albedo, ALBEDO_OBS, &
do_specified_rough_leng, ROUGH_MOM, ROUGH_HEAT, &
do_specified_land
#endif
implicit none
include 'netcdf.inc'
private
character(len=48), parameter :: module_name = 'flux_exchange_mod'
public :: flux_exchange_init, &
sfc_boundary_layer, &
generate_sfc_xgrid, &
flux_down_from_atmos, &
flux_up_to_atmos, &
flux_land_to_ice, &
flux_ice_to_ocean, &
flux_ocean_to_ice, &
flux_check_stocks, &
flux_init_stocks, &
flux_ice_to_ocean_stocks,&
flux_ocean_from_ice_stocks
!-----------------------------------------------------------------------
character(len=128) :: version = '$Id$'
character(len=128) :: tag = '$Name$'
!-----------------------------------------------------------------------
!---- exchange grid maps -----
type(xmap_type), save :: xmap_sfc, xmap_runoff
integer :: n_xgrid_sfc=0, n_xgrid_runoff=0
!-----------------------------------------------------------------------
!-------- namelist (for diagnostics) ------
character(len=4), parameter :: mod_name = 'flux'
integer :: id_drag_moist, id_drag_heat, id_drag_mom, &
id_rough_moist, id_rough_heat, id_rough_mom, &
id_land_mask, id_ice_mask, &
id_u_star, id_b_star, id_q_star, id_u_flux, id_v_flux, &
id_t_surf, id_t_flux, id_r_flux, id_q_flux, id_slp, &
id_t_atm, id_u_atm, id_v_atm, id_wind, &
id_t_ref, id_rh_ref, id_u_ref, id_v_ref, id_wind_ref, &
id_del_h, id_del_m, id_del_q, id_rough_scale, &
id_t_ca, id_q_surf, id_q_atm, id_z_atm, id_p_atm, id_gust, &
id_t_ref_land, id_rh_ref_land, id_u_ref_land, id_v_ref_land, &
id_q_ref, id_q_ref_land, id_q_flux_land, id_rh_ref_cmip
integer :: id_co2_atm_dvmr, id_co2_surf_dvmr
integer, allocatable :: id_tr_atm(:), id_tr_surf(:), id_tr_flux(:), id_tr_mol_flux(:)
logical :: first_static = .true.
logical :: do_init = .true.
integer :: remap_method = 1
real, parameter :: bound_tol = 1e-7
real, parameter :: d622 = rdgas/rvgas
real, parameter :: d378 = 1.0-d622
real :: z_ref_heat = 2. !< Reference height (meters) for temperature and relative humidity diagnostics (t_ref, rh_ref, del_h, del_q)
real :: z_ref_mom = 10. !< Reference height (meters) for mementum diagnostics (u_ref, v_ref, del_m)
logical :: ex_u_star_smooth_bug = .false. !< By default, the global exchange grid \c u_star will not be interpolated
!! from atmospheric grid, this is different from Jakarta behavior and will
!! change answers. So to preserve Jakarta behavior and reproduce answers
!! explicitly set this namelist variable to .true. in input.nml.
logical :: sw1way_bug = .false.
logical :: do_area_weighted_flux = .FALSE.
logical :: debug_stocks = .FALSE.
logical :: divert_stocks_report = .FALSE.
logical :: do_runoff = .TRUE. !< Turns on/off the land runoff interpolation to the ocean
logical :: do_forecast = .false.
integer :: nblocks = 1
logical :: partition_fprec_from_lprec = .FALSE. ! option for ATM override experiments where liquid+frozen precip are combined
! This option will convert liquid precip to snow when t_ref is less than
! tfreeze parameter
real, parameter :: tfreeze = 273.15
namelist /flux_exchange_nml/ z_ref_heat, z_ref_mom, ex_u_star_smooth_bug, sw1way_bug, &
do_area_weighted_flux, debug_stocks, divert_stocks_report, do_runoff, do_forecast, nblocks, &
partition_fprec_from_lprec
integer :: my_nblocks = 1
integer, allocatable :: block_start(:), block_end(:)
! ---- allocatable module storage --------------------------------------------
real, allocatable, dimension(:) :: &
! NOTE: T canopy is only differet from t_surf over vegetated land
ex_t_surf, & !< surface temperature for radiation calc, degK
ex_t_surf_miz,& !< miz
ex_t_ca, & !< near-surface (canopy) air temperature, degK
ex_p_surf, & !< surface pressure
ex_slp, & !< surface pressure
ex_flux_t, & !< sens heat flux
ex_flux_lw, & !< longwave radiation flux
ex_dhdt_surf, & !< d(sens.heat.flux)/d(T canopy)
ex_dedt_surf, & !< d(water.vap.flux)/d(T canopy)
ex_dqsatdt_surf, & !< d(water.vap.flux)/d(q canopy)
ex_e_q_n, &
ex_drdt_surf, & !< d(LW flux)/d(T surf)
ex_dhdt_atm, & !< d(sens.heat.flux)/d(T atm)
ex_flux_u, & !< u stress on atmosphere
ex_flux_v, & !< v stress on atmosphere
ex_dtaudu_atm,& !< d(stress)/d(u)
ex_dtaudv_atm,& !< d(stress)/d(v)
ex_albedo_fix,&
ex_albedo_vis_dir_fix,&
ex_albedo_nir_dir_fix,&
ex_albedo_vis_dif_fix,&
ex_albedo_nir_dif_fix,&
ex_old_albedo,& !< old value of albedo for downward flux calculations
ex_drag_q, & !< q drag.coeff.
ex_cd_t, &
ex_cd_m, &
ex_b_star, &
ex_u_star, &
ex_wind, &
ex_z_atm
#ifdef SCM
real, allocatable, dimension(:) :: &
ex_dhdt_surf_forland, &
ex_dedt_surf_forland, &
ex_dedq_surf_forland
#endif
real, allocatable, dimension(:,:) :: &
ex_tr_surf, & !< near-surface tracer fields
ex_flux_tr, & !< tracer fluxes
ex_dfdtr_surf, & !< d(tracer flux)/d(surf tracer)
ex_dfdtr_atm, & !< d(tracer flux)/d(atm tracer)
ex_e_tr_n, & !< coefficient in implicit scheme
ex_f_tr_delt_n !< coefficient in implicit scheme
logical, allocatable, dimension(:) :: &
ex_avail, & !< true where data on exchange grid are available
ex_land !< true if exchange grid cell is over land
real, allocatable, dimension(:) :: &
ex_e_t_n, &
ex_f_t_delt_n
integer :: n_atm_tr !< number of prognostic tracers in the atmos model
integer :: n_atm_tr_tot !< number of prognostic tracers in the atmos model
integer :: n_lnd_tr !< number of prognostic tracers in the land model
integer :: n_lnd_tr_tot !< number of prognostic tracers in the land model
integer :: n_exch_tr !< number of tracers exchanged between models
type :: tracer_ind_type
integer :: atm, ice, lnd !< indices of the tracer in the respective models
end type
type(tracer_ind_type), allocatable :: tr_table(:) !< table of tracer indices
type :: tracer_exch_ind_type
integer :: exch = 0 !< exchange grid index
integer :: ice = 0 !< ice model index
integer :: lnd = 0 !< land model index
end type tracer_exch_ind_type
type(tracer_exch_ind_type), allocatable :: tr_table_map(:) !< map atm tracers to exchange, ice and land variables
integer :: isphum = NO_TRACER !< index of specific humidity tracer in tracer table
integer :: ico2 = NO_TRACER !< index of co2 tracer in tracer table
type(coupler_1d_bc_type), save :: ex_gas_fields_atm !< gas fields in atm
!< Place holder for various atmospheric fields.
type(coupler_1d_bc_type), save :: ex_gas_fields_ice ! gas fields on ice
type(coupler_1d_bc_type), save :: ex_gas_fluxes ! gas flux
!< Place holder of intermediate calculations, such as
!< piston velocities etc.
integer :: ni_atm, nj_atm !< to do atmos diagnostic from flux_ocean_to_ice
real, dimension(3) :: ccc !< for conservation checks
!Balaji, sets boundary_type%xtype
! REGRID: grids are physically different, pass via exchange grid
! REDIST: same physical grid, different decomposition, must move data around
! DIRECT: same physical grid, same domain decomposition, can directly copy data
integer, parameter :: REGRID=1, REDIST=2, DIRECT=3
!Balaji: clocks moved into flux_exchange
integer :: cplClock, sfcClock, fluxAtmDnClock, fluxLandIceClock, &
fluxIceOceanClock, fluxOceanIceClock, regenClock, fluxAtmUpClock, &
cplOcnClock
logical :: ocn_pe, ice_pe
integer, allocatable, dimension(:) :: ocn_pelist, ice_pelist
! Exchange grid indices
integer :: X1_GRID_ATM, X1_GRID_ICE, X1_GRID_LND
integer :: X2_GRID_LND, X2_GRID_ICE
real :: Dt_atm, Dt_cpl
real :: ATM_PRECIP_NEW
integer :: runoff_id_diag =-1
integer :: nxc_ocn=0, nyc_ocn=0, nxc_ice=0, nyc_ice=0, nk_ice=0
contains
!#######################################################################
!> \brief Initialization routine.
!!
!! Initializes the interpolation routines,diagnostics and boundary data
!!
!! \throw FATAL, "grid_spec.nc incompatible with atmosphere resolution"
!! The atmosphere grid size from file grid_spec.nc is not compatible with the atmosphere
!! resolution from atmosphere model.
!! \throw FATAL, "grid_spec.nc incompatible with atmosphere longitudes (see xba.dat and yba.dat)"
!! The longitude from file grid_spec.nc ( from field yba ) is different from the longitude from atmosphere model.
!! \throw FATAL, "grid_spec.nc incompatible with atmosphere longitudes (see xba.dat and yba.dat)"
!! The longitude from file grid_spec.nc ( from field xba ) is different from the longitude from atmosphere model.
!! \throw FATAL, "grid_spec.nc incompatible with atmosphere latitudes (see grid_spec.nc)"
!! The latitude from file grid_spec.nc is different from the latitude from atmosphere model.
subroutine flux_exchange_init ( Time, Atm, Land, Ice, Ocean, Ocean_state,&
atmos_ice_boundary, land_ice_atmos_boundary, &
land_ice_boundary, ice_ocean_boundary, ocean_ice_boundary, &
dt_atmos, dt_cpld )
type(time_type), intent(in) :: Time !< The model's current time
type(atmos_data_type), intent(inout) :: Atm !< A derived data type to specify atmosphere boundary data
type(land_data_type), intent(in) :: Land !< A derived data type to specify land boundary data
type(ice_data_type), intent(inout) :: Ice !< A derived data type to specify ice boundary data
type(ocean_public_type), intent(inout) :: Ocean !< A derived data type to specify ocean boundary data
type(ocean_state_type), pointer :: Ocean_state
! All intent(OUT) derived types with pointer components must be
! COMPLETELY allocated here and in subroutines called from here;
! NO pointer components should have been allocated before entry if the
! derived type has intent(OUT) otherwise they may be lost.
type(atmos_ice_boundary_type), intent(inout) :: atmos_ice_boundary !< A derived data type to specify properties and fluxes passed from atmosphere to ice
type(land_ice_atmos_boundary_type),intent(inout) :: land_ice_atmos_boundary !< A derived data type to specify properties and fluxes passed from exchange grid to
!! the atmosphere, land and ice
type(land_ice_boundary_type), intent(inout) :: land_ice_boundary !< A derived data type to specify properties and fluxes passed from land to ice
type(ice_ocean_boundary_type), intent(inout) :: ice_ocean_boundary !< A derived data type to specify properties and fluxes passed from ice to ocean
type(ocean_ice_boundary_type), intent(inout) :: ocean_ice_boundary !< A derived data type to specify properties and fluxes passed from ocean to ice
integer, optional, intent(in) :: dt_atmos !< Atmosphere time step in seconds
integer, optional, intent(in) :: dt_cpld !< Coupled time step in seconds
character(len=64), parameter :: sub_name = 'flux_exchange_init'
character(len=256), parameter :: note_header = '==>Note from ' // trim(module_name) // &
'(' // trim(sub_name) // '):'
character(len=64), parameter :: grid_file = 'INPUT/grid_spec.nc'
character(len=256) :: atm_mosaic_file, tile_file
type(domain2d) :: domain2
integer :: isg, ieg, jsg, jeg
integer :: isc, iec, jsc, jec
integer :: isd, ied, jsd, jed
integer :: isc2, iec2, jsc2, jec2
integer :: nxg, nyg, ioff, joff
integer :: unit, ierr, io, i, j
integer :: nlon, nlat, siz(4)
integer :: outunit, logunit
real, dimension(:,:), allocatable :: tmpx(:,:), tmpy(:,:)
real, dimension(:), allocatable :: atmlonb, atmlatb
integer :: is, ie, js, je, kd
character(32) :: tr_name
logical :: found
integer :: n, npes_atm, npes_ocn, npes_all
integer, allocatable :: pelist(:)
!-----------------------------------------------------------------------
!
! initialize atmos_ocean_fluxes
! Setting up flux types, allocates the arrays.
!
!
! ocean_tracer_flux_init is called first since it has the meaningful value to set
! for the input/output file names for the tracer flux values used in restarts. These
! values could be set in the field table, and this ordering allows this.
! atmos_tracer_flux_init is called last since it will use the values set in
! ocean_tracer_flux_init with the exception of atm_tr_index, which can only
! be meaningfully set from the atmospheric model (not from the field table)
!
call ocean_model_flux_init(Ocean_state)
call atmos_tracer_flux_init
call atmos_ocean_fluxes_init(ex_gas_fluxes, ex_gas_fields_atm, ex_gas_fields_ice)
!-----------------------------------------------------------------------
outunit = stdout(); logunit = stdlog()
!----- read namelist -------
#ifdef INTERNAL_FILE_NML
read (input_nml_file, flux_exchange_nml, iostat=io)
ierr = check_nml_error (io, 'flux_exchange_nml')
#else
unit = open_namelist_file()
ierr=1; do while (ierr /= 0)
read (unit, nml=flux_exchange_nml, iostat=io, end=10)
ierr = check_nml_error (io, 'flux_exchange_nml')
enddo
10 call mpp_close(unit)
#endif
!----- write namelist to logfile -----
call write_version_number (version, tag)
if( mpp_pe() == mpp_root_pe() )write( logunit, nml=flux_exchange_nml )
if(nblocks<1) call error_mesg ('flux_exchange_mod', &
'flux_exchange_nml nblocks must be positive', FATAL)
allocate(block_start(nblocks), block_end(nblocks))
!----- find out number of atmospheric prognostic tracers and index of specific
! humidity in the tracer table
call get_number_tracers (MODEL_ATMOS, num_tracers=n_atm_tr_tot, &
num_prog=n_atm_tr)
call get_number_tracers (MODEL_LAND, num_tracers=n_lnd_tr_tot, &
num_prog=n_lnd_tr)
! assemble the table of tracer number translation by matching names of
! prognostic tracers in the atmosphere and surface models; skip all atmos.
! tracers that have no corresponding surface tracers.
allocate(tr_table(n_atm_tr))
allocate(tr_table_map(n_atm_tr))
n = 1
do i = 1,n_atm_tr
call get_tracer_names( MODEL_ATMOS, i, tr_name )
tr_table(n)%atm = i
tr_table(n)%ice = get_tracer_index ( MODEL_ICE, tr_name )
tr_table_map(i)%ice = tr_table(n)%ice
tr_table(n)%lnd = get_tracer_index ( MODEL_LAND, tr_name )
tr_table_map(i)%lnd = tr_table(n)%lnd
if(tr_table(n)%ice/=NO_TRACER.or.tr_table(n)%lnd/=NO_TRACER) then
tr_table_map(i)%exch = n
n = n + 1
endif
enddo
n_exch_tr = n - 1
!
! Set up tracer table entries for ocean-atm gas fluxes where the names of tracers in the
! atmosphere and ocean may not be equal
!
do n = 1, ex_gas_fluxes%num_bcs !{
if (ex_gas_fluxes%bc(n)%atm_tr_index .gt. 0) then !{
found = .false.
do i = 1, n_exch_tr !{
if (ex_gas_fluxes%bc(n)%atm_tr_index .eq. tr_table(i)%atm) then
found = .true.
exit
endif
enddo !} i
if (.not. found) then
n_exch_tr = n_exch_tr + 1
tr_table(n_exch_tr)%atm = ex_gas_fluxes%bc(n)%atm_tr_index
tr_table(n_exch_tr)%ice = NO_TRACER ! because ocean-atm gas fluxes are not held in the ice model as tracers
tr_table(n_exch_tr)%lnd = NO_TRACER ! because this would have been found above
tr_table_map(n_exch_tr)%exch = n_exch_tr
tr_table_map(n_exch_tr)%ice = tr_table(n_exch_tr)%ice
tr_table_map(n_exch_tr)%lnd = tr_table(n_exch_tr)%lnd
endif
endif !}
enddo !} n
write(outunit,*) trim(note_header), ' Number of exchanged tracers = ', n_exch_tr
write(logunit,*) trim(note_header), ' Number of exchanged tracers = ', n_exch_tr
do i = 1,n_exch_tr
call get_tracer_names( MODEL_ATMOS, tr_table(i)%atm, tr_name )
write(outunit,*)'Tracer field name :'//trim(tr_name)
write(logunit,*)'Tracer field name :'//trim(tr_name)
enddo
! find out which tracer is specific humidity
! +fix-me-slm+ specific humidity may not be present if we are running with
! dry atmosphere. Besides, model may use mixing ratio ('mix_rat') (?). However,
! some atmos code also assumes 'sphum' is present, so for now the following
! code may be good enough.
do i = 1,n_exch_tr
call get_tracer_names( MODEL_ATMOS, tr_table(i)%atm, tr_name )
if(lowercase(tr_name)=='sphum') then
isphum = i
endif
! jgj: find out which exchange tracer is co2
if(lowercase(tr_name)=='co2') then
ico2 = i
write(outunit,*)'Exchange tracer index for '//trim(tr_name),' : ',ico2
endif
enddo
if (isphum==NO_TRACER) then
call error_mesg('flux_exchange_mod',&
'tracer "sphum" must be present in the atmosphere', FATAL )
endif
if (ico2==NO_TRACER) then
call error_mesg('flux_exchange_mod',&
'tracer "co2" not present in the atmosphere', NOTE )
endif
!--------- read gridspec file ------------------
!only atmos pelists needs to do it here, ocean model will do it elsewhere
ice_pe = Atm%pe
ocn_pe = Ocean%is_ocean_pe
allocate( ice_pelist(size(Atm%pelist)) ) !if ice/land become concurrent, this won't be true...
ice_pelist(:) = Atm%pelist(:)
allocate( ocn_pelist(size(Ocean%pelist)) )
ocn_pelist(:) = Ocean%pelist(:)
call get_ocean_model_area_elements(Ocean%domain, grid_file)
if( Atm%pe )then
call mpp_set_current_pelist(Atm%pelist)
!
! check atmosphere and grid_spec.nc have same atmosphere lat/lon boundaries
!
call mpp_get_global_domain(Atm%domain, isg, ieg, jsg, jeg, xsize=nxg, ysize=nyg)
call mpp_get_compute_domain(Atm%domain, isc, iec, jsc, jec)
call mpp_get_data_domain(Atm%domain, isd, ied, jsd, jed)
if(size(Atm%lon_bnd,1) .NE. iec-isc+2 .OR. size(Atm%lon_bnd,2) .NE. jec-jsc+2) then
call error_mesg ('flux_exchange_mod', &
'size of Atm%lon_bnd does not match the Atm computational domain', FATAL)
endif
ioff = lbound(Atm%lon_bnd,1) - isc
joff = lbound(Atm%lon_bnd,2) - jsc
if(field_exist(grid_file, "AREA_ATM" ) ) then ! old grid
call field_size(grid_file, "AREA_ATM", siz)
nlon = siz(1)
nlat = siz(2)
if (nlon /= nxg .or. nlat /= nyg) then
if (mpp_pe()==mpp_root_pe()) then
print *, 'grid_spec.nc has', nlon, 'longitudes,', nlat, 'latitudes; ', &
'atmosphere has', nxg, 'longitudes,', &
nyg, 'latitudes (see xba.dat and yba.dat)'
end if
call error_mesg ('flux_exchange_mod', &
'grid_spec.nc incompatible with atmosphere resolution', FATAL)
end if
allocate( atmlonb(isg:ieg+1) )
allocate( atmlatb(jsg:jeg+1) )
call read_data(grid_file, 'xba', atmlonb, no_domain=.true. )
call read_data(grid_file, 'yba', atmlatb, no_domain=.true. )
do i=isc, iec+1
if(abs(atmlonb(i)-Atm%lon_bnd(i+ioff,jsc+joff)*45.0/atan(1.0))>bound_tol) then
print *, 'GRID_SPEC/ATMOS LONGITUDE INCONSISTENCY at i= ',i, ': ', &
atmlonb(i), Atm%lon_bnd(i+ioff,jsc+joff)*45.0/atan(1.0)
call error_mesg ('flux_exchange_mod', &
'grid_spec.nc incompatible with atmosphere longitudes (see xba.dat and yba.dat)'&
, FATAL)
endif
enddo
do j=jsc, jec+1
if(abs(atmlatb(j)-Atm%lat_bnd(isc+ioff,j+joff)*45.0/atan(1.0))>bound_tol) then
print *, 'GRID_SPEC/ATMOS LATITUDE INCONSISTENCY at j= ',j, ': ', &
atmlatb(j), Atm%lat_bnd(isc+ioff, j+joff)*45.0/atan(1.0)
call error_mesg ('flux_exchange_mod', &
'grid_spec.nc incompatible with atmosphere latitudes (see xba.dat and yba.dat)'&
, FATAL)
endif
enddo
deallocate(atmlonb, atmlatb)
else if(field_exist(grid_file, "atm_mosaic_file" ) ) then ! mosaic grid file.
call read_data(grid_file, 'atm_mosaic_file', atm_mosaic_file)
call get_mosaic_tile_grid(tile_file, 'INPUT/'//trim(atm_mosaic_file), Atm%domain)
call field_size(tile_file, 'area', siz)
nlon = siz(1); nlat = siz(2)
if( mod(nlon,2) .NE. 0) call mpp_error(FATAL, &
'flux_exchange_mod: atmos supergrid longitude size can not be divided by 2')
if( mod(nlat,2) .NE. 0) call mpp_error(FATAL, &
'flux_exchange_mod: atmos supergrid latitude size can not be divided by 2')
nlon = nlon/2
nlat = nlat/2
if (nlon /= nxg .or. nlat /= nyg) then
if (mpp_pe()==mpp_root_pe()) then
print *, 'atmosphere mosaic tile has', nlon, 'longitudes,', nlat, 'latitudes; ', &
'atmosphere has', nxg, 'longitudes,', nyg, 'latitudes'
end if
call error_mesg ('flux_exchange_mod', &
'atmosphere mosaic tile grid file incompatible with atmosphere resolution', FATAL)
end if
call mpp_copy_domain(Atm%domain, domain2)
call mpp_set_compute_domain(domain2, 2*isc-1, 2*iec+1, 2*jsc-1, 2*jec+1, 2*(iec-isc)+3, 2*(jec-jsc)+3 )
call mpp_set_data_domain (domain2, 2*isd-1, 2*ied+1, 2*jsd-1, 2*jed+1, 2*(ied-isd)+3, 2*(jed-jsd)+3 )
call mpp_set_global_domain (domain2, 2*isg-1, 2*ieg+1, 2*jsg-1, 2*jeg+1, 2*(ieg-isg)+3, 2*(jeg-jsg)+3 )
call mpp_get_compute_domain(domain2, isc2, iec2, jsc2, jec2)
if(isc2 .NE. 2*isc-1 .OR. iec2 .NE. 2*iec+1 .OR. jsc2 .NE. 2*jsc-1 .OR. jec2 .NE. 2*jec+1) then
call mpp_error(FATAL, 'flux_exchange_mod: supergrid domain is not set properly')
endif
allocate(tmpx(isc2:iec2,jsc2:jec2), tmpy(isc2:iec2,jsc2:jec2) )
call read_data( tile_file, 'x', tmpx, domain2)
call read_data( tile_file, 'y', tmpy, domain2)
call mpp_deallocate_domain(domain2)
do j = jsc, jec+1
do i = isc, iec+1
if (abs(tmpx(2*i-1,2*j-1)-Atm%lon_bnd(i+ioff,j+joff)*45.0/atan(1.0))>bound_tol) then
print *, 'GRID_SPEC/ATMOS LONGITUDE INCONSISTENCY at i= ',i, ', j= ', j, ': ', &
tmpx(2*i-1,2*j-1), Atm%lon_bnd(i+ioff,j+joff)*45.0/atan(1.0)
call error_mesg ('flux_exchange_mod', &
'grid_spec.nc incompatible with atmosphere longitudes (see '//trim(tile_file)//')'&
,FATAL)
end if
if (abs(tmpy(2*i-1,2*j-1)-Atm%lat_bnd(i+ioff,j+joff)*45.0/atan(1.0))>bound_tol) then
print *, 'GRID_SPEC/ATMOS LATITUDE INCONSISTENCY at i= ',i, ', j= ', j, ': ', &
tmpy(2*i-1,2*j-1), Atm%lat_bnd(i+ioff,j+joff)*45.0/atan(1.0)