ROMS
Loading...
Searching...
No Matches
mod_boundary Module Reference

Data Types

type  t_apply
 
type  t_boundary
 

Functions/Subroutines

subroutine, public allocate_boundary (ng)
 
subroutine, public deallocate_boundary (ng)
 
subroutine, public initialize_boundary (ng, tile, model)
 

Variables

type(t_apply), dimension(:), allocatable lbc_apply
 
type(t_boundary), dimension(:), allocatable boundary
 

Function/Subroutine Documentation

◆ allocate_boundary()

subroutine, public mod_boundary::allocate_boundary ( integer, intent(in) ng)

Definition at line 750 of file mod_boundary.F.

751!
752!=======================================================================
753! !
754! This routine initializes all variables in the module for all nested !
755! grids. Currently, there is not parallel tiling in boundary arrays. !
756! !
757!=======================================================================
758!
759 USE mod_param
760 USE mod_ncparam
761 USE mod_scalars
762!
763! Imported variable declarations.
764!
765 integer, intent(in) :: ng
766!
767! Local variable declarations.
768!
769 integer :: LBi, UBi, LBj, UBj
770#ifdef ADJUST_BOUNDARY
771 integer :: LBij, UBij
772#endif
773 integer :: my_tile
774
775 real(r8) :: Xsize, Ysize
776#ifdef ADJUST_BOUNDARY
777 real(r8) :: XYsize
778#endif
779!
780!-----------------------------------------------------------------------
781! Initialize module variables.
782!-----------------------------------------------------------------------
783!
784! See dimension ranges. Notice that boundary arrays are dimensioned
785! with the global dimensions of grid. That is, no tiling ranges in
786! distributed-memory. This is done to facilitate processing.
787!
788 my_tile=-1 ! for global values
789 lbi=bounds(ng)%LBi(my_tile)
790 ubi=bounds(ng)%UBi(my_tile)
791 lbj=bounds(ng)%LBj(my_tile)
792 ubj=bounds(ng)%UBj(my_tile)
793#ifdef ADJUST_BOUNDARY
794 lbij=bounds(ng)%LBij
795 ubij=bounds(ng)%UBij
796#endif
797!
798! Set horizontal array size.
799!
800 xsize=real(ubi-lbi,r8)
801 ysize=real(ubj-lbj,r8)
802#ifdef ADJUST_BOUNDARY
803 xysize=real(ubij-lbij,r8)
804#endif
805!
806! Allocate structures.
807!
808 IF (ng.eq.1) THEN
809 allocate ( lbc_apply(ngrids) )
810 allocate ( boundary(ngrids) )
811 END IF
812!
813! Lateral boundary conditions apply switches. These switches need to
814! be initilized to TRUE here because 'initialize_boundary' is called
815! several times in adjoint-based application to clear state arrays.
816! These switches are part of the application grid and will be set to
817! FALSE elsewhere, if the boundary point is assigned by a nested grid.
818!
819 allocate ( lbc_apply(ng) % west(lbj:ubj) )
820 lbc_apply(ng) % west = .true.
821 dmem(ng)=dmem(ng)+ysize
822
823 allocate ( lbc_apply(ng) % east(lbj:ubj) )
824 lbc_apply(ng) % east = .true.
825 dmem(ng)=dmem(ng)+ysize
826
827 allocate ( lbc_apply(ng) % south(lbi:ubi) )
828 lbc_apply(ng) % south = .true.
829 dmem(ng)=dmem(ng)+xsize
830
831 allocate ( lbc_apply(ng) % north(lbi:ubi) )
832 lbc_apply(ng) % north = .true.
833 dmem(ng)=dmem(ng)+xsize
834!
835!-----------------------------------------------------------------------
836! Nonlinear model state.
837!-----------------------------------------------------------------------
838!
839#if defined ADJOINT || defined TANGENT || defined TL_IOMS
840 IF ( lbc(iwest,isfsur,ng)%acquire.or. &
841 & ad_lbc(iwest,isfsur,ng)%acquire) THEN
842#else
843 IF (lbc(iwest,isfsur,ng)%acquire) THEN
844#endif
845 allocate ( boundary(ng) % zeta_west(lbj:ubj) )
846 dmem(ng)=dmem(ng)+ysize
847
848#if defined CELERITY_READ || defined CELERITY_WRITE
849 allocate ( boundary(ng) % zeta_west_C2(lbj:ubj) )
850 dmem(ng)=dmem(ng)+ysize
851
852 allocate ( boundary(ng) % zeta_west_Ce(lbj:ubj) )
853 dmem(ng)=dmem(ng)+ysize
854
855 allocate ( boundary(ng) % zeta_west_Cx(lbj:ubj) )
856 dmem(ng)=dmem(ng)+ysize
857#endif
858#ifndef ANA_FSOBC
859 allocate ( boundary(ng) % zetaG_west(lbj:ubj,2) )
860 dmem(ng)=dmem(ng)+2.0_r8*ysize
861#endif
862 END IF
863!
864#if defined ADJOINT || defined TANGENT || defined TL_IOMS
865 IF ( lbc(ieast,isfsur,ng)%acquire.or. &
866 & ad_lbc(ieast,isfsur,ng)%acquire) THEN
867#else
868 IF (lbc(ieast,isfsur,ng)%acquire) THEN
869#endif
870 allocate ( boundary(ng) % zeta_east(lbj:ubj) )
871 dmem(ng)=dmem(ng)+ysize
872
873#if defined CELERITY_READ || defined CELERITY_WRITE
874 allocate ( boundary(ng) % zeta_east_C2(lbj:ubj) )
875 dmem(ng)=dmem(ng)+ysize
876
877 allocate ( boundary(ng) % zeta_east_Ce(lbj:ubj) )
878 dmem(ng)=dmem(ng)+ysize
879
880 allocate ( boundary(ng) % zeta_east_Cx(lbj:ubj) )
881 dmem(ng)=dmem(ng)+ysize
882#endif
883#ifndef ANA_FSOBC
884 allocate ( boundary(ng) % zetaG_east(lbj:ubj,2) )
885 dmem(ng)=dmem(ng)+2.0_r8*ysize
886#endif
887 END IF
888!
889#if defined ADJOINT || defined TANGENT || defined TL_IOMS
890 IF ( lbc(isouth,isfsur,ng)%acquire.or. &
891 & ad_lbc(isouth,isfsur,ng)%acquire) THEN
892#else
893 IF (lbc(isouth,isfsur,ng)%acquire) THEN
894#endif
895 allocate ( boundary(ng) % zeta_south(lbi:ubi) )
896 dmem(ng)=dmem(ng)+xsize
897
898#if defined CELERITY_READ || defined CELERITY_WRITE
899 allocate ( boundary(ng) % zeta_south_C2(lbi:ubi) )
900 dmem(ng)=dmem(ng)+xsize
901
902 allocate ( boundary(ng) % zeta_south_Ce(lbi:ubi) )
903 dmem(ng)=dmem(ng)+xsize
904
905 allocate ( boundary(ng) % zeta_south_Cx(lbi:ubi) )
906 dmem(ng)=dmem(ng)+xsize
907#endif
908#ifndef ANA_FSOBC
909 allocate ( boundary(ng) % zetaG_south(lbi:ubi,2) )
910 dmem(ng)=dmem(ng)+2.0_r8*xsize
911#endif
912 END IF
913!
914#if defined ADJOINT || defined TANGENT || defined TL_IOMS
915 IF ( lbc(inorth,isfsur,ng)%acquire.or. &
916 & ad_lbc(inorth,isfsur,ng)%acquire) THEN
917#else
918 IF (lbc(inorth,isfsur,ng)%acquire) THEN
919#endif
920 allocate ( boundary(ng) % zeta_north(lbi:ubi) )
921 dmem(ng)=dmem(ng)+xsize
922
923#if defined CELERITY_READ || defined CELERITY_WRITE
924 allocate ( boundary(ng) % zeta_north_C2(lbi:ubi) )
925 dmem(ng)=dmem(ng)+xsize
926
927 allocate ( boundary(ng) % zeta_north_Ce(lbi:ubi) )
928 dmem(ng)=dmem(ng)+xsize
929
930 allocate ( boundary(ng) % zeta_north_Cx(lbi:ubi) )
931 dmem(ng)=dmem(ng)+xsize
932#endif
933#ifndef ANA_FSOBC
934 allocate ( boundary(ng) % zetaG_north(lbi:ubi,2) )
935 dmem(ng)=dmem(ng)+2.0_r8*xsize
936#endif
937 END IF
938!
939#if defined ADJOINT || defined TANGENT || defined TL_IOMS
940 IF ( lbc(iwest,isubar,ng)%acquire.or. &
941 & ad_lbc(iwest,isubar,ng)%acquire) THEN
942#else
943 IF (lbc(iwest,isubar,ng)%acquire) THEN
944#endif
945 allocate ( boundary(ng) % ubar_west(lbj:ubj) )
946 dmem(ng)=dmem(ng)+ysize
947
948#if defined CELERITY_READ || defined CELERITY_WRITE
949 allocate ( boundary(ng) % ubar_west_C2(lbj:ubj) )
950 dmem(ng)=dmem(ng)+ysize
951
952 allocate ( boundary(ng) % ubar_west_Ce(lbj:ubj) )
953 dmem(ng)=dmem(ng)+ysize
954
955 allocate ( boundary(ng) % ubar_west_Cx(lbj:ubj) )
956 dmem(ng)=dmem(ng)+ysize
957#endif
958#ifndef ANA_M2OBC
959 allocate ( boundary(ng) % ubarG_west(lbj:ubj,2) )
960 dmem(ng)=dmem(ng)+2.0_r8*ysize
961#endif
962 END IF
963#ifdef WEC
964 IF (lbc(iwest,isu2sd,ng)%acquire) THEN
965 allocate ( boundary(ng) % ubarstokes_west(lbj:ubj) )
966 dmem(ng)=dmem(ng)+ysize
967 END IF
968#endif
969!
970#if defined ADJOINT || defined TANGENT || defined TL_IOMS
971 IF ( lbc(ieast,isubar,ng)%acquire.or. &
972 & ad_lbc(ieast,isubar,ng)%acquire) THEN
973#else
974 IF (lbc(ieast,isubar,ng)%acquire) THEN
975#endif
976 allocate ( boundary(ng) % ubar_east(lbj:ubj) )
977 dmem(ng)=dmem(ng)+ysize
978
979#if defined CELERITY_READ || defined CELERITY_WRITE
980 allocate ( boundary(ng) % ubar_east_C2(lbj:ubj) )
981 dmem(ng)=dmem(ng)+ysize
982
983 allocate ( boundary(ng) % ubar_east_Ce(lbj:ubj) )
984 dmem(ng)=dmem(ng)+ysize
985
986 allocate ( boundary(ng) % ubar_east_Cx(lbj:ubj) )
987 dmem(ng)=dmem(ng)+ysize
988#endif
989#ifndef ANA_M2OBC
990 allocate ( boundary(ng) % ubarG_east(lbj:ubj,2) )
991 dmem(ng)=dmem(ng)+2.0_r8*ysize
992#endif
993 END IF
994#ifdef WEC
995 IF (lbc(ieast,isu2sd,ng)%acquire) THEN
996 allocate ( boundary(ng) % ubarstokes_east(lbj:ubj) )
997 dmem(ng)=dmem(ng)+ysize
998 END IF
999#endif
1000!
1001#if defined ADJOINT || defined TANGENT || defined TL_IOMS
1002 IF ( lbc(isouth,isubar,ng)%acquire.or. &
1003 & ad_lbc(isouth,isubar,ng)%acquire) THEN
1004#else
1005 IF (lbc(isouth,isubar,ng)%acquire) THEN
1006#endif
1007 allocate ( boundary(ng) % ubar_south(lbi:ubi) )
1008 dmem(ng)=dmem(ng)+xsize
1009#if defined CELERITY_READ || defined CELERITY_WRITE
1010 allocate ( boundary(ng) % ubar_south_C2(lbi:ubi) )
1011 dmem(ng)=dmem(ng)+xsize
1012
1013 allocate ( boundary(ng) % ubar_south_Ce(lbi:ubi) )
1014 dmem(ng)=dmem(ng)+xsize
1015
1016 allocate ( boundary(ng) % ubar_south_Cx(lbi:ubi) )
1017 dmem(ng)=dmem(ng)+xsize
1018#endif
1019#ifndef ANA_M2OBC
1020 allocate ( boundary(ng) % ubarG_south(lbi:ubi,2) )
1021 dmem(ng)=dmem(ng)+2.0_r8*xsize
1022#endif
1023 END IF
1024#ifdef WEC
1025 IF (lbc(isouth,isu2sd,ng)%acquire) THEN
1026 allocate ( boundary(ng) % ubarstokes_south(lbi:ubi) )
1027 dmem(ng)=dmem(ng)+xsize
1028 END IF
1029#endif
1030!
1031#if defined ADJOINT || defined TANGENT || defined TL_IOMS
1032 IF ( lbc(inorth,isubar,ng)%acquire.or. &
1033 & ad_lbc(inorth,isubar,ng)%acquire) THEN
1034#else
1035 IF (lbc(inorth,isubar,ng)%acquire) THEN
1036#endif
1037 allocate ( boundary(ng) % ubar_north(lbi:ubi) )
1038 dmem(ng)=dmem(ng)+xsize
1039
1040#if defined CELERITY_READ || defined CELERITY_WRITE
1041 allocate ( boundary(ng) % ubar_north_C2(lbi:ubi) )
1042 dmem(ng)=dmem(ng)+xsize
1043
1044 allocate ( boundary(ng) % ubar_north_Ce(lbi:ubi) )
1045 dmem(ng)=dmem(ng)+xsize
1046
1047 allocate ( boundary(ng) % ubar_north_Cx(lbi:ubi) )
1048 dmem(ng)=dmem(ng)+xsize
1049#endif
1050#ifndef ANA_M2OBC
1051 allocate ( boundary(ng) % ubarG_north(lbi:ubi,2) )
1052 dmem(ng)=dmem(ng)+2.0_r8*xsize
1053#endif
1054 END IF
1055#ifdef WEC
1056 IF (lbc(inorth,isu2sd,ng)%acquire) THEN
1057 allocate ( boundary(ng) % ubarstokes_north(lbi:ubi) )
1058 dmem(ng)=dmem(ng)+xsize
1059 END IF
1060#endif
1061!
1062#if defined ADJOINT || defined TANGENT || defined TL_IOMS
1063 IF ( lbc(iwest,isvbar,ng)%acquire.or. &
1064 & ad_lbc(iwest,isvbar,ng)%acquire) THEN
1065#else
1066 IF (lbc(iwest,isvbar,ng)%acquire) THEN
1067#endif
1068 allocate ( boundary(ng) % vbar_west(lbj:ubj) )
1069 dmem(ng)=dmem(ng)+ysize
1070
1071#if defined CELERITY_READ || defined CELERITY_WRITE
1072 allocate ( boundary(ng) % vbar_west_C2(lbj:ubj) )
1073 dmem(ng)=dmem(ng)+ysize
1074
1075 allocate ( boundary(ng) % vbar_west_Ce(lbj:ubj) )
1076 dmem(ng)=dmem(ng)+ysize
1077
1078 allocate ( boundary(ng) % vbar_west_Cx(lbj:ubj) )
1079 dmem(ng)=dmem(ng)+ysize
1080#endif
1081#ifndef ANA_M2OBC
1082 allocate ( boundary(ng) % vbarG_west(lbj:ubj,2) )
1083 dmem(ng)=dmem(ng)+2.0_r8*ysize
1084#endif
1085 END IF
1086#ifdef WEC
1087 IF (lbc(iwest,isv2sd,ng)%acquire) THEN
1088 allocate ( boundary(ng) % vbarstokes_west(lbj:ubj) )
1089 dmem(ng)=dmem(ng)+ysize
1090 END IF
1091#endif
1092!
1093#if defined ADJOINT || defined TANGENT || defined TL_IOMS
1094 IF ( lbc(ieast,isvbar,ng)%acquire.or. &
1095 & ad_lbc(ieast,isvbar,ng)%acquire) THEN
1096#else
1097 IF (lbc(ieast,isvbar,ng)%acquire) THEN
1098#endif
1099 allocate ( boundary(ng) % vbar_east(lbj:ubj) )
1100 dmem(ng)=dmem(ng)+ysize
1101
1102#if defined CELERITY_READ || defined CELERITY_WRITE
1103 allocate ( boundary(ng) % vbar_east_C2(lbj:ubj) )
1104 dmem(ng)=dmem(ng)+ysize
1105
1106 allocate ( boundary(ng) % vbar_east_Ce(lbj:ubj) )
1107 dmem(ng)=dmem(ng)+ysize
1108
1109 allocate ( boundary(ng) % vbar_east_Cx(lbj:ubj) )
1110 dmem(ng)=dmem(ng)+ysize
1111#endif
1112#ifndef ANA_M2OBC
1113 allocate ( boundary(ng) % vbarG_east(lbj:ubj,2) )
1114 dmem(ng)=dmem(ng)+2.0_r8*ysize
1115#endif
1116 END IF
1117#ifdef WEC
1118 IF (lbc(ieast,isv2sd,ng)%acquire) THEN
1119 allocate ( boundary(ng) % vbarstokes_east(lbj:ubj) )
1120 dmem(ng)=dmem(ng)+ysize
1121 END IF
1122#endif
1123!
1124#if defined ADJOINT || defined TANGENT || defined TL_IOMS
1125 IF ( lbc(isouth,isvbar,ng)%acquire.or. &
1126 & ad_lbc(isouth,isvbar,ng)%acquire) THEN
1127#else
1128 IF (lbc(isouth,isvbar,ng)%acquire) THEN
1129#endif
1130 allocate ( boundary(ng) % vbar_south(lbi:ubi) )
1131 dmem(ng)=dmem(ng)+xsize
1132
1133#if defined CELERITY_READ || defined CELERITY_WRITE
1134 allocate ( boundary(ng) % vbar_south_C2(lbi:ubi) )
1135 dmem(ng)=dmem(ng)+xsize
1136
1137 allocate ( boundary(ng) % vbar_south_Ce(lbi:ubi) )
1138 dmem(ng)=dmem(ng)+xsize
1139
1140 allocate ( boundary(ng) % vbar_south_Cx(lbi:ubi) )
1141 dmem(ng)=dmem(ng)+xsize
1142#endif
1143#ifndef ANA_M2OBC
1144 allocate ( boundary(ng) % vbarG_south(lbi:ubi,2) )
1145 dmem(ng)=dmem(ng)+2.0_r8*xsize
1146#endif
1147 END IF
1148#ifdef WEC
1149 IF (lbc(isouth,isv2sd,ng)%acquire) THEN
1150 allocate ( boundary(ng) % vbarstokes_south(lbj:ubj) )
1151 dmem(ng)=dmem(ng)+xsize
1152 END IF
1153#endif
1154!
1155#if defined ADJOINT || defined TANGENT || defined TL_IOMS
1156 IF ( lbc(inorth,isvbar,ng)%acquire.or. &
1157 & ad_lbc(inorth,isvbar,ng)%acquire) THEN
1158#else
1159 IF (lbc(inorth,isvbar,ng)%acquire) THEN
1160#endif
1161 allocate ( boundary(ng) % vbar_north(lbi:ubi) )
1162 dmem(ng)=dmem(ng)+xsize
1163
1164#if defined CELERITY_READ || defined CELERITY_WRITE
1165 allocate ( boundary(ng) % vbar_north_C2(lbi:ubi) )
1166 dmem(ng)=dmem(ng)+xsize
1167
1168 allocate ( boundary(ng) % vbar_north_Ce(lbi:ubi) )
1169 dmem(ng)=dmem(ng)+xsize
1170
1171 allocate ( boundary(ng) % vbar_north_Cx(lbi:ubi) )
1172 dmem(ng)=dmem(ng)+xsize
1173#endif
1174#ifndef ANA_M2OBC
1175 allocate ( boundary(ng) % vbarG_north(lbi:ubi,2) )
1176 dmem(ng)=dmem(ng)+2.0_r8*xsize
1177#endif
1178 END IF
1179#ifdef WEC
1180 IF (lbc(inorth,isv2sd,ng)%acquire) THEN
1181 allocate ( boundary(ng) % vbarstokes_north(lbj:ubj) )
1182 dmem(ng)=dmem(ng)+xsize
1183 END IF
1184#endif
1185
1186#ifdef SOLVE3D
1187!
1188# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1189 IF ( lbc(iwest,isuvel,ng)%acquire.or. &
1190 & ad_lbc(iwest,isuvel,ng)%acquire) THEN
1191# else
1192 IF (lbc(iwest,isuvel,ng)%acquire) THEN
1193# endif
1194 allocate ( boundary(ng) % u_west(lbj:ubj,n(ng)) )
1195 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1196
1197# if defined CELERITY_READ || defined CELERITY_WRITE
1198 allocate ( boundary(ng) % u_west_C2(lbj:ubj,n(ng)) )
1199 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1200
1201 allocate ( boundary(ng) % u_west_Ce(lbj:ubj,n(ng)) )
1202 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1203
1204 allocate ( boundary(ng) % u_west_Cx(lbj:ubj,n(ng)) )
1205 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1206# endif
1207# ifndef ANA_M3OBC
1208 allocate ( boundary(ng) % uG_west(lbj:ubj,n(ng),2) )
1209 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng),r8)*ysize
1210# endif
1211 END IF
1212# ifdef WEC
1213 IF (lbc(iwest,isu3sd,ng)%acquire) THEN
1214 allocate ( boundary(ng) % ustokes_west(lbj:ubj,n(ng)) )
1215 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1216 END IF
1217# endif
1218!
1219# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1220 IF ( lbc(ieast,isuvel,ng)%acquire.or. &
1221 & ad_lbc(ieast,isuvel,ng)%acquire) THEN
1222# else
1223 IF (lbc(ieast,isuvel,ng)%acquire) THEN
1224# endif
1225 allocate ( boundary(ng) % u_east(lbj:ubj,n(ng)) )
1226 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1227
1228# if defined CELERITY_READ || defined CELERITY_WRITE
1229 allocate ( boundary(ng) % u_east_C2(lbj:ubj,n(ng)) )
1230 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1231
1232 allocate ( boundary(ng) % u_east_Ce(lbj:ubj,n(ng)) )
1233 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1234
1235 allocate ( boundary(ng) % u_east_Cx(lbj:ubj,n(ng)) )
1236 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1237# endif
1238# ifndef ANA_M3OBC
1239 allocate ( boundary(ng) % uG_east(lbj:ubj,n(ng),2) )
1240 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng),r8)*ysize
1241# endif
1242 END IF
1243# ifdef WEC
1244 IF (lbc(ieast,isu3sd,ng)%acquire) THEN
1245 allocate ( boundary(ng) % ustokes_east(lbj:ubj,n(ng)) )
1246 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1247 END IF
1248# endif
1249!
1250# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1251 IF ( lbc(isouth,isuvel,ng)%acquire.or. &
1252 & ad_lbc(isouth,isuvel,ng)%acquire) THEN
1253# else
1254 IF (lbc(isouth,isuvel,ng)%acquire) THEN
1255# endif
1256 allocate ( boundary(ng) % u_south(lbi:ubi,n(ng)) )
1257 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1258
1259# if defined CELERITY_READ || defined CELERITY_WRITE
1260 allocate ( boundary(ng) % u_south_C2(lbi:ubi,n(ng)) )
1261 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1262
1263 allocate ( boundary(ng) % u_south_Ce(lbi:ubi,n(ng)) )
1264 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1265
1266 allocate ( boundary(ng) % u_south_Cx(lbi:ubi,n(ng)) )
1267 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1268# endif
1269# ifndef ANA_M3OBC
1270 allocate ( boundary(ng) % uG_south(lbi:ubi,n(ng),2) )
1271 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng),r8)*xsize
1272# endif
1273 END IF
1274# ifdef WEC
1275 IF (lbc(isouth,isu3sd,ng)%acquire) THEN
1276 allocate ( boundary(ng) % ustokes_south(lbi:ubi,n(ng)) )
1277 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1278 END IF
1279# endif
1280!
1281# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1282 IF ( lbc(inorth,isuvel,ng)%acquire.or. &
1283 & ad_lbc(inorth,isuvel,ng)%acquire) THEN
1284# else
1285 IF (lbc(inorth,isuvel,ng)%acquire) THEN
1286# endif
1287 allocate ( boundary(ng) % u_north(lbi:ubi,n(ng)) )
1288 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1289
1290# if defined CELERITY_READ || defined CELERITY_WRITE
1291 allocate ( boundary(ng) % u_north_C2(lbi:ubi,n(ng)) )
1292 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1293
1294 allocate ( boundary(ng) % u_north_Ce(lbi:ubi,n(ng)) )
1295 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1296
1297 allocate ( boundary(ng) % u_north_Cx(lbi:ubi,n(ng)) )
1298 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1299# endif
1300# ifndef ANA_M3OBC
1301 allocate ( boundary(ng) % uG_north(lbi:ubi,n(ng),2) )
1302 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng),r8)*xsize
1303# endif
1304 END IF
1305# ifdef WEC
1306 IF (lbc(inorth,isu3sd,ng)%acquire) THEN
1307 allocate ( boundary(ng) % ustokes_north(lbi:ubi,n(ng)) )
1308 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1309 END IF
1310# endif
1311!
1312# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1313 IF ( lbc(iwest,isvvel,ng)%acquire.or. &
1314 & ad_lbc(iwest,isvvel,ng)%acquire) THEN
1315# else
1316 IF (lbc(iwest,isvvel,ng)%acquire) THEN
1317# endif
1318 allocate ( boundary(ng) % v_west(lbj:ubj,n(ng)) )
1319 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1320
1321# if defined CELERITY_READ || defined CELERITY_WRITE
1322 allocate ( boundary(ng) % v_west_C2(lbj:ubj,n(ng)) )
1323 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1324
1325 allocate ( boundary(ng) % v_west_Ce(lbj:ubj,n(ng)) )
1326 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1327
1328 allocate ( boundary(ng) % v_west_Cx(lbj:ubj,n(ng)) )
1329 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1330# endif
1331# ifndef ANA_M3OBC
1332 allocate ( boundary(ng) % vG_west(lbj:ubj,n(ng),2) )
1333 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng),r8)*ysize
1334# endif
1335 END IF
1336# ifdef WEC
1337 IF (lbc(iwest,isv3sd,ng)%acquire) THEN
1338 allocate ( boundary(ng) % vstokes_west(lbj:ubj,n(ng)) )
1339 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1340 END IF
1341# endif
1342!
1343# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1344 IF ( lbc(ieast,isvvel,ng)%acquire.or. &
1345 & ad_lbc(ieast,isvvel,ng)%acquire) THEN
1346# else
1347 IF (lbc(ieast,isvvel,ng)%acquire) THEN
1348# endif
1349 allocate ( boundary(ng) % v_east(lbj:ubj,n(ng)) )
1350 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1351
1352# if defined CELERITY_READ || defined CELERITY_WRITE
1353 allocate ( boundary(ng) % v_east_C2(lbj:ubj,n(ng)) )
1354 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1355
1356 allocate ( boundary(ng) % v_east_Ce(lbj:ubj,n(ng)) )
1357 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1358
1359 allocate ( boundary(ng) % v_east_Cx(lbj:ubj,n(ng)) )
1360 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1361# endif
1362# ifndef ANA_M3OBC
1363 allocate ( boundary(ng) % vG_east(lbj:ubj,n(ng),2) )
1364 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng),r8)*ysize
1365# endif
1366 END IF
1367# ifdef WEC
1368 IF (lbc(ieast,isv3sd,ng)%acquire) THEN
1369 allocate ( boundary(ng) % vstokes_east(lbj:ubj,n(ng)) )
1370 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1371 END IF
1372# endif
1373!
1374# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1375 IF ( lbc(isouth,isvvel,ng)%acquire.or. &
1376 & ad_lbc(isouth,isvvel,ng)%acquire) THEN
1377# else
1378 IF (lbc(isouth,isvvel,ng)%acquire) THEN
1379# endif
1380 allocate ( boundary(ng) % v_south(lbi:ubi,n(ng)) )
1381 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1382
1383# if defined CELERITY_READ || defined CELERITY_WRITE
1384 allocate ( boundary(ng) % v_south_C2(lbi:ubi,n(ng)) )
1385 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1386
1387 allocate ( boundary(ng) % v_south_Ce(lbi:ubi,n(ng)) )
1388 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1389
1390 allocate ( boundary(ng) % v_south_Cx(lbi:ubi,n(ng)) )
1391 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1392# endif
1393# ifndef ANA_M3OBC
1394 allocate ( boundary(ng) % vG_south(lbi:ubi,n(ng),2) )
1395 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng),r8)*xsize
1396# endif
1397 END IF
1398# ifdef WEC
1399 IF (lbc(isouth,isv3sd,ng)%acquire) THEN
1400 allocate ( boundary(ng) % vstokes_south(lbi:ubi,n(ng)) )
1401 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1402 END IF
1403# endif
1404!
1405# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1406 IF ( lbc(inorth,isvvel,ng)%acquire.or. &
1407 & ad_lbc(inorth,isvvel,ng)%acquire) THEN
1408# else
1409 IF (lbc(inorth,isvvel,ng)%acquire) THEN
1410# endif
1411 allocate ( boundary(ng) % v_north(lbi:ubi,n(ng)) )
1412 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1413
1414# if defined CELERITY_READ || defined CELERITY_WRITE
1415 allocate ( boundary(ng) % u_north_C2(lbi:ubi,n(ng)) )
1416 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1417
1418 allocate ( boundary(ng) % u_north_Ce(lbi:ubi,n(ng)) )
1419 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1420
1421 allocate ( boundary(ng) % u_north_Cx(lbi:ubi,n(ng)) )
1422 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1423# endif
1424# ifndef ANA_M3OBC
1425 allocate ( boundary(ng) % vG_north(lbi:ubi,n(ng),2) )
1426 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng),r8)*xsize
1427# endif
1428 END IF
1429# ifdef WEC
1430 IF (lbc(inorth,isv3sd,ng)%acquire) THEN
1431 allocate ( boundary(ng) % vstokes_north(lbi:ubi,n(ng)) )
1432 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1433 END IF
1434# endif
1435!
1436# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1437 IF (any( lbc(iwest,istvar(:),ng)%acquire).or. &
1438 & any(ad_lbc(iwest,istvar(:),ng)%acquire)) THEN
1439# else
1440 IF (any(lbc(iwest,istvar(:),ng)%acquire)) THEN
1441# endif
1442 allocate ( boundary(ng) % t_west(lbj:ubj,n(ng),nt(ng)) )
1443 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1444
1445# if defined CELERITY_READ || defined CELERITY_WRITE
1446 allocate ( boundary(ng) % t_west_C2(lbj:ubj,n(ng),nt(ng)) )
1447 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1448
1449 allocate ( boundary(ng) % t_west_Ce(lbj:ubj,n(ng),nt(ng)) )
1450 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1451
1452 allocate ( boundary(ng) % t_west_Cx(lbj:ubj,n(ng),nt(ng)) )
1453 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1454# endif
1455# ifndef ANA_TOBC
1456 allocate ( boundary(ng) % tG_west(lbj:ubj,n(ng),2,nt(ng)) )
1457 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng)*nt(ng),r8)*ysize
1458# endif
1459 END IF
1460!
1461# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1462 IF (any( lbc(ieast,istvar(:),ng)%acquire).or. &
1463 & any(ad_lbc(ieast,istvar(:),ng)%acquire)) THEN
1464# else
1465 IF (any(lbc(ieast,istvar(:),ng)%acquire)) THEN
1466# endif
1467 allocate ( boundary(ng) % t_east(lbj:ubj,n(ng),nt(ng)) )
1468 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1469
1470# if defined CELERITY_READ || defined CELERITY_WRITE
1471 allocate ( boundary(ng) % t_east_C2(lbj:ubj,n(ng),nt(ng)) )
1472 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1473
1474 allocate ( boundary(ng) % t_east_Ce(lbj:ubj,n(ng),nt(ng)) )
1475 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1476
1477 allocate ( boundary(ng) % t_east_Cx(lbj:ubj,n(ng),nt(ng)) )
1478 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1479# endif
1480# ifndef ANA_TOBC
1481 allocate ( boundary(ng) % tG_east(lbj:ubj,n(ng),2,nt(ng)) )
1482 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng)*nt(ng),r8)*ysize
1483# endif
1484 END IF
1485!
1486# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1487 IF (any( lbc(isouth,istvar(:),ng)%acquire).or. &
1488 & any(ad_lbc(isouth,istvar(:),ng)%acquire)) THEN
1489# else
1490 IF (any(lbc(isouth,istvar(:),ng)%acquire)) THEN
1491# endif
1492 allocate ( boundary(ng) % t_south(lbi:ubi,n(ng),nt(ng)) )
1493 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1494
1495# if defined CELERITY_READ || defined CELERITY_WRITE
1496 allocate ( boundary(ng) % t_south_C2(lbi:ubi,n(ng),nt(ng)) )
1497 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1498
1499 allocate ( boundary(ng) % t_south_Ce(lbi:ubi,n(ng),nt(ng)) )
1500 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1501
1502 allocate ( boundary(ng) % t_south_Cx(lbi:ubi,n(ng),nt(ng)) )
1503 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1504# endif
1505# ifndef ANA_TOBC
1506 allocate ( boundary(ng) % tG_south(lbi:ubi,n(ng),2,nt(ng)) )
1507 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng)*nt(ng),r8)*xsize
1508# endif
1509 END IF
1510!
1511# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1512 IF (any( lbc(inorth,istvar(:),ng)%acquire).or. &
1513 & any(ad_lbc(inorth,istvar(:),ng)%acquire)) THEN
1514# else
1515 IF (any(lbc(inorth,istvar(:),ng)%acquire)) THEN
1516# endif
1517 allocate ( boundary(ng) % t_north(lbi:ubi,n(ng),nt(ng)) )
1518 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1519
1520# if defined CELERITY_READ || defined CELERITY_WRITE
1521 allocate ( boundary(ng) % t_north_C2(lbi:ubi,n(ng),nt(ng)) )
1522 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1523
1524 allocate ( boundary(ng) % t_north_Ce(lbi:ubi,n(ng),nt(ng)) )
1525 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1526
1527 allocate ( boundary(ng) % t_north_Cx(lbi:ubi,n(ng),nt(ng)) )
1528 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1529# endif
1530# ifndef ANA_TOBC
1531 allocate ( boundary(ng) % tG_north(lbi:ubi,n(ng),2,nt(ng)) )
1532 dmem(ng)=dmem(ng)+2.0_r8*real(n(ng)*nt(ng),r8)*xsize
1533# endif
1534 END IF
1535#endif
1536
1537#if defined TANGENT || defined TL_IOMS
1538!
1539!-----------------------------------------------------------------------
1540! Tangent linear model state.
1541!-----------------------------------------------------------------------
1542!
1543 IF (tl_lbc(iwest,isfsur,ng)%acquire) THEN
1544 allocate ( boundary(ng) % tl_zeta_west(lbj:ubj) )
1545 dmem(ng)=dmem(ng)+ysize
1546 END IF
1547
1548 IF (tl_lbc(ieast,isfsur,ng)%acquire) THEN
1549 allocate ( boundary(ng) % tl_zeta_east(lbj:ubj) )
1550 dmem(ng)=dmem(ng)+ysize
1551 END IF
1552
1553 IF (tl_lbc(isouth,isfsur,ng)%acquire) THEN
1554 allocate ( boundary(ng) % tl_zeta_south(lbi:ubi) )
1555 dmem(ng)=dmem(ng)+xsize
1556 END IF
1557
1558 IF (tl_lbc(inorth,isfsur,ng)%acquire) THEN
1559 allocate ( boundary(ng) % tl_zeta_north(lbi:ubi) )
1560 dmem(ng)=dmem(ng)+xsize
1561 END IF
1562!
1563 IF (tl_lbc(iwest,isubar,ng)%acquire) THEN
1564 allocate ( boundary(ng) % tl_ubar_west(lbj:ubj) )
1565 dmem(ng)=dmem(ng)+ysize
1566 END IF
1567
1568 IF (tl_lbc(ieast,isubar,ng)%acquire) THEN
1569 allocate ( boundary(ng) % tl_ubar_east(lbj:ubj) )
1570 dmem(ng)=dmem(ng)+ysize
1571 END IF
1572
1573 IF (tl_lbc(isouth,isubar,ng)%acquire) THEN
1574 allocate ( boundary(ng) % tl_ubar_south(lbi:ubi) )
1575 dmem(ng)=dmem(ng)+xsize
1576 END IF
1577
1578 IF (tl_lbc(inorth,isubar,ng)%acquire) THEN
1579 allocate ( boundary(ng) % tl_ubar_north(lbi:ubi) )
1580 dmem(ng)=dmem(ng)+xsize
1581 END IF
1582!
1583 IF (tl_lbc(iwest,isvbar,ng)%acquire) THEN
1584 allocate ( boundary(ng) % tl_vbar_west(lbj:ubj) )
1585 dmem(ng)=dmem(ng)+ysize
1586 END IF
1587
1588 IF (tl_lbc(ieast,isvbar,ng)%acquire) THEN
1589 allocate ( boundary(ng) % tl_vbar_east(lbj:ubj) )
1590 dmem(ng)=dmem(ng)+ysize
1591 END IF
1592
1593 IF (tl_lbc(isouth,isvbar,ng)%acquire) THEN
1594 allocate ( boundary(ng) % tl_vbar_south(lbi:ubi) )
1595 dmem(ng)=dmem(ng)+xsize
1596 END IF
1597
1598 IF (tl_lbc(inorth,isvbar,ng)%acquire) THEN
1599 allocate ( boundary(ng) % tl_vbar_north(lbi:ubi) )
1600 dmem(ng)=dmem(ng)+xsize
1601 END IF
1602
1603# ifdef SOLVE3D
1604!
1605 IF (tl_lbc(iwest,isuvel,ng)%acquire) THEN
1606 allocate ( boundary(ng) % tl_u_west(lbj:ubj,n(ng)) )
1607 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1608 END IF
1609
1610 IF (tl_lbc(ieast,isuvel,ng)%acquire) THEN
1611 allocate ( boundary(ng) % tl_u_east(lbj:ubj,n(ng)) )
1612 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1613 END IF
1614
1615 IF (tl_lbc(isouth,isuvel,ng)%acquire) THEN
1616 allocate ( boundary(ng) % tl_u_south(lbi:ubi,n(ng)) )
1617 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1618 END IF
1619
1620 IF (tl_lbc(inorth,isuvel,ng)%acquire) THEN
1621 allocate ( boundary(ng) % tl_u_north(lbi:ubi,n(ng)) )
1622 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1623 END IF
1624!
1625 IF (tl_lbc(iwest,isvvel,ng)%acquire) THEN
1626 allocate ( boundary(ng) % tl_v_west(lbj:ubj,n(ng)) )
1627 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1628 END IF
1629
1630 IF (tl_lbc(ieast,isvvel,ng)%acquire) THEN
1631 allocate ( boundary(ng) % tl_v_east(lbj:ubj,n(ng)) )
1632 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1633 END IF
1634
1635 IF (tl_lbc(isouth,isvvel,ng)%acquire) THEN
1636 allocate ( boundary(ng) % tl_v_south(lbi:ubi,n(ng)) )
1637 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1638 END IF
1639
1640 IF (tl_lbc(inorth,isvvel,ng)%acquire) THEN
1641 allocate ( boundary(ng) % tl_v_north(lbi:ubi,n(ng)) )
1642 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1643 END IF
1644!
1645 IF (any(tl_lbc(iwest,istvar(:),ng)%acquire)) THEN
1646 allocate ( boundary(ng) % tl_t_west(lbj:ubj,n(ng),nt(ng)) )
1647 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1648 END IF
1649
1650 IF (any(tl_lbc(ieast,istvar(:),ng)%acquire)) THEN
1651 allocate ( boundary(ng) % tl_t_east(lbj:ubj,n(ng),nt(ng)) )
1652 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1653 END IF
1654
1655 IF (any(tl_lbc(isouth,istvar(:),ng)%acquire)) THEN
1656 allocate ( boundary(ng) % tl_t_south(lbi:ubi,n(ng),nt(ng)) )
1657 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1658 END IF
1659
1660 IF (any(tl_lbc(inorth,istvar(:),ng)%acquire)) THEN
1661 allocate ( boundary(ng) % tl_t_north(lbi:ubi,n(ng),nt(ng)) )
1662 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1663 END IF
1664# endif
1665#endif
1666
1667#ifdef ADJOINT
1668!
1669!-----------------------------------------------------------------------
1670! Adjoint model state.
1671!-----------------------------------------------------------------------
1672!
1673 IF (ad_lbc(iwest,isfsur,ng)%acquire) THEN
1674 allocate ( boundary(ng) % ad_zeta_west(lbj:ubj) )
1675 dmem(ng)=dmem(ng)+ysize
1676 END IF
1677
1678 IF (ad_lbc(ieast,isfsur,ng)%acquire) THEN
1679 allocate ( boundary(ng) % ad_zeta_east(lbj:ubj) )
1680 dmem(ng)=dmem(ng)+ysize
1681 END IF
1682
1683 IF (ad_lbc(isouth,isfsur,ng)%acquire) THEN
1684 allocate ( boundary(ng) % ad_zeta_south(lbi:ubi) )
1685 dmem(ng)=dmem(ng)+xsize
1686 END IF
1687
1688 IF (ad_lbc(inorth,isfsur,ng)%acquire) THEN
1689 allocate ( boundary(ng) % ad_zeta_north(lbi:ubi) )
1690 dmem(ng)=dmem(ng)+xsize
1691 END IF
1692!
1693 IF (ad_lbc(iwest,isubar,ng)%acquire) THEN
1694 allocate ( boundary(ng) % ad_ubar_west(lbj:ubj) )
1695 dmem(ng)=dmem(ng)+ysize
1696 END IF
1697
1698 IF (ad_lbc(ieast,isubar,ng)%acquire) THEN
1699 allocate ( boundary(ng) % ad_ubar_east(lbj:ubj) )
1700 dmem(ng)=dmem(ng)+ysize
1701 END IF
1702
1703 IF (ad_lbc(isouth,isubar,ng)%acquire) THEN
1704 allocate ( boundary(ng) % ad_ubar_south(lbi:ubi) )
1705 dmem(ng)=dmem(ng)+xsize
1706 END IF
1707
1708 IF (ad_lbc(inorth,isubar,ng)%acquire) THEN
1709 allocate ( boundary(ng) % ad_ubar_north(lbi:ubi) )
1710 dmem(ng)=dmem(ng)+xsize
1711 END IF
1712!
1713 IF (ad_lbc(iwest,isvbar,ng)%acquire) THEN
1714 allocate ( boundary(ng) % ad_vbar_west(lbj:ubj) )
1715 dmem(ng)=dmem(ng)+ysize
1716 END IF
1717
1718 IF (ad_lbc(ieast,isvbar,ng)%acquire) THEN
1719 allocate ( boundary(ng) % ad_vbar_east(lbj:ubj) )
1720 dmem(ng)=dmem(ng)+ysize
1721 END IF
1722
1723 IF (ad_lbc(isouth,isvbar,ng)%acquire) THEN
1724 allocate ( boundary(ng) % ad_vbar_south(lbi:ubi) )
1725 dmem(ng)=dmem(ng)+xsize
1726 END IF
1727
1728 IF (ad_lbc(inorth,isvbar,ng)%acquire) THEN
1729 allocate ( boundary(ng) % ad_vbar_north(lbi:ubi) )
1730 dmem(ng)=dmem(ng)+xsize
1731 END IF
1732
1733# ifdef SOLVE3D
1734!
1735 IF (ad_lbc(iwest,isuvel,ng)%acquire) THEN
1736 allocate ( boundary(ng) % ad_u_west(lbj:ubj,n(ng)) )
1737 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1738 END IF
1739
1740 IF (ad_lbc(ieast,isuvel,ng)%acquire) THEN
1741 allocate ( boundary(ng) % ad_u_east(lbj:ubj,n(ng)) )
1742 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1743 END IF
1744
1745 IF (ad_lbc(isouth,isuvel,ng)%acquire) THEN
1746 allocate ( boundary(ng) % ad_u_south(lbi:ubi,n(ng)) )
1747 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1748 END IF
1749
1750 IF (ad_lbc(inorth,isuvel,ng)%acquire) THEN
1751 allocate ( boundary(ng) % ad_u_north(lbi:ubi,n(ng)) )
1752 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1753 END IF
1754!
1755 IF (ad_lbc(iwest,isvvel,ng)%acquire) THEN
1756 allocate ( boundary(ng) % ad_v_west(lbj:ubj,n(ng)) )
1757 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1758 END IF
1759
1760 IF (ad_lbc(ieast,isvvel,ng)%acquire) THEN
1761 allocate ( boundary(ng) % ad_v_east(lbj:ubj,n(ng)) )
1762 dmem(ng)=dmem(ng)+real(n(ng),r8)*ysize
1763 END IF
1764
1765 IF (ad_lbc(isouth,isvvel,ng)%acquire) THEN
1766 allocate ( boundary(ng) % ad_v_south(lbi:ubi,n(ng)) )
1767 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1768 END IF
1769
1770 IF (ad_lbc(inorth,isvvel,ng)%acquire) THEN
1771 allocate ( boundary(ng) % ad_v_north(lbi:ubi,n(ng)) )
1772 dmem(ng)=dmem(ng)+real(n(ng),r8)*xsize
1773 END IF
1774!
1775 IF (any(ad_lbc(iwest,istvar(:),ng)%acquire)) THEN
1776 allocate ( boundary(ng) % ad_t_west(lbj:ubj,n(ng),nt(ng)) )
1777 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1778 END IF
1779
1780 IF (any(ad_lbc(ieast,istvar(:),ng)%acquire)) THEN
1781 allocate ( boundary(ng) % ad_t_east(lbj:ubj,n(ng),nt(ng)) )
1782 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*ysize
1783 END IF
1784
1785 IF (any(ad_lbc(isouth,istvar(:),ng)%acquire)) THEN
1786 allocate ( boundary(ng) % ad_t_south(lbi:ubi,n(ng),nt(ng)) )
1787 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1788 END IF
1789
1790 IF (any(ad_lbc(inorth,istvar(:),ng)%acquire)) THEN
1791 allocate ( boundary(ng) % ad_t_north(lbi:ubi,n(ng),nt(ng)) )
1792 dmem(ng)=dmem(ng)+real(n(ng)*nt(ng),r8)*xsize
1793 END IF
1794# endif
1795#endif
1796
1797#ifdef ADJUST_BOUNDARY
1798!
1799!-----------------------------------------------------------------------
1800! Open boundaries arrays used in 4DVar adjustments.
1801!-----------------------------------------------------------------------
1802!
1803# ifdef SOLVE3D
1804 allocate ( boundary(ng) % t_obc(lbij:ubij,n(ng),4, &
1805 & nbrec(ng),2,nt(ng)) )
1806 dmem(ng)=dmem(ng)+8.0_r8*real(n(ng)*nbrec(ng)*nt(ng),r8)*xysize
1807
1808 allocate ( boundary(ng) % u_obc(lbij:ubij,n(ng), &
1809 & 4,nbrec(ng),2) )
1810 dmem(ng)=dmem(ng)+8.0_r8*real(n(ng)*nbrec(ng),r8)*xysize
1811
1812 allocate ( boundary(ng) % v_obc(lbij:ubij,n(ng), &
1813 & 4,nbrec(ng),2) )
1814 dmem(ng)=dmem(ng)+8.0_r8*real(n(ng)*nbrec(ng),r8)*xysize
1815!
1816 allocate ( boundary(ng) % ad_t_obc(lbij:ubij,n(ng),4, &
1817 & nbrec(ng),2,nt(ng)) )
1818 dmem(ng)=dmem(ng)+8.0_r8*real(n(ng)*nbrec(ng)*nt(ng),r8)*xysize
1819
1820 allocate ( boundary(ng) % ad_u_obc(lbij:ubij,n(ng), &
1821 & 4,nbrec(ng),2) )
1822 dmem(ng)=dmem(ng)+8.0_r8*real(n(ng)*nbrec(ng),r8)*xysize
1823
1824 allocate ( boundary(ng) % ad_v_obc(lbij:ubij,n(ng), &
1825 & 4,nbrec(ng),2) )
1826 dmem(ng)=dmem(ng)+8.0_r8*real(n(ng)*nbrec(ng),r8)*xysize
1827!
1828 allocate ( boundary(ng) % tl_t_obc(lbij:ubij,n(ng),4, &
1829 & nbrec(ng),2,nt(ng)) )
1830 dmem(ng)=dmem(ng)+8.0_r8*real(n(ng)*nbrec(ng)*nt(ng),r8)*xysize
1831
1832 allocate ( boundary(ng) % tl_u_obc(lbij:ubij,n(ng), &
1833 & 4,nbrec(ng),2) )
1834 dmem(ng)=dmem(ng)+8.0_r8*real(n(ng)*nbrec(ng),r8)*xysize
1835
1836 allocate ( boundary(ng) % tl_v_obc(lbij:ubij,n(ng), &
1837 & 4,nbrec(ng),2) )
1838 dmem(ng)=dmem(ng)+8.0_r8*real(n(ng)*nbrec(ng),r8)*xysize
1839!
1840 allocate ( boundary(ng) % b_t_obc(lbij:ubij,n(ng),4,nt(ng)) )
1841 dmem(ng)=dmem(ng)+4.0_r8*real(n(ng)*nt(ng),r8)*xysize
1842
1843 allocate ( boundary(ng) % b_u_obc(lbij:ubij,n(ng),4) )
1844 dmem(ng)=dmem(ng)+4.0_r8*real(n(ng),r8)*xysize
1845
1846 allocate ( boundary(ng) % b_v_obc(lbij:ubij,n(ng),4) )
1847 dmem(ng)=dmem(ng)+4.0_r8*real(n(ng),r8)*xysize
1848!
1849 allocate ( boundary(ng) % d_t_obc(lbij:ubij,n(ng),4, &
1850 & nbrec(ng),nt(ng)) )
1851 dmem(ng)=dmem(ng)+4.0_r8*real(n(ng)*nbrec(ng)*nt(ng),r8)*xysize
1852
1853 allocate ( boundary(ng) % d_u_obc(lbij:ubij,n(ng), &
1854 & 4,nbrec(ng)) )
1855 dmem(ng)=dmem(ng)+4.0_r8*real(n(ng)*nbrec(ng),r8)*xysize
1856
1857 allocate ( boundary(ng) % d_v_obc(lbij:ubij,n(ng), &
1858 & 4,nbrec(ng)) )
1859 dmem(ng)=dmem(ng)+4.0_r8*real(n(ng)*nbrec(ng),r8)*xysize
1860!
1861 allocate ( boundary(ng) % e_t_obc(lbij:ubij,n(ng),4,nt(ng)) )
1862 dmem(ng)=dmem(ng)+4.0_r8*real(n(ng)*nt(ng),r8)*xysize
1863
1864 allocate ( boundary(ng) % e_u_obc(lbij:ubij,n(ng),4) )
1865 dmem(ng)=dmem(ng)+4.0_r8*real(n(ng),r8)*xysize
1866
1867 allocate ( boundary(ng) % e_v_obc(lbij:ubij,n(ng),4) )
1868 dmem(ng)=dmem(ng)+4.0_r8*real(n(ng),r8)*xysize
1869# endif
1870 allocate ( boundary(ng) % ubar_obc(lbij:ubij,4,nbrec(ng),2) )
1871 dmem(ng)=dmem(ng)+8.0_r8*real(nbrec(ng),r8)*xysize
1872
1873 allocate ( boundary(ng) % vbar_obc(lbij:ubij,4,nbrec(ng),2) )
1874 dmem(ng)=dmem(ng)+8.0_r8*real(nbrec(ng),r8)*xysize
1875
1876 allocate ( boundary(ng) % zeta_obc(lbij:ubij,4,nbrec(ng),2) )
1877 dmem(ng)=dmem(ng)+8.0_r8*real(nbrec(ng),r8)*xysize
1878!
1879 allocate ( boundary(ng) % ad_ubar_obc(lbij:ubij,4,nbrec(ng),2) )
1880 dmem(ng)=dmem(ng)+8.0_r8*real(nbrec(ng),r8)*xysize
1881
1882 allocate ( boundary(ng) % ad_vbar_obc(lbij:ubij,4,nbrec(ng),2) )
1883 dmem(ng)=dmem(ng)+8.0_r8*real(nbrec(ng),r8)*xysize
1884
1885 allocate ( boundary(ng) % ad_zeta_obc(lbij:ubij,4,nbrec(ng),2) )
1886 dmem(ng)=dmem(ng)+8.0_r8*real(nbrec(ng),r8)*xysize
1887!
1888 allocate ( boundary(ng) % tl_ubar_obc(lbij:ubij,4,nbrec(ng),2) )
1889 dmem(ng)=dmem(ng)+8.0_r8*real(nbrec(ng),r8)*xysize
1890
1891 allocate ( boundary(ng) % tl_vbar_obc(lbij:ubij,4,nbrec(ng),2) )
1892 dmem(ng)=dmem(ng)+8.0_r8*real(nbrec(ng),r8)*xysize
1893
1894 allocate ( boundary(ng) % tl_zeta_obc(lbij:ubij,4,nbrec(ng),2) )
1895 dmem(ng)=dmem(ng)+8.0_r8*real(nbrec(ng),r8)*xysize
1896!
1897 allocate ( boundary(ng) % b_ubar_obc(lbij:ubij,4) )
1898 dmem(ng)=dmem(ng)+4.0_r8*xysize
1899
1900 allocate ( boundary(ng) % b_vbar_obc(lbij:ubij,4) )
1901 dmem(ng)=dmem(ng)+4.0_r8*xysize
1902
1903 allocate ( boundary(ng) % b_zeta_obc(lbij:ubij,4) )
1904 dmem(ng)=dmem(ng)+4.0_r8*xysize
1905!
1906 allocate ( boundary(ng) % d_ubar_obc(lbij:ubij,4,nbrec(ng)) )
1907 dmem(ng)=dmem(ng)+4.0_r8*real(nbrec(ng),r8)*xysize
1908
1909 allocate ( boundary(ng) % d_vbar_obc(lbij:ubij,4,nbrec(ng)) )
1910 dmem(ng)=dmem(ng)+4.0_r8*real(nbrec(ng),r8)*xysize
1911
1912 allocate ( boundary(ng) % d_zeta_obc(lbij:ubij,4,nbrec(ng)) )
1913 dmem(ng)=dmem(ng)+4.0_r8*real(nbrec(ng),r8)*xysize
1914!
1915 allocate ( boundary(ng) % e_ubar_obc(lbij:ubij,4) )
1916 dmem(ng)=dmem(ng)+4.0_r8*xysize
1917
1918 allocate ( boundary(ng) % e_vbar_obc(lbij:ubij,4) )
1919 dmem(ng)=dmem(ng)+4.0_r8*xysize
1920
1921 allocate ( boundary(ng) % e_zeta_obc(lbij:ubij,4) )
1922 dmem(ng)=dmem(ng)+4.0_r8*xysize
1923#endif
1924!
1925 RETURN
integer isvvel
integer isvbar
integer, dimension(:), allocatable istvar
integer isuvel
integer isfsur
integer isubar
type(t_lbc), dimension(:,:,:), allocatable ad_lbc
Definition mod_param.F:378
integer, dimension(:), allocatable n
Definition mod_param.F:479
type(t_bounds), dimension(:), allocatable bounds
Definition mod_param.F:232
type(t_lbc), dimension(:,:,:), allocatable tl_lbc
Definition mod_param.F:379
real(r8), dimension(:), allocatable dmem
Definition mod_param.F:137
type(t_lbc), dimension(:,:,:), allocatable lbc
Definition mod_param.F:375
integer ngrids
Definition mod_param.F:113
integer, dimension(:), allocatable nt
Definition mod_param.F:489
integer, parameter iwest
integer, parameter isouth
integer, parameter ieast
integer, parameter inorth
integer, dimension(:), allocatable nbrec

