[1632] | 1 | module write_field_loc |
---|
| 2 | implicit none |
---|
| 3 | |
---|
| 4 | interface WriteField_u |
---|
| 5 | module procedure Write_field1d_u,Write_Field2d_u |
---|
| 6 | end interface WriteField_u |
---|
| 7 | |
---|
| 8 | interface WriteField_v |
---|
| 9 | module procedure Write_field1d_v,Write_Field2d_v |
---|
| 10 | end interface WriteField_v |
---|
| 11 | |
---|
| 12 | contains |
---|
| 13 | |
---|
| 14 | subroutine write_field1D_u(name,Field) |
---|
| 15 | character(len=*) :: name |
---|
| 16 | real, dimension(:) :: Field |
---|
| 17 | |
---|
| 18 | CALL write_field_u_gen(name,Field,1) |
---|
| 19 | |
---|
| 20 | end subroutine write_field1D_u |
---|
| 21 | |
---|
| 22 | subroutine write_field2D_u(name,Field) |
---|
| 23 | implicit none |
---|
| 24 | |
---|
| 25 | character(len=*) :: name |
---|
| 26 | real, dimension(:,:) :: Field |
---|
| 27 | integer :: ll |
---|
| 28 | |
---|
| 29 | ll=size(field,2) |
---|
| 30 | CALL write_field_u_gen(name,Field,ll) |
---|
| 31 | |
---|
| 32 | end subroutine write_field2D_u |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | SUBROUTINE write_field_u_gen(name,Field,ll) |
---|
[1823] | 36 | USE parallel_lmdz |
---|
[1632] | 37 | USE write_field |
---|
| 38 | USE mod_hallo |
---|
[5271] | 39 | USE dimensions_mod, ONLY: iim, jjm, llm, ndm |
---|
[5272] | 40 | USE paramet_mod_h, ONLY: iip1, iip2, iip3, jjp1, llmp1, llmp2, llmm1, kftd, ip1jm, ip1jmp1, & |
---|
| 41 | ip1jmi1, ijp1llm, ijmllm, mvar, jcfil, jcfllm |
---|
[5271] | 42 | implicit none |
---|
| 43 | |
---|
[5272] | 44 | |
---|
[1632] | 45 | |
---|
| 46 | character(len=*) :: name |
---|
| 47 | real, dimension(ijb_u:ije_u,ll) :: Field |
---|
| 48 | real, allocatable,SAVE :: New_Field(:,:,:) |
---|
| 49 | integer,dimension(0:mpi_size-1) :: jj_nb_master |
---|
[1848] | 50 | type(Request),SAVE :: Request_write |
---|
| 51 | !$OMP THREADPRIVATE(Request_write) |
---|
[1632] | 52 | integer :: ll,i |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | jj_nb_master(:)=0 |
---|
| 56 | jj_nb_master(0)=jjp1 |
---|
| 57 | !$OMP BARRIER |
---|
| 58 | !$OMP MASTER |
---|
| 59 | allocate(New_Field(iip1,jjp1,ll)) |
---|
| 60 | !$OMP END MASTER |
---|
| 61 | !$OMP BARRIER |
---|
| 62 | |
---|
| 63 | !$OMP DO SCHEDULE(STATIC,OMP_CHUNK) |
---|
| 64 | DO i=1,ll |
---|
| 65 | New_Field(:,jj_begin:jj_end,i)=reshape(Field(ij_begin:ij_end,i),(/iip1,jj_nb/)) |
---|
| 66 | ENDDO |
---|
[1848] | 67 | !$OMP BARRIER |
---|
[1632] | 68 | call Register_SwapField(new_field,new_field,ip1jmp1,ll,jj_Nb_master,Request_write) |
---|
| 69 | call SendRequest(Request_write) |
---|
| 70 | !$OMP BARRIER |
---|
| 71 | call WaitRequest(Request_write) |
---|
| 72 | !$OMP BARRIER |
---|
| 73 | |
---|
| 74 | !$OMP MASTER |
---|
| 75 | if (MPI_Rank==0) call WriteField(name,New_Field) |
---|
| 76 | DEALLOCATE(New_Field) |
---|
| 77 | !$OMP END MASTER |
---|
| 78 | !$OMP BARRIER |
---|
| 79 | END SUBROUTINE write_field_u_gen |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | subroutine write_field1D_v(name,Field) |
---|
| 83 | character(len=*) :: name |
---|
| 84 | real, dimension(:) :: Field |
---|
| 85 | |
---|
| 86 | CALL write_field_v_gen(name,Field,1) |
---|
| 87 | |
---|
| 88 | end subroutine write_field1D_v |
---|
| 89 | |
---|
| 90 | subroutine write_field2D_v(name,Field) |
---|
| 91 | implicit none |
---|
| 92 | |
---|
| 93 | character(len=*) :: name |
---|
| 94 | real, dimension(:,:) :: Field |
---|
| 95 | integer :: ll |
---|
| 96 | |
---|
| 97 | ll=size(field,2) |
---|
| 98 | CALL write_field_v_gen(name,Field,ll) |
---|
| 99 | |
---|
| 100 | end subroutine write_field2D_v |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | SUBROUTINE write_field_v_gen(name,Field,ll) |
---|
[1823] | 104 | USE parallel_lmdz |
---|
[1632] | 105 | USE write_field |
---|
| 106 | USE mod_hallo |
---|
[5271] | 107 | USE dimensions_mod, ONLY: iim, jjm, llm, ndm |
---|
[5272] | 108 | USE paramet_mod_h, ONLY: iip1, iip2, iip3, jjp1, llmp1, llmp2, llmm1, kftd, ip1jm, ip1jmp1, & |
---|
| 109 | ip1jmi1, ijp1llm, ijmllm, mvar, jcfil, jcfllm |
---|
[5271] | 110 | implicit none |
---|
| 111 | |
---|
[5272] | 112 | |
---|
[1632] | 113 | |
---|
| 114 | character(len=*) :: name |
---|
| 115 | real, dimension(ijb_v:ije_v,ll) :: Field |
---|
| 116 | real, allocatable,SAVE :: New_Field(:,:,:) |
---|
| 117 | integer,dimension(0:mpi_size-1) :: jj_nb_master |
---|
[1848] | 118 | type(Request),SAVE :: Request_write |
---|
| 119 | !$OMP THREADPRIVATE(Request_write) |
---|
[1632] | 120 | integer :: ll,i,jje,ije,jjn |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | jj_nb_master(:)=0 |
---|
| 124 | jj_nb_master(0)=jjp1 |
---|
| 125 | |
---|
| 126 | !$OMP BARRIER |
---|
| 127 | !$OMP MASTER |
---|
| 128 | allocate(New_Field(iip1,jjm,ll)) |
---|
| 129 | !$OMP END MASTER |
---|
| 130 | !$OMP BARRIER |
---|
| 131 | |
---|
| 132 | IF (pole_sud) THEN |
---|
| 133 | jje=jj_end-1 |
---|
| 134 | ije=ij_end-iip1 |
---|
| 135 | jjn=jj_nb-1 |
---|
| 136 | ELSE |
---|
| 137 | jje=jj_end |
---|
| 138 | ije=ij_end |
---|
| 139 | jjn=jj_nb |
---|
| 140 | ENDIF |
---|
| 141 | |
---|
| 142 | !$OMP DO SCHEDULE(STATIC,OMP_CHUNK) |
---|
| 143 | DO i=1,ll |
---|
| 144 | New_Field(:,jj_begin:jje,i)=reshape(Field(ij_begin:ije,i),(/iip1,jjn/)) |
---|
| 145 | ENDDO |
---|
[1848] | 146 | !$OMP BARRIER |
---|
[1632] | 147 | call Register_SwapField(new_field,new_field,ip1jm,ll,jj_Nb_master,Request_write) |
---|
| 148 | call SendRequest(Request_write) |
---|
| 149 | !$OMP BARRIER |
---|
| 150 | call WaitRequest(Request_write) |
---|
| 151 | !$OMP BARRIER |
---|
| 152 | |
---|
| 153 | !$OMP MASTER |
---|
| 154 | if (MPI_Rank==0) call WriteField(name,New_Field) |
---|
| 155 | DEALLOCATE(New_Field) |
---|
| 156 | !$OMP END MASTER |
---|
| 157 | !$OMP BARRIER |
---|
| 158 | END SUBROUTINE write_field_v_gen |
---|
| 159 | |
---|
| 160 | end module write_field_loc |
---|
| 161 | |
---|