Changeset 953 for codes/icosagcm/trunk/src/dissip
- Timestamp:
- 07/15/19 12:29:31 (5 years ago)
- Location:
- codes/icosagcm/trunk/src/dissip
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/trunk/src/dissip/dissip_gcm.F90
r933 r953 1 1 MODULE dissip_gcm_mod 2 2 USE icosa 3 3 USE abort_mod 4 4 PRIVATE 5 5 … … 48 48 USE icosa 49 49 IMPLICIT NONE 50 CALL allocate_field(f_due_diss1,field_u,type_real,llm )51 CALL allocate_field(f_due_diss2,field_u,type_real,llm )50 CALL allocate_field(f_due_diss1,field_u,type_real,llm,ondevice=.TRUE.) 51 CALL allocate_field(f_due_diss2,field_u,type_real,llm,ondevice=.TRUE.) 52 52 CALL allocate_field(f_dtheta_diss,field_t,type_real,llm) 53 CALL allocate_field(f_dtheta_rhodz_diss,field_t,type_real,llm )53 CALL allocate_field(f_dtheta_rhodz_diss,field_t,type_real,llm,ondevice=.TRUE.) 54 54 ALLOCATE(tau_graddiv(llm)) 55 55 ALLOCATE(tau_gradrot(llm)) 56 56 ALLOCATE(tau_divgrad(llm)) 57 !$acc enter data create(tau_graddiv(:),tau_gradrot(:),tau_divgrad(:)) async 57 58 END SUBROUTINE allocate_dissip 58 59 … … 66 67 USE transfert_omp_mod 67 68 USE omp_para 69 USE abort_mod 68 70 IMPLICIT NONE 69 71 … … 98 100 IF (is_master) PRINT *, 'No Rayleigh friction' 99 101 CASE('dcmip2_schaer_noshear') 102 CALL abort_acc("rayleigh_friction_type /= 'none'") 100 103 rayleigh_friction_type=1 101 104 rayleigh_shear=0 102 105 IF (is_master) PRINT *, 'Rayleigh friction : Schaer-like mountain without shear DCMIP2.1' 103 106 CASE('dcmip2_schaer_shear') 107 CALL abort_acc("rayleigh_friction_type /= 'none'") 104 108 rayleigh_shear=1 105 109 rayleigh_friction_type=2 106 110 IF (is_master) PRINT *, 'Rayleigh friction : Schaer-like mountain with shear DCMIP2.2' 107 111 CASE('giant_liu_schneider') 112 CALL abort_acc("rayleigh_friction_type /= 'none'") 108 113 rayleigh_friction_type=99 109 114 IF (is_master) PRINT *, 'Rayleigh friction : giant planets Liu Schneider 2010' … … 130 135 131 136 CALL allocate_dissip 132 CALL allocate_field(f_u,field_u,type_real )133 CALL allocate_field(f_du,field_u,type_real )134 CALL allocate_field(f_theta,field_t,type_real )135 CALL allocate_field(f_dtheta,field_t,type_real )137 CALL allocate_field(f_u,field_u,type_real,ondevice=.TRUE.) 138 CALL allocate_field(f_du,field_u,type_real,ondevice=.TRUE.) 139 CALL allocate_field(f_theta,field_t,type_real,ondevice=.TRUE.) 140 CALL allocate_field(f_dtheta,field_t,type_real,ondevice=.TRUE.) 136 141 137 142 CALL init_message(f_due_diss1,req_e1_vect,req_due) … … 173 178 CALL RANDOM_SEED(put=(/(i,i=1,M)/)) 174 179 180 ! This cannot be ported on GPU due to compiler limitations 175 181 DO j=jj_begin,jj_end 176 182 DO i=ii_begin,ii_end … … 192 198 dumax=0 193 199 DO iter=1,nitergdiv 200 CALL update_device_field(f_u) 194 201 CALL transfert_request(f_u,req_e1_vect) 202 195 203 DO ind=1,ndomain 196 204 IF (.NOT. assigned_domain(ind) .OR. .NOT. is_omp_level_master) CYCLE … … 200 208 du=f_du(ind) 201 209 CALL compute_gradiv_inplace(u,1,1) 210 ! This should be ported on GPU but we are running into compiler issues... 211 !$acc update host(u(:)) wait 202 212 du=u 203 213 ENDDO 204 214 ENDDO 205 215 216 CALL update_device_field(f_du) 206 217 CALL transfert_request(f_du,req_e1_vect) 207 218 CALL update_host_field(f_du) 219 208 220 DO ind=1,ndomain 209 221 IF (.NOT. assigned_domain(ind) .OR. .NOT. is_omp_level_master) CYCLE 210 222 CALL swap_dimensions(ind) 211 223 CALL swap_geometry(ind) 212 u=f_u(ind)213 224 du=f_du(ind) 214 225 226 ! Not ported on GPU because all the other kernels cannot be ported 215 227 DO j=jj_begin,jj_end 216 228 DO i=ii_begin,ii_end … … 240 252 u=f_u(ind) 241 253 du=f_du(ind) 254 ! This should be ported on GPU but we are running into compiler issues... 242 255 u=du/dumax 243 256 ENDDO … … 265 278 CALL RANDOM_SEED(put=(/(i,i=1,M)/)) 266 279 280 ! This cannot be ported on GPU due to compiler limitations 267 281 DO j=jj_begin,jj_end 268 282 DO i=ii_begin,ii_end … … 280 294 !$OMP BARRIER 281 295 282 283 296 DO it=1,20 284 297 285 298 dumax=0 286 299 DO iter=1,nitergrot 300 CALL update_device_field(f_u) 287 301 CALL transfert_request(f_u,req_e1_vect) 288 302 DO ind=1,ndomain … … 293 307 du=f_du(ind) 294 308 CALL compute_gradrot_inplace(u,1,1) 309 ! This should be ported on GPU but we are running into compiler issues... 310 !$acc update host(u(:)) wait 295 311 du=u 296 312 ENDDO 297 313 ENDDO 298 314 315 CALL update_device_field(f_du) 299 316 CALL transfert_request(f_du,req_e1_vect) 317 CALL update_host_field(f_du) 300 318 301 319 DO ind=1,ndomain … … 303 321 CALL swap_dimensions(ind) 304 322 CALL swap_geometry(ind) 305 u=f_u(ind)306 323 du=f_du(ind) 307 324 325 ! Not ported on GPU because all the other kernels cannot be ported 308 326 DO j=jj_begin,jj_end 309 327 DO i=ii_begin,ii_end … … 334 352 u=f_u(ind) 335 353 du=f_du(ind) 354 ! This should be ported on GPU but we are running into compiler issues... 336 355 u=du/dumax 337 356 ENDDO … … 358 377 CALL RANDOM_SEED(put=(/(i,i=1,M)/)) 359 378 379 ! This cannot be ported on GPU due to compiler limitations 360 380 DO j=jj_begin,jj_end 361 381 DO i=ii_begin,ii_end … … 373 393 dthetamax=0 374 394 DO iter=1,niterdivgrad 395 CALL update_device_field(f_theta) 375 396 CALL transfert_request(f_theta,req_i1) 376 397 DO ind=1,ndomain … … 381 402 dtheta=f_dtheta(ind) 382 403 CALL compute_divgrad_inplace(theta,1,1) 404 ! This should be ported on GPU but we are running into compiler issues... 405 !$acc update host(theta(:)) wait 383 406 dtheta=theta 384 407 ENDDO 385 408 ENDDO 386 409 410 CALL update_device_field(f_dtheta) 387 411 CALL transfert_request(f_dtheta,req_i1) 412 CALL update_host_field(f_dtheta) 388 413 389 414 DO ind=1,ndomain … … 391 416 CALL swap_dimensions(ind) 392 417 CALL swap_geometry(ind) 393 theta=f_theta(ind)394 418 dtheta=f_dtheta(ind) 395 419 420 ! Not ported on GPU because all the other kernels cannot be ported 396 421 DO j=jj_begin,jj_end 397 422 DO i=ii_begin,ii_end … … 421 446 theta=f_theta(ind) 422 447 dtheta=f_dtheta(ind) 448 ! This should be ported on GPU but we are running into compiler issues... 423 449 theta=dtheta/dthetamax 424 450 ENDDO … … 489 515 ENDIF 490 516 517 !$acc update device(tau_graddiv(:),tau_gradrot(:),tau_divgrad(:)) async 518 491 519 END SUBROUTINE init_dissip 492 520 … … 501 529 USE time_mod 502 530 USE omp_para 531 USE abort_mod 503 532 IMPLICIT NONE 504 533 TYPE(t_field),POINTER :: f_ps(:), f_mass(:), f_phis(:), f_geopot(:) … … 534 563 dtheta_rhodz_diss=f_dtheta_rhodz_diss(ind) 535 564 565 !$acc parallel loop collapse(2) present(due(:,:), dtheta_rhodz(:,:,:), due_diss1(:,:), due_diss2(:,:), dtheta_rhodz_diss(:,:), tau_graddiv(:), tau_gradrot(:), tau_divgrad(:)) async 536 566 DO l=ll_begin,ll_end 537 567 !DIR$ SIMD … … 545 575 ENDDO 546 576 ENDDO 577 !$acc end parallel loop 547 578 548 579 ! dtheta_rhodz=0 … … 550 581 551 582 IF(rayleigh_friction_type>0) THEN 583 CALL abort_acc("dissip/rayleigh_friction_type>0") 552 584 IF(rayleigh_friction_type<99) THEN 553 585 phi=f_geopot(ind) … … 562 594 ELSE 563 595 ue=f_ue(ind) 596 !$acc parallel loop present(ue(:,:), due(:,:), lat_e(:)) 564 597 DO ij=ij_begin,ij_end 565 598 nn = ij+u_right … … 577 610 ENDIF 578 611 ENDDO 612 !$acc end parallel loop 579 613 ENDIF 580 614 END IF 581 615 END DO 582 583 616 CALL trace_end("dissip") 584 617 585 !CALL write_dissip_tendencies618 !CALL write_dissip_tendencies 586 619 !$OMP BARRIER 587 620 … … 653 686 ue=f_ue(ind) 654 687 due=f_due(ind) 688 !$acc parallel loop present(ue(:,:), due(:,:)) async 655 689 DO l = ll_begin, ll_end 690 !$acc loop 656 691 !DIR$ SIMD 657 692 DO ij=ij_begin,ij_end … … 664 699 665 700 DO it=1,nitergdiv 666 667 701 CALL send_message(f_due,req_due) 668 702 CALL wait_message(req_due) 669 703 670 704 DO ind=1,ndomain 671 705 IF (.NOT. assigned_domain(ind)) CYCLE 672 706 CALL swap_dimensions(ind) 673 707 CALL swap_geometry(ind) 674 due=f_due(ind) 708 due=f_due(ind) 675 709 CALL compute_gradiv_inplace(due,ll_begin,ll_end) 676 710 ENDDO … … 702 736 ue=f_ue(ind) 703 737 due=f_due(ind) 738 !$acc parallel loop present(ue(:,:), due(:,:)) async 704 739 DO l = ll_begin, ll_end 740 !$acc loop 705 741 !DIR$ SIMD 706 742 DO ij=ij_begin,ij_end … … 713 749 714 750 DO it=1,nitergrot 715 716 751 CALL send_message(f_due,req_due) 717 752 CALL wait_message(req_due) … … 740 775 REAL(rstd),POINTER :: theta(:,:) 741 776 REAL(rstd),POINTER :: dtheta(:,:) 742 INTEGER :: ind 777 INTEGER :: ind, l, ij 743 778 INTEGER :: it 744 779 … … 751 786 theta=f_theta(ind) 752 787 dtheta=f_dtheta(ind) 753 dtheta=theta 788 ! Replace Fortran 90 construct dtheta=theta because it confuses PGI acc kernels... 789 !$acc parallel loop collapse(2) present(theta(:,:), dtheta(:,:)) async 790 DO l=ll_begin,ll_end 791 !DIR$ SIMD 792 DO ij=1,iim*jjm 793 dtheta(ij,l)=theta(ij,l) 794 ENDDO 795 ENDDO 796 !$acc end parallel loop 754 797 ENDDO 755 798 756 799 DO it=1,niterdivgrad 757 758 800 CALL transfert_request(f_dtheta,req_i1) 759 801 … … 797 839 theta_rhodz=f_theta_rhodz(ind) 798 840 dtheta_rhodz=f_dtheta_rhodz(ind) 841 !$acc parallel loop present(mass(:,:), theta_rhodz(:,:,:), dtheta_rhodz(:,:)) async 799 842 DO l = ll_begin, ll_end 843 !$acc loop 800 844 !DIR$ SIMD 801 845 DO ij=ij_begin,ij_end … … 806 850 807 851 DO it=1,niterdivgrad 808 809 852 CALL send_message(f_dtheta_rhodz,req_dtheta) 810 853 CALL wait_message(req_dtheta) … … 826 869 mass=f_mass(ind) 827 870 871 !$acc parallel loop collapse(2) present(mass(:,:), dtheta_rhodz(:,:)) async 828 872 DO l = ll_begin, ll_end 829 873 !DIR$ SIMD … … 832 876 ENDDO 833 877 ENDDO 878 !$acc end parallel loop 834 879 ENDDO 835 880 … … 837 882 CALL trace_end("divgrad") 838 883 839 END SUBROUTINE divgrad_theta_rhodz 840 884 END SUBROUTINE divgrad_theta_rhodz 885 841 886 SUBROUTINE compute_gradiv(ue,gradivu_e,llb,lle) 842 USE icosa843 IMPLICIT NONE844 887 INTEGER,INTENT(IN) :: llb 845 888 INTEGER,INTENT(IN) :: lle 889 REAL(rstd),INTENT(OUT) :: gradivu_e(iim*3*jjm,llm) 846 890 REAL(rstd),INTENT(IN) :: ue(iim*3*jjm,llm) 847 REAL(rstd),INTENT(OUT) :: gradivu_e(iim*3*jjm,llm) 848 891 849 892 gradivu_e = ue 850 CALL compute_gradiv_inplace(gradivu_e, llb, lle) 893 CALL compute_gradiv_inplace(gradivu_e,llb,lle) 894 851 895 END SUBROUTINE compute_gradiv 852 896 853 897 SUBROUTINE compute_gradiv_inplace(ue_gradivu_e,llb,lle) 854 USE icosa 855 IMPLICIT NONE 898 USE geometry, ONLY : Ai, ne, le, de 856 899 INTEGER,INTENT(IN) :: llb 857 900 INTEGER,INTENT(IN) :: lle … … 861 904 INTEGER :: ij,l 862 905 906 ! ue and gradivu_e second dimension is not always llm so use the bounds explicitly 907 !$acc data present( ue_gradivu_e(:,llb:lle), Ai(:), ne(:,:), le(:), de(:)) create(divu_i(:,:)) async 908 909 !$acc parallel loop collapse(2) async 863 910 DO l=llb,lle 864 911 !DIR$ SIMD … … 872 919 ENDDO 873 920 ENDDO 921 !$acc end parallel loop 874 922 923 !$acc parallel loop collapse(2) async 875 924 DO l=llb,lle 876 925 !DIR$ SIMD … … 881 930 ENDDO 882 931 ENDDO 883 932 !$acc end parallel loop 933 934 !$acc parallel loop collapse(2) async 884 935 DO l=llb,lle 885 936 !DIR$ SIMD … … 889 940 ue_gradivu_e(ij+u_ldown,l)=-ue_gradivu_e(ij+u_ldown,l)*cgraddiv 890 941 ENDDO 891 ENDDO 942 ENDDO 943 !$acc end parallel loop 944 !$acc end data 892 945 END SUBROUTINE compute_gradiv_inplace 893 946 894 947 SUBROUTINE compute_divgrad(theta,divgrad_i,llb,lle) 895 USE icosa896 IMPLICIT NONE897 948 INTEGER,INTENT(IN) :: llb 898 949 INTEGER,INTENT(IN) :: lle 899 950 REAL(rstd),INTENT(IN) :: theta(iim*jjm,1:lle) 900 951 REAL(rstd),INTENT(OUT) :: divgrad_i(iim*jjm,1:lle) 901 952 902 953 divgrad_i = theta 903 CALL compute_divgrad_inplace(divgrad_i, llb,lle)904 END SUBROUTINE 954 CALL compute_divgrad_inplace(divgrad_i,llb,lle) 955 END SUBROUTINE compute_divgrad 905 956 906 957 SUBROUTINE compute_divgrad_inplace(theta_divgrad_i,llb,lle) 907 USE icosa 908 IMPLICIT NONE 958 USE geometry, ONLY : Ai, ne, le, de 909 959 INTEGER,INTENT(IN) :: llb 910 960 INTEGER,INTENT(IN) :: lle … … 912 962 REAL(rstd) :: grad_e(3*iim*jjm,llb:lle) 913 963 914 INTEGER :: ij,l 964 INTEGER :: ij,l 965 966 ! theta and divgrad_i second dimension is not always llm so use the bounds explicitly 967 !$acc data present(theta_divgrad_i(:,llb:lle), Ai(:), de(:), ne(:,:), le(:)) create(grad_e(:,:)) async 968 969 !$acc parallel loop collapse(2) async 915 970 DO l=llb,lle 916 971 !DIR$ SIMD … … 920 975 grad_e(ij+u_ldown,l)=-1/de(ij+u_ldown)*(ne(ij,ldown)*theta_divgrad_i(ij,l)+ne(ij+t_ldown,rup)*theta_divgrad_i(ij+t_ldown,l) ) 921 976 ENDDO 922 ENDDO 977 ENDDO 978 !$acc end parallel loop 923 979 980 981 !$acc parallel loop collapse(2) async 924 982 DO l=llb,lle 925 983 !DIR$ SIMD … … 933 991 ENDDO 934 992 ENDDO 993 !$acc end parallel loop 935 994 995 !$acc parallel loop collapse(2) async 936 996 DO l=llb,lle 937 997 DO ij=ij_begin,ij_end … … 939 999 ENDDO 940 1000 ENDDO 1001 !$acc end parallel loop 1002 !$acc end data 941 1003 END SUBROUTINE compute_divgrad_inplace 942 1004 … … 946 1008 REAL(rstd),INTENT(IN) :: ue(iim*3*jjm,lle) 947 1009 REAL(rstd),INTENT(OUT) :: gradrot_e(iim*3*jjm,lle) 948 1010 949 1011 gradrot_e = ue 950 1012 CALL compute_gradrot_inplace(gradrot_e,llb,lle) 951 END SUBROUTINE 952 1013 END SUBROUTINE compute_gradrot 1014 953 1015 SUBROUTINE compute_gradrot_inplace(ue_gradrot_e,llb,lle) 954 USE icosa 955 IMPLICIT NONE 1016 USE geometry, ONLY : Av, ne, le, de 956 1017 INTEGER,INTENT(IN) :: llb 957 1018 INTEGER,INTENT(IN) :: lle … … 961 1022 INTEGER :: ij,l 962 1023 1024 ! ue and gradrot_e second dimension is not always llm so use the bounds explicitly 1025 ! gradrot_e should be copyout but using copy instead allows to compare the output 1026 ! more easily as the code sometimes uses unintialed values 1027 !$acc data present(ue_gradrot_e(:,llb:lle), Av(:), ne(:,:), de(:), le(:)) create(rot_v(:,:)) async 1028 1029 !$acc parallel loop collapse(2) async 963 1030 DO l=llb,lle 964 1031 !DIR$ SIMD … … 972 1039 ENDDO 973 1040 ENDDO 974 1041 !$acc end parallel loop 1042 1043 !$acc parallel loop collapse(2) async 975 1044 DO l=llb,lle 976 1045 !DIR$ SIMD … … 981 1050 ENDDO 982 1051 ENDDO 983 1052 !$acc end parallel loop 1053 1054 !$acc parallel loop collapse(2) async 984 1055 DO l=llb,lle 985 1056 !DIR$ SIMD … … 989 1060 ue_gradrot_e(ij+u_ldown,l)=-ue_gradrot_e(ij+u_ldown,l)*cgradrot 990 1061 ENDDO 991 ENDDO 1062 ENDDO 1063 !$acc end parallel loop 1064 !$acc end data 992 1065 END SUBROUTINE compute_gradrot_inplace 993 1066 994 1067 995 1068 END MODULE dissip_gcm_mod 996 -
codes/icosagcm/trunk/src/dissip/sponge.f90
r548 r953 24 24 USE omp_para 25 25 USE mpipara, ONLY: is_mpi_master 26 USE abort_mod 26 27 IMPLICIT NONE 27 28 INTEGER :: l … … 43 44 RETURN 44 45 ENDIF 46 47 IF (iflag_sponge > 0) THEN 48 CALL abort_acc("iflag_sponge > 0") 49 END IF 45 50 46 51 !$OMP MASTER
Note: See TracChangeset
for help on using the changeset viewer.