References mod_param::ad_lbc, boundary, mod_param::bounds, mod_param::dmem, mod_scalars::ieast, mod_scalars::inorth, mod_ncparam::isfsur, mod_scalars::isouth, mod_ncparam::istvar, mod_ncparam::isubar, mod_ncparam::isuvel, mod_ncparam::isvbar, mod_ncparam::isvvel, mod_scalars::iwest, mod_param::lbc, lbc_apply, mod_param::n, mod_scalars::nbrec, mod_param::ngrids, mod_param::nt, mod_kinds::r8, and mod_param::tl_lbc.

Referenced by mod_arrays::roms_allocate_arrays().

Here is the caller graph for this function:

◆ deallocate_boundary()

subroutine, public mod_boundary::deallocate_boundary ( integer, intent(in) ng)

Definition at line 1928 of file mod_boundary.F.

1929!
1930!=======================================================================
1931! !
1932! This routine initializes all variables in the module for all nested !
1933! grids. Currently, there is not parallel tiling in boundary arrays. !
1934! !
1935!=======================================================================
1936!
1937 USE mod_param
1938 USE mod_ncparam
1939 USE mod_scalars
1940
1941#ifdef SUBOBJECT_DEALLOCATION
1942!
1943 USE destroy_mod, ONLY : destroy
1944#endif
1945!
1946! Imported variable declarations.
1947!
1948 integer, intent(in) :: ng
1949!
1950! Local variable declarations.
1951!
1952 character (len=*), parameter :: MyFile = &
1953 & __FILE__//", deallocate_boundary"
1954
1955#ifdef SUBOBJECT_DEALLOCATION
1956!
1957!-----------------------------------------------------------------------
1958! Deallocate each variable in the derived-type T_APPLY and T_BOUNDARY
1959! structures separately.
1960!-----------------------------------------------------------------------
1961!
1962! Lateral boundary conditions apply switches.
1963!
1964 IF (.not.destroy(ng, lbc_apply(ng)%west, myfile, &
1965 & __line__, 'LBC_apply(ng)%west')) RETURN
1966
1967 IF (.not.destroy(ng, lbc_apply(ng)%east, myfile, &
1968 & __line__, 'LBC_apply(ng)%east')) RETURN
1969
1970 IF (.not.destroy(ng, lbc_apply(ng)%south, myfile, &
1971 & __line__, 'LBC_apply(ng)%south')) RETURN
1972
1973 IF (.not.destroy(ng, lbc_apply(ng)%north, myfile, &
1974 & __line__, 'LBC_apply(ng)%north')) RETURN
1975!
1976! Nonlinear model state.
1977!
1978# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1979 IF ( lbc(iwest,isfsur,ng)%acquire.or. &
1980 & ad_lbc(iwest,isfsur,ng)%acquire) THEN
1981# else
1982 IF (lbc(iwest,isfsur,ng)%acquire) THEN
1983# endif
1984 IF (.not.destroy(ng, boundary(ng)%zeta_west, myfile, &
1985 & __line__, 'BOUNDARY(ng)%zeta_west')) RETURN
1986
1987# if defined CELERITY_READ || defined CELERITY_WRITE
1988 IF (.not.destroy(ng, boundary(ng)%zeta_west_C2, myfile, &
1989 & __line__, 'BOUNDARY(ng)%zeta_west_C2')) RETURN
1990
1991 IF (.not.destroy(ng, boundary(ng)%zeta_west_Ce, myfile, &
1992 & __line__, 'BOUNDARY(ng)%zeta_west_Ce')) RETURN
1993
1994 IF (.not.destroy(ng, boundary(ng)%zeta_west_Cx, myfile, &
1995 & __line__, 'BOUNDARY(ng)%zeta_west_Cx')) RETURN
1996# endif
1997
1998# ifndef ANA_FSOBC
1999 IF (.not.destroy(ng, boundary(ng)%zetaG_west, myfile, &
2000 & __line__, 'BOUNDARY(ng)%zetaG_west')) RETURN
2001# endif
2002 END IF
2003!
2004# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2005 IF ( lbc(ieast,isfsur,ng)%acquire.or. &
2006 & ad_lbc(ieast,isfsur,ng)%acquire) THEN
2007# else
2008 IF (lbc(ieast,isfsur,ng)%acquire) THEN
2009# endif
2010 IF (.not.destroy(ng, boundary(ng)%zeta_east, myfile, &
2011 & __line__, 'BOUNDARY(ng)%zeta_east')) RETURN
2012
2013# if defined CELERITY_READ || defined CELERITY_WRITE
2014 IF (.not.destroy(ng, boundary(ng)%zeta_east_C2, myfile, &
2015 & __line__, 'BOUNDARY(ng)%zeta_east_C2')) RETURN
2016
2017 IF (.not.destroy(ng, boundary(ng)%zeta_east_Ce, myfile, &
2018 & __line__, 'BOUNDARY(ng)%zeta_east_Ce')) RETURN
2019
2020 IF (.not.destroy(ng, boundary(ng)%zeta_east_Cx, myfile, &
2021 & __line__, 'BOUNDARY(ng)%zeta_east_Cx')) RETURN
2022# endif
2023
2024# ifndef ANA_FSOBC
2025 IF (.not.destroy(ng, boundary(ng)%zetaG_east, myfile, &
2026 & __line__, 'BOUNDARY(ng)%zetaG_east')) RETURN
2027# endif
2028 END IF
2029!
2030# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2031 IF ( lbc(isouth,isfsur,ng)%acquire.or. &
2032 & ad_lbc(isouth,isfsur,ng)%acquire) THEN
2033# else
2034 IF (lbc(isouth,isfsur,ng)%acquire) THEN
2035# endif
2036 IF (.not.destroy(ng, boundary(ng)%zeta_south, myfile, &
2037 & __line__, 'BOUNDARY(ng)%zeta_south')) RETURN
2038
2039# if defined CELERITY_READ || defined CELERITY_WRITE
2040 IF (.not.destroy(ng, boundary(ng)%zeta_south_C2, myfile, &
2041 & __line__, 'BOUNDARY(ng)%zeta_south_C2')) RETURN
2042
2043 IF (.not.destroy(ng, boundary(ng)%zeta_south_Ce, myfile, &
2044 & __line__, 'BOUNDARY(ng)%zeta_south_Ce')) RETURN
2045
2046 IF (.not.destroy(ng, boundary(ng)%zeta_south_Cx, myfile, &
2047 & __line__, 'BOUNDARY(ng)%zeta_south_Cx')) RETURN
2048# endif
2049
2050# ifndef ANA_FSOBC
2051 IF (.not.destroy(ng, boundary(ng)%zetaG_south, myfile, &
2052 & __line__, 'BOUNDARY(ng)%zetaG_south')) RETURN
2053# endif
2054 END IF
2055!
2056# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2057 IF ( lbc(inorth,isfsur,ng)%acquire.or. &
2058 & ad_lbc(inorth,isfsur,ng)%acquire) THEN
2059# else
2060 IF (lbc(inorth,isfsur,ng)%acquire) THEN
2061# endif
2062 IF (.not.destroy(ng, boundary(ng)%zeta_north, myfile, &
2063 & __line__, 'BOUNDARY(ng)%zeta_north')) RETURN
2064
2065# if defined CELERITY_READ || defined CELERITY_WRITE
2066 IF (.not.destroy(ng, boundary(ng)%zeta_north_C2, myfile, &
2067 & __line__, 'BOUNDARY(ng)%zeta_north_C2')) RETURN
2068
2069 IF (.not.destroy(ng, boundary(ng)%zeta_north_Ce, myfile, &
2070 & __line__, 'BOUNDARY(ng)%zeta_north_Ce')) RETURN
2071
2072 IF (.not.destroy(ng, boundary(ng)%zeta_north_Cx, myfile, &
2073 & __line__, 'BOUNDARY(ng)%zeta_north_Cx')) RETURN
2074# endif
2075
2076# ifndef ANA_FSOBC
2077 IF (.not.destroy(ng, boundary(ng)%zetaG_north, myfile, &
2078 & __line__, 'BOUNDARY(ng)%zetaG_north')) RETURN
2079# endif
2080 END IF
2081!
2082# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2083 IF ( lbc(iwest,isubar,ng)%acquire.or. &
2084 & ad_lbc(iwest,isubar,ng)%acquire) THEN
2085# else
2086 IF (lbc(iwest,isubar,ng)%acquire) THEN
2087# endif
2088 IF (.not.destroy(ng, boundary(ng)%ubar_west, myfile, &
2089 & __line__, 'BOUNDARY(ng)%ubar_west')) RETURN
2090
2091# if defined CELERITY_READ || defined CELERITY_WRITE
2092 IF (.not.destroy(ng, boundary(ng)%ubar_west_C2, myfile, &
2093 & __line__, 'BOUNDARY(ng)%ubar_west_C2')) RETURN
2094
2095 IF (.not.destroy(ng, boundary(ng)%ubar_west_Ce, myfile, &
2096 & __line__, 'BOUNDARY(ng)%ubar_west_Ce')) RETURN
2097
2098 IF (.not.destroy(ng, boundary(ng)%ubar_west_Cx, myfile, &
2099 & __line__, 'BOUNDARY(ng)%ubar_west_Cx')) RETURN
2100# endif
2101
2102# ifndef ANA_M2OBC
2103 IF (.not.destroy(ng, boundary(ng)%ubarG_west, myfile, &
2104 & __line__, 'BOUNDARY(ng)%ubarG_west')) RETURN
2105# endif
2106 END IF
2107# ifdef WEC
2108 IF (lbc(iwest,isu2sd,ng)%acquire) THEN
2109 IF (.not.destroy(ng, boundary(ng)%ubarstokes_west, myfile, &
2110 & __line__, 'BOUNDARY(ng)%ubarstokes_west')) RETURN
2111 END IF
2112# endif
2113!
2114# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2115 IF ( lbc(ieast,isubar,ng)%acquire.or. &
2116 & ad_lbc(ieast,isubar,ng)%acquire) THEN
2117# else
2118 IF (lbc(ieast,isubar,ng)%acquire) THEN
2119# endif
2120 IF (.not.destroy(ng, boundary(ng)%ubar_east, myfile, &
2121 & __line__, 'BOUNDARY(ng)%ubar_east')) RETURN
2122
2123# if defined CELERITY_READ || defined CELERITY_WRITE
2124 IF (.not.destroy(ng, boundary(ng)%ubar_east_C2, myfile, &
2125 & __line__, 'BOUNDARY(ng)%ubar_east_C2')) RETURN
2126
2127 IF (.not.destroy(ng, boundary(ng)%ubar_east_Ce, myfile, &
2128 & __line__, 'BOUNDARY(ng)%ubar_east_Ce')) RETURN
2129
2130 IF (.not.destroy(ng, boundary(ng)%ubar_east_Cx, myfile, &
2131 & __line__, 'BOUNDARY(ng)%ubar_east_Cx')) RETURN
2132# endif
2133
2134# ifndef ANA_M2OBC
2135 IF (.not.destroy(ng, boundary(ng)%ubarG_east, myfile, &
2136 & __line__, 'BOUNDARY(ng)%ubarG_east')) RETURN
2137# endif
2138 END IF
2139# ifdef WEC
2140 IF (lbc(ieast,isu2sd,ng)%acquire) THEN
2141 IF (.not.destroy(ng, boundary(ng)%ubarstokes_east, myfile, &
2142 & __line__, 'BOUNDARY(ng)%ubarstokes_east')) RETURN
2143 END IF
2144# endif
2145!
2146# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2147 IF ( lbc(isouth,isubar,ng)%acquire.or. &
2148 & ad_lbc(isouth,isubar,ng)%acquire) THEN
2149# else
2150 IF (lbc(isouth,isubar,ng)%acquire) THEN
2151# endif
2152 IF (.not.destroy(ng, boundary(ng)%ubar_south, myfile, &
2153 & __line__, 'BOUNDARY(ng)%ubar_south')) RETURN
2154
2155# if defined CELERITY_READ || defined CELERITY_WRITE
2156 IF (.not.destroy(ng, boundary(ng)%ubar_south_C2, myfile, &
2157 & __line__, 'BOUNDARY(ng)%ubar_south_C2')) RETURN
2158
2159 IF (.not.destroy(ng, boundary(ng)%ubar_south_Ce, myfile, &
2160 & __line__, 'BOUNDARY(ng)%ubar_south_Ce')) RETURN
2161
2162 IF (.not.destroy(ng, boundary(ng)%ubar_south_Cx, myfile, &
2163 & __line__, 'BOUNDARY(ng)%ubar_south_Cx')) RETURN
2164# endif
2165
2166# ifndef ANA_M2OBC
2167 IF (.not.destroy(ng, boundary(ng)%ubarG_south, myfile, &
2168 & __line__, 'BOUNDARY(ng)%ubarG_south')) RETURN
2169# endif
2170 END IF
2171# ifdef WEC
2172 IF (lbc(isouth,isu2sd,ng)%acquire) THEN
2173 IF (.not.destroy(ng, boundary(ng)%ubarstokes_south, myfile, &
2174 & __line__, 'BOUNDARY(ng)%ubarstokes_south')) RETURN
2175 END IF
2176# endif
2177!
2178# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2179 IF ( lbc(inorth,isubar,ng)%acquire.or. &
2180 & ad_lbc(inorth,isubar,ng)%acquire) THEN
2181# else
2182 IF (lbc(inorth,isubar,ng)%acquire) THEN
2183# endif
2184 IF (.not.destroy(ng, boundary(ng)%ubar_north, myfile, &
2185 & __line__, 'BOUNDARY(ng)%ubar_north')) RETURN
2186
2187# if defined CELERITY_READ || defined CELERITY_WRITE
2188 IF (.not.destroy(ng, boundary(ng)%ubar_north_C2, myfile, &
2189 & __line__, 'BOUNDARY(ng)%ubar_north_C2')) RETURN
2190
2191 IF (.not.destroy(ng, boundary(ng)%ubar_north_Ce, myfile, &
2192 & __line__, 'BOUNDARY(ng)%ubar_north_Ce')) RETURN
2193
2194 IF (.not.destroy(ng, boundary(ng)%ubar_north_Cx, myfile, &
2195 & __line__, 'BOUNDARY(ng)%ubar_north_Cx')) RETURN
2196# endif
2197
2198# ifndef ANA_M2OBC
2199 IF (.not.destroy(ng, boundary(ng)%ubarG_north, myfile, &
2200 & __line__, 'BOUNDARY(ng)%ubarG_north')) RETURN
2201# endif
2202 END IF
2203# ifdef WEC
2204 IF (lbc(inorth,isu2sd,ng)%acquire) THEN
2205 IF (.not.destroy(ng, boundary(ng)%ubarstokes_north, myfile, &
2206 & __line__, 'BOUNDARY(ng)%ubarstokes_north')) RETURN
2207 END IF
2208# endif
2209!
2210# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2211 IF ( lbc(iwest,isvbar,ng)%acquire.or. &
2212 & ad_lbc(iwest,isvbar,ng)%acquire) THEN
2213# else
2214 IF (lbc(iwest,isvbar,ng)%acquire) THEN
2215# endif
2216 IF (.not.destroy(ng, boundary(ng)%vbar_west, myfile, &
2217 & __line__, 'BOUNDARY(ng)%vbar_west')) RETURN
2218
2219# if defined CELERITY_READ || defined CELERITY_WRITE
2220 IF (.not.destroy(ng, boundary(ng)%vbar_west_C2, myfile, &
2221 & __line__, 'BOUNDARY(ng)%vbar_west_C2')) RETURN
2222
2223 IF (.not.destroy(ng, boundary(ng)%vbar_west_Ce, myfile, &
2224 & __line__, 'BOUNDARY(ng)%vbar_west_Ce')) RETURN
2225
2226 IF (.not.destroy(ng, boundary(ng)%vbar_west_Cx, myfile, &
2227 & __line__, 'BOUNDARY(ng)%vbar_west_Cx')) RETURN
2228# endif
2229
2230# ifndef ANA_M2OBC
2231 IF (.not.destroy(ng, boundary(ng)%vbarG_west, myfile, &
2232 & __line__, 'BOUNDARY(ng)%vbarG_west')) RETURN
2233# endif
2234 END IF
2235# ifdef WEC
2236 IF (lbc(iwest,isv2sd,ng)%acquire) THEN
2237 IF (.not.destroy(ng, boundary(ng)%vbarstokes_west, myfile, &
2238 & __line__, 'BOUNDARY(ng)%vbarstokes_west')) RETURN
2239 END IF
2240# endif
2241!
2242# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2243 IF ( lbc(ieast,isvbar,ng)%acquire.or. &
2244 & ad_lbc(ieast,isvbar,ng)%acquire) THEN
2245# else
2246 IF (lbc(ieast,isvbar,ng)%acquire) THEN
2247# endif
2248 IF (.not.destroy(ng, boundary(ng)%vbar_east, myfile, &
2249 & __line__, 'BOUNDARY(ng)%vbar_east')) RETURN
2250
2251# if defined CELERITY_READ || defined CELERITY_WRITE
2252 IF (.not.destroy(ng, boundary(ng)%vbar_east_C2, myfile, &
2253 & __line__, 'BOUNDARY(ng)%vbar_east_C2')) RETURN
2254
2255 IF (.not.destroy(ng, boundary(ng)%vbar_east_Ce, myfile, &
2256 & __line__, 'BOUNDARY(ng)%vbar_east_Ce')) RETURN
2257
2258 IF (.not.destroy(ng, boundary(ng)%vbar_east_Cx, myfile, &
2259 & __line__, 'BOUNDARY(ng)%vbar_east_Cx')) RETURN
2260# endif
2261
2262# ifndef ANA_M2OBC
2263 IF (.not.destroy(ng, boundary(ng)%vbarG_east, myfile, &
2264 & __line__, 'BOUNDARY(ng)%vbarG_east')) RETURN
2265# endif
2266 END IF
2267# ifdef WEC
2268 IF (lbc(ieast,isv2sd,ng)%acquire) THEN
2269 IF (.not.destroy(ng, boundary(ng)%vbarstokes_east, myfile, &
2270 & __line__, 'BOUNDARY(ng)%vbarstokes_east')) RETURN
2271 END IF
2272# endif
2273!
2274# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2275 IF ( lbc(isouth,isvbar,ng)%acquire.or. &
2276 & ad_lbc(isouth,isvbar,ng)%acquire) THEN
2277# else
2278 IF (lbc(isouth,isvbar,ng)%acquire) THEN
2279# endif
2280 IF (.not.destroy(ng, boundary(ng)%vbar_south, myfile, &
2281 & __line__, 'BOUNDARY(ng)%vbar_south')) RETURN
2282
2283# if defined CELERITY_READ || defined CELERITY_WRITE
2284 IF (.not.destroy(ng, boundary(ng)%vbar_south_C2, myfile, &
2285 & __line__, 'BOUNDARY(ng)%vbar_south_C2')) RETURN
2286
2287 IF (.not.destroy(ng, boundary(ng)%vbar_south_Ce, myfile, &
2288 & __line__, 'BOUNDARY(ng)%vbar_south_Ce')) RETURN
2289
2290 IF (.not.destroy(ng, boundary(ng)%vbar_south_Cx, myfile, &
2291 & __line__, 'BOUNDARY(ng)%vbar_south_Cx')) RETURN
2292# endif
2293
2294# ifndef ANA_M2OBC
2295 IF (.not.destroy(ng, boundary(ng)%vbarG_south, myfile, &
2296 & __line__, 'BOUNDARY(ng)%vbarG_south')) RETURN
2297# endif
2298 END IF
2299# ifdef WEC
2300 IF (lbc(isouth,isv2sd,ng)%acquire) THEN
2301 IF (.not.destroy(ng, boundary(ng)%vbarstokes_south, myfile, &
2302 & __line__, 'BOUNDARY(ng)%vbarstokes_south')) RETURN
2303 END IF
2304# endif
2305!
2306# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2307 IF ( lbc(inorth,isvbar,ng)%acquire.or. &
2308 & ad_lbc(inorth,isvbar,ng)%acquire) THEN
2309# else
2310 IF (lbc(inorth,isvbar,ng)%acquire) THEN
2311# endif
2312 IF (.not.destroy(ng, boundary(ng)%vbar_north, myfile, &
2313 & __line__, 'BOUNDARY(ng)%vbar_north')) RETURN
2314
2315# if defined CELERITY_READ || defined CELERITY_WRITE
2316 IF (.not.destroy(ng, boundary(ng)%vbar_north_C2, myfile, &
2317 & __line__, 'BOUNDARY(ng)%vbar_north_C2')) RETURN
2318
2319 IF (.not.destroy(ng, boundary(ng)%vbar_north_Ce, myfile, &
2320 & __line__, 'BOUNDARY(ng)%vbar_north_Ce')) RETURN
2321
2322 IF (.not.destroy(ng, boundary(ng)%vbar_north_Cx, myfile, &
2323 & __line__, 'BOUNDARY(ng)%vbar_north_Cx')) RETURN
2324# endif
2325
2326# ifndef ANA_M2OBC
2327 IF (.not.destroy(ng, boundary(ng)%vbarG_north, myfile, &
2328 & __line__, 'BOUNDARY(ng)%vbarG_north')) RETURN
2329# endif
2330 END IF
2331# ifdef WEC
2332 IF (lbc(inorth,isv2sd,ng)%acquire) THEN
2333 IF (.not.destroy(ng, boundary(ng)%vbarstokes_north, myfile, &
2334 & __line__, 'BOUNDARY(ng)%vbarstokes_north')) RETURN
2335 END IF
2336# endif
2337
2338# ifdef SOLVE3D
2339!
2340# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2341 IF ( lbc(iwest,isuvel,ng)%acquire.or. &
2342 & ad_lbc(iwest,isuvel,ng)%acquire) THEN
2343# else
2344 IF (lbc(iwest,isuvel,ng)%acquire) THEN
2345# endif
2346 IF (.not.destroy(ng, boundary(ng)%u_west, myfile, &
2347 & __line__, 'BOUNDARY(ng)%u_west')) RETURN
2348
2349# if defined CELERITY_READ || defined CELERITY_WRITE
2350 IF (.not.destroy(ng, boundary(ng)%u_west_C2, myfile, &
2351 & __line__, 'BOUNDARY(ng)%u_west_C2')) RETURN
2352
2353 IF (.not.destroy(ng, boundary(ng)%u_west_Ce, myfile, &
2354 & __line__, 'BOUNDARY(ng)%u_west_Ce')) RETURN
2355
2356 IF (.not.destroy(ng, boundary(ng)%u_west_Cx, myfile, &
2357 & __line__, 'BOUNDARY(ng)%u_west_Cx')) RETURN
2358# endif
2359
2360# ifndef ANA_M3OBC
2361 IF (.not.destroy(ng, boundary(ng)%uG_west, myfile, &
2362 & __line__, 'BOUNDARY(ng)%uG_west')) RETURN
2363# endif
2364 END IF
2365# ifdef WEC
2366 IF (lbc(iwest,isu3sd,ng)%acquire) THEN
2367 IF (.not.destroy(ng, boundary(ng)%ustokes_west, myfile, &
2368 & __line__, 'BOUNDARY(ng)%ustokes_west')) RETURN
2369 END IF
2370# endif
2371!
2372# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2373 IF ( lbc(ieast,isuvel,ng)%acquire.or. &
2374 & ad_lbc(ieast,isuvel,ng)%acquire) THEN
2375# else
2376 IF (lbc(ieast,isuvel,ng)%acquire) THEN
2377# endif
2378 IF (.not.destroy(ng, boundary(ng)%u_east, myfile, &
2379 & __line__, 'BOUNDARY(ng)%u_east')) RETURN
2380
2381# if defined CELERITY_READ || defined CELERITY_WRITE
2382 IF (.not.destroy(ng, boundary(ng)%u_east_C2, myfile, &
2383 & __line__, 'BOUNDARY(ng)%u_east_C2')) RETURN
2384
2385 IF (.not.destroy(ng, boundary(ng)%u_east_Ce, myfile, &
2386 & __line__, 'BOUNDARY(ng)%u_east_Ce')) RETURN
2387
2388 IF (.not.destroy(ng, boundary(ng)%u_east_Cx, myfile, &
2389 & __line__, 'BOUNDARY(ng)%u_east_Cx')) RETURN
2390# endif
2391
2392# ifndef ANA_M3OBC
2393 IF (.not.destroy(ng, boundary(ng)%uG_east, myfile, &
2394 & __line__, 'BOUNDARY(ng)%uG_east')) RETURN
2395# endif
2396 END IF
2397# ifdef WEC
2398 IF (lbc(ieast,isu3sd,ng)%acquire) THEN
2399 IF (.not.destroy(ng, boundary(ng)%ustokes_east, myfile, &
2400 & __line__, 'BOUNDARY(ng)%ustokes_east')) RETURN
2401 END IF
2402# endif
2403!
2404# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2405 IF ( lbc(isouth,isuvel,ng)%acquire.or. &
2406 & ad_lbc(isouth,isuvel,ng)%acquire) THEN
2407# else
2408 IF (lbc(isouth,isuvel,ng)%acquire) THEN
2409# endif
2410 IF (.not.destroy(ng, boundary(ng)%u_south, myfile, &
2411 & __line__, 'BOUNDARY(ng)%u_south')) RETURN
2412
2413# if defined CELERITY_READ || defined CELERITY_WRITE
2414 IF (.not.destroy(ng, boundary(ng)%u_south_C2, myfile, &
2415 & __line__, 'BOUNDARY(ng)%u_south_C2')) RETURN
2416
2417 IF (.not.destroy(ng, boundary(ng)%u_south_Ce, myfile, &
2418 & __line__, 'BOUNDARY(ng)%u_south_Ce')) RETURN
2419
2420 IF (.not.destroy(ng, boundary(ng)%u_south_Cx, myfile, &
2421 & __line__, 'BOUNDARY(ng)%u_south_Cx')) RETURN
2422# endif
2423
2424# ifndef ANA_M3OBC
2425 IF (.not.destroy(ng, boundary(ng)%uG_south, myfile, &
2426 & __line__, 'BOUNDARY(ng)%uG_south')) RETURN
2427# endif
2428 END IF
2429# ifdef WEC
2430 IF (lbc(isouth,isu3sd,ng)%acquire) THEN
2431 IF (.not.destroy(ng, boundary(ng)%ustokes_south, myfile, &
2432 & __line__, 'BOUNDARY(ng)%ustokes_south')) RETURN
2433 END IF
2434# endif
2435!
2436# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2437 IF ( lbc(inorth,isuvel,ng)%acquire.or. &
2438 & ad_lbc(inorth,isuvel,ng)%acquire) THEN
2439# else
2440 IF (lbc(inorth,isuvel,ng)%acquire) THEN
2441# endif
2442 IF (.not.destroy(ng, boundary(ng)%u_north, myfile, &
2443 & __line__, 'BOUNDARY(ng)%u_north')) RETURN
2444
2445# if defined CELERITY_READ || defined CELERITY_WRITE
2446 IF (.not.destroy(ng, boundary(ng)%u_north_C2, myfile, &
2447 & __line__, 'BOUNDARY(ng)%u_north_C2')) RETURN
2448
2449 IF (.not.destroy(ng, boundary(ng)%u_north_Ce, myfile, &
2450 & __line__, 'BOUNDARY(ng)%u_north_Ce')) RETURN
2451
2452 IF (.not.destroy(ng, boundary(ng)%u_north_Cx, myfile, &
2453 & __line__, 'BOUNDARY(ng)%u_north_Cx')) RETURN
2454# endif
2455
2456# ifndef ANA_M3OBC
2457 IF (.not.destroy(ng, boundary(ng)%uG_north, myfile, &
2458 & __line__, 'BOUNDARY(ng)%uG_north')) RETURN
2459# endif
2460 END IF
2461# ifdef WEC
2462 IF (lbc(inorth,isu3sd,ng)%acquire) THEN
2463 IF (.not.destroy(ng, boundary(ng)%ustokes_north, myfile, &
2464 & __line__, 'BOUNDARY(ng)%ustokes_north')) RETURN
2465 END IF
2466# endif
2467!
2468# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2469 IF ( lbc(iwest,isvvel,ng)%acquire.or. &
2470 & ad_lbc(iwest,isvvel,ng)%acquire) THEN
2471# else
2472 IF (lbc(iwest,isvvel,ng)%acquire) THEN
2473# endif
2474 IF (.not.destroy(ng, boundary(ng)%v_west, myfile, &
2475 & __line__, 'BOUNDARY(ng)%v_west')) RETURN
2476
2477# if defined CELERITY_READ || defined CELERITY_WRITE
2478 IF (.not.destroy(ng, boundary(ng)%v_west_C2, myfile, &
2479 & __line__, 'BOUNDARY(ng)%v_west_C2')) RETURN
2480
2481 IF (.not.destroy(ng, boundary(ng)%v_west_Ce, myfile, &
2482 & __line__, 'BOUNDARY(ng)%v_west_Ce')) RETURN
2483
2484 IF (.not.destroy(ng, boundary(ng)%v_west_Cx, myfile, &
2485 & __line__, 'BOUNDARY(ng)%v_west_Cx')) RETURN
2486# endif
2487
2488# ifndef ANA_M3OBC
2489 IF (.not.destroy(ng, boundary(ng)%vG_west, myfile, &
2490 & __line__, 'BOUNDARY(ng)%vG_west')) RETURN
2491# endif
2492 END IF
2493# ifdef WEC
2494 IF (lbc(iwest,isv3sd,ng)%acquire) THEN
2495 IF (.not.destroy(ng, boundary(ng)%vstokes_west, myfile, &
2496 & __line__, 'BOUNDARY(ng)%vstokes_west')) RETURN
2497 END IF
2498# endif
2499!
2500# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2501 IF ( lbc(ieast,isvvel,ng)%acquire.or. &
2502 & ad_lbc(ieast,isvvel,ng)%acquire) THEN
2503# else
2504 IF (lbc(ieast,isvvel,ng)%acquire) THEN
2505# endif
2506 IF (.not.destroy(ng, boundary(ng)%v_east, myfile, &
2507 & __line__, 'BOUNDARY(ng)%v_east')) RETURN
2508
2509# if defined CELERITY_READ || defined CELERITY_WRITE
2510 IF (.not.destroy(ng, boundary(ng)%v_east_C2, myfile, &
2511 & __line__, 'BOUNDARY(ng)%v_east_C2')) RETURN
2512
2513 IF (.not.destroy(ng, boundary(ng)%v_east_Ce, myfile, &
2514 & __line__, 'BOUNDARY(ng)%v_east_Ce')) RETURN
2515
2516 IF (.not.destroy(ng, boundary(ng)%v_east_Cx, myfile, &
2517 & __line__, 'BOUNDARY(ng)%v_east_Cx')) RETURN
2518# endif
2519
2520# ifndef ANA_M3OBC
2521 IF (.not.destroy(ng, boundary(ng)%vG_east, myfile, &
2522 & __line__, 'BOUNDARY(ng)%vG_east')) RETURN
2523# endif
2524 END IF
2525# ifdef WEC
2526 IF (lbc(ieast,isv3sd,ng)%acquire) THEN
2527 IF (.not.destroy(ng, boundary(ng)%vstokes_east, myfile, &
2528 & __line__, 'BOUNDARY(ng)%vstokes_east')) RETURN
2529 END IF
2530# endif
2531!
2532# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2533 IF ( lbc(isouth,isvvel,ng)%acquire.or. &
2534 & ad_lbc(isouth,isvvel,ng)%acquire) THEN
2535# else
2536 IF (lbc(isouth,isvvel,ng)%acquire) THEN
2537# endif
2538 IF (.not.destroy(ng, boundary(ng)%v_south, myfile, &
2539 & __line__, 'BOUNDARY(ng)%v_south')) RETURN
2540
2541# if defined CELERITY_READ || defined CELERITY_WRITE
2542 IF (.not.destroy(ng, boundary(ng)%v_south_C2, myfile, &
2543 & __line__, 'BOUNDARY(ng)%v_south_C2')) RETURN
2544
2545 IF (.not.destroy(ng, boundary(ng)%v_south_Ce, myfile, &
2546 & __line__, 'BOUNDARY(ng)%v_south_Ce')) RETURN
2547
2548 IF (.not.destroy(ng, boundary(ng)%v_south_Cx, myfile, &
2549 & __line__, 'BOUNDARY(ng)%v_south_Cx')) RETURN
2550# endif
2551
2552# ifndef ANA_M3OBC
2553 IF (.not.destroy(ng, boundary(ng)%vG_south, myfile, &
2554 & __line__, 'BOUNDARY(ng)%vG_south')) RETURN
2555# endif
2556 END IF
2557# ifdef WEC
2558 IF (lbc(isouth,isv3sd,ng)%acquire) THEN
2559 IF (.not.destroy(ng, boundary(ng)%vstokes_south, myfile, &
2560 & __line__, 'BOUNDARY(ng)%vstokes_south')) RETURN
2561 END IF
2562# endif
2563!
2564# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2565 IF ( lbc(inorth,isvvel,ng)%acquire.or. &
2566 & ad_lbc(inorth,isvvel,ng)%acquire) THEN
2567# else
2568 IF (lbc(inorth,isvvel,ng)%acquire) THEN
2569# endif
2570 IF (.not.destroy(ng, boundary(ng)%v_north, myfile, &
2571 & __line__, 'BOUNDARY(ng)%v_north')) RETURN
2572
2573# if defined CELERITY_READ || defined CELERITY_WRITE
2574 IF (.not.destroy(ng, boundary(ng)%u_north_C2, myfile, &
2575 & __line__, 'BOUNDARY(ng)%u_north_C2')) RETURN
2576
2577 IF (.not.destroy(ng, boundary(ng)%u_north_Ce, myfile, &
2578 & __line__, 'BOUNDARY(ng)%u_north_Ce')) RETURN
2579
2580 IF (.not.destroy(ng, boundary(ng)%u_north_Cx, myfile, &
2581 & __line__, 'BOUNDARY(ng)%u_north_Cx')) RETURN
2582# endif
2583
2584# ifndef ANA_M3OBC
2585 IF (.not.destroy(ng, boundary(ng)%vG_north, myfile, &
2586 & __line__, 'BOUNDARY(ng)%vG_north')) RETURN
2587# endif
2588 END IF
2589# ifdef WEC
2590 IF (lbc(inorth,isv3sd,ng)%acquire) THEN
2591 IF (.not.destroy(ng, boundary(ng)%vstokes_north, myfile, &
2592 & __line__, 'BOUNDARY(ng)%vstokes_north')) RETURN
2593 END IF
2594# endif
2595!
2596# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2597 IF (any( lbc(iwest,istvar(:),ng)%acquire).or. &
2598 & any(ad_lbc(iwest,istvar(:),ng)%acquire)) THEN
2599# else
2600 IF (any(lbc(iwest,istvar(:),ng)%acquire)) THEN
2601# endif
2602 IF (.not.destroy(ng, boundary(ng)%t_west, myfile, &
2603 & __line__, 'BOUNDARY(ng)%t_west')) RETURN
2604
2605# if defined CELERITY_READ || defined CELERITY_WRITE
2606 IF (.not.destroy(ng, boundary(ng)%t_west_C2, myfile, &
2607 & __line__, 'BOUNDARY(ng)%t_west_C2')) RETURN
2608
2609 IF (.not.destroy(ng, boundary(ng)%t_west_Ce, myfile, &
2610 & __line__, 'BOUNDARY(ng)%t_west_Ce')) RETURN
2611
2612 IF (.not.destroy(ng, boundary(ng)%t_west_Cx, myfile, &
2613 & __line__, 'BOUNDARY(ng)%t_west_Cx')) RETURN
2614# endif
2615
2616# ifndef ANA_TOBC
2617 IF (.not.destroy(ng, boundary(ng)%tG_west, myfile, &
2618 & __line__, 'BOUNDARY(ng)%tG_west')) RETURN
2619# endif
2620 END IF
2621!
2622# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2623 IF (any( lbc(ieast,istvar(:),ng)%acquire).or. &
2624 & any(ad_lbc(ieast,istvar(:),ng)%acquire)) THEN
2625# else
2626 IF (any(lbc(ieast,istvar(:),ng)%acquire)) THEN
2627# endif
2628 IF (.not.destroy(ng, boundary(ng)%t_east, myfile, &
2629 & __line__, 'BOUNDARY(ng)%t_east')) RETURN
2630
2631# if defined CELERITY_READ || defined CELERITY_WRITE
2632 IF (.not.destroy(ng, boundary(ng)%t_east_C2, myfile, &
2633 & __line__, 'BOUNDARY(ng)%t_east_C2')) RETURN
2634
2635 IF (.not.destroy(ng, boundary(ng)%t_east_Ce, myfile, &
2636 & __line__, 'BOUNDARY(ng)%t_east_Ce')) RETURN
2637
2638 IF (.not.destroy(ng, boundary(ng)%t_east_Cx, myfile, &
2639 & __line__, 'BOUNDARY(ng)%t_east_Cx')) RETURN
2640# endif
2641
2642# ifndef ANA_TOBC
2643 IF (.not.destroy(ng, boundary(ng)%tG_east, myfile, &
2644 & __line__, 'BOUNDARY(ng)%tG_east')) RETURN
2645# endif
2646 END IF
2647!
2648# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2649 IF (any( lbc(isouth,istvar(:),ng)%acquire).or. &
2650 & any(ad_lbc(isouth,istvar(:),ng)%acquire)) THEN
2651# else
2652 IF (any(lbc(isouth,istvar(:),ng)%acquire)) THEN
2653# endif
2654 IF (.not.destroy(ng, boundary(ng)%t_south, myfile, &
2655 & __line__, 'BOUNDARY(ng)%t_south')) RETURN
2656
2657# if defined CELERITY_READ || defined CELERITY_WRITE
2658 IF (.not.destroy(ng, boundary(ng)%t_south_C2, myfile, &
2659 & __line__, 'BOUNDARY(ng)%t_south_C2')) RETURN
2660
2661 IF (.not.destroy(ng, boundary(ng)%t_south_Ce, myfile, &
2662 & __line__, 'BOUNDARY(ng)%t_south_Ce')) RETURN
2663
2664 IF (.not.destroy(ng, boundary(ng)%t_south_Cx, myfile, &
2665 & __line__, 'BOUNDARY(ng)%t_south_Cx')) RETURN
2666# endif
2667
2668# ifndef ANA_TOBC
2669 IF (.not.destroy(ng, boundary(ng)%tG_south, myfile, &
2670 & __line__, 'BOUNDARY(ng)%tG_south')) RETURN
2671# endif
2672 END IF
2673!
2674# if defined ADJOINT || defined TANGENT || defined TL_IOMS
2675 IF (any( lbc(inorth,istvar(:),ng)%acquire).or. &
2676 & any(ad_lbc(inorth,istvar(:),ng)%acquire)) THEN
2677# else
2678 IF (any(lbc(inorth,istvar(:),ng)%acquire)) THEN
2679# endif
2680 IF (.not.destroy(ng, boundary(ng)%t_north, myfile, &
2681 & __line__, 'BOUNDARY(ng)%t_north')) RETURN
2682
2683# if defined CELERITY_READ || defined CELERITY_WRITE
2684 IF (.not.destroy(ng, boundary(ng)%t_north_C2, myfile, &
2685 & __line__, 'BOUNDARY(ng)%t_north_C2')) RETURN
2686
2687 IF (.not.destroy(ng, boundary(ng)%t_north_Ce, myfile, &
2688 & __line__, 'BOUNDARY(ng)%t_north_Ce')) RETURN
2689
2690 IF (.not.destroy(ng, boundary(ng)%t_north_Cx, myfile, &
2691 & __line__, 'BOUNDARY(ng)%t_north_Cx')) RETURN
2692# endif
2693
2694# ifndef ANA_TOBC
2695 IF (.not.destroy(ng, boundary(ng)%tG_north, myfile, &
2696 & __line__, 'BOUNDARY(ng)%tG_north')) RETURN
2697# endif
2698 END IF
2699# endif
2700
2701# if defined TANGENT || defined TL_IOMS
2702!
2703! Tangent linear model state.
2704!
2705 IF (tl_lbc(iwest,isfsur,ng)%acquire) THEN
2706 IF (.not.destroy(ng, boundary(ng)%tl_zeta_west, myfile, &
2707 & __line__, 'BOUNDARY(ng)%tl_zeta_west')) RETURN
2708 END IF
2709
2710 IF (tl_lbc(ieast,isfsur,ng)%acquire) THEN
2711 IF (.not.destroy(ng, boundary(ng)%tl_zeta_east, myfile, &
2712 & __line__, 'BOUNDARY(ng)%tl_zeta_east')) RETURN
2713 END IF
2714
2715 IF (tl_lbc(isouth,isfsur,ng)%acquire) THEN
2716 IF (.not.destroy(ng, boundary(ng)%tl_zeta_south, myfile, &
2717 & __line__, 'BOUNDARY(ng)%tl_zeta_south')) RETURN
2718 END IF
2719
2720 IF (tl_lbc(inorth,isfsur,ng)%acquire) THEN
2721 IF (.not.destroy(ng, boundary(ng)%tl_zeta_north, myfile, &
2722 & __line__, 'BOUNDARY(ng)%tl_zeta_north')) RETURN
2723 END IF
2724!
2725 IF (tl_lbc(iwest,isubar,ng)%acquire) THEN
2726 IF (.not.destroy(ng, boundary(ng)%tl_ubar_west, myfile, &
2727 & __line__, 'BOUNDARY(ng)%tl_ubar_west')) RETURN
2728 END IF
2729
2730 IF (tl_lbc(ieast,isubar,ng)%acquire) THEN
2731 IF (.not.destroy(ng, boundary(ng)%tl_ubar_east, myfile, &
2732 & __line__, 'BOUNDARY(ng)%tl_ubar_east')) RETURN
2733 END IF
2734
2735 IF (tl_lbc(isouth,isubar,ng)%acquire) THEN
2736 IF (.not.destroy(ng, boundary(ng)%tl_ubar_south, myfile, &
2737 & __line__, 'BOUNDARY(ng)%tl_ubar_south')) RETURN
2738 END IF
2739
2740 IF (tl_lbc(inorth,isubar,ng)%acquire) THEN
2741 IF (.not.destroy(ng, boundary(ng)%tl_ubar_north, myfile, &
2742 & __line__, 'BOUNDARY(ng)%tl_ubar_north')) RETURN
2743 END IF
2744!
2745 IF (tl_lbc(iwest,isvbar,ng)%acquire) THEN
2746 IF (.not.destroy(ng, boundary(ng)%tl_vbar_west, myfile, &
2747 & __line__, 'BOUNDARY(ng)%tl_vbar_west')) RETURN
2748 END IF
2749
2750 IF (tl_lbc(ieast,isvbar,ng)%acquire) THEN
2751 IF (.not.destroy(ng, boundary(ng)%tl_vbar_east, myfile, &
2752 & __line__, 'BOUNDARY(ng)%tl_vbar_east')) RETURN
2753 END IF
2754
2755 IF (tl_lbc(isouth,isvbar,ng)%acquire) THEN
2756 IF (.not.destroy(ng, boundary(ng)%tl_vbar_south, myfile, &
2757 & __line__, 'BOUNDARY(ng)%tl_vbar_south')) RETURN
2758 END IF
2759
2760 IF (tl_lbc(inorth,isvbar,ng)%acquire) THEN
2761 IF (.not.destroy(ng, boundary(ng)%tl_vbar_north, myfile, &
2762 & __line__, 'BOUNDARY(ng)%tl_vbar_north')) RETURN
2763 END IF
2764
2765# ifdef SOLVE3D
2766!
2767 IF (tl_lbc(iwest,isuvel,ng)%acquire) THEN
2768 IF (.not.destroy(ng, boundary(ng)%tl_u_west, myfile, &
2769 & __line__, 'BOUNDARY(ng)%tl_u_west')) RETURN
2770 END IF
2771 IF (tl_lbc(ieast,isuvel,ng)%acquire) THEN
2772 IF (.not.destroy(ng, boundary(ng)%tl_u_east, myfile, &
2773 & __line__, 'BOUNDARY(ng)%tl_u_east')) RETURN
2774 END IF
2775
2776 IF (tl_lbc(isouth,isuvel,ng)%acquire) THEN
2777 IF (.not.destroy(ng, boundary(ng)%tl_u_south, myfile, &
2778 & __line__, 'BOUNDARY(ng)%tl_u_south')) RETURN
2779 END IF
2780
2781 IF (tl_lbc(inorth,isuvel,ng)%acquire) THEN
2782 IF (.not.destroy(ng, boundary(ng)%tl_u_north, myfile, &
2783 & __line__, 'BOUNDARY(ng)%tl_u_north')) RETURN
2784 END IF
2785!
2786 IF (tl_lbc(iwest,isvvel,ng)%acquire) THEN
2787 IF (.not.destroy(ng, boundary(ng)%tl_v_west, myfile, &
2788 & __line__, 'BOUNDARY(ng)%tl_v_west')) RETURN
2789 END IF
2790
2791 IF (tl_lbc(ieast,isvvel,ng)%acquire) THEN
2792 IF (.not.destroy(ng, boundary(ng)%tl_v_east, myfile, &
2793 & __line__, 'BOUNDARY(ng)%tl_v_east')) RETURN
2794 END IF
2795
2796 IF (tl_lbc(isouth,isvvel,ng)%acquire) THEN
2797 IF (.not.destroy(ng, boundary(ng)%tl_v_south, myfile, &
2798 & __line__, 'BOUNDARY(ng)%tl_v_south')) RETURN
2799 END IF
2800
2801 IF (tl_lbc(inorth,isvvel,ng)%acquire) THEN
2802 IF (.not.destroy(ng, boundary(ng)%tl_v_north, myfile, &
2803 & __line__, 'BOUNDARY(ng)%tl_v_north')) RETURN
2804 END IF
2805!
2806 IF (any(tl_lbc(iwest,istvar(:),ng)%acquire)) THEN
2807 IF (.not.destroy(ng, boundary(ng)%tl_t_west, myfile, &
2808 & __line__, 'BOUNDARY(ng)%tl_t_west')) RETURN
2809 END IF
2810
2811 IF (any(tl_lbc(ieast,istvar(:),ng)%acquire)) THEN
2812 IF (.not.destroy(ng, boundary(ng)%tl_t_east, myfile, &
2813 & __line__, 'BOUNDARY(ng)%tl_t_east')) RETURN
2814 END IF
2815
2816 IF (any(tl_lbc(isouth,istvar(:),ng)%acquire)) THEN
2817 IF (.not.destroy(ng, boundary(ng)%tl_t_south, myfile, &
2818 & __line__, 'BOUNDARY(ng)%tl_t_south')) RETURN
2819 END IF
2820
2821 IF (any(tl_lbc(inorth,istvar(:),ng)%acquire)) THEN
2822 IF (.not.destroy(ng, boundary(ng)%tl_t_north, myfile, &
2823 & __line__, 'BOUNDARY(ng)%tl_t_north')) RETURN
2824 END IF
2825# endif
2826# endif
2827
2828# ifdef ADJOINT
2829!
2830! Adjoint model state.
2831!
2832 IF (ad_lbc(iwest,isfsur,ng)%acquire) THEN
2833 IF (.not.destroy(ng, boundary(ng)%ad_zeta_west, myfile, &
2834 & __line__, 'BOUNDARY(ng)%ad_zeta_west')) RETURN
2835 END IF
2836
2837 IF (ad_lbc(ieast,isfsur,ng)%acquire) THEN
2838 IF (.not.destroy(ng, boundary(ng)%ad_zeta_east, myfile, &
2839 & __line__, 'BOUNDARY(ng)%ad_zeta_east')) RETURN
2840 END IF
2841
2842 IF (ad_lbc(isouth,isfsur,ng)%acquire) THEN
2843 IF (.not.destroy(ng, boundary(ng)%ad_zeta_south, myfile, &
2844 & __line__, 'BOUNDARY(ng)%ad_zeta_south')) RETURN
2845 END IF
2846
2847 IF (ad_lbc(inorth,isfsur,ng)%acquire) THEN
2848 IF (.not.destroy(ng, boundary(ng)%ad_zeta_north, myfile, &
2849 & __line__, 'BOUNDARY(ng)%ad_zeta_north')) RETURN
2850 END IF
2851!
2852 IF (ad_lbc(iwest,isubar,ng)%acquire) THEN
2853 IF (.not.destroy(ng, boundary(ng)%ad_ubar_west, myfile, &
2854 & __line__, 'BOUNDARY(ng)%ad_ubar_west')) RETURN
2855 END IF
2856
2857 IF (ad_lbc(ieast,isubar,ng)%acquire) THEN
2858 IF (.not.destroy(ng, boundary(ng)%ad_ubar_east, myfile, &
2859 & __line__, 'BOUNDARY(ng)%ad_ubar_east')) RETURN
2860 END IF
2861
2862 IF (ad_lbc(isouth,isubar,ng)%acquire) THEN
2863 IF (.not.destroy(ng, boundary(ng)%ad_ubar_south, myfile, &
2864 & __line__, 'BOUNDARY(ng)%ad_ubar_south')) RETURN
2865 END IF
2866
2867 IF (ad_lbc(inorth,isubar,ng)%acquire) THEN
2868 IF (.not.destroy(ng, boundary(ng)%ad_ubar_north, myfile, &
2869 & __line__, 'BOUNDARY(ng)%ad_ubar_north')) RETURN
2870 END IF
2871!
2872 IF (ad_lbc(iwest,isvbar,ng)%acquire) THEN
2873 IF (.not.destroy(ng, boundary(ng)%ad_vbar_west, myfile, &
2874 & __line__, 'BOUNDARY(ng)%ad_vbar_west')) RETURN
2875 END IF
2876
2877 IF (ad_lbc(ieast,isvbar,ng)%acquire) THEN
2878 IF (.not.destroy(ng, boundary(ng)%ad_vbar_east, myfile, &
2879 & __line__, 'BOUNDARY(ng)%ad_vbar_east')) RETURN
2880 END IF
2881
2882 IF (ad_lbc(isouth,isvbar,ng)%acquire) THEN
2883 IF (.not.destroy(ng, boundary(ng)%ad_vbar_south, myfile, &
2884 & __line__, 'BOUNDARY(ng)%ad_vbar_south')) RETURN
2885 END IF
2886
2887 IF (ad_lbc(inorth,isvbar,ng)%acquire) THEN
2888 IF (.not.destroy(ng, boundary(ng)%ad_vbar_north, myfile, &
2889 & __line__, 'BOUNDARY(ng)%ad_vbar_north')) RETURN
2890 END IF
2891
2892# ifdef SOLVE3D
2893!
2894 IF (ad_lbc(iwest,isuvel,ng)%acquire) THEN
2895 IF (.not.destroy(ng, boundary(ng)%ad_u_west, myfile, &
2896 & __line__, 'BOUNDARY(ng)%ad_u_west')) RETURN
2897 END IF
2898
2899 IF (ad_lbc(ieast,isuvel,ng)%acquire) THEN
2900 IF (.not.destroy(ng, boundary(ng)%ad_u_east, myfile, &
2901 & __line__, 'BOUNDARY(ng)%ad_u_east')) RETURN
2902 END IF
2903
2904 IF (ad_lbc(isouth,isuvel,ng)%acquire) THEN
2905 IF (.not.destroy(ng, boundary(ng)%ad_u_south, myfile, &
2906 & __line__, 'BOUNDARY(ng)%ad_u_south')) RETURN
2907 END IF
2908
2909 IF (ad_lbc(isouth,isuvel,ng)%acquire) THEN
2910 IF (.not.destroy(ng, boundary(ng)%ad_u_north, myfile, &
2911 & __line__, 'BOUNDARY(ng)%ad_u_north')) RETURN
2912 END IF
2913!
2914 IF (ad_lbc(iwest,isvvel,ng)%acquire) THEN
2915 IF (.not.destroy(ng, boundary(ng)%ad_v_west, myfile, &
2916 & __line__, 'BOUNDARY(ng)%ad_v_west')) RETURN
2917 END IF
2918
2919 IF (ad_lbc(ieast,isvvel,ng)%acquire) THEN
2920 IF (.not.destroy(ng, boundary(ng)%ad_v_east, myfile, &
2921 & __line__, 'BOUNDARY(ng)%ad_v_east')) RETURN
2922 END IF
2923
2924 IF (ad_lbc(isouth,isvvel,ng)%acquire) THEN
2925 IF (.not.destroy(ng, boundary(ng)%ad_v_south, myfile, &
2926 & __line__, 'BOUNDARY(ng)%ad_v_south')) RETURN
2927 END IF
2928
2929 IF (ad_lbc(inorth,isvvel,ng)%acquire) THEN
2930 IF (.not.destroy(ng, boundary(ng)%ad_v_north, myfile, &
2931 & __line__, 'BOUNDARY(ng)%ad_v_north')) RETURN
2932 END IF
2933!
2934 IF (any(ad_lbc(iwest,istvar(:),ng)%acquire)) THEN
2935 IF (.not.destroy(ng, boundary(ng)%ad_t_west, myfile, &
2936 & __line__, 'BOUNDARY(ng)%ad_t_west')) RETURN
2937 END IF
2938
2939 IF (any(ad_lbc(ieast,istvar(:),ng)%acquire)) THEN
2940 IF (.not.destroy(ng, boundary(ng)%ad_t_east, myfile, &
2941 & __line__, 'BOUNDARY(ng)%ad_t_east')) RETURN
2942 END IF
2943
2944 IF (any(ad_lbc(isouth,istvar(:),ng)%acquire)) THEN
2945 IF (.not.destroy(ng, boundary(ng)%ad_t_south, myfile, &
2946 & __line__, 'BOUNDARY(ng)%ad_t_south')) RETURN
2947 END IF
2948
2949 IF (any(ad_lbc(inorth,istvar(:),ng)%acquire)) THEN
2950 IF (.not.destroy(ng, boundary(ng)%ad_t_north, myfile, &
2951 & __line__, 'BOUNDARY(ng)%ad_t_north')) RETURN
2952 END IF
2953# endif
2954# endif
2955
2956# ifdef ADJUST_BOUNDARY
2957!
2958! Open boundaries arrays used in 4DVar adjustments.
2959!
2960# ifdef SOLVE3D
2961 IF (.not.destroy(ng, boundary(ng)%t_obc, myfile, &
2962 & __line__, 'BOUNDARY(ng)%t_obc')) RETURN
2963
2964 IF (.not.destroy(ng, boundary(ng)%u_obc, myfile, &
2965 & __line__, 'BOUNDARY(ng)%u_obc')) RETURN
2966
2967 IF (.not.destroy(ng, boundary(ng)%v_obc, myfile, &
2968 & __line__, 'BOUNDARY(ng)%v_obc')) RETURN
2969!
2970 IF (.not.destroy(ng, boundary(ng)%ad_t_obc, myfile, &
2971 & __line__, 'BOUNDARY(ng)%ad_t_obc')) RETURN
2972
2973 IF (.not.destroy(ng, boundary(ng)%ad_u_obc, myfile, &
2974 & __line__, 'BOUNDARY(ng)%ad_u_obc')) RETURN
2975
2976 IF (.not.destroy(ng, boundary(ng)%ad_v_obc, myfile, &
2977 & __line__, 'BOUNDARY(ng)%ad_v_obc')) RETURN
2978!
2979 IF (.not.destroy(ng, boundary(ng)%tl_t_obc, myfile, &
2980 & __line__, 'BOUNDARY(ng)%tl_t_obc')) RETURN
2981
2982 IF (.not.destroy(ng, boundary(ng)%tl_u_obc, myfile, &
2983 & __line__, 'BOUNDARY(ng)%tl_u_obc')) RETURN
2984
2985 IF (.not.destroy(ng, boundary(ng)%tl_v_obc, myfile, &
2986 & __line__, 'BOUNDARY(ng)%tl_v_obc')) RETURN
2987!
2988 IF (.not.destroy(ng, boundary(ng)%b_t_obc, myfile, &
2989 & __line__, 'BOUNDARY(ng)%b_t_obc')) RETURN
2990
2991 IF (.not.destroy(ng, boundary(ng)%b_u_obc, myfile, &
2992 & __line__, 'BOUNDARY(ng)%b_u_obc')) RETURN
2993
2994 IF (.not.destroy(ng, boundary(ng)%b_v_obc, myfile, &
2995 & __line__, 'BOUNDARY(ng)%b_v_obc')) RETURN
2996!
2997 IF (.not.destroy(ng, boundary(ng)%d_t_obc, myfile, &
2998 & __line__, 'BOUNDARY(ng)%d_t_obc')) RETURN
2999
3000 IF (.not.destroy(ng, boundary(ng)%d_u_obc, myfile, &
3001 & __line__, 'BOUNDARY(ng)%d_u_obc')) RETURN
3002
3003 IF (.not.destroy(ng, boundary(ng)%d_v_obc, myfile, &
3004 & __line__, 'BOUNDARY(ng)%d_v_obc')) RETURN
3005!
3006 IF (.not.destroy(ng, boundary(ng)%e_t_obc, myfile, &
3007 & __line__, 'BOUNDARY(ng)%e_t_obc')) RETURN
3008
3009 IF (.not.destroy(ng, boundary(ng)%e_u_obc, myfile, &
3010 & __line__, 'BOUNDARY(ng)%e_u_obc')) RETURN
3011
3012 IF (.not.destroy(ng, boundary(ng)%e_v_obc, myfile, &
3013 & __line__, 'BOUNDARY(ng)%e_v_obc')) RETURN
3014# endif
3015
3016 IF (.not.destroy(ng, boundary(ng)%ubar_obc, myfile, &
3017 & __line__, 'BOUNDARY(ng)%ubar_obc')) RETURN
3018
3019 IF (.not.destroy(ng, boundary(ng)%vbar_obc, myfile, &
3020 & __line__, 'BOUNDARY(ng)%vbar_obc')) RETURN
3021
3022 IF (.not.destroy(ng, boundary(ng)%zeta_obc, myfile, &
3023 & __line__, 'BOUNDARY(ng)%zeta_obc')) RETURN
3024!
3025 IF (.not.destroy(ng, boundary(ng)%ad_ubar_obc, myfile, &
3026 & __line__, 'BOUNDARY(ng)%ad_ubar_obc')) RETURN
3027
3028 IF (.not.destroy(ng, boundary(ng)%ad_vbar_obc, myfile, &
3029 & __line__, 'BOUNDARY(ng)%ad_vbar_obc')) RETURN
3030
3031 IF (.not.destroy(ng, boundary(ng)%ad_zeta_obc, myfile, &
3032 & __line__, 'BOUNDARY(ng)%ad_zeta_obc')) RETURN
3033!
3034 IF (.not.destroy(ng, boundary(ng)%tl_ubar_obc, myfile, &
3035 & __line__, 'BOUNDARY(ng)%tl_ubar_obc')) RETURN
3036
3037 IF (.not.destroy(ng, boundary(ng)%tl_vbar_obc, myfile, &
3038 & __line__, 'BOUNDARY(ng)%tl_vbar_obc')) RETURN
3039
3040 IF (.not.destroy(ng, boundary(ng)%tl_zeta_obc, myfile, &
3041 & __line__, 'BOUNDARY(ng)%tl_zeta_obc')) RETURN
3042!
3043 IF (.not.destroy(ng, boundary(ng)%b_ubar_obc, myfile, &
3044 & __line__, 'BOUNDARY(ng)%b_ubar_obc')) RETURN
3045
3046 IF (.not.destroy(ng, boundary(ng)%b_vbar_obc, myfile, &
3047 & __line__, 'BOUNDARY(ng)%b_vbar_obc')) RETURN
3048
3049 IF (.not.destroy(ng, boundary(ng)%b_zeta_obc, myfile, &
3050 & __line__, 'BOUNDARY(ng)%b_zeta_obc')) RETURN
3051!
3052 IF (.not.destroy(ng, boundary(ng)%d_ubar_obc, myfile, &
3053 & __line__, 'BOUNDARY(ng)%d_ubar_obc')) RETURN
3054
3055 IF (.not.destroy(ng, boundary(ng)%d_vbar_obc, myfile, &
3056 & __line__, 'BOUNDARY(ng)%d_vbar_obc')) RETURN
3057
3058 IF (.not.destroy(ng, boundary(ng)%d_zeta_obc, myfile, &
3059 & __line__, 'BOUNDARY(ng)%d_zeta_obc')) RETURN
3060!
3061 IF (.not.destroy(ng, boundary(ng)%e_ubar_obc, myfile, &
3062 & __line__, 'BOUNDARY(ng)%e_ubar_obc')) RETURN
3063
3064 IF (.not.destroy(ng, boundary(ng)%e_vbar_obc, myfile, &
3065 & __line__, 'BOUNDARY(ng)%e_vbar_obc')) RETURN
3066
3067 IF (.not.destroy(ng, boundary(ng)%e_zeta_obc, myfile, &
3068 & __line__, 'BOUNDARY(ng)%e_zeta_obc')) RETURN
3069# endif
3070#endif
3071!
3072!-----------------------------------------------------------------------
3073! Deallocate derived-type LBC_apply and BOUNDARY structures.
3074!-----------------------------------------------------------------------
3075!
3076 IF (ng.eq.ngrids) THEN
3077 IF (allocated(lbc_apply)) deallocate ( lbc_apply )
3078 IF (allocated(boundary)) deallocate ( boundary )
3079 END IF
3080!
3081 RETURN

