Newer
Older
NSIZELBXR_ll=2*JPHEXT ! 2
ALLOCATE(XLBXRM(IISIZEX2,IJSIZEX2,IKU,NRR))
ENDIF
ELSE
NSIZELBXR_ll=0
ALLOCATE(XLBXRM(0,0,0,0))
END IF
!
IF ( NSV > 0 ) THEN
IF ( ANY( LHORELAX_SV(:)) ) THEN
NSIZELBXSV_ll=2* NRIMX+2*JPHEXT
ALLOCATE(XLBXSVM(IISIZEXF,IJSIZEXF,IKU,NSV))
ELSE
NSIZELBXSV_ll=2*JPHEXT ! 2
ALLOCATE(XLBXSVM(IISIZEX2,IJSIZEX2,IKU,NSV))
END IF
ELSE
NSIZELBXSV_ll=0
ALLOCATE(XLBXSVM(0,0,0,0))
END IF
!
ELSE ! 3D case
!
!
CALL GET_SIZEX_LB(HLUOUT,NIMAX_ll,NJMAX_ll,NRIMX, &
IISIZEXF,IJSIZEXF,IISIZEXFU,IJSIZEXFU, &
IISIZEX4,IJSIZEX4,IISIZEX2,IJSIZEX2)
CALL GET_SIZEY_LB(HLUOUT,NIMAX_ll,NJMAX_ll,NRIMY, &
IISIZEYF,IJSIZEYF,IISIZEYFV,IJSIZEYFV, &
IISIZEY4,IJSIZEY4,IISIZEY2,IJSIZEY2)
!
! check if local domain not to small for NRIMX NRIMY
!
IF ( CLBCX(1) /= 'CYCL' ) THEN

Juan Escobar
committed
IF ( NRIMX .GT. IDIMX ) THEN
WRITE(*,'(A,I8,A/A,2I8,/A)') "Processor=", IP-1, &

Juan Escobar
committed
" :: INI_MODEL_n ERROR: ( NRIMX > IDIMX ) ", &
" Local domain to small for relaxation NRIMX,IDIMX ", &
NRIMX,IDIMX ,&
" change relaxation parameters or number of processors "
!callabortstop
CALL ABORT
STOP
END IF
END IF
IF ( CLBCY(1) /= 'CYCL' ) THEN

Juan Escobar
committed
IF ( NRIMY .GT. IDIMY ) THEN
WRITE(*,'(A,I8,A/A,2I8,/A)') "Processor=", IP-1, &

