!$Id: inca_write_field_p.F90 10 2007-08-09 12:43:01Z acosce $ !! ========================================================================= !! INCA - INteraction with Chemistry and Aerosols !! !! Copyright Laboratoire des Sciences du Climat et de l'Environnement (LSCE) !! Unite mixte CEA-CNRS-UVSQ !! !! Contributors to this INCA subroutine: !! !! !! Anne Cozic, LSCE, anne.cozic@cea.fr !! Yann Meurdesoif, LSCE, yann.meurdesoif@cea.fr !! !! This software is a computer program whose purpose is to simulate the !! atmospheric gas phase and aerosol composition. The model is designed to be !! used within a transport model or a general circulation model. This version !! of INCA was designed to be coupled to the LMDz GCM. LMDz-INCA accounts !! for emissions, transport (resolved and sub-grid scale), photochemical !! transformations, and scavenging (dry deposition and washout) of chemical !! species and aerosols interactively in the GCM. Several versions of the INCA !! model are currently used depending on the envisaged applications with the !! chemistry-climate model. !! !! This software is governed by the CeCILL license under French law and !! abiding by the rules of distribution of free software. You can use, !! modify and/ or redistribute the software under the terms of the CeCILL !! license as circulated by CEA, CNRS and INRIA at the following URL !! "http://www.cecill.info". !! !! As a counterpart to the access to the source code and rights to copy, !! modify and redistribute granted by the license, users are provided only !! with a limited warranty and the software's author, the holder of the !! economic rights, and the successive licensors have only limited !! liability. !! !! In this respect, the user's attention is drawn to the risks associated !! with loading, using, modifying and/or developing or reproducing the !! software by the user in light of its specific status of free software, !! that may mean that it is complicated to manipulate, and that also !! therefore means that it is reserved for developers and experienced !! professionals having in-depth computer knowledge. Users are therefore !! encouraged to load and test the software's suitability as regards their !! requirements in conditions enabling the security of their systems and/or !! data to be ensured and, more generally, to use and operate it in the !! same conditions as regards security. !! !! The fact that you are presently reading this means that you have had !! knowledge of the CeCILL license and that you accept its terms. !! ========================================================================= MODULE inca_Write_field_p INTERFACE WriteField_p MODULE PROCEDURE WriteField_1d_p,WriteField_2d_p, WriteField_3d_p END INTERFACE INTERFACE WriteFieldI_p MODULE PROCEDURE WriteFieldI_2d_p END INTERFACE CONTAINS SUBROUTINE INIT_WRITEFIELD_P(index) USE MOD_INCA_PARA USE inca_Write_Field, ONLY : Init_WriteField IMPLICIT NONE INTEGER,INTENT(in) :: INDEX(nbp_loc) INTEGER :: index_p(nbp_loc) INTEGER :: index_g(nbp_glo) index_p(:)=INDEX(:)+(jj_begin-1)*iim_g CALL gather(index_p,index_g) !$OMP MASTER IF (is_mpi_root) CALL Init_WriteField(iim_g,jjm_g,nbp_glo,index_g) !$OMP END MASTER END SUBROUTINE init_WriteField_p SUBROUTINE WriteField_1d_p(name,Field) USE INCA_DIM USE MOD_INCA_PARA USE MOD_GRID_INCA USE INCA_WRITE_FIELD, ONLY : WriteField IMPLICIT NONE CHARACTER(len=*) :: name INTEGER :: ll REAL, DIMENSION(plon_omp) :: Field REAL,SAVE,ALLOCATABLE :: Field_tmp(:,:) REAL, DIMENSION(plon_glo):: New_Field REAL, DIMENSION(iim_glo,jjm_glo):: Field_2d CALL Gather(Field,New_Field) !$OMP MASTER IF (is_mpi_root) THEN CALL Grid1Dto2D_glo(New_Field,Field_2D) CALL WriteField(name,Field_2d) ENDIF !$OMP END MASTER !$OMP BARRIER END SUBROUTINE WriteField_1d_p !------------------------------------------------ SUBROUTINE WriteField_2d_p(name,Field,ll) USE INCA_DIM USE MOD_INCA_PARA USE MOD_GRID_INCA USE INCA_WRITE_FIELD, ONLY : WriteField IMPLICIT NONE CHARACTER(len=*) :: name INTEGER :: ll REAL, DIMENSION(plon_omp,ll) :: Field REAL,SAVE,ALLOCATABLE :: Field_tmp(:,:) REAL, DIMENSION(plon_glo,ll):: New_Field REAL, DIMENSION(iim_glo,jjm_glo,ll):: Field_2d CALL Gather(Field,New_Field) !$OMP MASTER IF (is_mpi_root) THEN CALL Grid1Dto2D_glo(New_Field,Field_2D) CALL WriteField(name,Field_2d) ENDIF !$OMP END MASTER !$OMP BARRIER END SUBROUTINE WriteField_2d_p !------------------------------------------------ !------------------------------------------------ SUBROUTINE WriteField_3d_p(name,Field,ll,mm) USE INCA_DIM USE MOD_INCA_PARA USE MOD_GRID_INCA USE inca_Write_field, ONLY : WriteField IMPLICIT NONE CHARACTER(len=*) :: name INTEGER :: ll, mm, m REAL, DIMENSION(plon_omp,ll,mm) :: Field REAL, DIMENSION(plon_glo,ll,mm):: New_Field REAL, DIMENSION(iim_glo,jjm_glo,ll,mm):: Field_2d REAL, DIMENSION(plon_omp,ll) :: Field_tmp REAL, DIMENSION(plon_glo,ll):: New_Field_tmp DO m= 1, mm Field_tmp(:,:) = Field(:,:,m) CALL Gather(Field_tmp,New_Field_tmp) New_Field(:,:,m) = New_Field_tmp(:,:) ENDDO !$OMP MASTER IF (is_mpi_root) THEN DO m= 1, mm CALL Grid1Dto2D_glo(New_Field(:,:,m),Field_2D(:,:,:,m)) ENDDO CALL WriteField(name,Field_2d) ENDIF !$OMP END MASTER !$OMP BARRIER END SUBROUTINE WriteField_3d_p !------------------------------------------------ SUBROUTINE WriteFieldI_2d_p(name,Field) USE MOD_INCA_PARA USE inca_Write_field, ONLY : WriteFieldI IMPLICIT NONE CHARACTER(len=*) :: name REAL, DIMENSION(:,:) :: Field INTEGER, DIMENSION(2) :: Dim REAL, ALLOCATABLE, DIMENSION(:,:) :: Field_g Dim=SHAPE(Field) ALLOCATE(Field_g(nbp_glo,DIM(2))) CALL gather(Field,Field_g) !$OMP MASTER IF (is_mpi_root) CALL WriteFieldI(name,Field_g) !$OMP END MASTER DEALLOCATE(Field_g) END SUBROUTINE WriteFieldI_2d_p function int2str(int) implicit none integer, parameter :: MaxLen=10 integer,intent(in) :: int character(len=MaxLen) :: int2str logical :: flag integer :: i flag=.true. i=int int2str='' do while (flag) int2str=CHAR(MOD(i,10)+48)//int2str i=i/10 if (i==0) flag=.false. enddo end function int2str END MODULE inca_Write_field_p