References mod_param::ad_lbc, boundary, mod_scalars::ieast, mod_scalars::inorth, mod_ncparam::isfsur, mod_scalars::isouth, mod_ncparam::istvar, mod_ncparam::isubar, mod_ncparam::isuvel, mod_ncparam::isvbar, mod_ncparam::isvvel, mod_scalars::iwest, mod_param::lbc, lbc_apply, mod_param::ngrids, and mod_param::tl_lbc.

Referenced by mod_arrays::roms_deallocate_arrays().

Here is the caller graph for this function:

◆ initialize_boundary()

subroutine, public mod_boundary::initialize_boundary ( integer, intent(in) ng,
integer, intent(in) tile,
integer, intent(in) model )

Definition at line 3084 of file mod_boundary.F.

3085!
3086!=======================================================================
3087! !
3088! This routine initialize all variables in the module using first !
3089! touch distribution policy. In shared-memory configuration, this !
3090! operation actually performs propagation of the "shared arrays" !
3091! across the cluster, unless another policy is specified to !
3092! override the default. !
3093! !
3094!=======================================================================
3095!
3096 USE mod_param
3097 USE mod_ncparam
3098 USE mod_scalars
3099!
3100! Imported variable declarations.
3101!
3102 integer, intent(in) :: ng, tile, model
3103!
3104! Local variable declarations.
3105!
3106 real(r8), parameter :: IniVal = 0.0_r8
3107
3108#ifndef DISTRIBUTE
3109# include "set_bounds.h"
3110#endif
3111!
3112!-----------------------------------------------------------------------
3113! Initialize nonlinear model state.
3114!-----------------------------------------------------------------------
3115!
3116 IF ((model.eq.0).or.(model.eq.inlm)) THEN
3117
3118 IF (domain(ng)%NorthWest_Test(tile).and. &
3119 & lbc(iwest,isfsur,ng)%acquire) THEN
3120 boundary(ng) % zeta_west = inival
3121#if defined CELERITY_READ || defined CELERITY_WRITE
3122 boundary(ng) % zeta_west_C2 = inival
3123 boundary(ng) % zeta_west_Ce = inival
3124 boundary(ng) % zeta_west_Cx = inival
3125#endif
3126#ifndef ANA_FSOBC
3127 boundary(ng) % zetaG_west = inival
3128#endif
3129 END IF
3130
3131 IF (domain(ng)%SouthEast_Test(tile).and. &
3132 & lbc(ieast,isfsur,ng)%acquire) THEN
3133 boundary(ng) % zeta_east = inival
3134#if defined CELERITY_READ || defined CELERITY_WRITE
3135 boundary(ng) % zeta_east_C2 = inival
3136 boundary(ng) % zeta_east_Ce = inival
3137 boundary(ng) % zeta_east_Cx = inival
3138#endif
3139#ifndef ANA_FSOBC
3140 boundary(ng) % zetaG_east = inival
3141#endif
3142 END IF
3143
3144 IF (domain(ng)%SouthWest_Test(tile).and. &
3145 & lbc(isouth,isfsur,ng)%acquire) THEN
3146 boundary(ng) % zeta_south = inival
3147#if defined CELERITY_READ || defined CELERITY_WRITE
3148 boundary(ng) % zeta_south_C2 = inival
3149 boundary(ng) % zeta_south_Ce = inival
3150 boundary(ng) % zeta_south_Cx = inival
3151#endif
3152#ifndef ANA_FSOBC
3153 boundary(ng) % zetaG_south = inival
3154#endif
3155 END IF
3156
3157 IF (domain(ng)%NorthEast_Test(tile).and. &
3158 & lbc(inorth,isfsur,ng)%acquire) THEN
3159 boundary(ng) % zeta_north = inival
3160#if defined CELERITY_READ || defined CELERITY_WRITE
3161 boundary(ng) % zeta_north_C2 = inival
3162 boundary(ng) % zeta_north_Ce = inival
3163 boundary(ng) % zeta_north_Cx = inival
3164#endif
3165#ifndef ANA_FSOBC
3166 boundary(ng) % zetaG_north = inival
3167#endif
3168 END IF
3169!
3170 IF (domain(ng)%NorthWest_Test(tile).and. &
3171 & lbc(iwest,isubar,ng)%acquire) THEN
3172 boundary(ng) % ubar_west = inival
3173#if defined CELERITY_READ || defined CELERITY_WRITE
3174 boundary(ng) % ubar_west_C2 = inival
3175 boundary(ng) % ubar_west_Ce = inival
3176 boundary(ng) % ubar_west_Cx = inival
3177#endif
3178#ifndef ANA_M2OBC
3179 boundary(ng) % ubarG_west = inival
3180#endif
3181 END IF
3182#ifdef WEC
3183 IF (domain(ng)%NorthWest_Test(tile).and. &
3184 & lbc(iwest,isu2sd,ng)%acquire) THEN
3185 boundary(ng) % ubarstokes_west = inival
3186 END IF
3187#endif
3188
3189 IF (domain(ng)%SouthEast_Test(tile).and. &
3190 & lbc(ieast,isubar,ng)%acquire) THEN
3191 boundary(ng) % ubar_east = inival
3192#if defined CELERITY_READ || defined CELERITY_WRITE
3193 boundary(ng) % ubar_east_C2 = inival
3194 boundary(ng) % ubar_east_Ce = inival
3195 boundary(ng) % ubar_east_Cx = inival
3196#endif
3197#ifndef ANA_M2OBC
3198 boundary(ng) % ubarG_east = inival
3199#endif
3200 END IF
3201#ifdef WEC
3202 IF (domain(ng)%SouthEast_Test(tile).and. &
3203 & lbc(ieast,isu2sd,ng)%acquire) THEN
3204 boundary(ng) % ubarstokes_east = inival
3205 END IF
3206#endif
3207
3208 IF (domain(ng)%SouthWest_Test(tile).and. &
3209 & lbc(isouth,isubar,ng)%acquire) THEN
3210 boundary(ng) % ubar_south = inival
3211#if defined CELERITY_READ || defined CELERITY_WRITE
3212 boundary(ng) % ubar_south_C2 = inival
3213 boundary(ng) % ubar_south_Ce = inival
3214 boundary(ng) % ubar_south_Cx = inival
3215#endif
3216#ifndef ANA_M2OBC
3217 boundary(ng) % ubarG_south = inival
3218#endif
3219 END IF
3220#ifdef WEC
3221 IF (domain(ng)%SouthWest_Test(tile).and. &
3222 & lbc(isouth,isu2sd,ng)%acquire) THEN
3223 boundary(ng) % ubarstokes_south = inival
3224 END IF
3225#endif
3226
3227 IF (domain(ng)%NorthEast_Test(tile).and. &
3228 & lbc(inorth,isubar,ng)%acquire) THEN
3229 boundary(ng) % ubar_north = inival
3230#if defined CELERITY_READ || defined CELERITY_WRITE
3231 boundary(ng) % ubar_north_C2 = inival
3232 boundary(ng) % ubar_north_Ce = inival
3233 boundary(ng) % ubar_north_Cx = inival
3234#endif
3235#ifndef ANA_M2OBC
3236 boundary(ng) % ubarG_north = inival
3237 boundary(ng) % vbarG_north = inival
3238#endif
3239 END IF
3240#ifdef WEC
3241 IF (domain(ng)%NorthEast_Test(tile).and. &
3242 & lbc(inorth,isu2sd,ng)%acquire) THEN
3243 boundary(ng) % ubarstokes_north = inival
3244 END IF
3245#endif
3246!
3247 IF (domain(ng)%NorthWest_Test(tile).and. &
3248 & lbc(iwest,isvbar,ng)%acquire) THEN
3249 boundary(ng) % vbar_west = inival
3250#if defined CELERITY_READ || defined CELERITY_WRITE
3251 boundary(ng) % vbar_west_C2 = inival
3252 boundary(ng) % vbar_west_Ce = inival
3253 boundary(ng) % vbar_west_Cx = inival
3254#endif
3255#ifndef ANA_M2OBC
3256 boundary(ng) % vbarG_west = inival
3257#endif
3258 END IF
3259#ifdef WEC
3260 IF (domain(ng)%NorthWest_Test(tile).and. &
3261 & lbc(iwest,isv2sd,ng)%acquire) THEN
3262 boundary(ng) % vbarstokes_west = inival
3263 END IF
3264#endif
3265
3266 IF (domain(ng)%SouthEast_Test(tile).and. &
3267 & lbc(ieast,isvbar,ng)%acquire) THEN
3268 boundary(ng) % vbar_east = inival
3269#if defined CELERITY_READ || defined CELERITY_WRITE
3270 boundary(ng) % vbar_east_C2 = inival
3271 boundary(ng) % vbar_east_Ce = inival
3272 boundary(ng) % vbar_east_Cx = inival
3273#endif
3274#ifndef ANA_M2OBC
3275 boundary(ng) % vbarG_east = inival
3276#endif
3277 END IF
3278#ifdef WEC
3279 IF (domain(ng)%SouthEast_Test(tile).and. &
3280 & lbc(ieast,isv2sd,ng)%acquire) THEN
3281 boundary(ng) % vbarstokes_east = inival
3282 END IF
3283#endif
3284
3285 IF (domain(ng)%SouthWest_Test(tile).and. &
3286 & lbc(isouth,isvbar,ng)%acquire) THEN
3287 boundary(ng) % vbar_south = inival
3288#if defined CELERITY_READ || defined CELERITY_WRITE
3289 boundary(ng) % vbar_south_C2 = inival
3290 boundary(ng) % vbar_south_Ce = inival
3291 boundary(ng) % vbar_south_Cx = inival
3292#endif
3293#ifndef ANA_M2OBC
3294 boundary(ng) % vbarG_south = inival
3295#endif
3296 END IF
3297#ifdef WEC
3298 IF (domain(ng)%SouthWest_Test(tile).and. &
3299 & lbc(isouth,isv2sd,ng)%acquire) THEN
3300 boundary(ng) % vbarstokes_south = inival
3301 END IF
3302#endif
3303
3304 IF (domain(ng)%NorthEast_Test(tile).and. &
3305 & lbc(inorth,isvbar,ng)%acquire) THEN
3306 boundary(ng) % vbar_north = inival
3307#if defined CELERITY_READ || defined CELERITY_WRITE
3308 boundary(ng) % vbar_north_C2 = inival
3309 boundary(ng) % vbar_north_Ce = inival
3310 boundary(ng) % vbar_north_Cx = inival
3311#endif
3312#ifndef ANA_M2OBC
3313 boundary(ng) % vbarG_north = inival
3314#endif
3315 END IF
3316#ifdef WEC
3317 IF (domain(ng)%NorthEast_Test(tile).and. &
3318 & lbc(inorth,isv2sd,ng)%acquire) THEN
3319 boundary(ng) % vbarstokes_north = inival
3320 END IF
3321#endif
3322
3323#ifdef SOLVE3D
3324!
3325 IF (domain(ng)%NorthWest_Test(tile).and. &
3326 & lbc(iwest,isuvel,ng)%acquire) THEN
3327 boundary(ng) % u_west = inival
3328# if defined CELERITY_READ || defined CELERITY_WRITE
3329 boundary(ng) % u_west_C2 = inival
3330 boundary(ng) % u_west_Ce = inival
3331 boundary(ng) % u_west_Cx = inival
3332# endif
3333# ifndef ANA_M3OBC
3334 boundary(ng) % uG_west = inival
3335# endif
3336 END IF
3337# ifdef WEC
3338 IF (domain(ng)%NorthWest_Test(tile).and. &
3339 & lbc(iwest,isu3sd,ng)%acquire) THEN
3340 boundary(ng) % ustokes_west = inival
3341 END IF
3342# endif
3343
3344 IF (domain(ng)%SouthEast_Test(tile).and. &
3345 & lbc(ieast,isuvel,ng)%acquire) THEN
3346 boundary(ng) % u_east = inival
3347# if defined CELERITY_READ || defined CELERITY_WRITE
3348 boundary(ng) % u_east_C2 = inival
3349 boundary(ng) % u_east_Ce = inival
3350 boundary(ng) % u_east_Cx = inival
3351# endif
3352# ifndef ANA_M3OBC
3353 boundary(ng) % uG_east = inival
3354# endif
3355 END IF
3356# ifdef WEC
3357 IF (domain(ng)%SouthEast_Test(tile).and. &
3358 & lbc(ieast,isu3sd,ng)%acquire) THEN
3359 boundary(ng) % ustokes_east = inival
3360 END IF
3361# endif
3362
3363 IF (domain(ng)%SouthWest_Test(tile).and. &
3364 & lbc(isouth,isuvel,ng)%acquire) THEN
3365 boundary(ng) % u_south = inival
3366# if defined CELERITY_READ || defined CELERITY_WRITE
3367 boundary(ng) % u_south_C2 = inival
3368 boundary(ng) % u_south_Ce = inival
3369 boundary(ng) % u_south_Cx = inival
3370# endif
3371# ifndef ANA_M3OBC
3372 boundary(ng) % uG_south = inival
3373# endif
3374 END IF
3375# ifdef WEC
3376 IF (domain(ng)%SouthWest_Test(tile).and. &
3377 & lbc(isouth,isu3sd,ng)%acquire) THEN
3378 boundary(ng) % ustokes_south = inival
3379 END IF
3380# endif
3381
3382 IF (domain(ng)%NorthEast_Test(tile).and. &
3383 & lbc(inorth,isuvel,ng)%acquire) THEN
3384 boundary(ng) % u_north = inival
3385# if defined CELERITY_READ || defined CELERITY_WRITE
3386 boundary(ng) % u_north_C2 = inival
3387 boundary(ng) % u_north_Ce = inival
3388 boundary(ng) % u_north_Cx = inival
3389# endif
3390# ifndef ANA_M3OBC
3391 boundary(ng) % uG_north = inival
3392# endif
3393 END IF
3394# ifdef WEC
3395 IF (domain(ng)%NorthEast_Test(tile).and. &
3396 & lbc(inorth,isu3sd,ng)%acquire) THEN
3397 boundary(ng) % ustokes_north = inival
3398 END IF
3399# endif
3400!
3401 IF (domain(ng)%NorthWest_Test(tile).and. &
3402 & lbc(iwest,isvvel,ng)%acquire) THEN
3403 boundary(ng) % v_west = inival
3404# if defined CELERITY_READ || defined CELERITY_WRITE
3405 boundary(ng) % v_west_C2 = inival
3406 boundary(ng) % v_west_Ce = inival
3407 boundary(ng) % v_west_Cx = inival
3408# endif
3409# ifndef ANA_M3OBC
3410 boundary(ng) % vG_west = inival
3411# endif
3412 END IF
3413# ifdef WEC
3414 IF (domain(ng)%NorthWest_Test(tile).and. &
3415 & lbc(iwest,isv3sd,ng)%acquire) THEN
3416 boundary(ng) % vstokes_west = inival
3417 END IF
3418# endif
3419
3420 IF (domain(ng)%SouthEast_Test(tile).and. &
3421 & lbc(ieast,isvvel,ng)%acquire) THEN
3422 boundary(ng) % v_east = inival
3423# if defined CELERITY_READ || defined CELERITY_WRITE
3424 boundary(ng) % v_east_C2 = inival
3425 boundary(ng) % v_east_Ce = inival
3426 boundary(ng) % v_east_Cx = inival
3427# endif
3428# ifndef ANA_M3OBC
3429 boundary(ng) % vG_east = inival
3430# endif
3431 END IF
3432# ifdef WEC
3433 IF (domain(ng)%SouthEast_Test(tile).and. &
3434 & lbc(ieast,isv3sd,ng)%acquire) THEN
3435 boundary(ng) % vstokes_east = inival
3436 END IF
3437# endif
3438
3439 IF (domain(ng)%SouthWest_Test(tile).and. &
3440 & lbc(isouth,isvvel,ng)%acquire) THEN
3441 boundary(ng) % v_south = inival
3442# if defined CELERITY_READ || defined CELERITY_WRITE
3443 boundary(ng) % v_south_C2 = inival
3444 boundary(ng) % v_south_Ce = inival
3445 boundary(ng) % v_south_Cx = inival
3446# endif
3447# ifndef ANA_M3OBC
3448 boundary(ng) % vG_south = inival
3449# endif
3450 END IF
3451# ifdef WEC
3452 IF (domain(ng)%SouthWest_Test(tile).and. &
3453 & lbc(isouth,isv3sd,ng)%acquire) THEN
3454 boundary(ng) % vstokes_south = inival
3455 END IF
3456# endif
3457
3458 IF (domain(ng)%NorthEast_Test(tile).and. &
3459 & lbc(inorth,isvvel,ng)%acquire) THEN
3460 boundary(ng) % v_north = inival
3461# if defined CELERITY_READ || defined CELERITY_WRITE
3462 boundary(ng) % v_north_C2 = inival
3463 boundary(ng) % v_north_Ce = inival
3464 boundary(ng) % v_north_Cx = inival
3465# endif
3466# ifndef ANA_M3OBC
3467 boundary(ng) % vG_north = inival
3468# endif
3469 END IF
3470# ifdef WEC
3471 IF (domain(ng)%NorthEast_Test(tile).and. &
3472 & lbc(inorth,isv3sd,ng)%acquire) THEN
3473 boundary(ng) % vstokes_north = inival
3474 END IF
3475# endif
3476!
3477 IF (domain(ng)%NorthWest_Test(tile).and. &
3478 & any(lbc(iwest,istvar(:),ng)%acquire)) THEN
3479 boundary(ng) % t_west = inival
3480# if defined CELERITY_READ || defined CELERITY_WRITE
3481 boundary(ng) % t_west_C2 = inival
3482 boundary(ng) % t_west_Ce = inival
3483 boundary(ng) % t_west_Cx = inival
3484# endif
3485# ifndef ANA_TOBC
3486 boundary(ng) % tG_west = inival
3487# endif
3488 END IF
3489
3490 IF (domain(ng)%SouthEast_Test(tile).and. &
3491 & any(lbc(ieast,istvar(:),ng)%acquire)) THEN
3492 boundary(ng) % t_east = inival
3493# if defined CELERITY_READ || defined CELERITY_WRITE
3494 boundary(ng) % t_east_C2 = inival
3495 boundary(ng) % t_east_Ce = inival
3496 boundary(ng) % t_east_Cx = inival
3497# endif
3498# ifndef ANA_TOBC
3499 boundary(ng) % tG_east = inival
3500# endif
3501 END IF
3502
3503 IF (domain(ng)%SouthWest_Test(tile).and. &
3504 & any(lbc(isouth,istvar(:),ng)%acquire)) THEN
3505 boundary(ng) % t_south = inival
3506# if defined CELERITY_READ || defined CELERITY_WRITE
3507 boundary(ng) % t_south_C2 = inival
3508 boundary(ng) % t_south_Ce = inival
3509 boundary(ng) % t_south_Cx = inival
3510# endif
3511# ifndef ANA_TOBC
3512 boundary(ng) % tG_south = inival
3513# endif
3514 END IF
3515
3516 IF (domain(ng)%NorthEast_Test(tile).and. &
3517 & any(lbc(inorth,istvar(:),ng)%acquire)) THEN
3518 boundary(ng) % t_north = inival
3519# if defined CELERITY_READ || defined CELERITY_WRITE
3520 boundary(ng) % t_north_C2 = inival
3521 boundary(ng) % t_north_Ce = inival
3522 boundary(ng) % t_north_Cx = inival
3523# endif
3524# ifndef ANA_TOBC
3525 boundary(ng) % tG_north = inival
3526# endif
3527 END IF
3528#endif
3529 END IF
3530
3531#if defined TANGENT || defined TL_IOMS
3532!
3533!-----------------------------------------------------------------------
3534! Initialize tangent linear model state.
3535!-----------------------------------------------------------------------
3536!
3537 IF ((model.eq.0).or.(model.eq.itlm).or.(model.eq.irpm)) THEN
3538 IF (domain(ng)%NorthWest_Test(tile).and. &
3539 & tl_lbc(iwest,isfsur,ng)%acquire) THEN
3540 boundary(ng) % tl_zeta_west = inival
3541 END IF
3542
3543 IF (domain(ng)%SouthEast_Test(tile).and. &
3544 & tl_lbc(ieast,isfsur,ng)%acquire) THEN
3545 boundary(ng) % tl_zeta_east = inival
3546 END IF
3547
3548 IF (domain(ng)%SouthWest_Test(tile).and. &
3549 & tl_lbc(isouth,isfsur,ng)%acquire) THEN
3550 boundary(ng) % tl_zeta_south = inival
3551 END IF
3552
3553 IF (domain(ng)%NorthEast_Test(tile).and. &
3554 & tl_lbc(inorth,isfsur,ng)%acquire) THEN
3555 boundary(ng) % tl_zeta_north = inival
3556 END IF
3557!
3558 IF (domain(ng)%NorthWest_Test(tile).and. &
3559 & tl_lbc(iwest,isubar,ng)%acquire) THEN
3560 boundary(ng) % tl_ubar_west = inival
3561 END IF
3562
3563 IF (domain(ng)%SouthEast_Test(tile).and. &
3564 & tl_lbc(ieast,isubar,ng)%acquire) THEN
3565 boundary(ng) % tl_ubar_east = inival
3566 END IF
3567
3568 IF (domain(ng)%SouthWest_Test(tile).and. &
3569 & tl_lbc(isouth,isubar,ng)%acquire) THEN
3570 boundary(ng) % tl_ubar_south = inival
3571 END IF
3572
3573 IF (domain(ng)%NorthEast_Test(tile).and. &
3574 & tl_lbc(inorth,isubar,ng)%acquire) THEN
3575 boundary(ng) % tl_ubar_north = inival
3576 END IF
3577!
3578 IF (domain(ng)%NorthWest_Test(tile).and. &
3579 & tl_lbc(iwest,isvbar,ng)%acquire) THEN
3580 boundary(ng) % tl_vbar_west = inival
3581 END IF
3582
3583 IF (domain(ng)%SouthEast_Test(tile).and. &
3584 & tl_lbc(ieast,isvbar,ng)%acquire) THEN
3585 boundary(ng) % tl_vbar_east = inival
3586 END IF
3587
3588 IF (domain(ng)%SouthWest_Test(tile).and. &
3589 & tl_lbc(isouth,isvbar,ng)%acquire) THEN
3590 boundary(ng) % tl_vbar_south = inival
3591 END IF
3592
3593 IF (domain(ng)%NorthEast_Test(tile).and. &
3594 & tl_lbc(inorth,isvbar,ng)%acquire) THEN
3595 boundary(ng) % tl_vbar_north = inival
3596 END IF
3597
3598# ifdef SOLVE3D
3599!
3600 IF (domain(ng)%NorthWest_Test(tile).and. &
3601 & tl_lbc(iwest,isuvel,ng)%acquire) THEN
3602 boundary(ng) % tl_u_west = inival
3603 END IF
3604
3605 IF (domain(ng)%SouthEast_Test(tile).and. &
3606 & tl_lbc(ieast,isuvel,ng)%acquire) THEN
3607 boundary(ng) % tl_u_east = inival
3608 END IF
3609
3610 IF (domain(ng)%SouthWest_Test(tile).and. &
3611 & tl_lbc(isouth,isuvel,ng)%acquire) THEN
3612 boundary(ng) % tl_u_south = inival
3613 END IF
3614
3615 IF (domain(ng)%NorthEast_Test(tile).and. &
3616 & tl_lbc(inorth,isuvel,ng)%acquire) THEN
3617 boundary(ng) % tl_u_north = inival
3618 END IF
3619!
3620 IF (domain(ng)%NorthWest_Test(tile).and. &
3621 & tl_lbc(iwest,isvvel,ng)%acquire) THEN
3622 boundary(ng) % tl_v_west = inival
3623 END IF
3624
3625 IF (domain(ng)%SouthEast_Test(tile).and. &
3626 & tl_lbc(ieast,isvvel,ng)%acquire) THEN
3627 boundary(ng) % tl_v_east = inival
3628 END IF
3629
3630 IF (domain(ng)%SouthWest_Test(tile).and. &
3631 & tl_lbc(isouth,isvvel,ng)%acquire) THEN
3632 boundary(ng) % tl_v_south = inival
3633 END IF
3634
3635 IF (domain(ng)%NorthEast_Test(tile).and. &
3636 & tl_lbc(inorth,isvvel,ng)%acquire) THEN
3637 boundary(ng) % tl_v_north = inival
3638 END IF
3639!
3640 IF (domain(ng)%NorthWest_Test(tile).and. &
3641 & any(tl_lbc(iwest,istvar(:),ng)%acquire)) THEN
3642 boundary(ng) % tl_t_west = inival
3643 END IF
3644
3645 IF (domain(ng)%SouthEast_Test(tile).and. &
3646 & any(tl_lbc(ieast,istvar(:),ng)%acquire)) THEN
3647 boundary(ng) % tl_t_east = inival
3648 END IF
3649
3650 IF (domain(ng)%SouthWest_Test(tile).and. &
3651 & any(tl_lbc(isouth,istvar(:),ng)%acquire)) THEN
3652 boundary(ng) % tl_t_south = inival
3653 END IF
3654
3655 IF (domain(ng)%NorthEast_Test(tile).and. &
3656 & any(tl_lbc(inorth,istvar(:),ng)%acquire)) THEN
3657 boundary(ng) % tl_t_north = inival
3658 END IF
3659# endif
3660 END IF
3661#endif
3662
3663#ifdef ADJOINT
3664!
3665!-----------------------------------------------------------------------
3666! Initialize adjoint model state.
3667!-----------------------------------------------------------------------
3668!
3669 IF ((model.eq.0).or.(model.eq.iadm)) THEN
3670 IF (domain(ng)%NorthWest_Test(tile).and. &
3671 & ad_lbc(iwest,isfsur,ng)%acquire) THEN
3672 boundary(ng) % ad_zeta_west = inival
3673 END IF
3674
3675 IF (domain(ng)%SouthEast_Test(tile).and. &
3676 & ad_lbc(ieast,isfsur,ng)%acquire) THEN
3677 boundary(ng) % ad_zeta_east = inival
3678 END IF
3679
3680 IF (domain(ng)%SouthWest_Test(tile).and. &
3681 & ad_lbc(isouth,isfsur,ng)%acquire) THEN
3682 boundary(ng) % ad_zeta_south = inival
3683 END IF
3684
3685 IF (domain(ng)%NorthEast_Test(tile).and. &
3686 & ad_lbc(inorth,isfsur,ng)%acquire) THEN
3687 boundary(ng) % ad_zeta_north = inival
3688 END IF
3689!
3690 IF (domain(ng)%NorthWest_Test(tile).and. &
3691 & ad_lbc(iwest,isubar,ng)%acquire) THEN
3692 boundary(ng) % ad_ubar_west = inival
3693 END IF
3694
3695 IF (domain(ng)%SouthEast_Test(tile).and. &
3696 & ad_lbc(ieast,isubar,ng)%acquire) THEN
3697 boundary(ng) % ad_ubar_east = inival
3698 END IF
3699
3700 IF (domain(ng)%SouthWest_Test(tile).and. &
3701 & ad_lbc(isouth,isubar,ng)%acquire) THEN
3702 boundary(ng) % ad_ubar_south = inival
3703 END IF
3704
3705 IF (domain(ng)%NorthEast_Test(tile).and. &
3706 & ad_lbc(inorth,isubar,ng)%acquire) THEN
3707 boundary(ng) % ad_ubar_north = inival
3708 END IF
3709!
3710 IF (domain(ng)%NorthWest_Test(tile).and. &
3711 & ad_lbc(iwest,isvbar,ng)%acquire) THEN
3712 boundary(ng) % ad_vbar_west = inival
3713 END IF
3714
3715 IF (domain(ng)%SouthEast_Test(tile).and. &
3716 & ad_lbc(ieast,isvbar,ng)%acquire) THEN
3717 boundary(ng) % ad_vbar_east = inival
3718 END IF
3719
3720 IF (domain(ng)%SouthWest_Test(tile).and. &
3721 & ad_lbc(isouth,isvbar,ng)%acquire) THEN
3722 boundary(ng) % ad_vbar_south = inival
3723 END IF
3724
3725 IF (domain(ng)%NorthEast_Test(tile).and. &
3726 & ad_lbc(inorth,isvbar,ng)%acquire) THEN
3727 boundary(ng) % ad_vbar_north = inival
3728 END IF
3729
3730# ifdef SOLVE3D
3731!
3732 IF (domain(ng)%NorthWest_Test(tile).and. &
3733 & ad_lbc(iwest,isuvel,ng)%acquire) THEN
3734 boundary(ng) % ad_u_west = inival
3735 END IF
3736
3737 IF (domain(ng)%SouthEast_Test(tile).and. &
3738 & ad_lbc(ieast,isuvel,ng)%acquire) THEN
3739 boundary(ng) % ad_u_east = inival
3740 END IF
3741
3742 IF (domain(ng)%SouthWest_Test(tile).and. &
3743 & ad_lbc(isouth,isuvel,ng)%acquire) THEN
3744 boundary(ng) % ad_u_south = inival
3745 END IF
3746
3747 IF (domain(ng)%NorthEast_Test(tile).and. &
3748 & ad_lbc(inorth,isuvel,ng)%acquire) THEN
3749 boundary(ng) % ad_u_north = inival
3750 END IF
3751!
3752 IF (domain(ng)%NorthWest_Test(tile).and. &
3753 & ad_lbc(iwest,isvvel,ng)%acquire) THEN
3754 boundary(ng) % ad_v_west = inival
3755 END IF
3756
3757 IF (domain(ng)%SouthEast_Test(tile).and. &
3758 & ad_lbc(ieast,isvvel,ng)%acquire) THEN
3759 boundary(ng) % ad_v_east = inival
3760 END IF
3761
3762 IF (domain(ng)%SouthWest_Test(tile).and. &
3763 & ad_lbc(isouth,isvvel,ng)%acquire) THEN
3764 boundary(ng) % ad_v_south = inival
3765 END IF
3766
3767 IF (domain(ng)%NorthEast_Test(tile).and. &
3768 & ad_lbc(inorth,isvvel,ng)%acquire) THEN
3769 boundary(ng) % ad_v_north = inival
3770 END IF
3771!
3772 IF (domain(ng)%NorthWest_Test(tile).and. &
3773 & any(ad_lbc(iwest,istvar(:),ng)%acquire)) THEN
3774 boundary(ng) % ad_t_west = inival
3775 END IF
3776
3777 IF (domain(ng)%SouthEast_Test(tile).and. &
3778 & any(ad_lbc(ieast,istvar(:),ng)%acquire)) THEN
3779 boundary(ng) % ad_t_east = inival
3780 END IF
3781
3782 IF (domain(ng)%SouthWest_Test(tile).and. &
3783 & any(ad_lbc(isouth,istvar(:),ng)%acquire)) THEN
3784 boundary(ng) % ad_t_south = inival
3785 END IF
3786
3787 IF (domain(ng)%NorthEast_Test(tile).and. &
3788 & any(ad_lbc(inorth,istvar(:),ng)%acquire)) THEN
3789 boundary(ng) % ad_t_north = inival
3790 END IF
3791# endif
3792 END IF
3793#endif
3794
3795#ifdef ADJUST_BOUNDARY
3796!
3797!-----------------------------------------------------------------------
3798! Open boundaries arrays used in 4DVar adjustments.
3799!-----------------------------------------------------------------------
3800!
3801 IF ((model.eq.0).or.(model.eq.inlm)) THEN
3802 IF (domain(ng)%NorthEast_Test(tile)) THEN
3803# ifdef SOLVE3D
3804 boundary(ng) % b_t_obc = inival
3805 boundary(ng) % b_u_obc = inival
3806 boundary(ng) % b_v_obc = inival
3807
3808 boundary(ng) % d_t_obc = inival
3809 boundary(ng) % d_u_obc = inival
3810 boundary(ng) % d_v_obc = inival
3811
3812 boundary(ng) % e_t_obc = inival
3813 boundary(ng) % e_u_obc = inival
3814 boundary(ng) % e_v_obc = inival
3815
3816 boundary(ng) % t_obc = inival
3817 boundary(ng) % u_obc = inival
3818 boundary(ng) % v_obc = inival
3819# endif
3820 boundary(ng) % b_ubar_obc = inival
3821 boundary(ng) % b_vbar_obc = inival
3822 boundary(ng) % b_zeta_obc = inival
3823
3824 boundary(ng) % d_ubar_obc = inival
3825 boundary(ng) % d_vbar_obc = inival
3826 boundary(ng) % d_zeta_obc = inival
3827
3828 boundary(ng) % e_ubar_obc = inival
3829 boundary(ng) % e_vbar_obc = inival
3830 boundary(ng) % e_zeta_obc = inival
3831
3832 boundary(ng) % ubar_obc = inival
3833 boundary(ng) % vbar_obc = inival
3834 boundary(ng) % zeta_obc = inival
3835 END IF
3836 END IF
3837
3838 IF ((model.eq.0).or.(model.eq.iadm)) THEN
3839 IF (domain(ng)%NorthEast_Test(tile)) THEN
3840# ifdef SOLVE3D
3841 boundary(ng) % ad_t_obc = inival
3842 boundary(ng) % ad_u_obc = inival
3843 boundary(ng) % ad_v_obc = inival
3844# endif
3845 boundary(ng) % ad_ubar_obc = inival
3846 boundary(ng) % ad_vbar_obc = inival
3847 boundary(ng) % ad_zeta_obc = inival
3848 END IF
3849 END IF
3850
3851 IF ((model.eq.0).or.(model.eq.itlm).or.(model.eq.irpm)) THEN
3852 IF (domain(ng)%NorthEast_Test(tile)) THEN
3853# ifdef SOLVE3D
3854 boundary(ng) % tl_t_obc = inival
3855 boundary(ng) % tl_u_obc = inival
3856 boundary(ng) % tl_v_obc = inival
3857# endif
3858 boundary(ng) % tl_ubar_obc = inival
3859 boundary(ng) % tl_vbar_obc = inival
3860 boundary(ng) % tl_zeta_obc = inival
3861 END IF
3862 END IF
3863#endif
3864!
3865 RETURN
integer, parameter inlm
Definition mod_param.F:662
integer, parameter irpm
Definition mod_param.F:664
integer, parameter iadm
Definition mod_param.F:665
type(t_domain), dimension(:), allocatable domain
Definition mod_param.F:329
integer, parameter itlm
Definition mod_param.F:663