Juan Escobar
committed
" :: INI_MODEL_n ERROR: ( NRIMY > IDIMY ) ", &
" Local domain to small for relaxation NRIMY,IDIMY ", &
NRIMY,IDIMY ,&
" change relaxation parameters or number of processors "
!callabortstop
CALL ABORT
STOP
END IF
END IF
IF ( LHORELAX_UVWTH ) THEN
NSIZELBX_ll=2*NRIMX+2*JPHEXT
NSIZELBXU_ll=2*NRIMX+2*JPHEXT
NSIZELBY_ll=2*NRIMY+2*JPHEXT
NSIZELBYV_ll=2*NRIMY+2*JPHEXT
ALLOCATE(XLBXUM(IISIZEXFU,IJSIZEXFU,IKU))
ALLOCATE(XLBYUM(IISIZEYF,IJSIZEYF,IKU))
ALLOCATE(XLBXVM(IISIZEXF,IJSIZEXF,IKU))
ALLOCATE(XLBYVM(IISIZEYFV,IJSIZEYFV,IKU))
ALLOCATE(XLBXWM(IISIZEXF,IJSIZEXF,IKU))
ALLOCATE(XLBYWM(IISIZEYF,IJSIZEYF,IKU))
ALLOCATE(XLBXTHM(IISIZEXF,IJSIZEXF,IKU))
ALLOCATE(XLBYTHM(IISIZEYF,IJSIZEYF,IKU))
ELSE
NSIZELBX_ll=2*JPHEXT ! 2
NSIZELBXU_ll=2*(JPHEXT+1) ! 4
NSIZELBY_ll=2*JPHEXT ! 2
NSIZELBYV_ll=2*(JPHEXT+1) ! 4
ALLOCATE(XLBXUM(IISIZEX4,IJSIZEX4,IKU))
ALLOCATE(XLBYUM(IISIZEY2,IJSIZEY2,IKU))
ALLOCATE(XLBXVM(IISIZEX2,IJSIZEX2,IKU))
ALLOCATE(XLBYVM(IISIZEY4,IJSIZEY4,IKU))
ALLOCATE(XLBXWM(IISIZEX2,IJSIZEX2,IKU))
ALLOCATE(XLBYWM(IISIZEY2,IJSIZEY2,IKU))
ALLOCATE(XLBXTHM(IISIZEX2,IJSIZEX2,IKU))
ALLOCATE(XLBYTHM(IISIZEY2,IJSIZEY2,IKU))
END IF
!
IF (CTURB /= 'NONE') THEN
IF ( LHORELAX_TKE) THEN
NSIZELBXTKE_ll=2*NRIMX+2*JPHEXT
NSIZELB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ll=2*JPHEXT ! 2
NSIZELBYSV_ll=2*JPHEXT ! 2
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
ALLOCATE(XLBXSVM(IISIZEX2,IJSIZEX2,IKU,NSV))
ALLOCATE(XLBYSVM(IISIZEY2,IJSIZEY2,IKU,NSV))
END IF
ELSE
NSIZELBXSV_ll=0
NSIZELBYSV_ll=0
ALLOCATE(XLBXSVM(0,0,0,0))
ALLOCATE(XLBYSVM(0,0,0,0))
END IF
END IF ! END OF THE IF STRUCTURE ON THE MODEL DIMENSION
!
!
IF ( KMI > 1 ) THEN
! it has been assumed that the THeta field used the largest rim area compared
! to the others prognostic variables, if it is not the case, you must change
! these lines
ALLOCATE(XCOEFLIN_LBXM(SIZE(XLBXTHM,1),SIZE(XLBXTHM,2),SIZE(XLBXTHM,3)))
ALLOCATE( NKLIN_LBXM(SIZE(XLBXTHM,1),SIZE(XLBXTHM,2),SIZE(XLBXTHM,3)))
ALLOCATE(XCOEFLIN_LBYM(SIZE(XLBYTHM,1),SIZE(XLBYTHM,2),SIZE(XLBYTHM,3)))
ALLOCATE( NKLIN_LBYM(SIZE(XLBYTHM,1),SIZE(XLBYTHM,2),SIZE(XLBYTHM,3)))
ALLOCATE(XCOEFLIN_LBXU(SIZE(XLBXUM,1),SIZE(XLBXUM,2),SIZE(XLBXUM,3)))
ALLOCATE( NKLIN_LBXU(SIZE(XLBXUM,1),SIZE(XLBXUM,2),SIZE(XLBXUM,3)))
ALLOCATE(XCOEFLIN_LBYU(SIZE(XLBYUM,1),SIZE(XLBYUM,2),SIZE(XLBYUM,3)))
ALLOCATE( NKLIN_LBYU(SIZE(XLBYUM,1),SIZE(XLBYUM,2),SIZE(XLBYUM,3)))
ALLOCATE(XCOEFLIN_LBXV(SIZE(XLBXVM,1),SIZE(XLBXVM,2),SIZE(XLBXVM,3)))
ALLOCATE( NKLIN_LBXV(SIZE(XLBXVM,1),SIZE(XLBXVM,2),SIZE(XLBXVM,3)))
ALLOCATE(XCOEFLIN_LBYV(SIZE(XLBYVM,1),SIZE(XLBYVM,2),SIZE(XLBYVM,3)))
ALLOCATE( NKLIN_LBYV(SIZE(XLBYVM,1),SIZE(XLBYVM,2),SIZE(XLBYVM,3)))
ALLOCATE(XCOEFLIN_LBXW(SIZE(XLBXWM,1),SIZE(XLBXWM,2),SIZE(XLBXWM,3)))
ALLOCATE( NKLIN_LBXW(SIZE(XLBXWM,1),SIZE(XLBXWM,2),SIZE(XLBXWM,3)))
ALLOCATE(XCOEFLIN_LBYW(SIZE(XLBYWM,1),SIZE(XLBYWM,2),SIZE(XLBYWM,3)))
ALLOCATE( NKLIN_LBYW(SIZE(XLBYWM,1),SIZE(XLBYWM,2),SIZE(XLBYWM,3)))
END IF
!
! allocation of the LS fields for vertical relaxation and numerical diffusion
IF( .NOT. LSTEADYLS ) THEN
!
ALLOCATE(XLSUS(SIZE(XLSUM,1),SIZE(XLSUM,2),SIZE(XLSUM,3)))
ALLOCATE(XLSVS(SIZE(XLSVM,1),SIZE(XLSVM,2),SIZE(XLSVM,3)))
ALLOCATE(XLSWS(SIZE(XLSWM,1),SIZE(XLSWM,2),SIZE(XLSWM,3)))
ALLOCATE(XLSTHS(SIZE(XLSTHM,1),SIZE(XLSTHM,2),SIZE(XLSTHM,3)))
ALLOCATE(XLSRVS(SIZE(XLSRVM,1),SIZE(XLSRVM,2),SIZE(XLSRVM,3)))
!
ELSE
!
ALLOCATE(XLSUS(0,0,0))
ALLOCATE(XLSVS(0,0,0))
ALLOCATE(XLSWS(0,0,0))
ALLOCATE(XLSTHS(0,0,0))
ALLOCATE(XLSRVS(0,0,0))
!
END IF
! allocation of the LB fields for horizontal relaxation and Lateral Boundaries
IF( .NOT. ( LSTEADYLS .AND. KMI==1 ) ) THEN
!
ALLOCATE(XLBXTKES(SIZE(XLBXTKEM,1),SIZE(XLBXTKEM,2),SIZE(XLBXTKEM,3)))
ALLOCATE(XLBYTKES(SIZE(XLBYTKEM,1),SIZE(XLBYTKEM,2),SIZE(XLBYTKEM,3)))
ALLOCATE(XLBXUS(SIZE(XLBXUM,1),SIZE(XLBXUM,2),SIZE(XLBXUM,3)))
ALLOCATE(XLBYUS(SIZE(XLBYUM,1),SIZE(XLBYUM,2),SIZE(XLBYUM,3)))
ALLOCATE(XLBXVS(SIZE(XLBXVM,1),SIZE(XLBXVM,2),SIZE(XLBXVM,3)))
ALLOCATE(XLBYVS(SIZE(XLBYVM,1),SIZE(XLBYVM,2),SIZE(XLBYVM,3)))
ALLOCATE(XLBXWS(SIZE(XLBXWM,1),SIZE(XLBXWM,2),SIZE(XLBXWM,3)))
ALLOCATE(XLBYWS(SIZE(XLBYWM,1),SIZE(XLBYWM,2),SIZE(XLBYWM,3)))
ALLOCATE(XLBXTHS(SIZE(XLBXTHM,1),SIZE(XLBXTHM,2),SIZE(XLBXTHM,3)))
ALLOCATE(XLBYTHS(SIZE(XLBYTHM,1),SIZE(XLBYTHM,2),SIZE(XLBYTHM,3)))
ALLOCATE(XLBXRS(SIZE(XLBXRM,1),SIZE(XLBXRM,2),SIZE(XLBXRM,3),SIZE(XLBXRM,4)))
ALLOCATE(XLBYRS(SIZE(XLBYRM,1),SIZE(XLBYRM,2),SIZE(XLBYRM,3),SIZE(XLBYRM,4)))
ALLOCATE(XLBXSVS(SIZE(XLBXSVM,1),SIZE(XLBXSVM,2),SIZE(XLBXSVM,3),SIZE(XLBXSVM,4)))
ALLOCATE(XLBYSVS(SIZE(XLBYSVM,1),SIZE(XLBYSVM,2),SIZE(XLBYSVM,3),SIZE(XLBYSVM,4)))
!
ELSE
!
ALLOCATE(XLBXTKES(0,0,0))
ALLOCATE(XLBYTKES(0,0,0))
ALLOCATE(XLBXUS(0,0,0))
ALLOCATE(XLBYUS(0,0,0))
ALLOCATE(XLBXVS(0,0,0))
ALLOCATE(XLBYVS(0,0,0))
ALLOCATE(XLBXWS(0,0,0))
ALLOCATE(XLBYWS(0,0,0))
ALLOCATE(XLBXTHS(0,0,0))
ALLOCATE(XLBYTHS(0,0,0))
ALLOCATE(XLBXRS(0,0,0,0))
ALLOCATE(XLBYRS(0,0,0,0))
ALLOCATE(XLBXSVS(0,0,0,0))
ALLOCATE(XLBYSVS(0,0,0,0))
!
END IF
!
!
!* 3.7 Module MODD_RADIATIONS_n (except XOZON and XAER)
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
!
!
NSWB_MNH = 6
ALLOCATE(XSW_BANDS (NSWB_MNH))
ALLOCATE(XZENITH (IIU,IJU))
ALLOCATE(XAZIM (IIU,IJU))
ALLOCATE(XALBUV (IIU,IJU))
ALLOCATE(XDIRSRFSWD(IIU,IJU,NSWB_MNH))
ALLOCATE(XSCAFLASWD(IIU,IJU,NSWB_MNH))
ALLOCATE(XFLALWD (IIU,IJU))
!
IF (CRAD /= 'NONE') THEN
ALLOCATE(XSLOPANG(IIU,IJU))
ALLOCATE(XSLOPAZI(IIU,IJU))
ALLOCATE(XDTHRAD(IIU,IJU,IKU))
ALLOCATE(XDIRFLASWD(IIU,IJU,NSWB_MNH))
ALLOCATE(XDIR_ALB(IIU,IJU,NSWB_MNH))
ALLOCATE(XSCA_ALB(IIU,IJU,NSWB_MNH))
ALLOCATE(XEMIS (IIU,IJU))
ALLOCATE(XTSRAD (IIU,IJU)) ; XTSRAD = 0.0
ALLOCATE(XSEA (IIU,IJU))
ALLOCATE(XZS_XY (IIU,IJU))
ALLOCATE(NCLEARCOL_TM1(IIU,IJU))
ALLOCATE(XSWU(IIU,IJU,IKU))
ALLOCATE(XSWD(IIU,IJU,IKU))
ALLOCATE(XLWU(IIU,IJU,IKU))
ALLOCATE(XLWD(IIU,IJU,IKU))
ALLOCATE(XDTHRADSW(IIU,IJU,IKU))
ALLOCATE(XDTHRADLW(IIU,IJU,IKU))
ALLOCATE(XRADEFF(IIU,IJU,IKU))
ELSE
ALLOCATE(XSLOPANG(0,0))
ALLOCATE(XSLOPAZI(0,0))
ALLOCATE(XDTHRAD(0,0,0))
ALLOCATE(XDIRFLASWD(0,0,0))
ALLOCATE(XDIR_ALB(0,0,0))
ALLOCATE(XSCA_ALB(0,0,0))
ALLOCATE(XEMIS (0,0))
ALLOCATE(XTSRAD (0,0))
ALLOCATE(XSEA (0,0))
ALLOCATE(XZS_XY (0,0))
ALLOCATE(NCLEARCOL_TM1(0,0))
ALLOCATE(XSWU(0,0,0))
ALLOCATE(XSWD(0,0,0))
ALLOCATE(XLWU(0,0,0))
ALLOCATE(XLWD(0,0,0))
ALLOCATE(XDTHRADSW(0,0,0))
ALLOCATE(XDTHRADLW(0,0,0))
ALLOCATE(XRADEFF(0,0,0))
END IF
IF (CRAD == 'ECMW') THEN
ALLOCATE(XSTROATM(31,6))
ALLOCATE(XSMLSATM(31,6))
ALLOCATE(XSMLWATM(31,6))
ALLOCATE(XSPOSATM(31,6))
ALLOCATE(XSPOWATM(31,6))
ALLOCATE(XSTATM(31,6))
ELSE
ALLOCATE(XSTROATM(0,0))
ALLOCATE(XSMLSATM(0,0))
ALLOCATE(XSMLWATM(0,0))
ALLOCATE(XSPOSATM(0,0))
ALLOCATE(XSPOWATM(0,0))
ALLOCATE(XSTATM(0,0))
END IF
!
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
!
IF (CDCONV /= 'NONE' .OR. CSCONV == 'KAFR') THEN
ALLOCATE(NCOUNTCONV(IIU,IJU))
ALLOCATE(XDTHCONV(IIU,IJU,IKU))
ALLOCATE(XDRVCONV(IIU,IJU,IKU))
ALLOCATE(XDRCCONV(IIU,IJU,IKU))
ALLOCATE(XDRICONV(IIU,IJU,IKU))
ALLOCATE(XPRCONV(IIU,IJU))
ALLOCATE(XPACCONV(IIU,IJU))
ALLOCATE(XPRSCONV(IIU,IJU))
! diagnostics
IF (LCH_CONV_LINOX) THEN
ALLOCATE(XIC_RATE(IIU,IJU))
ALLOCATE(XCG_RATE(IIU,IJU))
ALLOCATE(XIC_TOTAL_NUMBER(IIU,IJU))
ALLOCATE(XCG_TOTAL_NUMBER(IIU,IJU))
ELSE
ALLOCATE(XIC_RATE(0,0))
ALLOCATE(XCG_RATE(0,0))
ALLOCATE(XIC_TOTAL_NUMBER(0,0))
ALLOCATE(XCG_TOTAL_NUMBER(0,0))
END IF
IF ( LDIAGCONV ) THEN
ALLOCATE(XUMFCONV(IIU,IJU,IKU))
ALLOCATE(XDMFCONV(IIU,IJU,IKU))
ALLOCATE(XPRLFLXCONV(IIU,IJU,IKU))
ALLOCATE(XPRSFLXCONV(IIU,IJU,IKU))
ALLOCATE(XCAPE(IIU,IJU))
ALLOCATE(NCLTOPCONV(IIU,IJU))
ALLOCATE(NCLBASCONV(IIU,IJU))
ELSE
ALLOCATE(XUMFCONV(0,0,0))
ALLOCATE(XDMFCONV(0,0,0))
ALLOCATE(XPRLFLXCONV(0,0,0))
ALLOCATE(XPRSFLXCONV(0,0,0))
ALLOCATE(XCAPE(0,0))
ALLOCATE(NCLTOPCONV(0,0))
ALLOCATE(NCLBASCONV(0,0))
END IF
ELSE
ALLOCATE(XPRCONV(0,0))
ALLOCATE(XPACCONV(0,0))
ALLOCATE(XPRSCONV(0,0))
END IF
!
IF ((CDCONV == 'KAFR' .OR. CSCONV == 'KAFR') &
.AND. LSUBG_COND .AND. LSIG_CONV) THEN
ALLOCATE(XMFCONV(IIU,IJU,IKU))
ELSE
ALLOCATE(XMFCONV(0,0,0))
ENDIF
!
IF ((CDCONV == 'KAFR' .OR. CSCONV == 'KAFR') &
.AND. LCHTRANS .AND. NSV > 0 ) THEN
ALLOCATE(XDSVCONV(IIU,IJU,IKU,NSV))
ELSE
ALLOCATE(XDSVCONV(0,0,0,0))
END IF
!
ALLOCATE(XCF_MF(IIU,IJU,IKU)) ; XCF_MF=0.0
ALLOCATE(XRC_MF(IIU,IJU,IKU)) ; XRC_MF=0.0
ALLOCATE(XRI_MF(IIU,IJU,IKU)) ; XRI_MF=0.0
!
!
ALLOCATE(ZJ(IIU,IJU,IKU))
!
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
!
IF (KMI == 1) THEN
IF ( LFORCING ) THEN
ALLOCATE(TDTFRC(NFRC))
ALLOCATE(XUFRC(IKU,NFRC))
ALLOCATE(XVFRC(IKU,NFRC))
ALLOCATE(XWFRC(IKU,NFRC))
ALLOCATE(XTHFRC(IKU,NFRC))
ALLOCATE(XRVFRC(IKU,NFRC))
ALLOCATE(XTENDTHFRC(IKU,NFRC))
ALLOCATE(XTENDRVFRC(IKU,NFRC))
ALLOCATE(XGXTHFRC(IKU,NFRC))
ALLOCATE(XGYTHFRC(IKU,NFRC))
ALLOCATE(XPGROUNDFRC(NFRC))
ELSE
ALLOCATE(TDTFRC(0))
ALLOCATE(XUFRC(0,0))
ALLOCATE(XVFRC(0,0))
ALLOCATE(XWFRC(0,0))
ALLOCATE(XTHFRC(0,0))
ALLOCATE(XRVFRC(0,0))
ALLOCATE(XTENDTHFRC(0,0))
ALLOCATE(XTENDRVFRC(0,0))
ALLOCATE(XGXTHFRC(0,0))
ALLOCATE(XGYTHFRC(0,0))
ALLOCATE(XPGROUNDFRC(0))
END IF
IF ( LFORCING ) THEN
ALLOCATE(XWTFRC(IIU,IJU,IKU))
ALLOCATE(XUFRC_PAST(IIU,IJU,IKU)) ; XUFRC_PAST = XUNDEF
ALLOCATE(XVFRC_PAST(IIU,IJU,IKU)) ; XVFRC_PAST = XUNDEF
ELSE
ALLOCATE(XWTFRC(0,0,0))
ALLOCATE(XUFRC_PAST(0,0,0))
ALLOCATE(XVFRC_PAST(0,0,0))
END IF
END IF
! ----------------------------------------------------------------------
!
IF (L2D_ADV_FRC) THEN
WRITE(ILUOUT,*) 'L2D_ADV_FRC IS SET TO', L2D_ADV_FRC
WRITE(ILUOUT,*) 'ADV FRC WILL BE SET'
ALLOCATE(TDTADVFRC(NADVFRC))
ALLOCATE(XDTHFRC(IIU,IJU,IKU,NADVFRC)) ; XDTHFRC=0.
ALLOCATE(XDRVFRC(IIU,IJU,IKU,NADVFRC)) ; XDRVFRC=0.
ELSE
ALLOCATE(TDTADVFRC(0))
ALLOCATE(XDTHFRC(0,0,0,0))
ALLOCATE(XDRVFRC(0,0,0,0))
ENDIF
IF (L2D_REL_FRC) THEN
WRITE(ILUOUT,*) 'L2D_REL_FRC IS SET TO', L2D_REL_FRC
WRITE(ILUOUT,*) 'REL FRC WILL BE SET'
ALLOCATE(TDTRELFRC(NRELFRC))
ALLOCATE(XTHREL(IIU,IJU,IKU,NRELFRC)) ; XTHREL=0.
ALLOCATE(XRVREL(IIU,IJU,IKU,NRELFRC)) ; XRVREL=0.
ELSE
ALLOCATE(TDTRELFRC(0))
ALLOCATE(XTHREL(0,0,0,0))
ALLOCATE(XRVREL(0,0,0,0))
ENDIF
!
!* 4.11 BIS: Eddy fluxes allocation
!
IF ( LTH_FLX ) THEN
ALLOCATE(XVTH_FLUX_M(IIU,IJU,IKU)) ; XVTH_FLUX_M = 0.
ALLOCATE(XWTH_FLUX_M(IIU,IJU,IKU)) ; XWTH_FLUX_M = 0.
IF (KMI /= 1) THEN
ALLOCATE(XRTHS_EDDY_FLUX(IIU,IJU,IKU))
XRTHS_EDDY_FLUX = 0.
ENDIF
ELSE
ALLOCATE(XVTH_FLUX_M(0,0,0)) ; XVTH_FLUX_M = 0.
ALLOCATE(XWTH_FLUX_M(0,0,0)) ; XWTH_FLUX_M = 0.
END IF
!
IF ( LUV_FLX) THEN
ALLOCATE(XVU_FLUX_M(IIU,IJU,IKU)) ; XVU_FLUX_M = 0.
IF (KMI /= 1) THEN
ALLOCATE(XRVS_EDDY_FLUX(IIU,IJU,IKU))
XRVS_EDDY_FLUX = 0.
ENDIF
ELSE
ALLOCATE(XVU_FLUX_M(0,0,0)) ; XVU_FLUX_M = 0.
END IF
!
!
IF ( (CCLOUD == 'ICE3'.OR.CCLOUD == 'ICE4') .AND. &
(CPROGRAM == 'DIAG '.OR.CPROGRAM == 'MESONH')) THEN
ALLOCATE(XCIT(IIU,IJU,IKU))
ELSE
ALLOCATE(XCIT(0,0,0))
END IF
!
IF ( CCLOUD == 'KHKO' .OR. CCLOUD == 'C2R2') THEN
ALLOCATE(XSUPSAT(IIU,IJU,IKU))
ALLOCATE(XNACT(IIU,IJU,IKU))
ALLOCATE(XNPRO(IIU,IJU,IKU))
ALLOCATE(XSSPRO(IIU,IJU,IKU))
END IF
!
!
IF (.NOT.(ALLOCATED(XCEI))) ALLOCATE(XCEI(0,0,0))
IF (KMI == NMODEL_CLOUD .AND. CTURBLEN_CLOUD/='NONE' ) THEN
DEALLOCATE(XCEI)
ALLOCATE(XCEI(IIU,IJU,IKU))
ENDIF
!
IF (LUSECHAQ.AND.(CPROGRAM == 'DIAG '.OR.CPROGRAM == 'MESONH')) THEN
IF (LCH_PH) THEN
ALLOCATE(XPHC(IIU,IJU,IKU))
IF (NRRL==2) THEN
ALLOCATE(XPHR(IIU,IJU,IKU))
ALLOCATE(XACPHR(IIU,IJU))
XACPHR(:,:) = 0.
IF (NRRL==2) THEN
ALLOCATE(XACPRAQ(IIU,IJU,NSV_CHAC/2))
XACPRAQ(:,:,:) = 0.
ENDIF
ENDIF
!
!-------------------------------------------------------------------------------
!
! ---------------------------
!
IF ( CBUTYPE /= "NONE" .AND. NBUMOD == KMI ) THEN

