source: codes/icosagcm/trunk/src/output/write_etat0.f90 @ 1013

Last change on this file since 1013 was 1013, checked in by ymipsl, 4 years ago

1j+1j=2j : (x / r) * r /= x due to rounding error. So at restart a run did not have exactly the same metric than the previous run.

YM

File size: 2.6 KB
Line 
1MODULE write_etat0_mod
2
3
4
5CONTAINS
6
7  SUBROUTINE write_etat0(it,f_ps,f_phis,f_theta_rhodz,f_u, f_q, f_geopot, f_W)
8  USE icosa
9  USE restart_mod
10  USE wind_mod
11  USE write_field_mod
12  USE domain_mod
13  USE omp_para
14  USE xios_mod
15  USE checksum_mod
16  IMPLICIT NONE
17    INTEGER,INTENT(IN)    :: it
18    TYPE(t_field),POINTER :: f_ps(:)
19    TYPE(t_field),POINTER :: f_phis(:)
20    TYPE(t_field),POINTER :: f_theta_rhodz(:)
21    TYPE(t_field),POINTER :: f_u(:)
22    TYPE(t_field),POINTER :: f_q(:)
23    TYPE(t_field),POINTER, OPTIONAL :: f_geopot(:)
24    TYPE(t_field),POINTER, OPTIONAL :: f_W(:)
25 
26    TYPE(t_field),POINTER,SAVE :: f_ulon(:)
27    TYPE(t_field),POINTER,SAVE :: f_ulat(:)
28    TYPE(t_field),POINTER,SAVE :: f_theta_rhodz_1d(:)
29    TYPE(t_field),POINTER,SAVE :: f_xcell(:),f_ycell(:),f_zcell(:)
30    REAL(rstd), POINTER :: theta_rhodz(:,:,:),theta_rhodz_1d(:,:)
31    REAL(rstd), POINTER :: xcell(:), ycell(:), zcell(:)
32    INTEGER :: ind,n,i,j
33   
34   
35    CALL allocate_field(f_ulon,field_t,type_real,llm,name='ulon')
36    CALL allocate_field(f_ulat,field_t,type_real,llm,name='ulat')
37    CALL allocate_field(f_theta_rhodz_1d,field_t,type_real,llm,name='theta_rhodz')
38    CALL allocate_field(f_xcell,field_t,type_real,name='xcell')
39    CALL allocate_field(f_ycell,field_t,type_real,name='ycell')
40    CALL allocate_field(f_zcell,field_t,type_real,name='zcell')
41
42!$OMP BARRIER   
43    DO ind=1, ndomain
44      IF (.NOT. assigned_domain(ind) .OR. .NOT. is_omp_level_master) CYCLE
45      CALL swap_dimensions(ind)
46      CALL swap_geometry(ind)
47      theta_rhodz=f_theta_rhodz(ind) ; theta_rhodz_1d=f_theta_rhodz_1d(ind)
48      theta_rhodz_1d(:,:)=theta_rhodz(:,:,1)
49   
50      xcell=f_xcell(ind) ; ! xcell=xyz_i(:,1)/radius  => cannot use due to rounding error
51      ycell=f_ycell(ind) ; ! ycell=xyz_i(:,2)/radius  => for 1+1=2
52      zcell=f_zcell(ind) ; ! zcell=xyz_i(:,3)/radius
53
54      DO j=jj_begin,jj_end
55        DO i=ii_begin,ii_end
56          n=(j-1)*iim+i
57          xcell(n) = domain(ind)%xyz(1,i,j) ! not the best but for now it works
58          ycell(n) = domain(ind)%xyz(2,i,j) 
59          zcell(n) = domain(ind)%xyz(3,i,j) 
60        ENDDO
61      ENDDO       
62    ENDDO
63   
64    CALL transfert_request(f_u,req_e1_vect)
65    CALL un2ulonlat(f_u, f_ulon, f_ulat)
66
67    IF(hydrostatic) THEN
68       CALL write_restart(it,f_ps,f_phis,f_theta_rhodz_1d,f_u, f_ulon, f_ulat, f_q, f_xcell, f_ycell, f_zcell )
69    ELSE
70       CALL write_restart(it,f_ps,f_phis,f_theta_rhodz_1d,f_u, f_ulon, f_ulat, f_q, f_geopot, f_W, f_xcell, f_ycell, f_zcell)
71    END IF
72    CALL deallocate_field(f_ulon)
73    CALL deallocate_field(f_ulat)
74   
75  END SUBROUTINE write_etat0
76   
77END MODULE write_etat0_mod
Note: See TracBrowser for help on using the repository browser.