References mod_param::ad_lbc, boundary, mod_param::domain, mod_param::iadm, mod_scalars::ieast, mod_param::inlm, mod_scalars::inorth, mod_param::irpm, mod_ncparam::isfsur, mod_scalars::isouth, mod_ncparam::istvar, mod_ncparam::isubar, mod_ncparam::isuvel, mod_ncparam::isvbar, mod_ncparam::isvvel, mod_param::itlm, mod_scalars::iwest, mod_param::lbc, and mod_param::tl_lbc.

Referenced by ad_initial(), rbl4dvar_mod::analysis_initialize(), convolve_mod::error_covariance(), i4dvar_mod::increment(), r4dvar_mod::increment(), rbl4dvar_mod::increment(), r4dvar_mod::posterior_error(), rbl4dvar_mod::posterior_error(), mod_arrays::roms_initialize_arrays(), roms_kernel_mod::roms_run(), and tl_initial().

Here is the caller graph for this function:

Variable Documentation

◆ boundary

type (t_boundary), dimension(:), allocatable mod_boundary::boundary

Definition at line 746 of file mod_boundary.F.

746 TYPE (T_BOUNDARY), allocatable ::BOUNDARY(:)

Referenced by ad_convolution_mod::ad_convolution(), ad_get_data(), ad_obc_adjust_mod::ad_obc2d_adjust_tile(), ad_obc_adjust_mod::ad_obc_adjust_tile(), ad_set_data_tile(), ad_set_depth_mod::ad_set_depth_bry_tile(), ad_t3dbc_mod::ad_t3dbc_tile(), ad_u2dbc_mod::ad_u2dbc_tile(), ad_u3dbc_mod::ad_u3dbc_tile(), ad_v2dbc_mod::ad_v2dbc_tile(), ad_v3dbc_mod::ad_v3dbc_tile(), ad_variability_mod::ad_variability(), ad_wrt_his_mod::ad_wrt_his_nf90(), ad_wrt_his_mod::ad_wrt_his_pio(), ad_zetabc_mod::ad_zetabc_tile(), allocate_boundary(), analytical_mod::ana_fsobc_tile(), analytical_mod::ana_m2obc_tile(), analytical_mod::ana_m3obc_tile(), analytical_mod::ana_perturb(), analytical_mod::ana_tobc_tile(), comp_jb0_mod::aug_oper(), back_cost_mod::back_cost(), cgradient_mod::cgradient(), comp_jb0_mod::comp_jb0(), cost_grad_mod::cost_grad(), deallocate_boundary(), get_data(), get_state_mod::get_state_nf90(), get_state_mod::get_state_pio(), ini_lanczos_mod::ini_lanczos(), initialize_boundary(), lanc_resid_mod::lanc_resid(), ini_adjust_mod::load_adtotl(), obc_adjust_mod::load_obc_tile(), ini_adjust_mod::load_tltoad(), normalization_mod::normalization(), obc_adjust_mod::obc_adjust_tile(), posterior_mod::posterior(), posterior_var_mod::posterior_var(), random_ic_mod::random_ic(), rp_get_data(), rp_obc_adjust_mod::rp_obc2d_adjust_tile(), rp_obc_adjust_mod::rp_obc_adjust_tile(), rp_set_data_tile(), rp_set_depth_mod::rp_set_depth_bry_tile(), rp_t3dbc_mod::rp_t3dbc_tile(), rp_u2dbc_mod::rp_u2dbc_tile(), rp_u3dbc_mod::rp_u3dbc_tile(), rp_v2dbc_mod::rp_v2dbc_tile(), rp_v3dbc_mod::rp_v3dbc_tile(), rp_wrt_ini_mod::rp_wrt_ini_nf90(), rp_wrt_ini_mod::rp_wrt_ini_pio(), rp_zetabc_mod::rp_zetabc_tile(), set_data_tile(), set_depth_mod::set_depth_bry_tile(), set_tides_mod::set_tides_tile(), sum_grad_mod::sum_grad(), t3dbc_mod::t3dbc_tile(), tl_convolution_mod::tl_convolution(), tl_get_data(), inner2state_mod::tl_inner2state(), tl_obc_adjust_mod::tl_obc2d_adjust_tile(), tl_obc_adjust_mod::tl_obc_adjust_tile(), tl_set_data_tile(), tl_set_depth_mod::tl_set_depth_bry_tile(), tl_t3dbc_mod::tl_t3dbc_tile(), tl_u2dbc_mod::tl_u2dbc_tile(), tl_u3dbc_mod::tl_u3dbc_tile(), tl_v2dbc_mod::tl_v2dbc_tile(), tl_v3dbc_mod::tl_v3dbc_tile(), tl_variability_mod::tl_variability(), tl_wrt_his_mod::tl_wrt_his_nf90(), tl_wrt_his_mod::tl_wrt_his_pio(), tl_wrt_ini_mod::tl_wrt_ini_nf90(), tl_wrt_ini_mod::tl_wrt_ini_pio(), tl_zetabc_mod::tl_zetabc_tile(), u2dbc_mod::u2dbc_tile(), u3dbc_mod::u3dbc_tile(), v2dbc_mod::v2dbc_tile(), v3dbc_mod::v3dbc_tile(), wrt_error_mod::wrt_error_nf90(), wrt_error_mod::wrt_error_pio(), wrt_evolved_mod::wrt_evolved_nf90(), wrt_evolved_mod::wrt_evolved_pio(), wrt_ini_mod::wrt_frc_ad_nf90(), wrt_ini_mod::wrt_frc_ad_pio(), wrt_ini_mod::wrt_frc_nf90(), wrt_ini_mod::wrt_frc_pio(), wrt_hessian_mod::wrt_hessian_nf90(), wrt_hessian_mod::wrt_hessian_pio(), wrt_his_mod::wrt_his_nf90(), wrt_his_mod::wrt_his_pio(), wrt_state_mod::wrt_state_nf90(), wrt_state_mod::wrt_state_pio(), and zetabc_mod::zetabc_tile().

