Changeset 156
- Timestamp:
- 11/10/17 16:53:10 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SOURCES/flottab2-0.7.f90
r155 r156 746 746 call determin_front_tof ! version simplifiee 747 747 748 call determin_marais749 750 748 ! pour sorties initMIP: 751 749 debug_3D(:,:,118) = ice(:,:)*(1-mk(:,:)) … … 1322 1320 subroutine determin_marais 1323 1321 1324 !$ USE OMP_LIB 1325 1326 implicit none 1327 integer :: indice 1328 integer :: label ! no des taches rencontrées dans le mask 1329 integer :: label_max ! no temporaire maxi de tache rencontrées 1330 ! integer :: mask_nb = 4 1331 integer,parameter :: mask_nb = 2 ! version ou on ne compte pas les diagonales 1332 integer :: vartemp ! variable temporaire pour reorganiser compt 1333 ! integer,dimension(mask_nb) :: mask 1334 integer,dimension(mask_nb) :: mask 1335 1336 integer,dimension(nx,ny) :: table_out_marais !< pour les numeros des taches 1337 integer,dimension(0:n_ta_max) :: compt_marais !< contient les equivalence entre les taches 1338 integer,dimension(0:n_ta_max) :: nb_pts_marais !< indique le nombre de points par tache 1339 logical,dimension(0:n_ta_max) :: marais !< T si flottants entoure de poses, F sinon 1340 1322 !$ USE OMP_LIB 1323 1324 implicit none 1325 1326 integer :: indice 1327 integer :: label ! no des taches rencontrées dans le mask 1328 integer :: label_max ! no temporaire maxi de tache rencontrées 1329 integer,parameter :: mask_nb = 2 ! version ou on ne compte pas les diagonales 1330 integer,dimension(mask_nb) :: mask ! numero de tache des points adjacents 1331 1332 integer,dimension(nx,ny) :: table_out_marais !< numeros de tache d'un point ij 1333 integer,dimension(0:n_ta_max) :: compt_marais !< contient les equivalence entre les taches 1334 integer,dimension(0:n_ta_max) :: nb_pts_marais !< indique le nombre de points par tache 1335 logical,dimension(0:n_ta_max) :: marais !< T si flottants entoure de poses, F sinon 1336 1337 1341 1338 ! 1-initialisation 1342 1339 !----------------- 1343 label_max=1 ! numero de la tache, la premiere tache est notée 11344 label=11345 do i=1,n_ta_max1346 compt_marais(i)=i1347 enddo1348 !$OMP PARALLEL1349 !$OMP WORKSHARE1350 table_out_marais(:,:) = 01351 marais(:) = .true.1352 nb_pts_marais(:) = 01353 !$OMP END WORKSHARE1354 !$OMP END PARALLEL1340 label_max=1 ! numero de la tache, la premiere tache est notée 1 1341 label=1 1342 do i=1,n_ta_max 1343 compt_marais(i)=i 1344 enddo 1345 !$OMP PARALLEL 1346 !$OMP WORKSHARE 1347 table_out_marais(:,:) = 0 1348 marais(:) = .true. 1349 nb_pts_marais(:) = 0 1350 !$OMP END WORKSHARE 1351 !$OMP END PARALLEL 1355 1352 1356 1353 ! 2-reperage des taches 1357 1354 !---------------------- 1358 1355 1359 do j=2,ny-1 1360 do i=2,nx-1 1361 1362 1363 1364 IF ((ice(i,j).ge.1).and.flot(i,j)) THEN ! on est sur la glace qui flotte-------------------! 1365 !IF ((ice(i,j).ge.1).and.flot(i,j).and.(H(i,j).gt.1.)) THEN ! on est sur la glace qui flotte-------------------! 1366 1367 !write (*,*) "un point qui nous interesse!",i,j 1368 1356 do j=2,ny-1 1357 do i=2,nx-1 1358 if ((ice(i,j).ge.1).and.flot(i,j)) then ! on est sur la glace qui flotte-------------------! 1359 1369 1360 if (((ice(i-1,j).ge.1).and.flot(i-1,j)).or.((ice(i,j-1).ge.1).and.flot(i,j-1))) then !masque de 2 cases adjacentes 1370 !if (((ice(i-1,j).ge.1).and.flot(i-1,j).and.(H(i-1,j).gt.1.)).or.((ice(i,j-1).ge.1).and.flot(i,j-1).and.(H(i,j-1).gt.1.))) then !masque de 2 cases adjacentes 1371 ! un des voisins est deja en glace 1372 mask(1) = table_out_marais(i-1,j) 1373 mask(2) = table_out_marais(i,j-1) 1374 label = label_max 1375 1376 !on determine la valeur de la tache minimun (>0) presente ds le masque 1377 do indice=1,mask_nb 1378 if (mask(indice).gt.0) label=min(label,mask(indice)) 1379 enddo 1380 1381 !on fixe la valeur de la tache voisine minimun au point etudie (via label) 1382 table_out_marais(i,j)=label 1361 ! un des voisins est deja en glace 1362 mask(1) = table_out_marais(i-1,j) 1363 mask(2) = table_out_marais(i,j-1) 1364 label = label_max 1365 1366 ! on determine la valeur de la tache minimun (>0) presente ds le masque 1367 do indice=1,mask_nb 1368 if (mask(indice).gt.0) label=min(label,mask(indice)) 1369 enddo 1370 1371 ! on fixe la valeur de la tache voisine minimun au point etudie (via label) 1372 table_out_marais(i,j)=label 1383 1373 1384 !si un des voisins n'est pas glace alors la tache n'est pas un marais 1385 if ( (ice(i+1,j).eq.0) .or. (ice(i,j+1).eq.0) .or. (ice(i-1,j).eq.0) .or. (ice(i,j-1).eq.0) ) then 1386 marais(label)=.false. 1387 endif 1388 1389 ! si 2 taches differentes sont dans le masque, il faut les identifier dans compt 1390 ! i.e. les plus grands numeros correspondent au plus petit 1391 ! on lui affecte le numero de la tache fondamentale avec un signe - 1392 ! pour indiquer le changement 1393 1394 do indice=1,mask_nb 1395 if(mask(indice).gt.label) then 1396 compt_marais(mask(indice))=-label 1397 endif 1398 enddo 1399 1374 !si un des voisins n'est pas glace alors la tache n'est pas un marais 1375 if ( (ice(i+1,j).eq.0) .or. (ice(i,j+1).eq.0) .or. (ice(i-1,j).eq.0) .or. (ice(i,j-1).eq.0) ) then 1376 marais(label)=.false. 1377 endif 1378 1379 ! si 2 taches differentes sont dans le masque, il faut les identifier dans compt_marais 1380 ! on lui affecte le numero de la tache fondamentale 1381 1382 ! exemple on est sur le point X : 5 X 1383 do indice=1,mask_nb ! 20 1384 if(mask(indice).gt.label) then ! mask(2)=20 > 5 1385 compt_marais(mask(indice))=label ! compt_marais(20)=5 1386 if (.not.marais(mask(indice))) marais(label)=.false. ! si la tache n'etais pas un marais => marais =.false. marais(-(-5))=.false. 1387 where (table_out_marais(:,:).eq.mask(indice)) ! where table_out_marais(:,:)=mask(2)=20 1388 table_out_marais(:,:)=label ! table_out_marais(:,:)=label=5 1389 endwhere 1390 endif 1391 enddo 1400 1392 1401 1393 else !aucun des voisins est une tache 1402 1403 1394 table_out_marais(i,j)= label_max 1395 compt_marais(label_max)=label_max 1404 1396 1405 !si un des voisins n'est pas glace alors la tache n'est pas un marais 1406 if ( (ice(i+1,j).eq.0) .or. (ice(i,j+1).eq.0) .or. (ice(i-1,j).eq.0) .or. (ice(i,j-1).eq.0) ) then 1407 marais(label_max)=.false. 1408 endif 1409 1410 1411 label_max = label_max+1 1412 if (label_max.gt.n_ta_max) print*,'trop de taches=',label_max 1397 ! si un des voisins n'est pas glace alors la tache n'est pas un marais 1398 if ( (ice(i+1,j).eq.0) .or. (ice(i,j+1).eq.0) .or. (ice(i-1,j).eq.0) .or. (ice(i,j-1).eq.0) ) then 1399 marais(label_max)=.false. 1400 endif 1401 label_max = label_max+1 1402 if (label_max.gt.n_ta_max) print*,'ATTENTION trop de taches=',label_max 1413 1403 endif 1414 1415 1416 else !on est pas sur une tache---------------------------------------------- 1404 else ! on est pas sur une tache-------------------------------------------- 1417 1405 table_out_marais(i,j)=0 ! Pas necessaire (reecrit 0 sur 0) 1418 endif !--------------------------------------------------------------------- 1419 1420 1406 endif !--------------------------------------------------------------------- 1407 enddo 1421 1408 enddo 1422 enddo 1423 1424 marais(0)=.false. 1425 1426 ! On reorganise compt en ecrivant le numero de la tache fondamentale 1427 ! i.e. du plus petit numero present sur la tache (Sans utiliser de recursivité) 1428 ! On indique aussi le nb de point que contient chaque taches (nb_pts_tache) 1429 1430 do indice=1,label_max 1431 vartemp = compt_marais(indice) 1432 if (compt_marais(indice).lt.0) then 1433 compt_marais(indice)= compt_marais(-vartemp) 1434 if (.not.marais(indice)) marais(-vartemp)=.false. 1435 endif 1436 enddo 1437 1438 !$OMP PARALLEL 1439 !$OMP DO REDUCTION(+:nb_pts_marais) 1440 do j=1,ny 1441 do i=1,nx 1409 1410 marais(0)=.false. 1411 1412 !$OMP PARALLEL 1413 !$OMP DO 1414 do j=1,ny 1415 do i=1,nx 1442 1416 if (table_out_marais(i,j).ne.0) then 1443 table_out_marais(i,j)=compt_marais(table_out_marais(i,j)) 1444 nb_pts_marais(compt_marais(table_out_marais(i,j)))= nb_pts_marais(compt_marais(table_out_marais(i,j)))+1 1417 nb_pts_marais(compt_marais(table_out_marais(i,j)))= nb_pts_marais(compt_marais(table_out_marais(i,j)))+1 1445 1418 endif 1446 enddo1447 enddo1448 !$OMP END DO1449 !$OMP END PARALLEL1450 1451 do j=1,ny1452 do i=1,nx1453 1419 flot_marais(i,j) = marais(table_out_marais(i,j)) 1454 enddo 1455 enddo 1456 1457 debug_3D(:,:,122)=real(table_out_marais(:,:)) 1420 enddo 1421 enddo 1422 !$OMP END DO 1423 !$OMP END PARALLEL 1424 1425 debug_3D(:,:,122)=real(table_out_marais(:,:)) 1458 1426 1459 1427 end subroutine determin_marais
Note: See TracChangeset
for help on using the changeset viewer.