26 module coupler_types_mod
29 use fms2_io_mod,
only:
register_axis, unlimited, variable_exists, check_if_open
30 use fms2_io_mod,
only:
register_field, get_num_dimensions, variable_att_exists
31 use fms2_io_mod,
only: get_variable_attribute, get_dimension_size, get_dimension_names
32 use fms2_io_mod,
only: register_variable_attribute, get_variable_dimension_names
33 use fms2_io_mod,
only: get_variable_num_dimensions
34 #ifdef use_deprecated_io
36 use fms_io_mod,
only: query_initialized, restore_state
43 use fms_string_utils_mod,
only:
string
44 use platform_mod,
only: r4_kind, r8_kind, i8_kind, fms_file_len, fms_path_len
51 #include<file_version.h>
65 character(len=*),
parameter :: mod_name =
'coupler_types_mod'
81 character(len=48) :: name =
' '
82 logical :: mean = .true.
83 logical :: override = .false.
84 integer :: id_diag = 0
85 character(len=128) :: long_name =
' '
86 character(len=128) :: units =
' '
87 integer :: id_rest = 0
88 logical :: may_init = .true.
91 real(r8_kind),
pointer,
contiguous,
dimension(:,:,:) :: values => null()
99 character(len=48) :: name =
' '
100 integer :: num_fields = 0
102 character(len=128) :: flux_type =
' '
103 character(len=128) :: implementation =
' '
104 logical,
pointer,
dimension(:) :: flag => null()
105 integer :: atm_tr_index = 0
106 character(len=FMS_FILE_LEN) :: ice_restart_file =
' '
107 character(len=FMS_FILE_LEN) :: ocean_restart_file =
' '
108 #ifdef use_deprecated_io
109 type(restart_file_type),
pointer :: rest_type => null()
112 type(fmsnetcdfdomainfile_t),
pointer :: fms2_io_rest_type => null()
114 logical :: use_atm_pressure
115 logical :: use_10m_wind_speed
116 logical :: pass_through_ice
117 real(r8_kind),
pointer,
dimension(:) :: param => null()
118 real(r8_kind) :: mol_wt = 0.0_r8_kind
124 character(len=48) :: name =
' '
125 logical :: mean = .true.
126 logical :: override = .false.
127 integer :: id_diag = 0
128 character(len=128) :: long_name =
' '
129 character(len=128) :: units =
' '
130 integer :: id_rest = 0
131 logical :: may_init = .true.
134 real(r4_kind),
pointer,
contiguous,
dimension(:,:,:) :: values => null()
142 character(len=48) :: name =
' '
143 integer :: num_fields = 0
145 character(len=128) :: flux_type =
' '
146 character(len=128) :: implementation =
' '
147 logical,
pointer,
dimension(:) :: flag => null()
148 integer :: atm_tr_index = 0
149 character(len=FMS_FILE_LEN) :: ice_restart_file =
' '
150 character(len=FMS_FILE_LEN) :: ocean_restart_file =
' '
151 #ifdef use_deprecated_io
152 type(restart_file_type),
pointer :: rest_type => null()
155 type(fmsnetcdfdomainfile_t),
pointer :: fms2_io_rest_type => null()
157 logical :: use_atm_pressure
158 logical :: use_10m_wind_speed
159 logical :: pass_through_ice
163 real(r8_kind),
pointer,
dimension(:) :: param => null()
164 real(r8_kind) :: mol_wt = 0.0_r8_kind
170 integer :: num_bcs = 0
174 logical :: set = .false.
175 integer :: isd, isc, iec, ied
176 integer :: jsd, jsc, jec, jed
184 character(len=48) :: name =
' '
185 real(r8_kind),
pointer,
contiguous,
dimension(:,:) :: values => null()
188 logical :: mean = .true.
189 logical :: override = .false.
190 integer :: id_diag = 0
191 character(len=128) :: long_name =
' '
192 character(len=128) :: units =
' '
193 integer :: id_rest = 0
194 logical :: may_init = .true.
202 character(len=48) :: name =
' '
203 integer :: num_fields = 0
205 character(len=128) :: flux_type =
' '
206 character(len=128) :: implementation =
' '
207 real(r8_kind),
pointer,
dimension(:) :: param => null()
208 logical,
pointer,
dimension(:) :: flag => null()
209 integer :: atm_tr_index = 0
210 character(len=FMS_FILE_LEN) :: ice_restart_file =
' '
211 character(len=FMS_FILE_LEN) :: ocean_restart_file =
' '
212 #ifdef use_deprecated_io
213 type(restart_file_type),
pointer :: rest_type => null()
216 type(fmsnetcdfdomainfile_t),
pointer :: fms2_io_rest_type => null()
218 logical :: use_atm_pressure
219 logical :: use_10m_wind_speed
220 logical :: pass_through_ice
221 real(r8_kind) :: mol_wt = 0.0_r8_kind
227 character(len=44) :: name =
' '
228 real(r4_kind),
pointer,
contiguous,
dimension(:,:) :: values => null()
231 logical :: mean = .true.
232 logical :: override = .false.
233 integer :: id_diag = 0
234 character(len=124) :: long_name =
' '
235 character(len=124) :: units =
' '
236 integer :: id_rest = 0
237 logical :: may_init = .true.
245 character(len=44) :: name =
' '
246 integer :: num_fields = 0
248 character(len=124) :: flux_type =
' '
249 character(len=124) :: implementation =
' '
253 real(r8_kind),
pointer,
dimension(:) :: param => null()
254 logical,
pointer,
dimension(:) :: flag => null()
255 integer :: atm_tr_index = 0
256 character(len=FMS_FILE_LEN) :: ice_restart_file =
' '
257 character(len=FMS_FILE_LEN) :: ocean_restart_file =
' '
258 #ifdef use_deprecated_io
259 type(restart_file_type),
pointer :: rest_type => null()
262 type(fmsnetcdfdomainfile_t),
pointer :: fms2_io_rest_type => null()
264 logical :: use_atm_pressure
265 logical :: use_10m_wind_speed
266 logical :: pass_through_ice
267 real(r8_kind) :: mol_wt = 0.0_r8_kind
273 integer :: num_bcs = 0
278 logical :: set = .false.
279 integer :: isd, isc, iec, ied
280 integer :: jsd, jsc, jec, jed
286 character(len=48) :: name =
' '
287 real(r8_kind),
pointer,
dimension(:) :: values => null()
288 logical :: mean = .true.
289 logical :: override = .false.
290 integer :: id_diag = 0
291 character(len=128) :: long_name =
' '
292 character(len=128) :: units =
' '
293 logical :: may_init = .true.
301 character(len=48) :: name =
' '
302 integer :: num_fields = 0
304 character(len=128) :: flux_type =
' '
305 character(len=128) :: implementation =
' '
309 real(r8_kind),
pointer,
dimension(:) :: param => null()
310 logical,
pointer,
dimension(:) :: flag => null()
311 integer :: atm_tr_index = 0
312 character(len=FMS_FILE_LEN) :: ice_restart_file =
' '
313 character(len=FMS_FILE_LEN) :: ocean_restart_file =
' '
314 logical :: use_atm_pressure
315 logical :: use_10m_wind_speed
316 logical :: pass_through_ice
320 real(r8_kind) :: mol_wt = 0.0_r8_kind
327 character(len=48) :: name =
' '
328 real(r4_kind),
pointer,
dimension(:) :: values => null()
329 logical :: mean = .true.
330 logical :: override = .false.
331 integer :: id_diag = 0
332 character(len=128) :: long_name =
' '
333 character(len=128) :: units =
' '
334 logical :: may_init = .true.
342 character(len=48) :: name =
' '
343 integer :: num_fields = 0
345 character(len=128) :: flux_type =
' '
346 character(len=128) :: implementation =
' '
350 real(r8_kind),
pointer,
dimension(:) :: param => null()
351 logical,
pointer,
dimension(:) :: flag => null()
352 integer :: atm_tr_index = 0
353 character(len=FMS_FILE_LEN) :: ice_restart_file =
' '
354 character(len=FMS_FILE_LEN) :: ocean_restart_file =
' '
355 logical :: use_atm_pressure
356 logical :: use_10m_wind_speed
357 logical :: pass_through_ice
359 real(r8_kind) :: mol_wt = 0.0_r8_kind
366 integer :: num_bcs = 0
371 logical :: set = .false.
429 module procedure ct_rescale_data_2d_r4, ct_rescale_data_3d_r4
430 module procedure ct_rescale_data_2d_r8, ct_rescale_data_3d_r8
439 module procedure ct_increment_data_2d_3d_r4, ct_increment_data_2d_3d_r8
445 module procedure ct_extract_data_2d_r4, ct_extract_data_2d_r8
446 module procedure ct_extract_data_3d_r4, ct_extract_data_3d_r8
447 module procedure ct_extract_data_3d_2d_r4, ct_extract_data_3d_2d_r8
453 module procedure ct_set_data_2d_r4, ct_set_data_3d_r4, ct_set_data_2d_3d_r4
454 module procedure ct_set_data_2d_r8, ct_set_data_3d_r8, ct_set_data_2d_3d_r8
485 #ifdef use_deprecated_io
486 module procedure mpp_io_ct_register_restarts_2d, mpp_io_ct_register_restarts_3d
487 module procedure mpp_io_ct_register_restarts_to_file_2d, mpp_io_ct_register_restarts_to_file_3d
496 #ifdef use_deprecated_io
497 module procedure mpp_io_ct_restore_state_2d, mpp_io_ct_restore_state_3d
522 logical,
save :: module_is_initialized = .false.
525 if (module_is_initialized)
then
532 module_is_initialized = .true.
542 & diag_name, axes, time, suffix)
545 integer,
intent(in) :: is
546 integer,
intent(in) :: ie
547 integer,
intent(in) :: js
548 integer,
intent(in) :: je
549 character(len=*),
intent(in) :: diag_name
551 integer,
dimension(:),
intent(in) :: axes
553 character(len=*),
intent(in),
optional :: suffix
555 character(len=*),
parameter :: error_header =&
556 &
'==>Error from coupler_types_mod (coupler_type_copy_1d_2d):'
558 if (var_out%num_bcs > 0)
then
561 call mpp_error(fatal, trim(error_header) //
' Number of output fields exceeds zero')
564 if (var_in%num_bcs >= 0)&
565 &
call ct_spawn_1d_2d(var_in, var_out, (/ is, is, ie, ie /), (/ js, js, je, je /), suffix)
567 if ((var_out%num_bcs > 0) .and. (diag_name .ne.
' '))&
576 & diag_name, axes, time, suffix)
579 integer,
intent(in) :: is
580 integer,
intent(in) :: ie
581 integer,
intent(in) :: js
582 integer,
intent(in) :: je
583 integer,
intent(in) :: kd
584 character(len=*),
intent(in) :: diag_name
586 integer,
dimension(:),
intent(in) :: axes
588 character(len=*),
intent(in),
optional :: suffix
590 character(len=*),
parameter :: error_header =&
591 &
'==>Error from coupler_types_mod (coupler_type_copy_1d_3d):'
593 if (var_out%num_bcs > 0)
then
596 call mpp_error(fatal, trim(error_header) //
' Number of output fields exceeds zero')
599 if (var_in%num_bcs >= 0)&
600 &
call ct_spawn_1d_3d(var_in, var_out, (/ is, is, ie, ie /), (/ js, js, je, je /), (/1, kd/), suffix)
602 if ((var_out%num_bcs > 0) .and. (diag_name .ne.
' '))&
610 & diag_name, axes, time, suffix)
613 integer,
intent(in) :: is
614 integer,
intent(in) :: ie
615 integer,
intent(in) :: js
616 integer,
intent(in) :: je
617 character(len=*),
intent(in) :: diag_name
619 integer,
dimension(:),
intent(in) :: axes
621 character(len=*),
intent(in),
optional :: suffix
623 character(len=*),
parameter :: error_header =&
624 &
'==>Error from coupler_types_mod (coupler_type_copy_2d_2d):'
626 if (var_out%num_bcs > 0)
then
629 call mpp_error(fatal, trim(error_header) //
' Number of output fields exceeds zero')
632 if (var_in%num_bcs >= 0)&
633 &
call ct_spawn_2d_2d(var_in, var_out, (/ is, is, ie, ie /), (/ js, js, je, je /), suffix)
635 if ((var_out%num_bcs > 0) .and. (diag_name .ne.
' '))&
643 & diag_name, axes, time, suffix)
646 integer,
intent(in) :: is
647 integer,
intent(in) :: ie
648 integer,
intent(in) :: js
649 integer,
intent(in) :: je
650 integer,
intent(in) :: kd
651 character(len=*),
intent(in) :: diag_name
653 integer,
dimension(:),
intent(in) :: axes
655 character(len=*),
intent(in),
optional :: suffix
657 character(len=*),
parameter :: error_header =&
658 &
'==>Error from coupler_types_mod (coupler_type_copy_2d_3d):'
660 if (var_out%num_bcs > 0)
then
663 call mpp_error(fatal, trim(error_header) //
' Number of output fields exceeds zero')
666 if (var_in%num_bcs >= 0)&
667 &
call ct_spawn_2d_3d(var_in, var_out, (/ is, is, ie, ie /), (/ js, js, je, je /), (/1, kd/), suffix)
669 if ((var_out%num_bcs > 0) .and. (diag_name .ne.
' '))&
677 & diag_name, axes, time, suffix)
680 integer,
intent(in) :: is
681 integer,
intent(in) :: ie
682 integer,
intent(in) :: js
683 integer,
intent(in) :: je
684 character(len=*),
intent(in) :: diag_name
686 integer,
dimension(:),
intent(in) :: axes
688 character(len=*),
intent(in),
optional :: suffix
690 character(len=*),
parameter :: error_header =&
691 &
'==>Error from coupler_types_mod (coupler_type_copy_3d_2d):'
693 if (var_out%num_bcs > 0)
then
696 call mpp_error(fatal, trim(error_header) //
' Number of output fields exceeds zero')
699 if (var_in%num_bcs >= 0)&
700 &
call ct_spawn_3d_2d(var_in, var_out, (/ is, is, ie, ie /), (/ js, js, je, je /), suffix)
702 if ((var_out%num_bcs > 0) .and. (diag_name .ne.
' '))&
710 & diag_name, axes, time, suffix)
713 integer,
intent(in) :: is
714 integer,
intent(in) :: ie
715 integer,
intent(in) :: js
716 integer,
intent(in) :: je
717 integer,
intent(in) :: kd
718 character(len=*),
intent(in) :: diag_name
720 integer,
dimension(:),
intent(in) :: axes
722 character(len=*),
intent(in),
optional :: suffix
724 character(len=*),
parameter :: error_header =&
725 &
'==>Error from coupler_types_mod (coupler_type_copy_3d_3d):'
727 if (var_out%num_bcs > 0)
then
730 call mpp_error(fatal, trim(error_header) //
' Number of output fields exceeds zero')
733 if (var_in%num_bcs >= 0)&
734 &
call ct_spawn_3d_3d(var_in, var_out, (/ is, is, ie, ie /), (/ js, js, je, je /), (/1, kd/), suffix)
736 if ((var_out%num_bcs > 0) .and. (diag_name .ne.
' '))&
753 integer,
dimension(4),
intent(in) :: idim
755 integer,
dimension(4),
intent(in) :: jdim
757 character(len=*),
optional,
intent(in) :: suffix
758 logical,
optional,
intent(in) :: as_needed
761 character(len=*),
parameter :: error_header =&
762 &
'==>Error from coupler_types_mod (CT_spawn_1d_2d):'
763 character(len=400) :: error_msg
766 if (
present(as_needed))
then
768 if ((var%set) .or. (.not.var_in%set))
return
773 &
call mpp_error(fatal, trim(error_header) //
' The output type has already been initialized.')
774 if (.not.var_in%set)&
775 &
call mpp_error(fatal, trim(error_header) //
' The parent type has not been initialized.')
778 if(var_in%num_bcs .gt. 0)
then
779 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
780 if(
associated(var_in%bc) )
then
781 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both intialized,"//&
782 " only one should be associated per type.")
784 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both uninitialized,"//&
785 " one must be associated to copy field data.")
790 var%num_bcs = var_in%num_bcs
793 if ((idim(1) > idim(2)) .or. (idim(3) > idim(4)))
then
794 write (error_msg, *) trim(error_header),
' Disordered i-dimension index bound list ', idim
797 if ((jdim(1) > jdim(2)) .or. (jdim(3) > jdim(4)))
then
798 write (error_msg, *) trim(error_header),
' Disordered j-dimension index bound list ', jdim
801 var%isd = idim(1) ; var%isc = idim(2) ; var%iec = idim(3) ; var%ied = idim(4)
802 var%jsd = jdim(1) ; var%jsc = jdim(2) ; var%jec = jdim(3) ; var%jed = jdim(4)
804 if (var%num_bcs > 0)
then
805 if (
associated(var_in%bc))
then
806 if (
associated(var%bc))
then
807 call mpp_error(fatal, trim(error_header) //
' var%bc already associated')
809 allocate ( var%bc(var%num_bcs) )
810 do n = 1, var%num_bcs
811 var%bc(n)%name = var_in%bc(n)%name
812 var%bc(n)%atm_tr_index = var_in%bc(n)%atm_tr_index
813 var%bc(n)%flux_type = var_in%bc(n)%flux_type
814 var%bc(n)%implementation = var_in%bc(n)%implementation
815 var%bc(n)%ice_restart_file = var_in%bc(n)%ice_restart_file
816 var%bc(n)%ocean_restart_file = var_in%bc(n)%ocean_restart_file
817 var%bc(n)%use_atm_pressure = var_in%bc(n)%use_atm_pressure
818 var%bc(n)%use_10m_wind_speed = var_in%bc(n)%use_10m_wind_speed
819 var%bc(n)%pass_through_ice = var_in%bc(n)%pass_through_ice
820 var%bc(n)%mol_wt = var_in%bc(n)%mol_wt
821 var%bc(n)%num_fields = var_in%bc(n)%num_fields
822 if (
associated(var%bc(n)%field))
then
823 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field already associated'
826 allocate ( var%bc(n)%field(var%bc(n)%num_fields) )
827 do m = 1, var%bc(n)%num_fields
828 if (
present(suffix))
then
829 var%bc(n)%field(m)%name = trim(var_in%bc(n)%field(m)%name) // trim(suffix)
831 var%bc(n)%field(m)%name = var_in%bc(n)%field(m)%name
833 var%bc(n)%field(m)%long_name = var_in%bc(n)%field(m)%long_name
834 var%bc(n)%field(m)%units = var_in%bc(n)%field(m)%units
835 var%bc(n)%field(m)%may_init = var_in%bc(n)%field(m)%may_init
836 var%bc(n)%field(m)%mean = var_in%bc(n)%field(m)%mean
837 if (
associated(var%bc(n)%field(m)%values))
then
838 write (error_msg, *) trim(error_header),&
839 &
' var%bc(', n,
')%field(', m,
')%values already associated'
843 allocate ( var%bc(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed) )
844 var%bc(n)%field(m)%values(:,:) = 0.0_r8_kind
847 else if(
associated(var_in%bc_r4))
then
848 if (
associated(var%bc_r4))
then
849 call mpp_error(fatal, trim(error_header) //
' var%bc_r4 already associated')
851 allocate ( var%bc_r4(var%num_bcs) )
852 do n = 1, var%num_bcs
853 var%bc_r4(n)%name = var_in%bc_r4(n)%name
854 var%bc_r4(n)%atm_tr_index = var_in%bc_r4(n)%atm_tr_index
855 var%bc_r4(n)%flux_type = var_in%bc_r4(n)%flux_type
856 var%bc_r4(n)%implementation = var_in%bc_r4(n)%implementation
857 var%bc_r4(n)%ice_restart_file = var_in%bc_r4(n)%ice_restart_file
858 var%bc_r4(n)%ocean_restart_file = var_in%bc_r4(n)%ocean_restart_file
859 var%bc_r4(n)%use_atm_pressure = var_in%bc_r4(n)%use_atm_pressure
860 var%bc_r4(n)%use_10m_wind_speed = var_in%bc_r4(n)%use_10m_wind_speed
861 var%bc_r4(n)%pass_through_ice = var_in%bc_r4(n)%pass_through_ice
862 var%bc_r4(n)%mol_wt = var_in%bc_r4(n)%mol_wt
863 var%bc_r4(n)%num_fields = var_in%bc_r4(n)%num_fields
864 if (
associated(var%bc_r4(n)%field))
then
865 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field already associated'
868 allocate ( var%bc_r4(n)%field(var%bc_r4(n)%num_fields) )
869 do m = 1, var%bc_r4(n)%num_fields
870 if (
present(suffix))
then
871 var%bc_r4(n)%field(m)%name = trim(var_in%bc_r4(n)%field(m)%name) // trim(suffix)
873 var%bc_r4(n)%field(m)%name = var_in%bc_r4(n)%field(m)%name
875 var%bc_r4(n)%field(m)%long_name = var_in%bc_r4(n)%field(m)%long_name
876 var%bc_r4(n)%field(m)%units = var_in%bc_r4(n)%field(m)%units
877 var%bc_r4(n)%field(m)%may_init = var_in%bc_r4(n)%field(m)%may_init
878 var%bc_r4(n)%field(m)%mean = var_in%bc_r4(n)%field(m)%mean
879 if (
associated(var%bc_r4(n)%field(m)%values))
then
880 write (error_msg, *) trim(error_header),&
881 &
' var%bc_r4(', n,
')%field(', m,
')%values already associated'
885 allocate ( var%bc_r4(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed) )
886 var%bc_r4(n)%field(m)%values(:,:) = 0.0_r4_kind
890 call mpp_error(fatal, error_header//
"passed in type has unassociated coupler_field_type"// &
891 " pointers for both bc and bc_r4")
908 integer,
dimension(4),
intent(in) :: idim
910 integer,
dimension(4),
intent(in) :: jdim
912 integer,
dimension(2),
intent(in) :: kdim
914 character(len=*),
optional,
intent(in) :: suffix
915 logical,
optional,
intent(in) :: as_needed
918 character(len=*),
parameter :: error_header =&
919 &
'==>Error from coupler_types_mod (CT_spawn_1d_3d):'
920 character(len=400) :: error_msg
923 if (
present(as_needed))
then
925 if ((var%set) .or. (.not.var_in%set))
return
930 &
call mpp_error(fatal, trim(error_header) //
' The output type has already been initialized.')
931 if (.not.var_in%set)&
932 &
call mpp_error(fatal, trim(error_header) //
' The parent type has not been initialized.')
935 if(var_in%num_bcs .gt. 0)
then
936 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
937 if(
associated(var_in%bc))
then
938 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both intialized,"// &
939 " only one should be associated per type")
941 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both unintialized,"// &
942 " one must be associated to copy field data")
947 var%num_bcs = var_in%num_bcs
951 if ((idim(1) > idim(2)) .or. (idim(3) > idim(4)))
then
952 write (error_msg, *) trim(error_header),
' Disordered i-dimension index bound list ', idim
955 if ((jdim(1) > jdim(2)) .or. (jdim(3) > jdim(4)))
then
956 write (error_msg, *) trim(error_header),
' Disordered j-dimension index bound list ', jdim
959 var%isd = idim(1) ; var%isc = idim(2) ; var%iec = idim(3) ; var%ied = idim(4)
960 var%jsd = jdim(1) ; var%jsc = jdim(2) ; var%jec = jdim(3) ; var%jed = jdim(4)
961 var%ks = kdim(1) ; var%ke = kdim(2)
963 if (var%num_bcs > 0)
then
964 if (kdim(1) > kdim(2))
then
965 write (error_msg, *) trim(error_header),
' Disordered k-dimension index bound list ', kdim
968 if(
associated(var_in%bc))
then
969 if (
associated(var%bc))
then
970 call mpp_error(fatal, trim(error_header) //
' var%bc already associated')
972 allocate ( var%bc(var%num_bcs) )
973 do n = 1, var%num_bcs
974 var%bc(n)%name = var_in%bc(n)%name
975 var%bc(n)%atm_tr_index = var_in%bc(n)%atm_tr_index
976 var%bc(n)%flux_type = var_in%bc(n)%flux_type
977 var%bc(n)%implementation = var_in%bc(n)%implementation
978 var%bc(n)%ice_restart_file = var_in%bc(n)%ice_restart_file
979 var%bc(n)%ocean_restart_file = var_in%bc(n)%ocean_restart_file
980 var%bc(n)%use_atm_pressure = var_in%bc(n)%use_atm_pressure
981 var%bc(n)%use_10m_wind_speed = var_in%bc(n)%use_10m_wind_speed
982 var%bc(n)%pass_through_ice = var_in%bc(n)%pass_through_ice
983 var%bc(n)%mol_wt = var_in%bc(n)%mol_wt
984 var%bc(n)%num_fields = var_in%bc(n)%num_fields
985 if (
associated(var%bc(n)%field))
then
986 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field already associated'
989 allocate ( var%bc(n)%field(var%bc(n)%num_fields) )
990 do m = 1, var%bc(n)%num_fields
991 if (
present(suffix))
then
992 var%bc(n)%field(m)%name = trim(var_in%bc(n)%field(m)%name) // trim(suffix)
994 var%bc(n)%field(m)%name = var_in%bc(n)%field(m)%name
996 var%bc(n)%field(m)%long_name = var_in%bc(n)%field(m)%long_name
997 var%bc(n)%field(m)%units = var_in%bc(n)%field(m)%units
998 var%bc(n)%field(m)%may_init = var_in%bc(n)%field(m)%may_init
999 var%bc(n)%field(m)%mean = var_in%bc(n)%field(m)%mean
1000 if (
associated(var%bc(n)%field(m)%values))
then
1001 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field(', m,
')%values already associated'
1005 allocate ( var%bc(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed,var%ks:var%ke) )
1006 var%bc(n)%field(m)%values(:,:,:) = 0.0_r8_kind
1009 else if(
associated(var_in%bc_r4))
then
1010 if (
associated(var%bc_r4))
then
1011 call mpp_error(fatal, trim(error_header) //
' var%bc_r4 already associated')
1013 allocate ( var%bc_r4(var%num_bcs) )
1014 do n = 1, var%num_bcs
1015 var%bc_r4(n)%name = var_in%bc_r4(n)%name
1016 var%bc_r4(n)%atm_tr_index = var_in%bc_r4(n)%atm_tr_index
1017 var%bc_r4(n)%flux_type = var_in%bc_r4(n)%flux_type
1018 var%bc_r4(n)%implementation = var_in%bc_r4(n)%implementation
1019 var%bc_r4(n)%ice_restart_file = var_in%bc_r4(n)%ice_restart_file
1020 var%bc_r4(n)%ocean_restart_file = var_in%bc_r4(n)%ocean_restart_file
1021 var%bc_r4(n)%use_atm_pressure = var_in%bc_r4(n)%use_atm_pressure
1022 var%bc_r4(n)%use_10m_wind_speed = var_in%bc_r4(n)%use_10m_wind_speed
1023 var%bc_r4(n)%pass_through_ice = var_in%bc_r4(n)%pass_through_ice
1024 var%bc_r4(n)%mol_wt = var_in%bc_r4(n)%mol_wt
1025 var%bc_r4(n)%num_fields = var_in%bc_r4(n)%num_fields
1026 if (
associated(var%bc_r4(n)%field))
then
1027 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field already associated'
1030 allocate ( var%bc_r4(n)%field(var%bc_r4(n)%num_fields) )
1031 do m = 1, var%bc_r4(n)%num_fields
1032 if (
present(suffix))
then
1033 var%bc_r4(n)%field(m)%name = trim(var_in%bc_r4(n)%field(m)%name) // trim(suffix)
1035 var%bc_r4(n)%field(m)%name = var_in%bc_r4(n)%field(m)%name
1037 var%bc_r4(n)%field(m)%long_name = var_in%bc_r4(n)%field(m)%long_name
1038 var%bc_r4(n)%field(m)%units = var_in%bc_r4(n)%field(m)%units
1039 var%bc_r4(n)%field(m)%may_init = var_in%bc_r4(n)%field(m)%may_init
1040 var%bc_r4(n)%field(m)%mean = var_in%bc_r4(n)%field(m)%mean
1041 if (
associated(var%bc_r4(n)%field(m)%values))
then
1042 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field(', m,
')%values already associated'
1046 allocate ( var%bc_r4(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed,var%ks:var%ke) )
1047 var%bc_r4(n)%field(m)%values(:,:,:) = 0.0_r4_kind
1051 call mpp_error(fatal, error_header//
"passed in type has unassociated coupler_field_type"// &
1052 " pointers for both bc and bc_r4")
1070 integer,
dimension(4),
intent(in) :: idim
1072 integer,
dimension(4),
intent(in) :: jdim
1074 character(len=*),
optional,
intent(in) :: suffix
1075 logical,
optional,
intent(in) :: as_needed
1078 character(len=*),
parameter :: error_header =&
1079 &
'==>Error from coupler_types_mod (CT_spawn_2d_2d):'
1080 character(len=400) :: error_msg
1083 if (
present(as_needed))
then
1085 if ((var%set) .or. (.not.var_in%set))
return
1090 &
call mpp_error(fatal, trim(error_header) //
' The output type has already been initialized.')
1091 if (.not.var_in%set)&
1092 &
call mpp_error(fatal, trim(error_header) //
' The parent type has not been initialized.')
1095 if(var_in%num_bcs .gt. 0)
then
1096 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
1097 if(
associated(var_in%bc) )
then
1098 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both intialized,"// &
1099 " only one should be associated per type")
1101 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both unintialized,"// &
1102 " one must be associated to copy field data")
1107 var%num_bcs = var_in%num_bcs
1110 if ((idim(1) > idim(2)) .or. (idim(3) > idim(4)))
then
1111 write (error_msg, *) trim(error_header),
' Disordered i-dimension index bound list ', idim
1114 if ((jdim(1) > jdim(2)) .or. (jdim(3) > jdim(4)))
then
1115 write (error_msg, *) trim(error_header),
' Disordered j-dimension index bound list ', jdim
1118 var%isd = idim(1) ; var%isc = idim(2) ; var%iec = idim(3) ; var%ied = idim(4)
1119 var%jsd = jdim(1) ; var%jsc = jdim(2) ; var%jec = jdim(3) ; var%jed = jdim(4)
1121 if (var%num_bcs > 0)
then
1122 if(
associated(var_in%bc))
then
1123 if (
associated(var%bc))
then
1124 call mpp_error(fatal, trim(error_header) //
' var%bc already associated')
1126 allocate ( var%bc(var%num_bcs) )
1127 do n = 1, var%num_bcs
1128 var%bc(n)%name = var_in%bc(n)%name
1129 var%bc(n)%atm_tr_index = var_in%bc(n)%atm_tr_index
1130 var%bc(n)%flux_type = var_in%bc(n)%flux_type
1131 var%bc(n)%implementation = var_in%bc(n)%implementation
1132 var%bc(n)%ice_restart_file = var_in%bc(n)%ice_restart_file
1133 var%bc(n)%ocean_restart_file = var_in%bc(n)%ocean_restart_file
1134 var%bc(n)%use_atm_pressure = var_in%bc(n)%use_atm_pressure
1135 var%bc(n)%use_10m_wind_speed = var_in%bc(n)%use_10m_wind_speed
1136 var%bc(n)%pass_through_ice = var_in%bc(n)%pass_through_ice
1137 var%bc(n)%mol_wt = var_in%bc(n)%mol_wt
1138 var%bc(n)%num_fields = var_in%bc(n)%num_fields
1139 if (
associated(var%bc(n)%field))
then
1140 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field already associated'
1143 allocate ( var%bc(n)%field(var%bc(n)%num_fields) )
1144 do m = 1, var%bc(n)%num_fields
1145 if (
present(suffix))
then
1146 var%bc(n)%field(m)%name = trim(var_in%bc(n)%field(m)%name) // trim(suffix)
1148 var%bc(n)%field(m)%name = var_in%bc(n)%field(m)%name
1150 var%bc(n)%field(m)%long_name = var_in%bc(n)%field(m)%long_name
1151 var%bc(n)%field(m)%units = var_in%bc(n)%field(m)%units
1152 var%bc(n)%field(m)%may_init = var_in%bc(n)%field(m)%may_init
1153 var%bc(n)%field(m)%mean = var_in%bc(n)%field(m)%mean
1154 if (
associated(var%bc(n)%field(m)%values))
then
1155 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field(', m,
')%values already associated'
1159 allocate ( var%bc(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed) )
1160 var%bc(n)%field(m)%values(:,:) = 0.0_r8_kind
1163 else if (
associated(var_in%bc_r4))
then
1164 if (
associated(var%bc_r4))
then
1165 call mpp_error(fatal, trim(error_header) //
' var%bc_r4 already associated')
1167 allocate ( var%bc_r4(var%num_bcs) )
1168 do n = 1, var%num_bcs
1169 var%bc_r4(n)%name = var_in%bc_r4(n)%name
1170 var%bc_r4(n)%atm_tr_index = var_in%bc_r4(n)%atm_tr_index
1171 var%bc_r4(n)%flux_type = var_in%bc_r4(n)%flux_type
1172 var%bc_r4(n)%implementation = var_in%bc_r4(n)%implementation
1173 var%bc_r4(n)%ice_restart_file = var_in%bc_r4(n)%ice_restart_file
1174 var%bc_r4(n)%ocean_restart_file = var_in%bc_r4(n)%ocean_restart_file
1175 var%bc_r4(n)%use_atm_pressure = var_in%bc_r4(n)%use_atm_pressure
1176 var%bc_r4(n)%use_10m_wind_speed = var_in%bc_r4(n)%use_10m_wind_speed
1177 var%bc_r4(n)%pass_through_ice = var_in%bc_r4(n)%pass_through_ice
1178 var%bc_r4(n)%mol_wt = var_in%bc_r4(n)%mol_wt
1179 var%bc_r4(n)%num_fields = var_in%bc_r4(n)%num_fields
1180 if (
associated(var%bc_r4(n)%field))
then
1181 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field already associated'
1184 allocate ( var%bc_r4(n)%field(var%bc_r4(n)%num_fields) )
1185 do m = 1, var%bc_r4(n)%num_fields
1186 if (
present(suffix))
then
1187 var%bc_r4(n)%field(m)%name = trim(var_in%bc_r4(n)%field(m)%name) // trim(suffix)
1189 var%bc_r4(n)%field(m)%name = var_in%bc_r4(n)%field(m)%name
1191 var%bc_r4(n)%field(m)%long_name = var_in%bc_r4(n)%field(m)%long_name
1192 var%bc_r4(n)%field(m)%units = var_in%bc_r4(n)%field(m)%units
1193 var%bc_r4(n)%field(m)%may_init = var_in%bc_r4(n)%field(m)%may_init
1194 var%bc_r4(n)%field(m)%mean = var_in%bc_r4(n)%field(m)%mean
1195 if (
associated(var%bc_r4(n)%field(m)%values))
then
1196 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field(', m,
')%values already associated'
1200 allocate ( var%bc_r4(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed) )
1201 var%bc_r4(n)%field(m)%values(:,:) = 0.0_r4_kind
1205 call mpp_error(fatal, error_header//
"passed in type has unassociated coupler_field_type"// &
1206 " pointers for both bc and bc_r4")
1224 integer,
dimension(4),
intent(in) :: idim
1226 integer,
dimension(4),
intent(in) :: jdim
1228 integer,
dimension(2),
intent(in) :: kdim
1230 character(len=*),
optional,
intent(in) :: suffix
1231 logical,
optional,
intent(in) :: as_needed
1234 character(len=*),
parameter :: error_header =&
1235 &
'==>Error from coupler_types_mod (CT_spawn_2d_3d):'
1236 character(len=400) :: error_msg
1239 if (
present(as_needed))
then
1241 if ((var%set) .or. (.not.var_in%set))
return
1246 &
call mpp_error(fatal, trim(error_header) //
' The output type has already been initialized.')
1247 if (.not.var_in%set)&
1248 &
call mpp_error(fatal, trim(error_header) //
' The parent type has not been initialized.')
1250 if(var_in%num_bcs .gt. 0)
then
1252 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
1253 if(
associated(var_in%bc) )
then
1254 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both intialized,"// &
1255 " only one should be associated per type")
1257 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both unintialized,"// &
1258 " one must be associated to copy field data")
1263 var%num_bcs = var_in%num_bcs
1267 if ((idim(1) > idim(2)) .or. (idim(3) > idim(4)))
then
1268 write (error_msg, *) trim(error_header),
' Disordered i-dimension index bound list ', idim
1271 if ((jdim(1) > jdim(2)) .or. (jdim(3) > jdim(4)))
then
1272 write (error_msg, *) trim(error_header),
' Disordered j-dimension index bound list ', jdim
1275 if (kdim(1) > kdim(2))
then
1276 write (error_msg, *) trim(error_header),
' Disordered k-dimension index bound list ', kdim
1279 var%isd = idim(1) ; var%isc = idim(2) ; var%iec = idim(3) ; var%ied = idim(4)
1280 var%jsd = jdim(1) ; var%jsc = jdim(2) ; var%jec = jdim(3) ; var%jed = jdim(4)
1281 var%ks = kdim(1) ; var%ke = kdim(2)
1283 if (var%num_bcs > 0)
then
1284 if(
associated(var_in%bc))
then
1285 if (
associated(var%bc))
then
1286 call mpp_error(fatal, trim(error_header) //
' var%bc already associated')
1288 allocate ( var%bc(var%num_bcs) )
1289 do n = 1, var%num_bcs
1290 var%bc(n)%name = var_in%bc(n)%name
1291 var%bc(n)%atm_tr_index = var_in%bc(n)%atm_tr_index
1292 var%bc(n)%flux_type = var_in%bc(n)%flux_type
1293 var%bc(n)%implementation = var_in%bc(n)%implementation
1294 var%bc(n)%ice_restart_file = var_in%bc(n)%ice_restart_file
1295 var%bc(n)%ocean_restart_file = var_in%bc(n)%ocean_restart_file
1296 var%bc(n)%use_atm_pressure = var_in%bc(n)%use_atm_pressure
1297 var%bc(n)%use_10m_wind_speed = var_in%bc(n)%use_10m_wind_speed
1298 var%bc(n)%pass_through_ice = var_in%bc(n)%pass_through_ice
1299 var%bc(n)%mol_wt = var_in%bc(n)%mol_wt
1300 var%bc(n)%num_fields = var_in%bc(n)%num_fields
1301 if (
associated(var%bc(n)%field))
then
1302 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field already associated'
1305 allocate ( var%bc(n)%field(var%bc(n)%num_fields) )
1306 do m = 1, var%bc(n)%num_fields
1307 if (
present(suffix))
then
1308 var%bc(n)%field(m)%name = trim(var_in%bc(n)%field(m)%name) // trim(suffix)
1310 var%bc(n)%field(m)%name = var_in%bc(n)%field(m)%name
1312 var%bc(n)%field(m)%long_name = var_in%bc(n)%field(m)%long_name
1313 var%bc(n)%field(m)%units = var_in%bc(n)%field(m)%units
1314 var%bc(n)%field(m)%may_init = var_in%bc(n)%field(m)%may_init
1315 var%bc(n)%field(m)%mean = var_in%bc(n)%field(m)%mean
1316 if (
associated(var%bc(n)%field(m)%values))
then
1317 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field(', m,
')%values already associated'
1321 allocate ( var%bc(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed,var%ks:var%ke) )
1322 var%bc(n)%field(m)%values(:,:,:) = 0.0_r8_kind
1325 else if(
associated(var_in%bc_r4))
then
1326 if (
associated(var%bc_r4))
then
1327 call mpp_error(fatal, trim(error_header) //
' var%bc_r4 already associated')
1329 allocate ( var%bc_r4(var%num_bcs) )
1330 do n = 1, var%num_bcs
1331 var%bc_r4(n)%name = var_in%bc_r4(n)%name
1332 var%bc_r4(n)%atm_tr_index = var_in%bc_r4(n)%atm_tr_index
1333 var%bc_r4(n)%flux_type = var_in%bc_r4(n)%flux_type
1334 var%bc_r4(n)%implementation = var_in%bc_r4(n)%implementation
1335 var%bc_r4(n)%ice_restart_file = var_in%bc_r4(n)%ice_restart_file
1336 var%bc_r4(n)%ocean_restart_file = var_in%bc_r4(n)%ocean_restart_file
1337 var%bc_r4(n)%use_atm_pressure = var_in%bc_r4(n)%use_atm_pressure
1338 var%bc_r4(n)%use_10m_wind_speed = var_in%bc_r4(n)%use_10m_wind_speed
1339 var%bc_r4(n)%pass_through_ice = var_in%bc_r4(n)%pass_through_ice
1340 var%bc_r4(n)%mol_wt = var_in%bc_r4(n)%mol_wt
1341 var%bc_r4(n)%num_fields = var_in%bc_r4(n)%num_fields
1342 if (
associated(var%bc_r4(n)%field))
then
1343 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field already associated'
1346 allocate ( var%bc_r4(n)%field(var%bc_r4(n)%num_fields) )
1347 do m = 1, var%bc_r4(n)%num_fields
1348 if (
present(suffix))
then
1349 var%bc_r4(n)%field(m)%name = trim(var_in%bc_r4(n)%field(m)%name) // trim(suffix)
1351 var%bc_r4(n)%field(m)%name = var_in%bc_r4(n)%field(m)%name
1353 var%bc_r4(n)%field(m)%long_name = var_in%bc_r4(n)%field(m)%long_name
1354 var%bc_r4(n)%field(m)%units = var_in%bc_r4(n)%field(m)%units
1355 var%bc_r4(n)%field(m)%may_init = var_in%bc_r4(n)%field(m)%may_init
1356 var%bc_r4(n)%field(m)%mean = var_in%bc_r4(n)%field(m)%mean
1357 if (
associated(var%bc_r4(n)%field(m)%values))
then
1358 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field(', m,
')%values already associated'
1362 allocate ( var%bc_r4(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed,var%ks:var%ke) )
1363 var%bc_r4(n)%field(m)%values(:,:,:) = 0.0_r4_kind
1367 call mpp_error(fatal, error_header//
"passed in type has unassociated coupler_field_type"// &
1368 " pointers for both bc and bc_r4")
1385 integer,
dimension(4),
intent(in) :: idim
1387 integer,
dimension(4),
intent(in) :: jdim
1389 character(len=*),
optional,
intent(in) :: suffix
1390 logical,
optional,
intent(in) :: as_needed
1393 character(len=*),
parameter :: error_header =&
1394 &
'==>Error from coupler_types_mod (CT_spawn_3d_2d):'
1395 character(len=400) :: error_msg
1398 if (
present(as_needed))
then
1400 if ((var%set) .or. (.not.var_in%set))
return
1405 &
call mpp_error(fatal, trim(error_header) //
' The output type has already been initialized.')
1406 if (.not.var_in%set)&
1407 &
call mpp_error(fatal, trim(error_header) //
' The parent type has not been initialized.')
1409 if(var_in%num_bcs .gt. 0)
then
1411 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
1412 if(
associated(var_in%bc) )
then
1413 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both intialized,"// &
1414 " only one should be associated per type")
1416 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both unintialized,"// &
1417 " one must be associated to copy field data")
1422 var%num_bcs = var_in%num_bcs
1425 if ((idim(1) > idim(2)) .or. (idim(3) > idim(4)))
then
1426 write (error_msg, *) trim(error_header),
' Disordered i-dimension index bound list ', idim
1429 if ((jdim(1) > jdim(2)) .or. (jdim(3) > jdim(4)))
then
1430 write (error_msg, *) trim(error_header),
' Disordered j-dimension index bound list ', jdim
1433 var%isd = idim(1) ; var%isc = idim(2) ; var%iec = idim(3) ; var%ied = idim(4)
1434 var%jsd = jdim(1) ; var%jsc = jdim(2) ; var%jec = jdim(3) ; var%jed = jdim(4)
1436 if (var%num_bcs > 0)
then
1438 if(
associated(var_in%bc))
then
1439 if (
associated(var%bc))
then
1440 call mpp_error(fatal, trim(error_header) //
' var%bc already associated')
1442 allocate ( var%bc(var%num_bcs) )
1443 do n = 1, var%num_bcs
1444 var%bc(n)%name = var_in%bc(n)%name
1445 var%bc(n)%atm_tr_index = var_in%bc(n)%atm_tr_index
1446 var%bc(n)%flux_type = var_in%bc(n)%flux_type
1447 var%bc(n)%implementation = var_in%bc(n)%implementation
1448 var%bc(n)%ice_restart_file = var_in%bc(n)%ice_restart_file
1449 var%bc(n)%ocean_restart_file = var_in%bc(n)%ocean_restart_file
1450 var%bc(n)%use_atm_pressure = var_in%bc(n)%use_atm_pressure
1451 var%bc(n)%use_10m_wind_speed = var_in%bc(n)%use_10m_wind_speed
1452 var%bc(n)%pass_through_ice = var_in%bc(n)%pass_through_ice
1453 var%bc(n)%mol_wt = var_in%bc(n)%mol_wt
1454 var%bc(n)%num_fields = var_in%bc(n)%num_fields
1455 if (
associated(var%bc(n)%field))
then
1456 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field already associated'
1459 allocate ( var%bc(n)%field(var%bc(n)%num_fields) )
1460 do m = 1, var%bc(n)%num_fields
1461 if (
present(suffix))
then
1462 var%bc(n)%field(m)%name = trim(var_in%bc(n)%field(m)%name) // trim(suffix)
1464 var%bc(n)%field(m)%name = var_in%bc(n)%field(m)%name
1466 var%bc(n)%field(m)%long_name = var_in%bc(n)%field(m)%long_name
1467 var%bc(n)%field(m)%units = var_in%bc(n)%field(m)%units
1468 var%bc(n)%field(m)%may_init = var_in%bc(n)%field(m)%may_init
1469 var%bc(n)%field(m)%mean = var_in%bc(n)%field(m)%mean
1470 if (
associated(var%bc(n)%field(m)%values))
then
1471 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field(', m,
')%values already associated'
1475 allocate ( var%bc(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed) )
1476 var%bc(n)%field(m)%values(:,:) = 0.0_r8_kind
1480 else if (
associated(var_in%bc_r4))
then
1481 if (
associated(var%bc_r4))
then
1482 call mpp_error(fatal, trim(error_header) //
' var%bc_r4 already associated')
1484 allocate ( var%bc_r4(var%num_bcs) )
1485 do n = 1, var%num_bcs
1486 var%bc_r4(n)%name = var_in%bc_r4(n)%name
1487 var%bc_r4(n)%atm_tr_index = var_in%bc_r4(n)%atm_tr_index
1488 var%bc_r4(n)%flux_type = var_in%bc_r4(n)%flux_type
1489 var%bc_r4(n)%implementation = var_in%bc_r4(n)%implementation
1490 var%bc_r4(n)%ice_restart_file = var_in%bc_r4(n)%ice_restart_file
1491 var%bc_r4(n)%ocean_restart_file = var_in%bc_r4(n)%ocean_restart_file
1492 var%bc_r4(n)%use_atm_pressure = var_in%bc_r4(n)%use_atm_pressure
1493 var%bc_r4(n)%use_10m_wind_speed = var_in%bc_r4(n)%use_10m_wind_speed
1494 var%bc_r4(n)%pass_through_ice = var_in%bc_r4(n)%pass_through_ice
1495 var%bc_r4(n)%mol_wt = var_in%bc_r4(n)%mol_wt
1496 var%bc_r4(n)%num_fields = var_in%bc_r4(n)%num_fields
1497 if (
associated(var%bc_r4(n)%field))
then
1498 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field already associated'
1501 allocate ( var%bc_r4(n)%field(var%bc_r4(n)%num_fields) )
1502 do m = 1, var%bc_r4(n)%num_fields
1503 if (
present(suffix))
then
1504 var%bc_r4(n)%field(m)%name = trim(var_in%bc_r4(n)%field(m)%name) // trim(suffix)
1506 var%bc_r4(n)%field(m)%name = var_in%bc_r4(n)%field(m)%name
1508 var%bc_r4(n)%field(m)%long_name = var_in%bc_r4(n)%field(m)%long_name
1509 var%bc_r4(n)%field(m)%units = var_in%bc_r4(n)%field(m)%units
1510 var%bc_r4(n)%field(m)%may_init = var_in%bc_r4(n)%field(m)%may_init
1511 var%bc_r4(n)%field(m)%mean = var_in%bc_r4(n)%field(m)%mean
1512 if (
associated(var%bc_r4(n)%field(m)%values))
then
1513 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field(', m,
')%values already associated'
1517 allocate ( var%bc_r4(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed) )
1518 var%bc_r4(n)%field(m)%values(:,:) = 0.0_r4_kind
1522 call mpp_error(fatal, error_header//
"passed in type has unassociated coupler_field_type"// &
1523 " pointers for both bc and bc_r4")
1541 integer,
dimension(4),
intent(in) :: idim
1543 integer,
dimension(4),
intent(in) :: jdim
1545 integer,
dimension(2),
intent(in) :: kdim
1547 character(len=*),
optional,
intent(in) :: suffix
1548 logical,
optional,
intent(in) :: as_needed
1551 character(len=*),
parameter :: error_header =&
1552 &
'==>Error from coupler_types_mod (CT_spawn_3d_3d):'
1553 character(len=400) :: error_msg
1556 if (
present(as_needed))
then
1558 if ((var%set) .or. (.not.var_in%set))
return
1563 &
call mpp_error(fatal, trim(error_header) //
' The output type has already been initialized.')
1564 if (.not.var_in%set)&
1565 &
call mpp_error(fatal, trim(error_header) //
' The parent type has not been initialized.')
1567 if(var_in%num_bcs .gt. 0)
then
1569 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
1570 if(
associated(var_in%bc))
then
1571 call mpp_error(fatal, error_header//
"var_in%bc and var_in%bc_r4 are both initialized,"//&
1572 "only one should be allocated per type")
1574 call mpp_error(fatal, error_header//
"var_in%bc and var%bc_r4 are both uninitialized,"//&
1575 " one must be associated to copy field data")
1580 var%num_bcs = var_in%num_bcs
1583 if ((idim(1) > idim(2)) .or. (idim(3) > idim(4)))
then
1584 write (error_msg, *) trim(error_header),
' Disordered i-dimension index bound list ', idim
1587 if ((jdim(1) > jdim(2)) .or. (jdim(3) > jdim(4)))
then
1588 write (error_msg, *) trim(error_header),
' Disordered j-dimension index bound list ', jdim
1591 if (kdim(1) > kdim(2))
then
1592 write (error_msg, *) trim(error_header),
' Disordered k-dimension index bound list ', kdim
1595 var%isd = idim(1) ; var%isc = idim(2) ; var%iec = idim(3) ; var%ied = idim(4)
1596 var%jsd = jdim(1) ; var%jsc = jdim(2) ; var%jec = jdim(3) ; var%jed = jdim(4)
1597 var%ks = kdim(1) ; var%ke = kdim(2)
1599 if (var%num_bcs > 0)
then
1600 if(
associated(var_in%bc))
then
1601 if (
associated(var%bc))
then
1602 call mpp_error(fatal, trim(error_header) //
' var%bc already associated')
1604 allocate ( var%bc(var%num_bcs) )
1605 do n = 1, var%num_bcs
1606 var%bc(n)%name = var_in%bc(n)%name
1607 var%bc(n)%atm_tr_index = var_in%bc(n)%atm_tr_index
1608 var%bc(n)%flux_type = var_in%bc(n)%flux_type
1609 var%bc(n)%implementation = var_in%bc(n)%implementation
1610 var%bc(n)%ice_restart_file = var_in%bc(n)%ice_restart_file
1611 var%bc(n)%ocean_restart_file = var_in%bc(n)%ocean_restart_file
1612 var%bc(n)%use_atm_pressure = var_in%bc(n)%use_atm_pressure
1613 var%bc(n)%use_10m_wind_speed = var_in%bc(n)%use_10m_wind_speed
1614 var%bc(n)%pass_through_ice = var_in%bc(n)%pass_through_ice
1615 var%bc(n)%mol_wt = var_in%bc(n)%mol_wt
1616 var%bc(n)%num_fields = var_in%bc(n)%num_fields
1617 if (
associated(var%bc(n)%field))
then
1618 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field already associated'
1621 allocate ( var%bc(n)%field(var%bc(n)%num_fields) )
1622 do m = 1, var%bc(n)%num_fields
1623 if (
present(suffix))
then
1624 var%bc(n)%field(m)%name = trim(var_in%bc(n)%field(m)%name) // trim(suffix)
1626 var%bc(n)%field(m)%name = var_in%bc(n)%field(m)%name
1628 var%bc(n)%field(m)%long_name = var_in%bc(n)%field(m)%long_name
1629 var%bc(n)%field(m)%units = var_in%bc(n)%field(m)%units
1630 var%bc(n)%field(m)%may_init = var_in%bc(n)%field(m)%may_init
1631 var%bc(n)%field(m)%mean = var_in%bc(n)%field(m)%mean
1632 if (
associated(var%bc(n)%field(m)%values))
then
1633 write (error_msg, *) trim(error_header),
' var%bc(', n,
')%field(', m,
')%values already associated'
1638 allocate ( var%bc(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed,var%ks:var%ke) )
1639 var%bc(n)%field(m)%values(:,:,:) = 0.0_r8_kind
1642 else if(
associated(var_in%bc_r4))
then
1643 if (
associated(var%bc_r4))
then
1644 call mpp_error(fatal, trim(error_header) //
' var%bc_r4 already associated')
1646 allocate ( var%bc_r4(var%num_bcs) )
1647 do n = 1, var%num_bcs
1648 var%bc_r4(n)%name = var_in%bc_r4(n)%name
1649 var%bc_r4(n)%atm_tr_index = var_in%bc_r4(n)%atm_tr_index
1650 var%bc_r4(n)%flux_type = var_in%bc_r4(n)%flux_type
1651 var%bc_r4(n)%implementation = var_in%bc_r4(n)%implementation
1652 var%bc_r4(n)%ice_restart_file = var_in%bc_r4(n)%ice_restart_file
1653 var%bc_r4(n)%ocean_restart_file = var_in%bc_r4(n)%ocean_restart_file
1654 var%bc_r4(n)%use_atm_pressure = var_in%bc_r4(n)%use_atm_pressure
1655 var%bc_r4(n)%use_10m_wind_speed = var_in%bc_r4(n)%use_10m_wind_speed
1656 var%bc_r4(n)%pass_through_ice = var_in%bc_r4(n)%pass_through_ice
1657 var%bc_r4(n)%mol_wt = var_in%bc_r4(n)%mol_wt
1658 var%bc_r4(n)%num_fields = var_in%bc_r4(n)%num_fields
1659 if (
associated(var%bc_r4(n)%field))
then
1660 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field already associated'
1663 allocate ( var%bc_r4(n)%field(var%bc_r4(n)%num_fields) )
1664 do m = 1, var%bc_r4(n)%num_fields
1665 if (
present(suffix))
then
1666 var%bc_r4(n)%field(m)%name = trim(var_in%bc_r4(n)%field(m)%name) // trim(suffix)
1668 var%bc_r4(n)%field(m)%name = var_in%bc_r4(n)%field(m)%name
1670 var%bc_r4(n)%field(m)%long_name = var_in%bc_r4(n)%field(m)%long_name
1671 var%bc_r4(n)%field(m)%units = var_in%bc_r4(n)%field(m)%units
1672 var%bc_r4(n)%field(m)%may_init = var_in%bc_r4(n)%field(m)%may_init
1673 var%bc_r4(n)%field(m)%mean = var_in%bc_r4(n)%field(m)%mean
1674 if (
associated(var%bc_r4(n)%field(m)%values))
then
1675 write (error_msg, *) trim(error_header),
' var%bc_r4(', n,
')%field(', m,
')%values already associated'
1680 allocate ( var%bc_r4(n)%field(m)%values(var%isd:var%ied,var%jsd:var%jed,var%ks:var%ke) )
1681 var%bc_r4(n)%field(m)%values(:,:,:) = 0.0_r4_kind
1685 call mpp_error(fatal, error_header//
"passed in type has unassociated coupler_field_type"// &
1686 " pointers for both bc and bc_r4")
1704 & exclude_flux_type, only_flux_type, pass_through_ice)
1707 integer,
optional,
intent(in) :: halo_size
1708 integer,
optional,
intent(in) :: bc_index
1710 integer,
optional,
intent(in) :: field_index
1712 character(len=*),
optional,
intent(in) :: exclude_flux_type
1714 character(len=*),
optional,
intent(in) :: only_flux_type
1716 logical,
optional,
intent(in) :: pass_through_ice
1719 integer :: i, j, m, n, n1, n2, halo, i_off, j_off
1722 if (
present(bc_index))
then
1723 if (bc_index > var_in%num_bcs)&
1724 &
call mpp_error(fatal,
"CT_copy_data_2d: bc_index is present and exceeds var_in%num_bcs.")
1725 if (
present(field_index))
then
1726 if(
associated(var_in%bc))
then
1727 if (field_index > var_in%bc(bc_index)%num_fields)&
1728 &
call mpp_error(fatal,
"CT_copy_data_2d: field_index is present and exceeds num_fields for" //&
1729 & trim(var_in%bc(bc_index)%name) )
1731 if (field_index > var_in%bc_r4(bc_index)%num_fields)&
1732 &
call mpp_error(fatal,
"CT_copy_data_2d: field_index is present and exceeds num_fields for" //&
1733 & trim(var_in%bc_r4(bc_index)%name) )
1736 elseif (
present(field_index))
then
1737 call mpp_error(fatal,
"CT_copy_data_2d: bc_index must be present if field_index is present.")
1741 if (
present(halo_size)) halo = halo_size
1745 if (
present(bc_index))
then
1752 if ((var_in%iec-var_in%isc) /= (var%iec-var%isc))&
1753 &
call mpp_error(fatal,
"CT_copy_data_2d: There is an i-direction computational domain size mismatch.")
1754 if ((var_in%jec-var_in%jsc) /= (var%jec-var%jsc))&
1755 &
call mpp_error(fatal,
"CT_copy_data_2d: There is a j-direction computational domain size mismatch.")
1756 if ((var_in%isc-var_in%isd < halo) .or. (var_in%ied-var_in%iec < halo))&
1757 &
call mpp_error(fatal,
"CT_copy_data_2d: Excessive i-direction halo size for the input structure.")
1758 if ((var_in%jsc-var_in%jsd < halo) .or. (var_in%jed-var_in%jec < halo))&
1759 &
call mpp_error(fatal,
"CT_copy_data_2d: Excessive j-direction halo size for the input structure.")
1760 if ((var%isc-var%isd < halo) .or. (var%ied-var%iec < halo))&
1761 &
call mpp_error(fatal,
"CT_copy_data_2d: Excessive i-direction halo size for the output structure.")
1762 if ((var%jsc-var%jsd < halo) .or. (var%jed-var%jec < halo))&
1763 &
call mpp_error(fatal,
"CT_copy_data_2d: Excessive j-direction halo size for the output structure.")
1765 i_off = var_in%isc - var%isc
1766 j_off = var_in%jsc - var%jsc
1769 if(var_in%set .and. var_in%num_bcs .gt. 0)
then
1770 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
1771 if(
associated(var_in%bc) )
then
1772 call mpp_error(fatal,
"CT_copy_data_2d var_in%bc and var_in%bc_r4 are both intialized,"//&
1773 " only one should be associated per type")
1775 call mpp_error(fatal,
"CT_copy_data_2d var_in%bc and var_in%bc_r4 are both unintialized,"//&
1776 " one must be associated to copy field data.")
1782 if (
associated(var_in%bc) .or. var_in%num_bcs .lt. 1)
then
1785 if (copy_bc .and.
present(exclude_flux_type))&
1786 & copy_bc = .not.(trim(var%bc(n)%flux_type) == trim(exclude_flux_type))
1787 if (copy_bc .and.
present(only_flux_type))&
1788 & copy_bc = (trim(var%bc(n)%flux_type) == trim(only_flux_type))
1789 if (copy_bc .and.
present(pass_through_ice))&
1790 & copy_bc = (pass_through_ice .eqv. var%bc(n)%pass_through_ice)
1791 if (.not.copy_bc) cycle
1793 do m = 1, var%bc(n)%num_fields
1794 if (
present(field_index))
then
1795 if (m /= field_index) cycle
1797 if (
associated(var%bc(n)%field(m)%values) )
then
1798 do j=var%jsc-halo,var%jec+halo
1799 do i=var%isc-halo,var%iec+halo
1800 var%bc(n)%field(m)%values(i,j) = var_in%bc(n)%field(m)%values(i+i_off,j+j_off)
1806 else if (
associated(var_in%bc_r4))
then
1809 if (copy_bc .and.
present(exclude_flux_type))&
1810 & copy_bc = .not.(trim(var%bc_r4(n)%flux_type) == trim(exclude_flux_type))
1811 if (copy_bc .and.
present(only_flux_type))&
1812 & copy_bc = (trim(var%bc_r4(n)%flux_type) == trim(only_flux_type))
1813 if (copy_bc .and.
present(pass_through_ice))&
1814 & copy_bc = (pass_through_ice .eqv. var%bc_r4(n)%pass_through_ice)
1815 if (.not.copy_bc) cycle
1817 do m = 1, var%bc_r4(n)%num_fields
1818 if (
present(field_index))
then
1819 if (m /= field_index) cycle
1821 if (
associated(var%bc_r4(n)%field(m)%values) )
then
1822 do j=var%jsc-halo,var%jec+halo
1823 do i=var%isc-halo,var%iec+halo
1824 var%bc_r4(n)%field(m)%values(i,j) = var_in%bc_r4(n)%field(m)%values(i+i_off,j+j_off)
1831 call mpp_error(fatal,
"CT_copy_data_2d: passed in type has unassociated coupler_field_type"// &
1832 " pointers for both bc and bc_r4")
1851 & exclude_flux_type, only_flux_type, pass_through_ice)
1854 integer,
optional,
intent(in) :: halo_size
1855 integer,
optional,
intent(in) :: bc_index
1857 integer,
optional,
intent(in) :: field_index
1859 character(len=*),
optional,
intent(in) :: exclude_flux_type
1861 character(len=*),
optional,
intent(in) :: only_flux_type
1863 logical,
optional,
intent(in) :: pass_through_ice
1866 integer :: i, j, k, m, n, n1, n2, halo, i_off, j_off, k_off
1868 if (
present(bc_index))
then
1869 if (bc_index > var_in%num_bcs) &
1870 call mpp_error(fatal,
"CT_copy_data_3d: bc_index is present and exceeds var_in%num_bcs.")
1871 if (
present(field_index))
then
1872 if(
associated(var_in%bc))
then
1873 if (field_index > var_in%bc(bc_index)%num_fields)&
1874 &
call mpp_error(fatal,
"CT_copy_data_3d: field_index is present and exceeds num_fields for" //&
1875 & trim(var_in%bc(bc_index)%name) )
1877 if (field_index > var_in%bc_r4(bc_index)%num_fields)&
1878 &
call mpp_error(fatal,
"CT_copy_data_3d: field_index is present and exceeds num_fields for" //&
1879 & trim(var_in%bc_r4(bc_index)%name) )
1882 elseif (
present(field_index))
then
1883 call mpp_error(fatal,
"CT_copy_data_3d: bc_index must be present if field_index is present.")
1887 if (
present(halo_size)) halo = halo_size
1891 if (
present(bc_index))
then
1898 if ((var_in%iec-var_in%isc) /= (var%iec-var%isc))&
1899 &
call mpp_error(fatal,
"CT_copy_data_3d: There is an i-direction computational domain size mismatch.")
1900 if ((var_in%jec-var_in%jsc) /= (var%jec-var%jsc))&
1901 &
call mpp_error(fatal,
"CT_copy_data_3d: There is a j-direction computational domain size mismatch.")
1902 if ((var_in%ke-var_in%ks) /= (var%ke-var%ks))&
1903 &
call mpp_error(fatal,
"CT_copy_data_3d: There is a k-direction computational domain size mismatch.")
1904 if ((var_in%isc-var_in%isd < halo) .or. (var_in%ied-var_in%iec < halo))&
1905 &
call mpp_error(fatal,
"CT_copy_data_3d: Excessive i-direction halo size for the input structure.")
1906 if ((var_in%jsc-var_in%jsd < halo) .or. (var_in%jed-var_in%jec < halo))&
1907 &
call mpp_error(fatal,
"CT_copy_data_3d: Excessive j-direction halo size for the input structure.")
1908 if ((var%isc-var%isd < halo) .or. (var%ied-var%iec < halo))&
1909 &
call mpp_error(fatal,
"CT_copy_data_3d: Excessive i-direction halo size for the output structure.")
1910 if ((var%jsc-var%jsd < halo) .or. (var%jed-var%jec < halo))&
1911 &
call mpp_error(fatal,
"CT_copy_data_3d: Excessive j-direction halo size for the output structure.")
1913 i_off = var_in%isc - var%isc
1914 j_off = var_in%jsc - var%jsc
1915 k_off = var_in%ks - var%ks
1918 if(var_in%set .and. var_in%num_bcs .gt. 0)
then
1919 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
1920 if(
associated(var_in%bc) )
then
1921 call mpp_error(fatal,
"CT_copy_data_3d: var_in%bc and var_in%bc_r4 are both intialized,"//&
1922 " only one should be associated per type")
1924 call mpp_error(fatal,
"CT_copy_data_3d: var_in%bc and var_in%bc_r4 are both unintialized,"//&
1925 " one must be associated to copy field data.")
1931 if (
associated(var_in%bc) .or. var_in%num_bcs .lt. 1)
then
1934 if (copy_bc .and.
present(exclude_flux_type))&
1935 & copy_bc = .not.(trim(var%bc(n)%flux_type) == trim(exclude_flux_type))
1936 if (copy_bc .and.
present(only_flux_type))&
1937 & copy_bc = (trim(var%bc(n)%flux_type) == trim(only_flux_type))
1938 if (copy_bc .and.
present(pass_through_ice))&
1939 & copy_bc = (pass_through_ice .eqv. var%bc(n)%pass_through_ice)
1940 if (.not.copy_bc) cycle
1942 do m = 1, var_in%bc(n)%num_fields
1943 if (
present(field_index))
then
1944 if (m /= field_index) cycle
1946 if (
associated(var%bc(n)%field(m)%values) )
then
1948 do j=var%jsc-halo,var%jec+halo
1949 do i=var%isc-halo,var%iec+halo
1950 var%bc(n)%field(m)%values(i,j,k) = var_in%bc(n)%field(m)%values(i+i_off,j+j_off,k+k_off)
1957 else if (
associated(var_in%bc_r4))
then
1960 if (copy_bc .and.
present(exclude_flux_type))&
1961 & copy_bc = .not.(trim(var%bc_r4(n)%flux_type) == trim(exclude_flux_type))
1962 if (copy_bc .and.
present(only_flux_type))&
1963 & copy_bc = (trim(var%bc_r4(n)%flux_type) == trim(only_flux_type))
1964 if (copy_bc .and.
present(pass_through_ice))&
1965 & copy_bc = (pass_through_ice .eqv. var%bc_r4(n)%pass_through_ice)
1966 if (.not.copy_bc) cycle
1968 do m = 1, var_in%bc_r4(n)%num_fields
1969 if (
present(field_index))
then
1970 if (m /= field_index) cycle
1972 if (
associated(var%bc_r4(n)%field(m)%values) )
then
1974 do j=var%jsc-halo,var%jec+halo
1975 do i=var%isc-halo,var%iec+halo
1976 var%bc_r4(n)%field(m)%values(i,j,k) = var_in%bc_r4(n)%field(m)%values(i+i_off,j+j_off,k+k_off)
1984 call mpp_error(fatal,
"CT_copy_data_3d: passed in type has unassociated coupler_field_type"// &
1985 " pointers for both bc and bc_r4")
2003 & exclude_flux_type, only_flux_type, pass_through_ice,&
2004 & ind3_start, ind3_end)
2007 integer,
optional,
intent(in) :: halo_size
2008 integer,
optional,
intent(in) :: bc_index
2010 integer,
optional,
intent(in) :: field_index
2012 character(len=*),
optional,
intent(in) :: exclude_flux_type
2014 character(len=*),
optional,
intent(in) :: only_flux_type
2016 logical,
optional,
intent(in) :: pass_through_ice
2018 integer,
optional,
intent(in) :: ind3_start
2020 integer,
optional,
intent(in) :: ind3_end
2024 integer :: i, j, k, m, n, n1, n2, halo, i_off, j_off, ks, ke
2026 if (
present(bc_index))
then
2027 if (bc_index > var_in%num_bcs)&
2028 &
call mpp_error(fatal,
"CT_copy_data_2d_3d: bc_index is present and exceeds var_in%num_bcs.")
2029 if (
present(field_index))
then ;
if (field_index > var_in%bc(bc_index)%num_fields)&
2030 &
call mpp_error(fatal,
"CT_copy_data_2d_3d: field_index is present and exceeds num_fields for" //&
2031 & trim(var_in%bc(bc_index)%name) )
2033 elseif (
present(field_index))
then
2034 call mpp_error(fatal,
"CT_copy_data_2d_3d: bc_index must be present if field_index is present.")
2038 if (
present(halo_size)) halo = halo_size
2042 if (
present(bc_index))
then
2049 if ((var_in%iec-var_in%isc) /= (var%iec-var%isc))&
2050 &
call mpp_error(fatal,
"CT_copy_data_2d_3d: There is an i-direction computational domain size mismatch.")
2051 if ((var_in%jec-var_in%jsc) /= (var%jec-var%jsc))&
2052 &
call mpp_error(fatal,
"CT_copy_data_2d_3d: There is a j-direction computational domain size mismatch.")
2053 if ((var_in%isc-var_in%isd < halo) .or. (var_in%ied-var_in%iec < halo))&
2054 &
call mpp_error(fatal,
"CT_copy_data_2d_3d: Excessive i-direction halo size for the input structure.")
2055 if ((var_in%jsc-var_in%jsd < halo) .or. (var_in%jed-var_in%jec < halo))&
2056 &
call mpp_error(fatal,
"CT_copy_data_2d_3d: Excessive j-direction halo size for the input structure.")
2057 if ((var%isc-var%isd < halo) .or. (var%ied-var%iec < halo))&
2058 &
call mpp_error(fatal,
"CT_copy_data_2d_3d: Excessive i-direction halo size for the output structure.")
2059 if ((var%jsc-var%jsd < halo) .or. (var%jed-var%jec < halo))&
2060 &
call mpp_error(fatal,
"CT_copy_data_2d_3d: Excessive j-direction halo size for the output structure.")
2063 i_off = var_in%isc - var%isc
2064 j_off = var_in%jsc - var%jsc
2066 if(var_in%set .and. var_in%num_bcs .gt. 0)
then
2067 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
2068 if(
associated(var_in%bc) )
then
2069 call mpp_error(fatal,
"CT_copy_data_2d_3d: var_in%bc and var_in%bc_r4 are both intialized,"//&
2070 " only one should be associated per type")
2072 call mpp_error(fatal,
"CT_copy_data_2d_3d: var_in%bc and var_in%bc_r4 are both unintialized,"//&
2073 " one must be associated to copy field data.")
2080 if (
associated(var_in%bc) .or. var_in%num_bcs .lt. 1)
then
2083 if (copy_bc .and.
present(exclude_flux_type))&
2084 & copy_bc = .not.(trim(var_in%bc(n)%flux_type) == trim(exclude_flux_type))
2085 if (copy_bc .and.
present(only_flux_type))&
2086 & copy_bc = (trim(var_in%bc(n)%flux_type) == trim(only_flux_type))
2087 if (copy_bc .and.
present(pass_through_ice))&
2088 & copy_bc = (pass_through_ice .eqv. var_in%bc(n)%pass_through_ice)
2089 if (.not.copy_bc) cycle
2091 do m = 1, var_in%bc(n)%num_fields
2092 if (
present(field_index))
then
2093 if (m /= field_index) cycle
2095 if (
associated(var%bc(n)%field(m)%values) )
then
2097 if (
present(ind3_start)) ks = max(ks, ind3_start)
2099 if (
present(ind3_end)) ke = max(ke, ind3_end)
2101 do j=var%jsc-halo,var%jec+halo
2102 do i=var%isc-halo,var%iec+halo
2103 var%bc(n)%field(m)%values(i,j,k) = var_in%bc(n)%field(m)%values(i+i_off,j+j_off)
2111 else if (
associated(var_in%bc_r4))
then
2114 if (copy_bc .and.
present(exclude_flux_type))&
2115 & copy_bc = .not.(trim(var_in%bc_r4(n)%flux_type) == trim(exclude_flux_type))
2116 if (copy_bc .and.
present(only_flux_type))&
2117 & copy_bc = (trim(var_in%bc_r4(n)%flux_type) == trim(only_flux_type))
2118 if (copy_bc .and.
present(pass_through_ice))&
2119 & copy_bc = (pass_through_ice .eqv. var_in%bc_r4(n)%pass_through_ice)
2120 if (.not.copy_bc) cycle
2122 do m = 1, var_in%bc_r4(n)%num_fields
2123 if (
present(field_index))
then
2124 if (m /= field_index) cycle
2126 if (
associated(var%bc_r4(n)%field(m)%values) )
then
2128 if (
present(ind3_start)) ks = max(ks, ind3_start)
2130 if (
present(ind3_end)) ke = max(ke, ind3_end)
2132 do j=var%jsc-halo,var%jec+halo
2133 do i=var%isc-halo,var%iec+halo
2134 var%bc_r4(n)%field(m)%values(i,j,k) = var_in%bc_r4(n)%field(m)%values(i+i_off,j+j_off)
2142 call mpp_error(fatal,
"CT_copy_data_2d_3d: passed in type has unassociated coupler_field_type"// &
2143 " pointers for both bc and bc_r4")
2157 type(
domain2d),
intent(in) :: domain_in
2159 type(
domain2d),
intent(in) :: domain_out
2160 logical,
optional,
intent(in) :: complete
2162 real(r4_kind),
pointer,
dimension(:,:) :: null_ptr2D_r4 => null()
2163 real(r8_kind),
pointer,
dimension(:,:) :: null_ptr2D_r8 => null()
2164 logical :: do_in, do_out, do_complete
2165 integer :: m, n, fc, fc_in, fc_out
2167 do_complete = .true.
2168 if (
present(complete)) do_complete = complete
2172 do_out = var_out%set
2174 if(var_in%set .and. var_in%num_bcs .gt. 0)
then
2175 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
2176 if(
associated(var_in%bc) )
then
2177 call mpp_error(fatal,
"CT_redistribute_data_2d: var_in%bc and var_in%bc_r4 are both intialized,"//&
2178 " only one should be associated per type")
2180 call mpp_error(fatal,
"CT_redistribute_data_2d: var_in%bc and var_in%bc_r4 are both intialized,"//&
2181 " only one must be associated per type to redistribute field data.")
2187 if(
associated(var_in%bc) .or.
associated(var_out%bc) .or. var_in%num_bcs .lt. 1)
then
2188 fc_in = 0 ; fc_out = 0
2190 do n = 1, var_in%num_bcs
2191 do m = 1, var_in%bc(n)%num_fields
2192 if (
associated(var_in%bc(n)%field(m)%values)) fc_in = fc_in + 1
2196 if (fc_in == 0) do_in = .false.
2198 do n = 1, var_out%num_bcs
2199 do m = 1, var_out%bc(n)%num_fields
2200 if (
associated(var_out%bc(n)%field(m)%values)) fc_out = fc_out + 1
2204 if (fc_out == 0) do_out = .false.
2206 if (do_in .and. do_out)
then
2207 if (var_in%num_bcs /= var_out%num_bcs)
call mpp_error(fatal,&
2208 &
"Mismatch in num_bcs in CT_copy_data_2d.")
2209 if (fc_in /= fc_out)
call mpp_error(fatal,&
2210 &
"Mismatch in the total number of fields in CT_redistribute_data_2d.")
2213 if (.not.(do_in .or. do_out))
return
2216 if (do_in .and. do_out)
then
2217 do n = 1, var_in%num_bcs
2218 do m = 1, var_in%bc(n)%num_fields
2219 if (
associated(var_in%bc(n)%field(m)%values) .neqv.&
2220 &
associated(var_out%bc(n)%field(m)%values) ) &
2222 &
"CT_redistribute_data_2d: Mismatch in which var_in and var_out fields are associated"// &
2223 &
"Boundary condition:"//
string(n)//
" Field:"//
string(m))
2224 if (
associated(var_in%bc(n)%field(m)%values) )
then
2227 & domain_out, var_out%bc(n)%field(m)%values,&
2228 & complete=(do_complete.and.(fc==fc_in)) )
2233 do n = 1, var_in%num_bcs
2234 do m = 1, var_in%bc(n)%num_fields
2235 if (
associated(var_in%bc(n)%field(m)%values) )
then
2238 & domain_out, null_ptr2d_r8,&
2239 & complete=(do_complete.and.(fc==fc_in)) )
2243 elseif (do_out)
then
2244 do n = 1, var_out%num_bcs
2245 do m = 1, var_out%bc(n)%num_fields
2246 if (
associated(var_out%bc(n)%field(m)%values) )
then
2249 & domain_out, var_out%bc(n)%field(m)%values,&
2250 & complete=(do_complete.and.(fc==fc_out)) )
2256 else if(
associated(var_in%bc_r4) .or.
associated(var_out%bc_r4))
then
2257 fc_in = 0 ; fc_out = 0
2259 do n = 1, var_in%num_bcs
2260 do m = 1, var_in%bc_r4(n)%num_fields
2261 if (
associated(var_in%bc_r4(n)%field(m)%values)) fc_in = fc_in + 1
2265 if (fc_in == 0) do_in = .false.
2267 do n = 1, var_out%num_bcs
2268 do m = 1, var_out%bc_r4(n)%num_fields
2269 if (
associated(var_out%bc_r4(n)%field(m)%values)) fc_out = fc_out + 1
2273 if (fc_out == 0) do_out = .false.
2275 if (do_in .and. do_out)
then
2276 if (var_in%num_bcs /= var_out%num_bcs)
call mpp_error(fatal,&
2277 &
"Mismatch in num_bcs in CT_copy_data_2d.")
2278 if (fc_in /= fc_out)
call mpp_error(fatal,&
2279 &
"Mismatch in the total number of fields in CT_redistribute_data_2d.")
2282 if (.not.(do_in .or. do_out))
return
2285 if (do_in .and. do_out)
then
2286 do n = 1, var_in%num_bcs
2287 do m = 1, var_in%bc_r4(n)%num_fields
2288 if (
associated(var_in%bc_r4(n)%field(m)%values) .neqv.&
2289 &
associated(var_out%bc_r4(n)%field(m)%values) ) &
2291 &
"CT_redistribute_data_2d: Mismatch in which var_in and var_out fields are associated"// &
2292 &
"Boundary condition:"//
string(n)//
" Field:"//
string(m))
2293 if (
associated(var_in%bc_r4(n)%field(m)%values) )
then
2296 & domain_out, var_out%bc_r4(n)%field(m)%values,&
2297 & complete=(do_complete.and.(fc==fc_in)) )
2302 do n = 1, var_in%num_bcs
2303 do m = 1, var_in%bc_r4(n)%num_fields
2304 if (
associated(var_in%bc_r4(n)%field(m)%values) )
then
2307 & domain_out, null_ptr2d_r4,&
2308 & complete=(do_complete.and.(fc==fc_in)) )
2312 elseif (do_out)
then
2313 do n = 1, var_out%num_bcs
2314 do m = 1, var_out%bc_r4(n)%num_fields
2315 if (
associated(var_out%bc_r4(n)%field(m)%values) )
then
2318 & domain_out, var_out%bc_r4(n)%field(m)%values,&
2319 & complete=(do_complete.and.(fc==fc_out)) )
2325 call mpp_error(fatal,
"CT_redistribute_data_2d: passed in type has unassociated coupler_field_type"// &
2326 " pointers for both bc and bc_r4")
2336 type(
domain2d),
intent(in) :: domain_in
2338 type(
domain2d),
intent(in) :: domain_out
2339 logical,
optional,
intent(in) :: complete
2341 real(r4_kind),
pointer,
dimension(:,:,:) :: null_ptr3D_r4 => null()
2342 real(r8_kind),
pointer,
dimension(:,:,:) :: null_ptr3D_r8 => null()
2343 logical :: do_in, do_out, do_complete
2344 integer :: m, n, fc, fc_in, fc_out
2346 do_complete = .true.
2347 if (
present(complete)) do_complete = complete
2351 do_out = var_out%set
2356 if(var_in%set .and. var_in%num_bcs .gt. 0)
then
2357 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
2358 if(
associated(var_in%bc) )
then
2359 call mpp_error(fatal,
"CT_redistribute_data_3d: var_in%bc and var_in%bc_r4 are both intialized,"//&
2360 " only one should be associated per type")
2362 call mpp_error(fatal,
"CT_redistribute_data_3d: var_in%bc and var_in%bc_r4 are both intialized,"//&
2363 " only one must be associated per type to redistribute field data.")
2369 if(
associated(var_in%bc) .or.
associated(var_out%bc) .or. var_in%num_bcs .lt. 1)
then
2371 do n = 1, var_in%num_bcs
2372 do m = 1, var_in%bc(n)%num_fields
2373 if (
associated(var_in%bc(n)%field(m)%values)) fc_in = fc_in + 1
2377 if (fc_in == 0) do_in = .false.
2379 do n = 1, var_out%num_bcs
2380 do m = 1, var_out%bc(n)%num_fields
2381 if (
associated(var_out%bc(n)%field(m)%values)) fc_out = fc_out + 1
2385 if (fc_out == 0) do_out = .false.
2387 if (do_in .and. do_out)
then
2388 if (var_in%num_bcs /= var_out%num_bcs)
call mpp_error(fatal,&
2389 &
"Mismatch in num_bcs in CT_copy_data_3d.")
2390 if (fc_in /= fc_out)
call mpp_error(fatal,&
2391 &
"Mismatch in the total number of fields in CT_redistribute_data_3d.")
2394 if (.not.(do_in .or. do_out))
return
2397 if (do_in .and. do_out)
then
2398 do n = 1, var_in%num_bcs
2399 do m = 1, var_in%bc(n)%num_fields
2400 if (
associated(var_in%bc(n)%field(m)%values) .neqv.&
2401 &
associated(var_out%bc(n)%field(m)%values) )&
2403 &
"CT_redistribute_data_3d: Mismatch in which var_in and var_out fields are associated"// &
2404 &
"Boundary condition:"//
string(n)//
" Field:"//
string(m))
2405 if (
associated(var_in%bc(n)%field(m)%values) )
then
2408 & domain_out, var_out%bc(n)%field(m)%values,&
2409 & complete=(do_complete.and.(fc==fc_in)) )
2414 do n = 1, var_in%num_bcs
2415 do m = 1, var_in%bc(n)%num_fields
2416 if (
associated(var_in%bc(n)%field(m)%values) )
then
2419 & domain_out, null_ptr3d_r8,&
2420 & complete=(do_complete.and.(fc==fc_in)) )
2424 elseif (do_out)
then
2425 do n = 1, var_out%num_bcs
2426 do m = 1, var_out%bc(n)%num_fields
2427 if (
associated(var_out%bc(n)%field(m)%values) )
then
2430 & domain_out, var_out%bc(n)%field(m)%values,&
2431 & complete=(do_complete.and.(fc==fc_out)) )
2437 else if(
associated(var_in%bc_r4) .or.
associated(var_out%bc_r4))
then
2439 do n = 1, var_in%num_bcs
2440 do m = 1, var_in%bc_r4(n)%num_fields
2441 if (
associated(var_in%bc_r4(n)%field(m)%values)) fc_in = fc_in + 1
2445 if (fc_in == 0) do_in = .false.
2447 do n = 1, var_out%num_bcs
2448 do m = 1, var_out%bc_r4(n)%num_fields
2449 if (
associated(var_out%bc_r4(n)%field(m)%values)) fc_out = fc_out + 1
2453 if (fc_out == 0) do_out = .false.
2455 if (do_in .and. do_out)
then
2456 if (var_in%num_bcs /= var_out%num_bcs)
call mpp_error(fatal,&
2457 &
"Mismatch in num_bcs in CT_copy_data_3d.")
2458 if (fc_in /= fc_out)
call mpp_error(fatal,&
2459 &
"Mismatch in the total number of fields in CT_redistribute_data_3d.")
2462 if (.not.(do_in .or. do_out))
return
2465 if (do_in .and. do_out)
then
2466 do n = 1, var_in%num_bcs
2467 do m = 1, var_in%bc_r4(n)%num_fields
2468 if (
associated(var_in%bc_r4(n)%field(m)%values) .neqv.&
2469 &
associated(var_out%bc_r4(n)%field(m)%values) )&
2471 &
"CT_redistribute_data_3d: Mismatch in which var_in and var_out fields are associated"// &
2472 &
"Boundary condition:"//
string(n)//
" Field:"//
string(m))
2473 if (
associated(var_in%bc_r4(n)%field(m)%values) )
then
2476 & domain_out, var_out%bc_r4(n)%field(m)%values,&
2477 & complete=(do_complete.and.(fc==fc_in)) )
2482 do n = 1, var_in%num_bcs
2483 do m = 1, var_in%bc_r4(n)%num_fields
2484 if (
associated(var_in%bc_r4(n)%field(m)%values) )
then
2487 & domain_out, null_ptr3d_r4,&
2488 & complete=(do_complete.and.(fc==fc_in)) )
2492 elseif (do_out)
then
2493 do n = 1, var_out%num_bcs
2494 do m = 1, var_out%bc_r4(n)%num_fields
2495 if (
associated(var_out%bc_r4(n)%field(m)%values) )
then
2498 & domain_out, var_out%bc_r4(n)%field(m)%values,&
2499 & complete=(do_complete.and.(fc==fc_out)) )
2505 call mpp_error(fatal,
"CT_redistribute_data_3d: passed in type has unassociated coupler_field_type"// &
2506 " pointers for both bc and bc_r4")
2526 & scale_factor, scale_prev, exclude_flux_type, only_flux_type, pass_through_ice)
2529 integer,
optional,
intent(in) :: halo_size
2530 integer,
optional,
intent(in) :: bc_index
2532 integer,
optional,
intent(in) :: field_index
2534 real(r8_kind),
optional,
intent(in) :: scale_factor
2535 real(r8_kind),
optional,
intent(in) :: scale_prev
2536 character(len=*),
optional,
intent(in) :: exclude_flux_type
2538 character(len=*),
optional,
intent(in) :: only_flux_type
2540 logical,
optional,
intent(in) :: pass_through_ice
2543 real(r8_kind) :: scale, sc_prev
2544 logical :: increment_bc
2545 integer :: i, j, m, n, n1, n2, halo, i_off, j_off
2548 if (
present(scale_factor)) scale = scale_factor
2549 sc_prev = 1.0_r8_kind
2550 if (
present(scale_prev)) sc_prev = scale_prev
2552 if (
present(bc_index))
then
2553 if (bc_index > var_in%num_bcs)&
2554 &
call mpp_error(fatal,
"CT_increment_data_2d_2d: bc_index is present and exceeds var_in%num_bcs.")
2555 if (
present(field_index))
then
2556 if(
associated(var_in%bc))
then
2557 if (field_index > var_in%bc(bc_index)%num_fields)&
2558 &
call mpp_error(fatal,
"CT_increment_data_2d_2d: field_index is present and exceeds num_fields for" //&
2559 & trim(var_in%bc(bc_index)%name) )
2561 if (field_index > var_in%bc_r4(bc_index)%num_fields)&
2562 &
call mpp_error(fatal,
"CT_increment_data_2d_2d: field_index is present and exceeds num_fields for" //&
2563 & trim(var_in%bc_r4(bc_index)%name) )
2566 elseif (
present(field_index))
then
2567 call mpp_error(fatal,
"CT_increment_data_2d_2d: bc_index must be present if field_index is present.")
2571 if (
present(halo_size)) halo = halo_size
2575 if (
present(bc_index))
then
2582 if ((var_in%iec-var_in%isc) /= (var%iec-var%isc))&
2583 &
call mpp_error(fatal,
"CT_increment_data_2d: There is an i-direction computational domain size mismatch.")
2584 if ((var_in%jec-var_in%jsc) /= (var%jec-var%jsc))&
2585 &
call mpp_error(fatal,
"CT_increment_data_2d: There is a j-direction computational domain size mismatch.")
2586 if ((var_in%isc-var_in%isd < halo) .or. (var_in%ied-var_in%iec < halo))&
2587 &
call mpp_error(fatal,
"CT_increment_data_2d: Excessive i-direction halo size for the input structure.")
2588 if ((var_in%jsc-var_in%jsd < halo) .or. (var_in%jed-var_in%jec < halo))&
2589 &
call mpp_error(fatal,
"CT_increment_data_2d: Excessive j-direction halo size for the input structure.")
2590 if ((var%isc-var%isd < halo) .or. (var%ied-var%iec < halo))&
2591 &
call mpp_error(fatal,
"CT_increment_data_2d: Excessive i-direction halo size for the output structure.")
2592 if ((var%jsc-var%jsd < halo) .or. (var%jed-var%jec < halo))&
2593 &
call mpp_error(fatal,
"CT_increment_data_2d: Excessive j-direction halo size for the output structure.")
2595 i_off = var_in%isc - var%isc
2596 j_off = var_in%jsc - var%jsc
2600 if(var_in%set .and. var_in%num_bcs .gt. 0)
then
2601 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
2602 if(
associated(var_in%bc) )
then
2603 call mpp_error(fatal,
"CT_increment_data_2d_2d: var_in%bc and var_in%bc_r4 are both intialized,"// &
2604 " only one should be associated per type")
2606 call mpp_error(fatal,
"CT_increment_data_2d_2d: var_in%bc and var_in%bc_r4 are both intialized,"// &
2607 " only one must be associated per type to increment field data.")
2613 if(
associated(var_in%bc) .or. var_in%num_bcs .lt. 1)
then
2615 increment_bc = .true.
2616 if (increment_bc .and.
present(exclude_flux_type))&
2617 & increment_bc = .not.(trim(var%bc(n)%flux_type) == trim(exclude_flux_type))
2618 if (increment_bc .and.
present(only_flux_type))&
2619 & increment_bc = (trim(var%bc(n)%flux_type) == trim(only_flux_type))
2620 if (increment_bc .and.
present(pass_through_ice))&
2621 & increment_bc = (pass_through_ice .eqv. var%bc(n)%pass_through_ice)
2622 if (.not.increment_bc) cycle
2624 do m = 1, var_in%bc(n)%num_fields
2625 if (
present(field_index))
then
2626 if (m /= field_index) cycle
2628 if (
associated(var%bc(n)%field(m)%values) )
then
2629 do j=var%jsc-halo,var%jec+halo
2630 do i=var%isc-halo,var%iec+halo
2631 var%bc(n)%field(m)%values(i,j) = sc_prev * var%bc(n)%field(m)%values(i,j) +&
2632 & scale * var_in%bc(n)%field(m)%values(i+i_off,j+j_off)
2638 else if(
associated(var_in%bc_r4))
then
2640 increment_bc = .true.
2641 if (increment_bc .and.
present(exclude_flux_type))&
2642 & increment_bc = .not.(trim(var%bc_r4(n)%flux_type) == trim(exclude_flux_type))
2643 if (increment_bc .and.
present(only_flux_type))&
2644 & increment_bc = (trim(var%bc_r4(n)%flux_type) == trim(only_flux_type))
2645 if (increment_bc .and.
present(pass_through_ice))&
2646 & increment_bc = (pass_through_ice .eqv. var%bc_r4(n)%pass_through_ice)
2647 if (.not.increment_bc) cycle
2649 do m = 1, var_in%bc_r4(n)%num_fields
2650 if (
present(field_index))
then
2651 if (m /= field_index) cycle
2653 if (
associated(var%bc_r4(n)%field(m)%values) )
then
2654 do j=var%jsc-halo,var%jec+halo
2655 do i=var%isc-halo,var%iec+halo
2656 var%bc_r4(n)%field(m)%values(i,j) = real(sc_prev,r4_kind) * var%bc_r4(n)%field(m)%values(i,j) +&
2657 & real(scale,r4_kind) * var_in%bc_r4(n)%field(m)%values(i+i_off,j+j_off)
2664 call mpp_error(fatal,
"CT_increment_data_2d_2d: passed in type has unassociated coupler_field_type"// &
2665 " pointers for both bc and bc_r4")
2685 & scale_factor, scale_prev, exclude_flux_type, only_flux_type, pass_through_ice)
2688 integer,
optional,
intent(in) :: halo_size
2689 integer,
optional,
intent(in) :: bc_index
2691 integer,
optional,
intent(in) :: field_index
2693 real(r8_kind),
optional,
intent(in) :: scale_factor
2694 real(r8_kind),
optional,
intent(in) :: scale_prev
2695 character(len=*),
optional,
intent(in) :: exclude_flux_type
2697 character(len=*),
optional,
intent(in) :: only_flux_type
2699 logical,
optional,
intent(in) :: pass_through_ice
2702 real(r8_kind) :: scale, sc_prev
2703 logical :: increment_bc
2704 integer :: i, j, k, m, n, n1, n2, halo, i_off, j_off, k_off
2707 if (
present(scale_factor)) scale = scale_factor
2708 sc_prev = 1.0_r8_kind
2709 if (
present(scale_prev)) sc_prev = scale_prev
2711 if (
present(bc_index))
then
2712 if (bc_index > var_in%num_bcs)&
2713 &
call mpp_error(fatal,
"CT_increment_data_3d_3d: bc_index is present and exceeds var_in%num_bcs.")
2714 if(
associated(var_in%bc))
then
2715 if (
present(field_index))
then ;
if (field_index > var_in%bc(bc_index)%num_fields)&
2716 &
call mpp_error(fatal,
"CT_increment_data_3d_3d: field_index is present and exceeds num_fields for" //&
2717 & trim(var_in%bc(bc_index)%name) )
2719 else if(
associated(var_in%bc_r4))
then
2720 if (
present(field_index))
then ;
if (field_index > var_in%bc_r4(bc_index)%num_fields)&
2721 &
call mpp_error(fatal,
"CT_increment_data_3d_3d: field_index is present and exceeds num_fields for" //&
2722 & trim(var_in%bc_r4(bc_index)%name) )
2725 elseif (
present(field_index))
then
2726 call mpp_error(fatal,
"CT_increment_data_3d_3d: bc_index must be present if field_index is present.")
2730 if (
present(halo_size)) halo = halo_size
2734 if (
present(bc_index))
then
2741 if ((var_in%iec-var_in%isc) /= (var%iec-var%isc))&
2742 &
call mpp_error(fatal,
"CT_increment_data_3d: There is an i-direction computational domain size mismatch.")
2743 if ((var_in%jec-var_in%jsc) /= (var%jec-var%jsc))&
2744 &
call mpp_error(fatal,
"CT_increment_data_3d: There is a j-direction computational domain size mismatch.")
2745 if ((var_in%ke-var_in%ks) /= (var%ke-var%ks))&
2746 &
call mpp_error(fatal,
"CT_increment_data_3d: There is a k-direction computational domain size mismatch.")
2747 if ((var_in%isc-var_in%isd < halo) .or. (var_in%ied-var_in%iec < halo))&
2748 &
call mpp_error(fatal,
"CT_increment_data_3d: Excessive i-direction halo size for the input structure.")
2749 if ((var_in%jsc-var_in%jsd < halo) .or. (var_in%jed-var_in%jec < halo))&
2750 &
call mpp_error(fatal,
"CT_increment_data_3d: Excessive j-direction halo size for the input structure.")
2751 if ((var%isc-var%isd < halo) .or. (var%ied-var%iec < halo))&
2752 &
call mpp_error(fatal,
"CT_increment_data_3d: Excessive i-direction halo size for the output structure.")
2753 if ((var%jsc-var%jsd < halo) .or. (var%jed-var%jec < halo))&
2754 &
call mpp_error(fatal,
"CT_increment_data_3d: Excessive j-direction halo size for the output structure.")
2756 i_off = var_in%isc - var%isc
2757 j_off = var_in%jsc - var%jsc
2758 k_off = var_in%ks - var%ks
2762 if(var_in%set .and. var_in%num_bcs .gt. 0)
then
2763 if(
associated(var_in%bc) .eqv.
associated(var_in%bc_r4))
then
2764 if(
associated(var_in%bc) )
then
2765 call mpp_error(fatal,
"CT_increment_data_3d_3d: var_in%bc and var_in%bc_r4 are both intialized,"//&
2766 "only one should be associated per type")
2768 call mpp_error(fatal,
"CT_increment_data_3d_3d: var_in%bc and var_in%bc_r4 are both unintialized,"//&
2769 " only one must be associated per type to increment field data.")
2775 if(
associated(var_in%bc) .or. var_in%num_bcs .lt. 1)
then
2777 increment_bc = .true.
2778 if (increment_bc .and.
present(exclude_flux_type))&
2779 & increment_bc = .not.(trim(var%bc(n)%flux_type) == trim(exclude_flux_type))
2780 if (increment_bc .and.
present(only_flux_type))&
2781 & increment_bc = (trim(var%bc(n)%flux_type) == trim(only_flux_type))
2782 if (increment_bc .and.
present(pass_through_ice))&
2783 & increment_bc = (pass_through_ice .eqv. var%bc(n)%pass_through_ice)
2784 if (.not.increment_bc) cycle
2786 do m = 1, var_in%bc(n)%num_fields
2787 if (
present(field_index))
then
2788 if (m /= field_index) cycle
2790 if (
associated(var%bc(n)%field(m)%values) )
then
2792 do j=var%jsc-halo,var%jec+halo
2793 do i=var%isc-halo,var%iec+halo
2794 var%bc(n)%field(m)%values(i,j,k) = sc_prev * var%bc(n)%field(m)%values(i,j,k) +&
2795 & scale * var_in%bc(n)%field(m)%values(i+i_off,j+j_off,k+k_off)
2802 else if(
associated(var_in%bc_r4))
then
2804 increment_bc = .true.
2805 if (increment_bc .and.
present(exclude_flux_type))&
2806 & increment_bc = .not.(trim(var%bc_r4(n)%flux_type) == trim(exclude_flux_type))
2807 if (increment_bc .and.
present(only_flux_type))&
2808 & increment_bc = (trim(var%bc_r4(n)%flux_type) == trim(only_flux_type))
2809 if (increment_bc .and.
present(pass_through_ice))&
2810 & increment_bc = (pass_through_ice .eqv. var%bc_r4(n)%pass_through_ice)
2811 if (.not.increment_bc) cycle
2813 do m = 1, var_in%bc_r4(n)%num_fields
2814 if (
present(field_index))
then
2815 if (m /= field_index) cycle
2817 if (
associated(var%bc_r4(n)%field(m)%values) )
then
2819 do j=var%jsc-halo,var%jec+halo
2820 do i=var%isc-halo,var%iec+halo
2821 var%bc_r4(n)%field(m)%values(i,j,k) = real(sc_prev,r4_kind) * var%bc_r4(n)%field(m)%values(i,j,k) +&
2822 & real(scale,r4_kind) * var_in%bc_r4(n)%field(m)%values(i+i_off,j+j_off,k+k_off)
2830 call mpp_error(fatal,
"CT_increment_data_3d_3d: passed in type has unassociated coupler_field_type"// &
2831 " pointers for both bc and bc_r4")
2840 character(len=*),
intent(in) :: diag_name
2842 integer,
dimension(:),
intent(in) :: axes
2847 if (diag_name ==
' ')
return
2849 if (
size(axes) < 2)
then
2850 call mpp_error(fatal,
'==>Error from coupler_types_mod' //&
2851 &
'(coupler_types_set_diags_3d): axes has less than 2 elements')
2854 if(var%set .and. var%num_bcs .gt. 0)
then
2855 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
2856 if(
associated(var%bc) )
then
2857 call mpp_error(fatal,
"CT_set_diags_2d: var%bc and var%bc_r4 are both intialized,"//&
2858 "only one should be associated per type")
2860 call mpp_error(fatal,
"CT_set_diags_2d: var%bc and var%bc_r4 are both intialized,"//&
2861 "one should be associated per type to register fields with diag manager")
2867 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
2868 do n = 1, var%num_bcs
2869 do m = 1, var%bc(n)%num_fields
2871 & var%bc(n)%field(m)%name, axes(1:2), time,&
2872 & var%bc(n)%field(m)%long_name, var%bc(n)%field(m)%units)
2875 else if(
associated(var%bc_r4))
then
2876 do n = 1, var%num_bcs
2877 do m = 1, var%bc_r4(n)%num_fields
2879 & var%bc_r4(n)%field(m)%name, axes(1:2), time,&
2880 & var%bc_r4(n)%field(m)%long_name, var%bc_r4(n)%field(m)%units)
2884 call mpp_error(fatal,
"CT_set_diags_2d: passed in type has unassociated coupler_field_type"// &
2885 " pointers for both bc and bc_r4")
2896 character(len=*),
intent(in) :: diag_name
2898 integer,
dimension(:),
intent(in) :: axes
2903 if (diag_name ==
' ')
return
2905 if (
size(axes) < 3)
then
2906 call mpp_error(fatal,
'==>Error from coupler_types_mod' //&
2907 &
'(coupler_types_set_diags_3d): axes has less than 3 elements')
2910 if(var%set .and. var%num_bcs .gt. 0)
then
2911 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
2912 if(
associated(var%bc) )
then
2913 call mpp_error(fatal,
"CT_set_diags_3d: var%bc and var%bc_r4 are both intialized,"//&
2914 "only one should be associated per type")
2916 call mpp_error(fatal,
"CT_set_diags_3d: var%bc and var%bc_r4 are both unintialized,"//&
2917 "one should be associated per type to register fields with diag manager")
2923 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
2924 do n = 1, var%num_bcs
2925 do m = 1, var%bc(n)%num_fields
2927 & var%bc(n)%field(m)%name, axes(1:3), time,&
2928 & var%bc(n)%field(m)%long_name, var%bc(n)%field(m)%units )
2931 else if(
associated(var%bc_r4))
then
2932 do n = 1, var%num_bcs
2933 do m = 1, var%bc_r4(n)%num_fields
2935 & var%bc_r4(n)%field(m)%name, axes(1:3), time,&
2936 & var%bc_r4(n)%field(m)%long_name, var%bc_r4(n)%field(m)%units )
2940 call mpp_error(fatal,
"CT_set_diags_3d: passed in type has unassociated coupler_field_type"// &
2941 " pointers for both bc and bc_r4")
2950 logical,
allocatable,
optional,
intent(out) :: return_statuses(:,:)
2957 if(var%set .and. var%num_bcs .gt. 0)
then
2958 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
2959 if(
associated(var%bc) )
then
2960 call mpp_error(fatal,
"CT_send_data_2d: var%bc and var%bc_r4 are both intialized,"//&
2961 "only one should be associated per type")
2963 call mpp_error(fatal,
"CT_send_data_2d: var%bc and var%bc_r4 are both unintialized,"//&
2964 "one should be associated per type to send data to diag fields")
2970 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
2973 if(
present(return_statuses) .and. var%num_bcs .gt. 0)
then
2974 allocate(return_statuses(var%num_bcs, var%bc(1)%num_fields))
2977 do n = 1, var%num_bcs
2978 do m = 1, var%bc(n)%num_fields
2979 if (var%bc(n)%field(m)%id_diag > 0)
then
2980 used =
send_data(var%bc(n)%field(m)%id_diag, var%bc(n)%field(m)%values, time)
2981 if(
allocated(return_statuses)) return_statuses(n,m) = used
2986 else if(
associated(var%bc_r4))
then
2989 if(
present(return_statuses) .and. var%num_bcs .gt. 0)
then
2990 allocate(return_statuses(var%num_bcs, var%bc_r4(1)%num_fields))
2993 do n = 1, var%num_bcs
2994 do m = 1, var%bc_r4(n)%num_fields
2995 if (var%bc_r4(n)%field(m)%id_diag > 0)
then
2996 used =
send_data(var%bc_r4(n)%field(m)%id_diag, var%bc_r4(n)%field(m)%values, time)
2997 if(
allocated(return_statuses)) return_statuses(n,m) = used
3002 call mpp_error(fatal,
"CT_send_data_2d: passed in type has unassociated coupler_field_type"// &
3003 " pointers for both bc and bc_r4")
3011 logical,
allocatable,
optional,
intent(out) :: return_statuses(:,:)
3018 if(var%set .and. var%num_bcs .gt. 0)
then
3019 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
3020 if(
associated(var%bc) )
then
3021 call mpp_error(fatal,
"CT_send_data_3d: var%bc and var%bc_r4 are both intialized,"//&
3022 "only one should be associated per type")
3024 call mpp_error(fatal,
"CT_send_data_3d: var%bc and var%bc_r4 are both unintialized,"//&
3025 "one should be associated per type to send data to diag fields")
3031 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
3034 if(
present(return_statuses) .and. var%num_bcs .gt. 0)
then
3035 allocate(return_statuses(var%num_bcs, var%bc(1)%num_fields))
3038 do n = 1, var%num_bcs
3039 do m = 1, var%bc(n)%num_fields
3040 if (var%bc(n)%field(m)%id_diag > 0)
then
3041 used =
send_data(var%bc(n)%field(m)%id_diag, var%bc(n)%field(m)%values, time)
3042 if(
allocated(return_statuses)) return_statuses(n,m) = used
3046 else if(
associated(var%bc_r4))
then
3049 if(
present(return_statuses) .and. var%num_bcs .gt. 0)
then
3050 allocate(return_statuses(var%num_bcs, var%bc_r4(1)%num_fields))
3053 do n = 1, var%num_bcs
3054 do m = 1, var%bc_r4(n)%num_fields
3055 if (var%bc_r4(n)%field(m)%id_diag > 0)
then
3056 used =
send_data(var%bc_r4(n)%field(m)%id_diag, var%bc_r4(n)%field(m)%values, time)
3057 if(
allocated(return_statuses)) return_statuses(n,m) = used
3062 call mpp_error(fatal,
"CT_send_data_3d: passed in type has unassociated coupler_field_type"// &
3063 " pointers for both bc and bc_r4")
3072 type(fmsnetcdfdomainfile_t),
dimension(:),
pointer :: bc_rest_files
3073 integer,
intent(out) :: num_rest_files
3074 type(
domain2d),
intent(in) :: mpp_domain
3075 logical,
intent(in) :: to_read
3076 logical,
optional,
intent(in) :: ocean_restart
3077 character(len=*),
optional,
intent(in) :: directory
3079 character(len=FMS_FILE_LEN),
dimension(max(1,var%num_bcs)) :: rest_file_names
3080 character(len=FMS_FILE_LEN) :: file_nm
3084 character(len=20),
allocatable,
dimension(:) :: dim_names
3085 character(len=20) :: io_type
3086 logical,
dimension(max(1,var%num_bcs)) :: file_is_open
3087 character(len=FMS_PATH_LEN) :: dir
3089 if(var%set .and. var%num_bcs .gt. 0)
then
3090 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
3091 if(
associated(var%bc) )
then
3092 call mpp_error(fatal,
"CT_register_restarts_2d: var%bc and var%bc_r4 are both intialized,"//&
3093 "only one should be associated per type")
3095 call mpp_error(fatal,
"CT_register_restarts_2d: var%bc and var%bc_r4 are both unintialized,"//&
3096 "one should be associated per type to register restart fields")
3102 if (
present(ocean_restart)) ocn_rest = ocean_restart
3104 if (
present(directory)) dir = trim(directory)
3108 if (.not.
present(directory)) dir =
"INPUT/"
3110 io_type =
"overwrite"
3111 if (.not.
present(directory)) dir =
"RESTART/"
3116 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
3118 do n = 1, var%num_bcs
3119 if (var%bc(n)%num_fields <= 0) cycle
3120 file_nm = trim(var%bc(n)%ice_restart_file)
3121 if (ocn_rest) file_nm = trim(var%bc(n)%ocean_restart_file)
3122 do f = 1, num_rest_files
3123 if (trim(file_nm) == trim(rest_file_names(f)))
exit
3125 if (f>num_rest_files)
then
3126 num_rest_files = num_rest_files + 1
3127 rest_file_names(f) = trim(file_nm)
3131 if (num_rest_files == 0)
return
3133 allocate(bc_rest_files(num_rest_files))
3136 do n = 1, num_rest_files
3137 file_is_open(n) =
open_file(bc_rest_files(n), trim(dir)//rest_file_names(n), io_type, mpp_domain, &
3138 & is_restart=.true.)
3139 if (file_is_open(n))
then
3145 do n = 1, var%num_bcs
3146 if (var%bc(n)%num_fields <= 0) cycle
3148 file_nm = trim(var%bc(n)%ice_restart_file)
3149 if (ocn_rest) file_nm = trim(var%bc(n)%ocean_restart_file)
3150 do f = 1, num_rest_files
3151 if (trim(file_nm) == trim(rest_file_names(f)))
exit
3154 var%bc(n)%fms2_io_rest_type => bc_rest_files(f)
3156 do m = 1, var%bc(n)%num_fields
3157 if (file_is_open(f))
then
3158 if( to_read .and. variable_exists(bc_rest_files(f), var%bc(n)%field(m)%name))
then
3160 allocate(dim_names(get_variable_num_dimensions(bc_rest_files(f), var%bc(n)%field(m)%name)))
3161 call get_variable_dimension_names(bc_rest_files(f), &
3162 & var%bc(n)%field(m)%name, dim_names)
3165 allocate(dim_names(3))
3166 dim_names(1) =
"xaxis_1"
3167 dim_names(2) =
"yaxis_1"
3168 dim_names(3) =
"Time"
3172 & var%bc(n)%field(m)%name, var%bc(n)%field(m)%values, dim_names, &
3173 & is_optional=var%bc(n)%field(m)%may_init )
3175 deallocate(dim_names)
3179 else if(
associated(var%bc_r4))
then
3181 do n = 1, var%num_bcs
3182 if (var%bc_r4(n)%num_fields <= 0) cycle
3183 file_nm = trim(var%bc_r4(n)%ice_restart_file)
3184 if (ocn_rest) file_nm = trim(var%bc_r4(n)%ocean_restart_file)
3185 do f = 1, num_rest_files
3186 if (trim(file_nm) == trim(rest_file_names(f)))
exit
3188 if (f>num_rest_files)
then
3189 num_rest_files = num_rest_files + 1
3190 rest_file_names(f) = trim(file_nm)
3194 if (num_rest_files == 0)
return
3196 allocate(bc_rest_files(num_rest_files))
3199 do n = 1, num_rest_files
3200 file_is_open(n) =
open_file(bc_rest_files(n), trim(dir)//rest_file_names(n), io_type, mpp_domain, &
3201 & is_restart=.true.)
3202 if (file_is_open(n))
then
3208 do n = 1, var%num_bcs
3209 if (var%bc_r4(n)%num_fields <= 0) cycle
3211 file_nm = trim(var%bc_r4(n)%ice_restart_file)
3212 if (ocn_rest) file_nm = trim(var%bc_r4(n)%ocean_restart_file)
3213 do f = 1, num_rest_files
3214 if (trim(file_nm) == trim(rest_file_names(f)))
exit
3217 var%bc_r4(n)%fms2_io_rest_type => bc_rest_files(f)
3219 do m = 1, var%bc_r4(n)%num_fields
3220 if (file_is_open(f))
then
3221 if( to_read .and. variable_exists(bc_rest_files(f), var%bc_r4(n)%field(m)%name))
then
3223 allocate(dim_names(get_variable_num_dimensions(bc_rest_files(f), var%bc_r4(n)%field(m)%name)))
3224 call get_variable_dimension_names(bc_rest_files(f), &
3225 & var%bc_r4(n)%field(m)%name, dim_names)
3228 allocate(dim_names(3))
3229 dim_names(1) =
"xaxis_1"
3230 dim_names(2) =
"yaxis_1"
3231 dim_names(3) =
"Time"
3235 & var%bc_r4(n)%field(m)%name, var%bc_r4(n)%field(m)%values, dim_names, &
3236 & is_optional=var%bc_r4(n)%field(m)%may_init )
3238 deallocate(dim_names)
3243 call mpp_error(fatal,
"CT_register_restarts_2d: passed in type has unassociated coupler_field_type"// &
3244 " pointers for both bc and bc_r4")
3251 type(fmsnetcdfdomainfile_t),
intent(inout) :: fileobj
3253 character(len=20),
dimension(:),
allocatable :: file_dim_names
3257 logical :: is_domain_decomposed
3258 character(len=1) :: buffer
3260 ndims = get_num_dimensions(fileobj)
3261 allocate(file_dim_names(ndims))
3263 call get_dimension_names(fileobj, file_dim_names)
3266 is_domain_decomposed = .false.
3269 if (variable_exists(fileobj, file_dim_names(i)))
then
3272 if (variable_att_exists(fileobj, file_dim_names(i),
"axis"))
then
3273 call get_variable_attribute(fileobj, file_dim_names(i),
"axis", buffer)
3276 if (lowercase(buffer) .eq.
"x" .or. lowercase(buffer) .eq.
"y" )
then
3277 is_domain_decomposed = .true.
3281 else if (variable_att_exists(fileobj, file_dim_names(i),
"cartesian_axis"))
then
3282 call get_variable_attribute(fileobj, file_dim_names(i),
"cartesian_axis", buffer)
3285 if (lowercase(buffer) .eq.
"x" .or. lowercase(buffer) .eq.
"y" )
then
3286 is_domain_decomposed = .true.
3293 if (.not. is_domain_decomposed)
then
3294 call get_dimension_size(fileobj, file_dim_names(i), dim_size)
3304 type(fmsnetcdfdomainfile_t),
intent(inout) :: fileobj
3305 integer,
intent(in),
optional :: nz
3307 character(len=20) :: dim_names(4)
3309 dim_names(1) =
"xaxis_1"
3310 dim_names(2) =
"yaxis_1"
3316 if (.not.
present(nz))
then
3317 dim_names(3) =
"Time"
3320 dim_names(3) =
"zaxis_1"
3321 dim_names(4) =
"Time"
3328 call register_field(fileobj, dim_names(1),
"double", (/dim_names(1)/))
3329 call register_variable_attribute(fileobj, dim_names(1),
"axis",
"X", str_len=1)
3331 call register_field(fileobj, dim_names(2),
"double", (/dim_names(2)/))
3332 call register_variable_attribute(fileobj, dim_names(2),
"axis",
"Y", str_len=1)
3337 type(fmsnetcdfdomainfile_t),
intent(inout) :: fileobj
3338 logical,
intent(in) :: to_read
3339 integer,
intent(in),
optional :: nz
3354 type(fmsnetcdfdomainfile_t),
dimension(:),
pointer :: bc_rest_files
3355 integer,
intent(out) :: num_rest_files
3356 type(
domain2d),
intent(in) :: mpp_domain
3357 logical,
intent(in) :: to_read
3358 logical,
optional,
intent(in) :: ocean_restart
3359 character(len=*),
optional,
intent(in) :: directory
3361 character(len=FMS_FILE_LEN),
dimension(max(1,var%num_bcs)) :: rest_file_names
3362 character(len=FMS_FILE_LEN) :: file_nm
3366 character(len=20),
allocatable,
dimension(:) :: dim_names
3367 character(len=20) :: io_type
3368 logical,
dimension(max(1,var%num_bcs)) :: file_is_open
3369 character(len=FMS_PATH_LEN) :: dir
3372 if(var%set .and. var%num_bcs .gt. 0)
then
3373 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
3374 if(
associated(var%bc) )
then
3375 call mpp_error(fatal,
"CT_register_restarts_3d: var%bc and var%bc_r4 are both intialized,"//&
3376 "only one should be associated per type")
3378 call mpp_error(fatal,
"CT_register_restarts_3d: var%bc and var%bc_r4 are both unintialized,"//&
3379 "one should be associated per type to register restart fields")
3385 if (
present(ocean_restart)) ocn_rest = ocean_restart
3387 if (
present(directory)) dir = trim(directory)
3391 if (.not.
present(directory)) dir =
"INPUT/"
3393 io_type =
"overwrite"
3394 if (.not.
present(directory)) dir =
"RESTART/"
3397 nz = var%ke - var%ks + 1
3400 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
3402 do n = 1, var%num_bcs
3403 if (var%bc(n)%num_fields <= 0) cycle
3404 file_nm = trim(var%bc(n)%ice_restart_file)
3405 if (ocn_rest) file_nm = trim(var%bc(n)%ocean_restart_file)
3406 do f = 1, num_rest_files
3407 if (trim(file_nm) == trim(rest_file_names(f)))
exit
3409 if (f>num_rest_files)
then
3410 num_rest_files = num_rest_files + 1
3411 rest_file_names(f) = trim(file_nm)
3415 if (num_rest_files == 0)
return
3417 allocate(bc_rest_files(num_rest_files))
3420 do n = 1, num_rest_files
3421 file_is_open(n) =
open_file(bc_rest_files(n), trim(dir)//rest_file_names(n), io_type, mpp_domain, &
3422 & is_restart=.true.)
3423 if (file_is_open(n))
then
3434 do n = 1, var%num_bcs
3435 if (var%bc(n)%num_fields <= 0) cycle
3437 file_nm = trim(var%bc(n)%ice_restart_file)
3438 if (ocn_rest) file_nm = trim(var%bc(n)%ocean_restart_file)
3439 do f = 1, num_rest_files
3440 if (trim(file_nm) == trim(rest_file_names(f)))
exit
3443 var%bc(n)%fms2_io_rest_type => bc_rest_files(f)
3445 do m = 1, var%bc(n)%num_fields
3446 if (file_is_open(f))
then
3447 if( to_read .and. variable_exists(bc_rest_files(f), var%bc(n)%field(m)%name))
then
3449 allocate(dim_names(get_variable_num_dimensions(bc_rest_files(f), var%bc(n)%field(m)%name)))
3450 call get_variable_dimension_names(bc_rest_files(f), &
3451 & var%bc(n)%field(m)%name, dim_names)
3454 allocate(dim_names(4))
3455 dim_names(1) =
"xaxis_1"
3456 dim_names(2) =
"yaxis_1"
3457 dim_names(3) =
"zaxis_1"
3458 dim_names(4) =
"Time"
3462 & var%bc(n)%field(m)%name, var%bc(n)%field(m)%values, dim_names, &
3463 & is_optional=var%bc(n)%field(m)%may_init )
3464 deallocate(dim_names)
3468 else if(
associated(var%bc_r4))
then
3470 do n = 1, var%num_bcs
3471 if (var%bc_r4(n)%num_fields <= 0) cycle
3472 file_nm = trim(var%bc_r4(n)%ice_restart_file)
3473 if (ocn_rest) file_nm = trim(var%bc_r4(n)%ocean_restart_file)
3474 do f = 1, num_rest_files
3475 if (trim(file_nm) == trim(rest_file_names(f)))
exit
3477 if (f>num_rest_files)
then
3478 num_rest_files = num_rest_files + 1
3479 rest_file_names(f) = trim(file_nm)
3483 if (num_rest_files == 0)
return
3485 allocate(bc_rest_files(num_rest_files))
3488 do n = 1, num_rest_files
3489 file_is_open(n) =
open_file(bc_rest_files(n), trim(dir)//rest_file_names(n), io_type, mpp_domain, &
3490 & is_restart=.true.)
3491 if (file_is_open(n))
then
3502 do n = 1, var%num_bcs
3503 if (var%bc_r4(n)%num_fields <= 0) cycle
3505 file_nm = trim(var%bc_r4(n)%ice_restart_file)
3506 if (ocn_rest) file_nm = trim(var%bc_r4(n)%ocean_restart_file)
3507 do f = 1, num_rest_files
3508 if (trim(file_nm) == trim(rest_file_names(f)))
exit
3511 var%bc_r4(n)%fms2_io_rest_type => bc_rest_files(f)
3513 do m = 1, var%bc_r4(n)%num_fields
3514 if (file_is_open(f))
then
3515 if( to_read .and. variable_exists(bc_rest_files(f), var%bc_r4(n)%field(m)%name))
then
3517 allocate(dim_names(get_variable_num_dimensions(bc_rest_files(f), var%bc_r4(n)%field(m)%name)))
3518 call get_variable_dimension_names(bc_rest_files(f), &
3519 & var%bc_r4(n)%field(m)%name, dim_names)
3522 allocate(dim_names(4))
3523 dim_names(1) =
"xaxis_1"
3524 dim_names(2) =
"yaxis_1"
3525 dim_names(3) =
"zaxis_1"
3526 dim_names(4) =
"Time"
3530 & var%bc_r4(n)%field(m)%name, var%bc_r4(n)%field(m)%values, dim_names, &
3531 & is_optional=var%bc_r4(n)%field(m)%may_init )
3532 deallocate(dim_names)
3537 call mpp_error(fatal,
"CT_register_restarts_2d: passed in type has unassociated coupler_field_type"// &
3538 " pointers for both bc and bc_r4")
3544 character(len=*),
optional,
intent(in) :: directory
3546 logical,
optional,
intent(in) :: all_or_nothing
3549 logical,
optional,
intent(in) :: all_required
3552 logical,
optional,
intent(in) :: test_by_field
3554 logical,
intent(in) :: use_fms2_io
3556 integer :: n, m, num_fld
3557 character(len=80) :: unset_varname
3558 logical :: any_set, all_set, all_var_set, any_var_set, var_set
3560 if(var%set .and. var%num_bcs .gt. 0)
then
3561 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
3562 if(
associated(var%bc) )
then
3563 call mpp_error(fatal,
"CT_restore_state_2d: var%bc and var%bc_r4 are both initialized," // &
3564 "only one should be associated per type")
3566 call mpp_error(fatal,
"CT_restore_state_2d: var%bc and var%bc_r4 are both uninitialized," // &
3567 "one should be associated per type to restore state from restart")
3577 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
3578 do n = 1, var%num_bcs
3579 any_var_set = .false.
3580 all_var_set = .true.
3581 do m = 1, var%bc(n)%num_fields
3583 if (check_if_open(var%bc(n)%fms2_io_rest_type))
then
3584 var_set = variable_exists(var%bc(n)%fms2_io_rest_type, var%bc(n)%field(m)%name)
3587 if (.not.var_set) unset_varname = trim(var%bc(n)%field(m)%name)
3588 if (var_set) any_set = .true.
3589 if (all_set) all_set = var_set
3590 if (var_set) any_var_set = .true.
3591 if (all_var_set) all_var_set = var_set
3594 num_fld = num_fld + var%bc(n)%num_fields
3595 if ((var%bc(n)%num_fields > 0) .and.
present(test_by_field))
then
3596 if (test_by_field .and. (all_var_set .neqv. any_var_set))
call mpp_error(fatal,&
3597 &
"CT_restore_state_2d: test_by_field is true, and "//&
3598 & trim(unset_varname)//
" was not read but some other fields in "//&
3599 & trim(trim(var%bc(n)%name))//
" were.")
3602 else if(
associated(var%bc_r4))
then
3603 do n = 1, var%num_bcs
3604 any_var_set = .false.
3605 all_var_set = .true.
3606 do m = 1, var%bc_r4(n)%num_fields
3608 if (check_if_open(var%bc_r4(n)%fms2_io_rest_type))
then
3609 var_set = variable_exists(var%bc_r4(n)%fms2_io_rest_type, var%bc_r4(n)%field(m)%name)
3612 if (.not.var_set) unset_varname = trim(var%bc_r4(n)%field(m)%name)
3613 if (var_set) any_set = .true.
3614 if (all_set) all_set = var_set
3615 if (var_set) any_var_set = .true.
3616 if (all_var_set) all_var_set = var_set
3619 num_fld = num_fld + var%bc_r4(n)%num_fields
3620 if ((var%bc_r4(n)%num_fields > 0) .and.
present(test_by_field))
then
3621 if (test_by_field .and. (all_var_set .neqv. any_var_set))
call mpp_error(fatal,&
3622 &
"CT_restore_state_2d: test_by_field is true, and "//&
3623 & trim(unset_varname)//
" was not read but some other fields in "//&
3624 & trim(trim(var%bc_r4(n)%name))//
" were.")
3628 call mpp_error(fatal,
"CT_restore_state_2d: passed in type has unassociated coupler_field_type"// &
3629 " pointers for both bc and bc_r4")
3632 if ((num_fld > 0) .and.
present(all_or_nothing))
then
3633 if (all_or_nothing .and. (all_set .neqv. any_set))
call mpp_error(fatal,&
3634 &
"CT_restore_state_2d: all_or_nothing is true, and "//&
3635 & trim(unset_varname)//
" was not read but some other fields were.")
3638 if (
present(all_required))
then
3639 if (all_required .and. .not.all_set)
then
3640 call mpp_error(fatal,
"CT_restore_state_2d: all_required is true, but "//&
3641 & trim(unset_varname)//
" was not read from its restart file.")
3652 character(len=*),
optional,
intent(in) :: directory
3654 logical,
intent(in) :: use_fms2_io
3655 logical,
optional,
intent(in) :: all_or_nothing
3658 logical,
optional,
intent(in) :: all_required
3661 logical,
optional,
intent(in) :: test_by_field
3664 integer :: n, m, num_fld
3665 character(len=80) :: unset_varname
3666 logical :: any_set, all_set, all_var_set, any_var_set, var_set
3668 if(var%set .and. var%num_bcs .gt. 0)
then
3669 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
3670 if(
associated(var%bc) )
then
3671 call mpp_error(fatal,
"CT_restore_state_3d: var%bc and var%bc_r4 are both initialized," // &
3672 "only one should be associated per type")
3674 call mpp_error(fatal,
"CT_restore_state_3d: var%bc and var%bc_r4 are both uninitialized," // &
3675 "one should be associated per type to restore state from restart")
3685 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
3686 do n = 1, var%num_bcs
3687 any_var_set = .false.
3688 all_var_set = .true.
3689 do m = 1, var%bc(n)%num_fields
3691 if (check_if_open(var%bc(n)%fms2_io_rest_type))
then
3692 var_set = variable_exists(var%bc(n)%fms2_io_rest_type, var%bc(n)%field(m)%name)
3695 if (.not.var_set) unset_varname = trim(var%bc(n)%field(m)%name)
3697 if (var_set) any_set = .true.
3698 if (all_set) all_set = var_set
3699 if (var_set) any_var_set = .true.
3700 if (all_var_set) all_var_set = var_set
3703 num_fld = num_fld + var%bc(n)%num_fields
3704 if ((var%bc(n)%num_fields > 0) .and.
present(test_by_field))
then
3705 if (test_by_field .and. (all_var_set .neqv. any_var_set))
call mpp_error(fatal,&
3706 &
"CT_restore_state_3d: test_by_field is true, and "//&
3707 & trim(unset_varname)//
" was not read but some other fields in "//&
3708 & trim(trim(var%bc(n)%name))//
" were.")
3711 else if(
associated(var%bc_r4))
then
3712 do n = 1, var%num_bcs
3713 any_var_set = .false.
3714 all_var_set = .true.
3715 do m = 1, var%bc_r4(n)%num_fields
3717 if (check_if_open(var%bc_r4(n)%fms2_io_rest_type))
then
3718 var_set = variable_exists(var%bc_r4(n)%fms2_io_rest_type, var%bc_r4(n)%field(m)%name)
3721 if (.not.var_set) unset_varname = trim(var%bc_r4(n)%field(m)%name)
3723 if (var_set) any_set = .true.
3724 if (all_set) all_set = var_set
3725 if (var_set) any_var_set = .true.
3726 if (all_var_set) all_var_set = var_set
3729 num_fld = num_fld + var%bc_r4(n)%num_fields
3730 if ((var%bc_r4(n)%num_fields > 0) .and.
present(test_by_field))
then
3731 if (test_by_field .and. (all_var_set .neqv. any_var_set))
call mpp_error(fatal,&
3732 &
"CT_restore_state_3d: test_by_field is true, and "//&
3733 & trim(unset_varname)//
" was not read but some other fields in "//&
3734 & trim(trim(var%bc(n)%name))//
" were.")
3738 call mpp_error(fatal,
"CT_restore_state_3d: passed in type has unassociated coupler_field_type"// &
3739 " pointers for both bc and bc_r4")
3743 if ((num_fld > 0) .and.
present(all_or_nothing))
then
3744 if (all_or_nothing .and. (all_set .neqv. any_set))
call mpp_error(fatal,&
3745 &
"CT_restore_state_3d: all_or_nothing is true, and "//&
3746 & trim(unset_varname)//
" was not read but some other fields were.")
3749 if (
present(all_required))
then
3750 if (all_required .and. .not.all_set)
then
3751 call mpp_error(fatal,
"CT_restore_state_3d: all_required is true, but "//&
3752 & trim(unset_varname)//
" was not read from its restart file.")
3760 character(len=3),
intent(in) :: gridname
3765 if(var%set .and. var%num_bcs .gt. 0)
then
3766 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
3767 if(
associated(var%bc) )
then
3768 call mpp_error(fatal,
"CT_data_override_2d: var%bc and var%bc_r4 are both initialized," // &
3769 "only one should be associated per type")
3771 call mpp_error(fatal,
"CT_data_override_2d: var%bc and var%bc_r4 are both uninitialized," // &
3772 "one should be associated per type to perform data override")
3777 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
3778 do n = 1, var%num_bcs
3779 do m = 1, var%bc(n)%num_fields
3780 call data_override(gridname, var%bc(n)%field(m)%name, var%bc(n)%field(m)%values, time)
3783 else if(
associated(var%bc_r4))
then
3784 do n = 1, var%num_bcs
3785 do m = 1, var%bc_r4(n)%num_fields
3786 call data_override(gridname, var%bc_r4(n)%field(m)%name, var%bc_r4(n)%field(m)%values, time)
3790 call mpp_error(fatal,
"CT_data_override_2d: passed in type has unassociated coupler_field_type"// &
3791 " pointers for both bc and bc_r4")
3797 character(len=3),
intent(in) :: gridname
3801 real(r8_kind),
allocatable :: r8_field_values(:,:,:)
3805 if(var%set .and. var%num_bcs .gt. 0)
then
3806 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
3807 if(
associated(var%bc) )
then
3808 call mpp_error(fatal,
"CT_data_override_3d: var%bc and var%bc_r4 are both initialized," // &
3809 "only one should be associated per type")
3811 call mpp_error(fatal,
"CT_data_override_3d: var%bc and var%bc_r4 are both uninitialized," // &
3812 "one should be associated per type to perform data override")
3817 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
3818 do n = 1, var%num_bcs
3819 do m = 1, var%bc(n)%num_fields
3820 call data_override(gridname, var%bc(n)%field(m)%name, var%bc(n)%field(m)%values, time)
3823 else if(
associated(var%bc_r4))
then
3824 do n = 1, var%num_bcs
3825 do m = 1, var%bc_r4(n)%num_fields
3826 call data_override(gridname, var%bc_r4(n)%field(m)%name, var%bc_r4(n)%field(m)%values, time)
3830 call mpp_error(fatal,
"CT_data_override_3d: passed in type has unassociated coupler_field_type"// &
3831 " pointers for both bc and bc_r4")
3840 integer,
intent(in) :: outunit
3841 character(len=*),
optional,
intent(in) :: name_lead
3843 character(len=120) :: var_name
3845 integer(i8_kind) :: chks
3847 if(var%set .and. var%num_bcs .gt. 0)
then
3848 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
3849 if(
associated(var%bc) )
then
3850 call mpp_error(fatal,
"CT_write_chksums_2d: var%bc and var%bc_r4 are both initialized," // &
3851 "only one should be associated per type")
3853 call mpp_error(fatal,
"CT_write_chksums_2d: var%bc and var%bc_r4 are both uninitialized," // &
3854 "one should be associated per type to write checksums for fields")
3859 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
3860 do n = 1, var%num_bcs
3861 do m = 1, var%bc(n)%num_fields
3862 if (
present(name_lead))
then
3863 var_name = trim(name_lead)//trim(var%bc(n)%field(m)%name)
3865 var_name = trim(var%bc(n)%field(m)%name)
3867 chks =
mpp_chksum(var%bc(n)%field(m)%values(var%isc:var%iec,var%jsc:var%jec))
3868 if(outunit.ne.0)
write(outunit,
'(" CHECKSUM:: ",A40," = ",Z20)') trim(var_name), chks
3871 else if(
associated(var%bc_r4))
then
3872 do n = 1, var%num_bcs
3873 do m = 1, var%bc_r4(n)%num_fields
3874 if (
present(name_lead))
then
3875 var_name = trim(name_lead)//trim(var%bc_r4(n)%field(m)%name)
3877 var_name = trim(var%bc_r4(n)%field(m)%name)
3879 chks =
mpp_chksum(var%bc_r4(n)%field(m)%values(var%isc:var%iec,var%jsc:var%jec))
3880 if(outunit.ne.0)
write(outunit,
'(" CHECKSUM:: ",A40," = ",Z20)') trim(var_name), chks
3884 call mpp_error(fatal,
"CT_write_chksums_2d: passed in type has unassociated coupler_field_type"// &
3885 " pointers for both bc and bc_r4")
3892 integer,
intent(in) :: outunit
3893 character(len=*),
optional,
intent(in) :: name_lead
3895 character(len=120) :: var_name
3897 integer(i8_kind) :: chks
3899 if(var%set .and. var%num_bcs .gt. 0)
then
3900 if(
associated(var%bc) .eqv.
associated(var%bc_r4))
then
3901 if(
associated(var%bc) )
then
3902 call mpp_error(fatal,
"CT_write_chksums_3d: var%bc and var%bc_r4 are both initialized," // &
3903 "only one should be associated per type")
3905 call mpp_error(fatal,
"CT_write_chksums_3d: var%bc and var%bc_r4 are both uninitialized," // &
3906 "one should be associated per type to write checksums for fields")
3911 if(
associated(var%bc) .or. var%num_bcs .lt. 1)
then
3912 do n = 1, var%num_bcs
3913 do m = 1, var%bc(n)%num_fields
3914 if (
present(name_lead))
then
3915 var_name = trim(name_lead)//trim(var%bc(n)%field(m)%name)
3917 var_name = trim(var%bc(n)%field(m)%name)
3919 chks =
mpp_chksum(var%bc(n)%field(m)%values(var%isc:var%iec,var%jsc:var%jec,:))
3920 if(outunit.ne.0)
write(outunit,
'(" CHECKSUM:: ",A40," = ",Z20)') trim(var_name), chks
3923 else if(
associated(var%bc_r4))
then
3924 do n = 1, var%num_bcs
3925 do m = 1, var%bc_r4(n)%num_fields
3926 if (
present(name_lead))
then
3927 var_name = trim(name_lead)//trim(var%bc_r4(n)%field(m)%name)
3929 var_name = trim(var%bc_r4(n)%field(m)%name)
3931 chks =
mpp_chksum(var%bc_r4(n)%field(m)%values(var%isc:var%iec,var%jsc:var%jec,:))
3932 if(outunit.ne.0)
write(outunit,
'(" CHECKSUM:: ",A40," = ",Z20)') trim(var_name), chks
3936 call mpp_error(fatal,
"CT_write_chksums_2d: passed in type has unassociated coupler_field_type"// &
3937 " pointers for both bc and bc_r4")
3972 if (var%num_bcs > 0)
then
3973 if(
associated(var%bc))
then
3974 do n = 1, var%num_bcs
3975 do m = 1, var%bc(n)%num_fields
3976 deallocate ( var%bc(n)%field(m)%values )
3978 deallocate ( var%bc(n)%field )
3980 deallocate ( var%bc )
3981 else if(
associated(var%bc_r4))
then
3982 do n = 1, var%num_bcs
3983 do m = 1, var%bc_r4(n)%num_fields
3984 deallocate ( var%bc_r4(n)%field(m)%values )
3986 deallocate ( var%bc_r4(n)%field )
3988 deallocate ( var%bc_r4 )
3990 call mpp_error(fatal,
"CT_destructor_1d: passed in type has unassociated coupler_field_type"// &
3991 " pointers for both bc and bc_r4")
4005 if (var%num_bcs > 0)
then
4006 if(
associated(var%bc))
then
4007 do n = 1, var%num_bcs
4008 do m = 1, var%bc(n)%num_fields
4009 deallocate ( var%bc(n)%field(m)%values )
4011 deallocate ( var%bc(n)%field )
4013 deallocate ( var%bc )
4014 else if(
associated(var%bc_r4))
then
4015 do n = 1, var%num_bcs
4016 do m = 1, var%bc_r4(n)%num_fields
4017 deallocate ( var%bc_r4(n)%field(m)%values )
4019 deallocate ( var%bc_r4(n)%field )
4021 deallocate ( var%bc_r4 )
4023 call mpp_error(fatal,
"CT_destructor_2d: passed in type has unassociated coupler_field_type"// &
4024 " pointers for both bc and bc_r4")
4038 if (var%num_bcs > 0)
then
4039 if(
associated(var%bc))
then
4040 do n = 1, var%num_bcs
4041 do m = 1, var%bc(n)%num_fields
4042 deallocate ( var%bc(n)%field(m)%values )
4044 deallocate ( var%bc(n)%field )
4046 deallocate ( var%bc )
4047 else if(
associated(var%bc_r4))
then
4048 do n = 1, var%num_bcs
4049 do m = 1, var%bc_r4(n)%num_fields
4050 deallocate ( var%bc_r4(n)%field(m)%values )
4052 deallocate ( var%bc_r4(n)%field )
4054 deallocate ( var%bc_r4 )
4056 call mpp_error(fatal,
"CT_destructor_3d: passed in type has unassociated coupler_field_type"// &
4057 " pointers for both bc and bc_r4")
4066 #include "coupler_types_r4.fh"
4067 #include "coupler_types_r8.fh"
4073 #ifdef use_deprecated_io
4074 subroutine mpp_io_ct_register_restarts_2d(var, bc_rest_files, num_rest_files, mpp_domain, ocean_restart)
4076 type(restart_file_type),
dimension(:),
pointer :: bc_rest_files
4077 integer,
intent(out) :: num_rest_files
4078 type(
domain2d),
intent(in) :: mpp_domain
4079 logical,
optional,
intent(in) :: ocean_restart
4081 character(len=80),
dimension(max(1,var%num_bcs)) :: rest_file_names
4082 character(len=80) :: file_nm
4087 if (
present(ocean_restart)) ocn_rest = ocean_restart
4091 do n = 1, var%num_bcs
4092 if (var%bc(n)%num_fields <= 0) cycle
4093 file_nm = trim(var%bc(n)%ice_restart_file)
4094 if (ocn_rest) file_nm = trim(var%bc(n)%ocean_restart_file)
4095 do f = 1, num_rest_files
4096 if (trim(file_nm) == trim(rest_file_names(f)))
exit
4098 if (f>num_rest_files)
then
4099 num_rest_files = num_rest_files + 1
4100 rest_file_names(f) = trim(file_nm)
4104 if (num_rest_files == 0)
return
4107 allocate(bc_rest_files(num_rest_files))
4108 do n = 1, var%num_bcs
4109 if (var%bc(n)%num_fields <= 0) cycle
4111 file_nm = trim(var%bc(n)%ice_restart_file)
4112 if (ocn_rest) file_nm = trim(var%bc(n)%ocean_restart_file)
4113 do f = 1, num_rest_files
4114 if (trim(file_nm) == trim(rest_file_names(f)))
exit
4117 var%bc(n)%rest_type => bc_rest_files(f)
4118 do m = 1, var%bc(n)%num_fields
4119 var%bc(n)%field(m)%id_rest = fms_io_register_restart_field(bc_rest_files(f),&
4120 & rest_file_names(f), var%bc(n)%field(m)%name, var%bc(n)%field(m)%values,&
4121 & mpp_domain, mandatory=.not.var%bc(n)%field(m)%may_init )
4124 end subroutine mpp_io_ct_register_restarts_2d
4130 subroutine mpp_io_ct_register_restarts_to_file_2d(var, file_name, rest_file, mpp_domain, varname_prefix)
4132 character(len=*),
intent(in) :: file_name
4133 type(restart_file_type),
pointer :: rest_file
4135 type(
domain2d),
intent(in) :: mpp_domain
4136 character(len=*),
optional,
intent(in) :: varname_prefix
4141 character(len=128) :: var_name
4145 if (.not.
associated(rest_file))
allocate(rest_file)
4146 do n = 1, var%num_bcs
4147 if (var%bc(n)%num_fields <= 0) cycle
4149 var%bc(n)%rest_type => rest_file
4150 do m = 1, var%bc(n)%num_fields
4151 var_name = trim(var%bc(n)%field(m)%name)
4152 if (
present(varname_prefix)) var_name = trim(varname_prefix)//trim(var_name)
4153 var%bc(n)%field(m)%id_rest = fms_io_register_restart_field(rest_file,&
4154 & file_name, var_name, var%bc(n)%field(m)%values,&
4155 & mpp_domain, mandatory=.not.var%bc(n)%field(m)%may_init )
4158 end subroutine mpp_io_ct_register_restarts_to_file_2d
4164 subroutine mpp_io_ct_register_restarts_3d(var, bc_rest_files, num_rest_files, mpp_domain, ocean_restart)
4166 type(restart_file_type),
dimension(:),
pointer :: bc_rest_files
4167 integer,
intent(out) :: num_rest_files
4168 type(
domain2d),
intent(in) :: mpp_domain
4169 logical,
optional,
intent(in) :: ocean_restart
4171 character(len=80),
dimension(max(1,var%num_bcs)) :: rest_file_names
4172 character(len=80) :: file_nm
4177 if (
present(ocean_restart)) ocn_rest = ocean_restart
4181 do n = 1, var%num_bcs
4182 if (var%bc(n)%num_fields <= 0) cycle
4183 file_nm = trim(var%bc(n)%ice_restart_file)
4184 if (ocn_rest) file_nm = trim(var%bc(n)%ocean_restart_file)
4185 do f = 1, num_rest_files
4186 if (trim(file_nm) == trim(rest_file_names(f)))
exit
4188 if (f>num_rest_files)
then
4189 num_rest_files = num_rest_files + 1
4190 rest_file_names(f) = trim(file_nm)
4194 if (num_rest_files == 0)
return
4197 allocate(bc_rest_files(num_rest_files))
4198 do n = 1, var%num_bcs
4199 if (var%bc(n)%num_fields <= 0) cycle
4200 file_nm = trim(var%bc(n)%ice_restart_file)
4201 if (ocn_rest) file_nm = trim(var%bc(n)%ocean_restart_file)
4202 do f = 1, num_rest_files
4203 if (trim(file_nm) == trim(rest_file_names(f)))
exit
4206 var%bc(n)%rest_type => bc_rest_files(f)
4207 do m = 1, var%bc(n)%num_fields
4208 var%bc(n)%field(m)%id_rest = fms_io_register_restart_field(bc_rest_files(f),&
4209 & rest_file_names(f), var%bc(n)%field(m)%name, var%bc(n)%field(m)%values,&
4210 & mpp_domain, mandatory=.not.var%bc(n)%field(m)%may_init )
4213 end subroutine mpp_io_ct_register_restarts_3d
4218 subroutine mpp_io_ct_register_restarts_to_file_3d(var, file_name, rest_file, mpp_domain, varname_prefix)
4220 character(len=*),
intent(in) :: file_name
4221 type(restart_file_type),
pointer :: rest_file
4222 type(
domain2d),
intent(in) :: mpp_domain
4223 character(len=*),
optional,
intent(in) :: varname_prefix
4228 character(len=128) :: var_name
4232 if (.not.
associated(rest_file))
allocate(rest_file)
4233 do n = 1, var%num_bcs
4234 if (var%bc(n)%num_fields <= 0) cycle
4236 var%bc(n)%rest_type => rest_file
4237 do m = 1, var%bc(n)%num_fields
4238 var_name = trim(var%bc(n)%field(m)%name)
4239 if (
present(varname_prefix)) var_name = trim(varname_prefix)//trim(var_name)
4240 var%bc(n)%field(m)%id_rest = fms_io_register_restart_field(rest_file,&
4241 & file_name, var_name, var%bc(n)%field(m)%values,&
4242 & mpp_domain, mandatory=.not.var%bc(n)%field(m)%may_init )
4245 end subroutine mpp_io_ct_register_restarts_to_file_3d
4251 subroutine mpp_io_ct_restore_state_2d(var, directory, all_or_nothing, all_required, test_by_field)
4253 character(len=*),
optional,
intent(in) :: directory
4255 logical,
optional,
intent(in) :: all_or_nothing
4258 logical,
optional,
intent(in) :: all_required
4261 logical,
optional,
intent(in) :: test_by_field
4264 integer :: n, m, num_fld
4265 character(len=80) :: unset_varname
4266 logical :: any_set, all_set, all_var_set, any_var_set, var_set
4273 do n = 1, var%num_bcs
4274 any_var_set = .false.
4275 all_var_set = .true.
4276 do m = 1, var%bc(n)%num_fields
4278 if (var%bc(n)%field(m)%id_rest > 0)
then
4279 var_set = query_initialized(var%bc(n)%rest_type, var%bc(n)%field(m)%id_rest)
4280 if (.not.var_set)
then
4281 call restore_state(var%bc(n)%rest_type, var%bc(n)%field(m)%id_rest,&
4282 & directory=directory, nonfatal_missing_files=.true.)
4283 var_set = query_initialized(var%bc(n)%rest_type, var%bc(n)%field(m)%id_rest)
4287 if (.not.var_set) unset_varname = trim(var%bc(n)%field(m)%name)
4288 if (var_set) any_set = .true.
4289 if (all_set) all_set = var_set
4290 if (var_set) any_var_set = .true.
4291 if (all_var_set) all_var_set = var_set
4294 num_fld = num_fld + var%bc(n)%num_fields
4295 if ((var%bc(n)%num_fields > 0) .and.
present(test_by_field))
then
4296 if (test_by_field .and. (all_var_set .neqv. any_var_set))
call mpp_error(fatal,&
4297 &
"mpp_io_CT_restore_state_2d: test_by_field is true, and "//&
4298 & trim(unset_varname)//
" was not read but some other fields in "//&
4299 & trim(trim(var%bc(n)%name))//
" were.")
4303 if ((num_fld > 0) .and.
present(all_or_nothing))
then
4304 if (all_or_nothing .and. (all_set .neqv. any_set))
call mpp_error(fatal,&
4305 &
"mpp_io_CT_restore_state_2d: all_or_nothing is true, and "//&
4306 & trim(unset_varname)//
" was not read but some other fields were.")
4309 if (
present(all_required))
then
4310 if (all_required .and. .not.all_set)
then
4311 call mpp_error(fatal,
"mpp_io_CT_restore_state_2d: all_required is true, but "//&
4312 & trim(unset_varname)//
" was not read from its restart file.")
4315 end subroutine mpp_io_ct_restore_state_2d
4321 subroutine mpp_io_ct_restore_state_3d(var, directory, all_or_nothing, all_required, test_by_field)
4323 character(len=*),
optional,
intent(in) :: directory
4325 logical,
optional,
intent(in) :: all_or_nothing
4328 logical,
optional,
intent(in) :: all_required
4331 logical,
optional,
intent(in) :: test_by_field
4334 integer :: n, m, num_fld
4335 character(len=80) :: unset_varname
4336 logical :: any_set, all_set, all_var_set, any_var_set, var_set
4343 do n = 1, var%num_bcs
4344 any_var_set = .false.
4345 all_var_set = .true.
4346 do m = 1, var%bc(n)%num_fields
4348 if (var%bc(n)%field(m)%id_rest > 0)
then
4349 var_set = query_initialized(var%bc(n)%rest_type, var%bc(n)%field(m)%id_rest)
4350 if (.not.var_set)
then
4351 call restore_state(var%bc(n)%rest_type, var%bc(n)%field(m)%id_rest,&
4352 & directory=directory, nonfatal_missing_files=.true.)
4353 var_set = query_initialized(var%bc(n)%rest_type, var%bc(n)%field(m)%id_rest)
4357 if (.not.var_set) unset_varname = trim(var%bc(n)%field(m)%name)
4359 if (var_set) any_set = .true.
4360 if (all_set) all_set = var_set
4361 if (var_set) any_var_set = .true.
4362 if (all_var_set) all_var_set = var_set
4365 num_fld = num_fld + var%bc(n)%num_fields
4366 if ((var%bc(n)%num_fields > 0) .and.
present(test_by_field))
then
4367 if (test_by_field .and. (all_var_set .neqv. any_var_set))
call mpp_error(fatal,&
4368 &
"mpp_io_CT_restore_state_3d: test_by_field is true, and "//&
4369 & trim(unset_varname)//
" was not read but some other fields in "//&
4370 & trim(trim(var%bc(n)%name))//
" were.")
4374 if ((num_fld > 0) .and.
present(all_or_nothing))
then
4375 if (all_or_nothing .and. (all_set .neqv. any_set))
call mpp_error(fatal,&
4376 &
"mpp_io_CT_restore_state_3d: all_or_nothing is true, and "//&
4377 & trim(unset_varname)//
" was not read but some other fields were.")
4380 if (
present(all_required))
then
4381 if (all_required .and. .not.all_set)
then
4382 call mpp_error(fatal,
"mpp_io_CT_restore_state_3d: all_required is true, but "//&
4383 & trim(unset_varname)//
" was not read from its restart file.")
4386 end subroutine mpp_io_ct_restore_state_3d
4388 end module coupler_types_mod
subroutine ct_redistribute_data_2d(var_in, domain_in, var_out, domain_out, complete)
Redistribute the data in all elements of a coupler_2d_bc_type.
integer, public ind_kw
The index for the piston velocity.
subroutine ct_data_override_2d(gridname, var, Time)
Potentially override the values in a coupler_2d_bc_type.
subroutine register_axis_wrapper_write(fileobj, nz)
integer, public ind_u10
The index of the 10 m wind speed.
subroutine coupler_type_copy_2d_2d(var_in, var_out, is, ie, js, je, diag_name, axes, time, suffix)
Copy fields from one coupler type to another. 2-D to 2-D version for generic coupler_type_copy.
subroutine ct_spawn_3d_2d(var_in, var, idim, jdim, suffix, as_needed)
Generate one coupler type using another as a template. 3-D to 2-D version for generic CT_spawn.
integer, public ind_runoff
The index for a runoff flux.
integer, public ind_csurf
The index of the ocean surface concentration.
subroutine, public coupler_types_init
Initialize the coupler types.
subroutine ct_spawn_3d_3d(var_in, var, idim, jdim, kdim, suffix, as_needed)
Generate one coupler type using another as a template. 3-D to 3-D version for generic CT_spawn.
logical function ct_initialized_2d(var)
Indicate whether a coupler_2d_bc_type has been initialized.
subroutine ct_register_restarts_2d(var, bc_rest_files, num_rest_files, mpp_domain, to_read, ocean_restart, directory)
subroutine ct_send_data_3d(var, Time, return_statuses)
Write out all diagnostics of elements of a coupler_3d_bc_type.
integer, public ind_sc_no
The index for the Schmidt number for a tracer flux.
integer, public ind_deposition
The index for the atmospheric deposition flux.
subroutine ct_destructor_1d(var)
Deallocate all data associated with a coupler_1d_bc_type.
subroutine ct_destructor_2d(var)
Deallocate all data associated with a coupler_2d_bc_type.
subroutine ct_spawn_2d_2d(var_in, var, idim, jdim, suffix, as_needed)
Generate one coupler type using another as a template. 2-D to 2-D version for generic CT_spawn.
subroutine ct_write_chksums_2d(var, outunit, name_lead)
Write out checksums for the elements of a coupler_2d_bc_type.
subroutine ct_increment_data_3d_3d(var_in, var, halo_size, bc_index, field_index, scale_factor, scale_prev, exclude_flux_type, only_flux_type, pass_through_ice)
Increment data in all elements of one coupler_3d_bc_type.
subroutine ct_restore_state_2d(var, use_fms2_io, directory, all_or_nothing, all_required, test_by_field)
subroutine ct_set_diags_3d(var, diag_name, axes, time)
Register the diagnostics of a coupler_3d_bc_type.
subroutine register_axis_wrapper(fileobj, to_read, nz)
subroutine, public coupler_type_copy_1d_3d(var_in, var_out, is, ie, js, je, kd, diag_name, axes, time, suffix)
Copy fields from one coupler type to another. 1-D to 3-D version for generic coupler_type_copy.
subroutine coupler_type_copy_3d_3d(var_in, var_out, is, ie, js, je, kd, diag_name, axes, time, suffix)
Copy fields from one coupler type to another. 3-D to 3-D version for generic coupler_type_copy.
subroutine ct_redistribute_data_3d(var_in, domain_in, var_out, domain_out, complete)
Redistributes the data in all elements of one coupler_2d_bc_type.
subroutine ct_spawn_1d_3d(var_in, var, idim, jdim, kdim, suffix, as_needed)
Generate one coupler type using another as a template. 1-D to 3-D version for generic CT_spawn.
subroutine ct_copy_data_3d(var_in, var, halo_size, bc_index, field_index, exclude_flux_type, only_flux_type, pass_through_ice)
Copy all elements of coupler_3d_bc_type.
integer, public ind_alpha
The index of the solubility array for a tracer.
subroutine ct_set_diags_2d(var, diag_name, axes, time)
logical function ct_initialized_1d(var)
Indicate whether a coupler_1d_bc_type has been initialized.
subroutine ct_copy_data_2d(var_in, var, halo_size, bc_index, field_index, exclude_flux_type, only_flux_type, pass_through_ice)
Copy all elements of coupler_2d_bc_type. Do a direct copy of the data in all elements of one coupler_...
subroutine ct_spawn_2d_3d(var_in, var, idim, jdim, kdim, suffix, as_needed)
Generate one coupler type using another as a template. 2-D to 3-D version for generic CT_spawn.
subroutine ct_write_chksums_3d(var, outunit, name_lead)
Write out checksums for the elements of a coupler_3d_bc_type.
subroutine ct_spawn_1d_2d(var_in, var, idim, jdim, suffix, as_needed)
Generate one coupler type using another as a template. 1-D to 2-D version for generic coupler_type_sp...
subroutine coupler_type_copy_3d_2d(var_in, var_out, is, ie, js, je, diag_name, axes, time, suffix)
Copy fields from one coupler type to another. 3-D to 2-D version for generic coupler_type_copy.
integer, public ind_flux
The index for the tracer flux.
subroutine ct_destructor_3d(var)
Deallocate all data associated with a coupler_3d_bc_type.
integer, public ind_pcair
The index of the atmospheric concentration.
subroutine coupler_type_copy_2d_3d(var_in, var_out, is, ie, js, je, kd, diag_name, axes, time, suffix)
Copy fields from one coupler type to another. 2-D to 3-D version for generic coupler_type_copy.
integer, public ind_flux0
The index for the piston velocity.
subroutine ct_copy_data_2d_3d(var_in, var, halo_size, bc_index, field_index, exclude_flux_type, only_flux_type, pass_through_ice, ind3_start, ind3_end)
Copy all elements of coupler_2d_bc_type to coupler_3d_bc_type.
integer, public ind_psurf
The index of the surface atmospheric pressure.
subroutine ct_register_restarts_3d(var, bc_rest_files, num_rest_files, mpp_domain, to_read, ocean_restart, directory)
subroutine ct_increment_data_2d_2d(var_in, var, halo_size, bc_index, field_index, scale_factor, scale_prev, exclude_flux_type, only_flux_type, pass_through_ice)
Increment data in all elements of one coupler_2d_bc_type.
subroutine ct_data_override_3d(gridname, var, Time)
Potentially override the values in a coupler_3d_bc_type.
subroutine, public coupler_type_copy_1d_2d(var_in, var_out, is, ie, js, je, diag_name, axes, time, suffix)
Copy fields from one coupler type to another. 1-D to 2-D version for generic coupler_type_copy.
subroutine register_axis_wrapper_read(fileobj)
subroutine ct_restore_state_3d(var, use_fms2_io, directory, all_or_nothing, all_required, test_by_field)
Read in fields from restart files into a coupler_3d_bc_type.
integer, public ind_deltap
The index for ocean-air gas partial pressure change.
logical function ct_initialized_3d(var)
Indicate whether a coupler_3d_bc_type has been initialized.
subroutine ct_send_data_2d(var, Time, return_statuses)
Write out all diagnostics of elements of a coupler_2d_bc_type.
This is the interface to spawn one coupler_bc_type into another and then register diagnostics associa...
This is the interface to copy the field data from one coupler_bc_type to another of the same rank,...
This is the interface to override the values of the arrays in a coupler_bc_type.
This is the interface to deallocate any data associated with a coupler_bc_type.
This is the interface to increment the field data from one coupler_bc_type with the data from another...
This function interface indicates whether a coupler_bc_type has been initialized.
This is the interface to redistribute the field data from one coupler_bc_type to another of the same ...
This is the interface to register the fields in a coupler_bc_type to be saved in restart files.
This is the interface to rescale the field data in a coupler_bc_type.
This is the interface to read in the fields in a coupler_bc_type that have been saved in restart file...
This is the interface to write out diagnostics of the arrays in a coupler_bc_type.
This is the interface to set a field in a coupler_bc_type from an array.
This is the interface to set diagnostics for the arrays in a coupler_bc_type.
This is the interface to spawn one coupler_bc_type into another.
This is the interface to write out checksums for the elements of a coupler_bc_type.
Coupler data for 1D boundary conditions.
Coupler data for 1D fields.
Coupler data for 1D values.
Coupler data for 1D fields.
Coupler data for 1D values.
Coupler data for 2D boundary conditions.
Coupler data for 2D fields.
Coupler data for 2D values.
Coupler data for 2D fields.
Coupler data for 2D values.
Coupler data for 3D boundary conditions.
Coupler data for 3D fields.
Coupler data for 3D values.
Coupler data for 3D fields.
Coupler data for 3D values.
Interface for inserting and interpolating data into a file for a model's grid and time....
Register a diagnostic field for a given module.
Send data over to output fields.
Opens a given netcdf or domain file.
Add a dimension to a given file.
Defines a new field within the given file Example usage:
Similar to register_field, but occupies the field with data for restarts Example usage:
subroutine, public write_version_number(version, tag, unit)
Prints to the log file (or a specified unit) the version id string and tag name.
character(:) function, allocatable, public string(v, fmt)
Converts a number or a Boolean value to a string.
Reorganization of distributed global arrays. mpp_redistribute is used to reorganize a distributed ar...
The domain2D type contains all the necessary information to define the global, compute and data domai...
Calculate parallel checksums.
Type to represent amounts of time. Implemented as seconds and days to allow for larger intervals.