◆ lbc_apply

type (t_apply), dimension(:), allocatable mod_boundary::lbc_apply

Definition at line 394 of file mod_boundary.F.

394 TYPE (T_APPLY), allocatable :: LBC_apply(:)

Referenced by ad_bc_2d_mod::ad_bc_r2d_tile(), ad_bc_3d_mod::ad_bc_r3d_tile(), ad_bc_2d_mod::ad_bc_u2d_tile(), ad_bc_3d_mod::ad_bc_u3d_tile(), ad_bc_2d_mod::ad_bc_v2d_tile(), ad_bc_3d_mod::ad_bc_v3d_tile(), ad_bc_3d_mod::ad_bc_w3d_tile(), ad_bc_2d_mod::ad_dabc_r2d_tile(), ad_bc_3d_mod::ad_dabc_r3d_tile(), ad_bc_2d_mod::ad_dabc_u2d_tile(), ad_bc_3d_mod::ad_dabc_u3d_tile(), ad_bc_2d_mod::ad_dabc_v2d_tile(), ad_bc_3d_mod::ad_dabc_v3d_tile(), ad_t3dbc_mod::ad_t3dbc_tile(), ad_u2dbc_mod::ad_u2dbc_tile(), ad_u3dbc_mod::ad_u3dbc_tile(), ad_v2dbc_mod::ad_v2dbc_tile(), ad_v3dbc_mod::ad_v3dbc_tile(), ad_zetabc_mod::ad_zetabc_tile(), allocate_boundary(), mod_nesting::allocate_nesting(), bc_2d_mod::bc_r2d_tile(), bc_3d_mod::bc_r3d_tile(), bc_4d_mod::bc_r4d_tile(), bc_2d_mod::bc_u2d_tile(), bc_3d_mod::bc_u3d_tile(), bc_4d_mod::bc_u4d_tile(), bc_2d_mod::bc_v2d_tile(), bc_3d_mod::bc_v3d_tile(), bc_4d_mod::bc_v4d_tile(), bc_3d_mod::bc_w3d_tile(), bc_4d_mod::bc_w4d_tile(), bc_2d_mod::dabc_r2d_tile(), bc_3d_mod::dabc_r3d_tile(), bc_2d_mod::dabc_u2d_tile(), bc_3d_mod::dabc_u3d_tile(), bc_2d_mod::dabc_v2d_tile(), bc_3d_mod::dabc_v3d_tile(), deallocate_boundary(), rp_t3dbc_mod::rp_t3dbc_tile(), rp_u2dbc_mod::rp_u2dbc_tile(), rp_u3dbc_mod::rp_u3dbc_tile(), rp_v2dbc_mod::rp_v2dbc_tile(), rp_v3dbc_mod::rp_v3dbc_tile(), rp_zetabc_mod::rp_zetabc_tile(), t3dbc_mod::t3dbc_tile(), tkebc_mod::tkebc_tile(), tl_t3dbc_mod::tl_t3dbc_tile(), tl_u2dbc_mod::tl_u2dbc_tile(), tl_u3dbc_mod::tl_u3dbc_tile(), tl_v2dbc_mod::tl_v2dbc_tile(), tl_v3dbc_mod::tl_v3dbc_tile(), tl_zetabc_mod::tl_zetabc_tile(), u2dbc_mod::u2dbc_tile(), u3dbc_mod::u3dbc_tile(), v2dbc_mod::v2dbc_tile(), v3dbc_mod::v3dbc_tile(), and zetabc_mod::zetabc_tile().