WAUTELET Philippe
committed
CALL INI_BUDGET(ILUOUT,XTSTEP,NSV,NRR, &
LNUMDIFU,LNUMDIFTH,LNUMDIFSV, &
LHORELAX_UVWTH,LHORELAX_RV, LHORELAX_RC,LHORELAX_RR, &
LHORELAX_RI,LHORELAX_RS,LHORELAX_RG, LHORELAX_RH,LHORELAX_TKE, &
LHORELAX_SV,LVE_RELAX,LCHTRANS,LNUDGING,LDRAGTREE,LDEPOTREE, &
END IF
!
!-------------------------------------------------------------------------------
!
!
!
CALL INI_BIKHARDT_n (NDXRATIO_ALL(KMI),NDYRATIO_ALL(KMI),KMI)
!
!-------------------------------------------------------------------------------
!
!* 6. BUILT THE GENERIC OUTPUT NAME
! ----------------------------
!
IF (KMI == 1) THEN
DO IMI = 1 , NMODEL
WRITE(IO_SURF_MNH_MODEL(IMI)%COUTFILE,'(A,".",I1,".",A)') CEXP,IMI,TRIM(ADJUSTL(CSEG))
WRITE(YNAME, '(A,".",I1,".",A)') CEXP,IMI,TRIM(ADJUSTL(CSEG))//'.000'
CALL IO_FILE_ADD2LIST(LUNIT_MODEL(IMI)%TDIAFILE,YNAME,'DIACHRONIC','WRITE', &
KLFINPRAR=50,KLFITYPE=1,KLFIVERB=NVERB, &
TPDADFILE=LUNIT_MODEL(NDAD(IMI))%TDIAFILE )
TDIAFILE => LUNIT_MODEL(KMI)%TDIAFILE !Necessary because no call to GOTO_MODEL before needing it
!
IF (CPROGRAM=='MESONH') THEN
IF ( NDAD(KMI) == 1) CDAD_NAME(KMI) = CEXP//'.1.'//CSEG
IF ( NDAD(KMI) == 2) CDAD_NAME(KMI) = CEXP//'.2.'//CSEG
IF ( NDAD(KMI) == 3) CDAD_NAME(KMI) = CEXP//'.3.'//CSEG
IF ( NDAD(KMI) == 4) CDAD_NAME(KMI) = CEXP//'.4.'//CSEG
IF ( NDAD(KMI) == 5) CDAD_NAME(KMI) = CEXP//'.5.'//CSEG
IF ( NDAD(KMI) == 6) CDAD_NAME(KMI) = CEXP//'.6.'//CSEG
IF ( NDAD(KMI) == 7) CDAD_NAME(KMI) = CEXP//'.7.'//CSEG
IF ( NDAD(KMI) == 8) CDAD_NAME(KMI) = CEXP//'.8.'//CSEG
END IF
END IF
!
!-------------------------------------------------------------------------------
!
!* 7. INITIALIZE GRIDS AND METRIC COEFFICIENTS
! ----------------------------------------
!
CALL SET_GRID(KMI,TPINIFILE,HLUOUT,IIU,IJU,IKU,NIMAX_ll,NJMAX_ll, &
XBMX1,XBMX2,XBMX3,XBMX4,XBMY1,XBMY2,XBMY3,XBMY4, &
XBFX1,XBFX2,XBFX3,XBFX4,XBFY1,XBFY2,XBFY3,XBFY4, &
NXOR_ALL(KMI),NYOR_ALL(KMI),NXEND_ALL(KMI),NYEND_ALL(KMI), &
NDXRATIO_ALL(KMI),NDYRATIO_ALL(KMI), &
CLBCX,CLBCY, &
XTSTEP,XSEGLEN, &
XLONORI,XLATORI,XLON,XLAT, &
XXHAT,XYHAT,XDXHAT,XDYHAT, XMAP, &
XZS,XZZ,XZHAT,LSLEVE,XLEN1,XLEN2,XZSMT, &
ZJ, &
TDTMOD,TDTCUR,NSTOP,NBAK_NUMB,NOUT_NUMB,TBACKUPN,TOUTPUTN)
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
!
CALL METRICS(XMAP,XDXHAT,XDYHAT,XZZ,XDXX,XDYY,XDZX,XDZY,XDZZ)
!
!* update halos of metric coefficients
!
!
CALL UPDATE_METRICS(CLBCX,CLBCY,XDXX,XDYY,XDZX,XDZY,XDZZ)
!
!
CALL SET_DIRCOS(CLBCX,CLBCY,XDXX,XDYY,XDZX,XDZY,TZINITHALO2D_ll, &
XDIRCOSXW,XDIRCOSYW,XDIRCOSZW,XCOSSLOPE,XSINSLOPE )
!
! grid nesting initializations
IF ( KMI == 1 ) THEN
XTSTEP_MODEL1=XTSTEP
END IF
!
NDT_2_WAY(KMI)=4
!
!-------------------------------------------------------------------------------
!
!* 8. INITIALIZE DATA FOR JVALUES AND AEROSOLS
!
IF ( LUSECHEM .OR. LCHEMDIAG ) THEN
IF ((KMI==1).AND.(CPROGRAM == "MESONH".OR.CPROGRAM == "DIAG ")) &
CALL CH_INIT_JVALUES(TDTCUR%TDATE%DAY, TDTCUR%TDATE%MONTH, &
TDTCUR%TDATE%YEAR, ILUOUT, XCH_TUV_DOBNEW)
!
IF (LORILAM) THEN
CALL CH_AER_MOD_INIT
ELSE
IF (.NOT.(ASSOCIATED(XSOLORG))) ALLOCATE(XSOLORG(0,0,0,0))
IF (.NOT.(ASSOCIATED(XMI))) ALLOCATE(XMI(0,0,0,0))
ENDIF
ELSE
IF (.NOT.(ASSOCIATED(XMI))) ALLOCATE(XMI(0,0,0,0))
IF (.NOT.(ASSOCIATED(XSOLORG))) ALLOCATE(XSOLORG(0,0,0,0))
END IF
!
!-------------------------------------------------------------------------------
!
! --------------------------------
!
CALL MPPDB_CHECK3D(XUT,"INI_MODEL_N-before read_field::XUT",PRECISION)
CALL READ_FIELD(TPINIFILE,HLUOUT,IMASDEV, IIU,IJU,IKU,XTSTEP, &
CGETTKET,CGETRVT,CGETRCT,CGETRRT,CGETRIT,CGETCIT, &
CGETRST,CGETRGT,CGETRHT,CGETSVT,CGETSRCT,CGETSIGS,CGETCLDFR, &
CGETBL_DEPTH,CGETSBL_DEPTH,CGETPHC,CGETPHR,CUVW_ADV_SCHEME, &
CTEMP_SCHEME,NSIZELBX_ll,NSIZELBXU_ll,NSIZELBY_ll,NSIZELBYV_ll,&
NSIZELBXTKE_ll,NSIZELBYTKE_ll, &
NSIZELBXR_ll,NSIZELBYR_ll,NSIZELBXSV_ll,NSIZELBYSV_ll, &
XUM,XVM,XWM,XDUM,XDVM,XDWM, &
XUT,XVT,XWT,XTHT,XPABST,XPABSM,XTKET,XRTKEMS, &
XRT,XSVT,XCIT,XDRYMASST, &
XSIGS,XSRCT,XCLDFR,XBL_DEPTH,XSBL_DEPTH,XWTHVMF,XPHC,XPHR, &
XLSUM,XLSVM,XLSWM,XLSTHM,XLSRVM, &
XLBXUM,XLBXVM,XLBXWM,XLBXTHM,XLBXTKEM, &
XLBXRM,XLBXSVM, &
XLBYUM,XLBYVM,XLBYWM,XLBYTHM,XLBYTKEM, &
XLBYRM,XLBYSVM, &
NFRC,TDTFRC,XUFRC,XVFRC,XWFRC,XTHFRC,XRVFRC, &
XTENDTHFRC,XTENDRVFRC,XGXTHFRC,XGYTHFRC, &
XPGROUNDFRC, XATC, &
NADVFRC,TDTADVFRC,XDTHFRC,XDRVFRC, &
NRELFRC,TDTRELFRC,XTHREL,XRVREL, &
XVTH_FLUX_M,XWTH_FLUX_M,XVU_FLUX_M, &
XRUS_PRES,XRVS_PRES,XRWS_PRES,XRTHS_CLD,XRRS_CLD,XRSVS_CLD )
!
!-------------------------------------------------------------------------------
!
!
! ---------------------------
!
!

WAUTELET Philippe
committed
CALL SET_REF(KMI,TPINIFILE,HLUOUT, &
XZZ,XZHAT,ZJ,XDXX,XDYY,CLBCX,CLBCY, &
XREFMASS,XMASS_O_PHI0,XLINMASS, &
XRHODREF,XTHVREF,XRVREF,XEXNREF,XRHODJ )
!
!-------------------------------------------------------------------------------
!
! -----------------------------------
!
IF ((CTURB == 'TKEL').AND.(CCONF=='START')) THEN
CALL MPPDB_CHECK3D(XUT,"INI_MODEL_N-before ini_tke_eps::XUT",PRECISION)
CALL MPPDB_CHECK3D(XUT,"INI_MODEL_N-after ini_tke_eps::XUT",PRECISION)
! ----------------------------
!
CALL INI_LES_n
!
!-------------------------------------------------------------------------------
!
!* 11. INITIALIZE THE SOURCE OF TOTAL DRY MASS Md
! ------------------------------------------
!
IF((KMI==1).AND.LSTEADYLS) THEN
XDRYMASSS = 0.
END IF
!
!-------------------------------------------------------------------------------
!
! ----------------------------
!
IF (CELEC == 'NONE') THEN

WAUTELET Philippe
committed
CALL INI_MICRO_n(TPINIFILE,ILUOUT)
!
!-------------------------------------------------------------------------------
!
!* 13. INITIALIZE THE ATMOSPHERIC ELECTRICITY
! --------------------------------------
!
ELSE

WAUTELET Philippe
committed
CALL INI_ELEC_n(ILUOUT, CELEC, CCLOUD, HLUOUT, TPINIFILE, &
XTSTEP, XZZ, &
XDXX, XDYY, XDZZ, XDZX, XDZY )
!
WRITE (UNIT=ILUOUT,&
FMT='(/,"ELECTRIC VARIABLES ARE BETWEEN INDEX",I2," AND ",I2)')&
NSV_ELECBEG, NSV_ELECEND
!
IF( CGETSVT(NSV_ELECBEG)=='INIT' ) THEN
XSVT(:,:,:,NSV_ELECBEG) = XCION_POS_FW(:,:,:) ! Nb/kg
XSVT(:,:,:,NSV_ELECEND) = XCION_NEG_FW(:,:,:)
!
XSVT(:,:,:,NSV_ELECBEG+1:NSV_ELECEND-1) = 0.0
ELSE ! Convert elec_variables per m3 into elec_variables per kg of air
DO JSV = NSV_ELECBEG, NSV_ELECEND
XSVT(:,:,:,JSV) = XSVT(:,:,:,JSV) / XRHODREF(:,:,:)
ENDDO
END IF
END IF
!
!-------------------------------------------------------------------------------
!
! ----------------------------------
!
IF ((KMI==1).AND.(.NOT. LSTEADYLS)) THEN
CALL MPPDB_CHECK3D(XUT,"INI_MODEL_N-before ini_cpl::XUT",PRECISION)
CALL INI_CPL(HLUOUT,NSTOP,XTSTEP,LSTEADYLS,CCONF, &
CGETTKET, &
CGETRVT,CGETRCT,CGETRRT,CGETRIT, &
CGETRST,CGETRGT,CGETRHT,CGETSVT,LCH_INIT_FIELD, &
NSV,NIMAX_ll,NJMAX_ll, &
NSIZELBX_ll,NSIZELBXU_ll,NSIZELBY_ll,NSIZELBYV_ll, &
NSIZELBXTKE_ll,NSIZELBYTKE_ll, &
NSIZELBXR_ll,NSIZELBYR_ll,NSIZELBXSV_ll,NSIZELBYSV_ll, &
XLSUM,XLSVM,XLSWM,XLSTHM,XLSRVM,XDRYMASST, &
XLBXUM,XLBXVM,XLBXWM,XLBXTHM,XLBXTKEM,XLBXRM,XLBXSVM, &
XLBYUM,XLBYVM,XLBYWM,XLBYTHM,XLBYTKEM,XLBYRM,XLBYSVM, &
XLSUS,XLSVS,XLSWS,XLSTHS,XLSRVS,XDRYMASSS, &
XLBXUS,XLBXVS,XLBXWS,XLBXTHS,XLBXTKES,XLBXRS,XLBXSVS, &
XLBYUS,XLBYVS,XLBYWS,XLBYTHS,XLBYTKES,XLBYRS,XLBYSVS )
CALL MPPDB_CHECK3D(XUT,"INI_MODEL_N-after ini_cpl::XUT",PRECISION)
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
END IF
!
IF ( KMI > 1) THEN
! Use dummy pointers to correct an ifort BUG
DPTR_XBMX1=>XBMX1
DPTR_XBMX2=>XBMX2
DPTR_XBMX3=>XBMX3
DPTR_XBMX4=>XBMX4
DPTR_XBMY1=>XBMY1
DPTR_XBMY2=>XBMY2
DPTR_X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PTR_XBMY1,DPTR_XBMY2,DPTR_XBMY3,DPTR_XBMY4, &
DPTR_XBFX1,DPTR_XBFX2,DPTR_XBFX3,DPTR_XBFX4,DPTR_XBFY1,DPTR_XBFY2,DPTR_XBFY3,DPTR_XBFY4, &
NDXRATIO_ALL(KMI),NDYRATIO_ALL(KMI),NDTRATIO(KMI), &
DPTR_CLBCX,DPTR_CLBCY,NRIMX,NRIMY, &
DPTR_NKLIN_LBXU,DPTR_XCOEFLIN_LBXU,DPTR_NKLIN_LBYU,DPTR_XCOEFLIN_LBYU, &
DPTR_NKLIN_LBXV,DPTR_XCOEFLIN_LBXV,DPTR_NKLIN_LBYV,DPTR_XCOEFLIN_LBYV, &
DPTR_NKLIN_LBXW,DPTR_XCOEFLIN_LBXW,DPTR_NKLIN_LBYW,DPTR_XCOEFLIN_LBYW, &
DPTR_NKLIN_LBXM,DPTR_XCOEFLIN_LBXM,DPTR_NKLIN_LBYM,DPTR_XCOEFLIN_LBYM, &
CCLOUD, LUSECHAQ, LUSECHIC, &
DPTR_XLBXUM,DPTR_XLBYUM,DPTR_XLBXVM,DPTR_XLBYVM,DPTR_XLBXWM,DPTR_XLBYWM, &
DPTR_XLBXTHM,DPTR_XLBYTHM, &
DPTR_XLBXTKEM,DPTR_XLBYTKEM, &
DPTR_XLBXRM,DPTR_XLBYRM,DPTR_XLBXSVM,DPTR_XLBYSVM )
END IF
!
!
!-------------------------------------------------------------------------------
!
! -------------------------------
!
IF (LLG .AND. LINIT_LG .AND. CPROGRAM=='MESONH') &
CALL INI_LG(XXHAT,XYHAT,XZZ,XSVT,XLBXSVM,XLBYSVM)
!
!-------------------------------------------------------------------------------
!
!* 16. INITIALIZE THE PARAMETERS FOR THE DYNAMICS
! ------------------------------------------
!
CALL INI_DYNAMICS(HLUOUT,XLON,XLAT,XRHODJ,XTHVREF,XMAP,XZZ,XDXHAT,XDYHAT, &
XZHAT,CLBCX,CLBCY,XTSTEP, &
LVE_RELAX,LVE_RELAX_GRD,LHORELAX_UVWTH,LHORELAX_RV, &
LHORELAX_RC,LHORELAX_RR,LHORELAX_RI,LHORELAX_RS,LHORELAX_RG, &
LHORELAX_RH,LHORELAX_TKE,LHORELAX_SV, &
LHORELAX_SVC2R2,LHORELAX_SVC1R3,LHORELAX_SVELEC,LHORELAX_SVLG, &
LHORELAX_SVCHEM,LHORELAX_SVAER,LHORELAX_SVDST,LHORELAX_SVSLT, &
LHORELAX_SVPP,LHORELAX_SVCS,LHORELAX_SVCHIC, &
#ifdef MNH_FOREFIRE
LHORELAX_SVFF, &
#endif
XRIMKMAX,NRIMX,NRIMY, &
XALKTOP,XALKGRD,XALZBOT,XALZBAS, &
XT4DIFU,XT4DIFTH,XT4DIFSV, &
XCORIOX,XCORIOY,XCORIOZ,XCURVX,XCURVY, &
XDXHATM,XDYHATM,XRHOM,XAF,XBFY,XCF,XTRIGSX,XTRIGSY,NIFAXX,NIFAXY,&
XALK,XALKW,NALBOT,XALKBAS,XALKWBAS,NALBAS, &
LMASK_RELAX,XKURELAX,XKVRELAX,XKWRELAX, &
XDK2U,XDK4U,XDK2TH,XDK4TH,XDK2SV,XDK4SV, &
LZDIFFU,XZDIFFU_HALO2, &
XBFB,XBF_SXP2_YP1_Z )
!
!-------------------------------------------------------------------------------
!
! ---------------
!
IF (CRAD /= 'NONE') THEN
IF (CGETRAD =='INIT') THEN
GINIRAD =.TRUE.
ELSE
GINIRAD =.FALSE.
END IF

