source: CONFIG/publications/ICOLMDZORINCA_CO2_Transport_GMD_2023/INCA/src/INCA_PARA/inca_write_field_p.F90 @ 6610

Last change on this file since 6610 was 6610, checked in by acosce, 10 months ago

INCA used for ICOLMDZORINCA_CO2_Transport_GMD_2023

File size: 6.5 KB
Line 
1!$Id: inca_write_field_p.F90 10 2007-08-09 12:43:01Z acosce $
2!! =========================================================================
3!! INCA - INteraction with Chemistry and Aerosols
4!!
5!! Copyright Laboratoire des Sciences du Climat et de l'Environnement (LSCE)
6!!           Unite mixte CEA-CNRS-UVSQ
7!!
8!! Contributors to this INCA subroutine:
9!!
10!!
11!! Anne Cozic, LSCE, anne.cozic@cea.fr
12!! Yann Meurdesoif, LSCE, yann.meurdesoif@cea.fr
13!!
14!! This software is a computer program whose purpose is to simulate the
15!! atmospheric gas phase and aerosol composition. The model is designed to be
16!! used within a transport model or a general circulation model. This version
17!! of INCA was designed to be coupled to the LMDz GCM. LMDz-INCA accounts
18!! for emissions, transport (resolved and sub-grid scale), photochemical
19!! transformations, and scavenging (dry deposition and washout) of chemical
20!! species and aerosols interactively in the GCM. Several versions of the INCA
21!! model are currently used depending on the envisaged applications with the
22!! chemistry-climate model.
23!!
24!! This software is governed by the CeCILL  license under French law and
25!! abiding by the rules of distribution of free software.  You can  use,
26!! modify and/ or redistribute the software under the terms of the CeCILL
27!! license as circulated by CEA, CNRS and INRIA at the following URL
28!! "http://www.cecill.info".
29!!
30!! As a counterpart to the access to the source code and  rights to copy,
31!! modify and redistribute granted by the license, users are provided only
32!! with a limited warranty  and the software's author,  the holder of the
33!! economic rights,  and the successive licensors  have only  limited
34!! liability.
35!!
36!! In this respect, the user's attention is drawn to the risks associated
37!! with loading,  using,  modifying and/or developing or reproducing the
38!! software by the user in light of its specific status of free software,
39!! that may mean  that it is complicated to manipulate,  and  that  also
40!! therefore means  that it is reserved for developers  and  experienced
41!! professionals having in-depth computer knowledge. Users are therefore
42!! encouraged to load and test the software's suitability as regards their
43!! requirements in conditions enabling the security of their systems and/or
44!! data to be ensured and,  more generally, to use and operate it in the
45!! same conditions as regards security.
46!!
47!! The fact that you are presently reading this means that you have had
48!! knowledge of the CeCILL license and that you accept its terms.
49!! =========================================================================
50
51MODULE inca_Write_field_p
52
53  INTERFACE WriteField_p
54    MODULE PROCEDURE WriteField_1d_p,WriteField_2d_p, WriteField_3d_p
55  END INTERFACE
56 
57  INTERFACE WriteFieldI_p
58    MODULE PROCEDURE WriteFieldI_2d_p
59  END INTERFACE
60 
61 
62CONTAINS
63
64  SUBROUTINE INIT_WRITEFIELD_P(index)
65    USE MOD_INCA_PARA
66    USE inca_Write_Field, ONLY : Init_WriteField
67    IMPLICIT NONE
68    INTEGER,INTENT(in) :: INDEX(nbp_loc)
69   
70    INTEGER :: index_p(nbp_loc)
71    INTEGER :: index_g(nbp_glo)
72   
73    index_p(:)=INDEX(:)+(jj_begin-1)*iim_g
74    CALL gather(index_p,index_g)
75   
76!$OMP MASTER
77    IF (is_mpi_root) CALL Init_WriteField(iim_g,jjm_g,nbp_glo,index_g)
78!$OMP END MASTER
79   
80  END SUBROUTINE init_WriteField_p
81
82
83  SUBROUTINE WriteField_1d_p(name,Field)
84
85    USE INCA_DIM
86    USE MOD_INCA_PARA
87    USE MOD_GRID_INCA
88    USE INCA_WRITE_FIELD, ONLY : WriteField
89   
90    IMPLICIT NONE
91
92    CHARACTER(len=*)   :: name
93    INTEGER :: ll
94    REAL, DIMENSION(plon_omp) :: Field
95    REAL,SAVE,ALLOCATABLE :: Field_tmp(:,:)
96    REAL, DIMENSION(plon_glo):: New_Field
97    REAL, DIMENSION(iim_glo,jjm_glo):: Field_2d
98
99    CALL Gather(Field,New_Field)
100!$OMP MASTER
101    IF (is_mpi_root) THEN       
102      CALL Grid1Dto2D_glo(New_Field,Field_2D)
103      CALL WriteField(name,Field_2d)
104    ENDIF
105!$OMP END MASTER
106!$OMP BARRIER
107
108
109  END SUBROUTINE WriteField_1d_p
110
111!------------------------------------------------
112
113  SUBROUTINE WriteField_2d_p(name,Field,ll)
114
115    USE INCA_DIM
116    USE MOD_INCA_PARA
117    USE MOD_GRID_INCA
118    USE INCA_WRITE_FIELD, ONLY : WriteField
119   
120    IMPLICIT NONE
121
122    CHARACTER(len=*)   :: name
123    INTEGER :: ll
124    REAL, DIMENSION(plon_omp,ll) :: Field
125    REAL,SAVE,ALLOCATABLE :: Field_tmp(:,:)
126    REAL, DIMENSION(plon_glo,ll):: New_Field
127    REAL, DIMENSION(iim_glo,jjm_glo,ll):: Field_2d
128
129    CALL Gather(Field,New_Field)
130!$OMP MASTER
131    IF (is_mpi_root) THEN       
132      CALL Grid1Dto2D_glo(New_Field,Field_2D)
133      CALL WriteField(name,Field_2d)
134    ENDIF
135!$OMP END MASTER
136!$OMP BARRIER
137
138
139  END SUBROUTINE WriteField_2d_p
140
141!------------------------------------------------
142!------------------------------------------------
143
144  SUBROUTINE WriteField_3d_p(name,Field,ll,mm)
145   
146    USE INCA_DIM
147    USE MOD_INCA_PARA
148    USE MOD_GRID_INCA
149    USE inca_Write_field, ONLY : WriteField
150   
151    IMPLICIT NONE
152
153    CHARACTER(len=*)   :: name
154    INTEGER :: ll, mm, m
155    REAL, DIMENSION(plon_omp,ll,mm) :: Field
156    REAL, DIMENSION(plon_glo,ll,mm):: New_Field
157    REAL, DIMENSION(iim_glo,jjm_glo,ll,mm):: Field_2d
158    REAL, DIMENSION(plon_omp,ll) :: Field_tmp
159    REAL, DIMENSION(plon_glo,ll):: New_Field_tmp
160
161    DO m= 1, mm
162       Field_tmp(:,:) = Field(:,:,m)
163       CALL Gather(Field_tmp,New_Field_tmp)
164       New_Field(:,:,m) = New_Field_tmp(:,:)
165    ENDDO
166!$OMP MASTER
167    IF (is_mpi_root) THEN       
168       DO m= 1, mm
169          CALL Grid1Dto2D_glo(New_Field(:,:,m),Field_2D(:,:,:,m))
170       ENDDO
171       CALL WriteField(name,Field_2d)
172    ENDIF
173!$OMP END MASTER
174!$OMP BARRIER
175
176  END SUBROUTINE WriteField_3d_p
177 
178!------------------------------------------------
179
180  SUBROUTINE WriteFieldI_2d_p(name,Field)
181    USE MOD_INCA_PARA
182    USE inca_Write_field, ONLY : WriteFieldI
183    IMPLICIT NONE
184    CHARACTER(len=*) :: name
185    REAL, DIMENSION(:,:) :: Field 
186    INTEGER, DIMENSION(2) :: Dim
187   
188    REAL, ALLOCATABLE, DIMENSION(:,:) :: Field_g
189     
190    Dim=SHAPE(Field)
191     
192    ALLOCATE(Field_g(nbp_glo,DIM(2)))
193    CALL gather(Field,Field_g)
194   
195!$OMP MASTER
196    IF (is_mpi_root) CALL WriteFieldI(name,Field_g) 
197!$OMP END MASTER
198     
199    DEALLOCATE(Field_g)
200  END SUBROUTINE WriteFieldI_2d_p
201
202  function int2str(int)
203    implicit none
204    integer, parameter :: MaxLen=10
205    integer,intent(in) :: int
206    character(len=MaxLen) :: int2str
207    logical :: flag
208    integer :: i
209    flag=.true.
210   
211    i=int
212   
213    int2str=''
214    do while (flag)
215      int2str=CHAR(MOD(i,10)+48)//int2str
216      i=i/10
217      if (i==0) flag=.false.
218    enddo
219  end function int2str
220
221
222END MODULE inca_Write_field_p
223
224
225
Note: See TracBrowser for help on using the repository browser.