WAUTELET Philippe
committed
CALL INI_RADIATIONS(TPINIFILE,HLUOUT,GINIRAD,TDTCUR,TDTEXP,XZZ, &
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
XDXX, XDYY, &
XSINDEL,XCOSDEL,XTSIDER,XCORSOL, &
XSLOPANG,XSLOPAZI, &
XDTHRAD,XDIRFLASWD,XSCAFLASWD, &
XFLALWD,XDIRSRFSWD,NCLEARCOL_TM1, &
XZENITH,XAZIM, &
TDTRAD_FULL,TDTRAD_CLONLY, &
TZINITHALO2D_ll, &
XRADEFF,XSWU,XSWD,XLWU, &
XLWD,XDTHRADSW,XDTHRADLW )
!
IF (GINIRAD) CALL SUNPOS_n(XZENITH,PAZIMSOL=XAZIM)
CALL SURF_SOLAR_GEOM (XZS, XZS_XY)
!
ALLOCATE(XXHAT_ll (IIU_ll))
ALLOCATE(XYHAT_ll (IJU_ll))
ALLOCATE(XZS_ll (IIU_ll,IJU_ll))
ALLOCATE(XZS_XY_ll (IIU_ll,IJU_ll))
!
CALL GATHERALL_FIELD_ll('XY',XZS,XZS_ll,IRESP)
CALL GATHERALL_FIELD_ll('XY',XZS_XY,XZS_XY_ll,IRESP)
CALL GATHERALL_FIELD_ll('XX',XXHAT,XXHAT_ll,IRESP)
CALL GATHERALL_FIELD_ll('YY',XYHAT,XYHAT_ll,IRESP)
XZS_MAX_ll=MAXVAL(XZS_ll)
ELSE
XAZIM = XPI
XZENITH = XPI/2.
XDIRSRFSWD = 0.
XSCAFLASWD = 0.
XFLALWD = 300. ! W/m2
XTSIDER = 0.
END IF
!
!
CALL INI_SW_SETUP (CRAD,NSWB_MNH,XSW_BANDS)
!
!
! 17.1.1 Special initialisation for CO2 content
! CO2 (molar mass=44) horizontally and vertically homogeneous at 360 ppm
!
XCCO2 = 360.0E-06 * 44.0E-03 / XMD
!
!
! ---------------------------
!
ALLOCATE(ZCO2(IIU,IJU))
ZCO2(:,:) = XCCO2
!
ALLOCATE(ZDIR_ALB(IIU,IJU,NSWB_MNH))
ALLOCATE(ZSCA_ALB(IIU,IJU,NSWB_MNH))
ALLOCATE(ZEMIS (IIU,IJU))
ALLOCATE(ZTSRAD (IIU,IJU))
!
IF (IMASDEV>=46) THEN
CALL IO_READ_FIELD(TPINIFILE,'SURF',CSURF)
ELSE
CSURF = "EXTE"
END IF
!
!
IF (CSURF=='EXTE' .AND. (CPROGRAM=='MESONH' .OR. CPROGRAM=='DIAG ')) THEN
! ouverture du fichier PGD
IF ( LEN_TRIM(CINIFILEPGD) > 0 ) THEN

WAUTELET Philippe
committed
CALL IO_FILE_ADD2LIST(TINIFILEPGD,TRIM(CINIFILEPGD),'UNKNOWN','READ',KLFITYPE=2,KLFIVERB=NVERB)
CALL IO_FILE_OPEN_ll(TINIFILEPGD,OPARALLELIO=.FALSE.)
IF (IRESP/=0) THEN
WRITE(ILUOUT,FMT=*) "INI_MODEL_n ERROR TO OPEN THE FILE CINIFILEPGD=",CINIFILEPGD
WRITE(ILUOUT,FMT=*) "CHECK YOUR NAMELIST NAM_LUNITn"
!callabortstop
CALL PRINT_MSG(NVERB_FATAL,'GEN','INI_MODEL_n','')
ENDIF
ELSE
! case after a spawning
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
!* initialization of surface
CALL INIT_GROUND_PARAM_n ('ALL',SIZE(CSV),CSV,ZCO2, &
XZENITH,XAZIM,XSW_BANDS,ZDIR_ALB,ZSCA_ALB, &
ZEMIS,ZTSRAD )
!
IF (SIZE(XEMIS)>0) THEN
XDIR_ALB = ZDIR_ALB
XSCA_ALB = ZSCA_ALB
XEMIS = ZEMIS
XTSRAD = ZTSRAD
CALL MNHGET_SURF_PARAM_n (PSEA=XSEA)
END IF
ELSE
!* fields not physically necessary, but must be initialized
IF (SIZE(XEMIS)>0) THEN
XDIR_ALB = 0.
XSCA_ALB = 0.
XEMIS = 1.
XTSRAD = XTT
XSEA = 1.
END IF
END IF
IF (CSURF=='EXTE' .AND. (CPROGRAM=='SPAWN ')) THEN
! ouverture du fichier PGD

WAUTELET Philippe
committed
CALL IO_FILE_ADD2LIST(TINIFILEPGD,TRIM(CINIFILEPGD),'UNKNOWN','READ',KLFITYPE=2,KLFIVERB=NVERB)
CALL IO_FILE_OPEN_ll(TINIFILEPGD,OPARALLELIO=.FALSE.)
IF (IRESP/=0) THEN
WRITE(ILUOUT,FMT=*) "INI_MODEL_n ERROR TO OPEN THE FILE CINIFILEPGD=",CINIFILEPGD
WRITE(ILUOUT,FMT=*) "CHECK YOUR NAMELIST NAM_LUNIT2_SPA"
!callabortstop
CALL PRINT_MSG(NVERB_FATAL,'GEN','INI_MODEL_n','')
ENDIF
ENDIF
!
!* special case after spawning in prep_real_case
IF (CSURF=='EXRM' .AND. CPROGRAM=='REAL ') CSURF = 'EXTE'
!
DEALLOCATE(ZDIR_ALB)
DEALLOCATE(ZSCA_ALB)
DEALLOCATE(ZEMIS )
DEALLOCATE(ZTSRAD )
!
DEALLOCATE(ZCO2)
!
!
!* in a RESTART case, reads surface radiative quantities in the MESONH file
!
IF (CRAD == 'ECMW' .AND. CGETRAD=='READ') THEN

WAUTELET Philippe
committed
CALL INI_SURF_RAD(TPINIFILE, XDIR_ALB, XSCA_ALB, XEMIS, XTSRAD)