source: codes/icosagcm/trunk/src/initial/etat0_temperature.f90

Last change on this file was 901, checked in by adurocher, 5 years ago

trunk : Fixed compilation with --std=f2008 with gfortran

Added dynamico_abort() to replace non standard ABORT() intrinsic
Other modifications to respect the fortran standard

File size: 2.3 KB
Line 
1MODULE etat0_temperature_mod
2  USE prec
3  USE icosa, ONLY: llm,nqtot
4  IMPLICIT NONE
5  PRIVATE
6
7  REAL(rstd), SAVE, ALLOCATABLE :: t_profile(:)
8!$OMP THREADPRIVATE(t_profile)
9
10  PUBLIC :: getin_etat0, compute_etat0
11
12CONTAINS
13 
14  SUBROUTINE getin_etat0
15    USE getin_mod, ONLY: getin
16    USE mpipara, ONLY: is_mpi_root
17    USE omp_para, ONLY: omp_in_parallel
18    USE transfert_omp_mod, ONLY: bcast_omp
19    USE free_unit_mod, ONLY : free_unit
20    USE abort_mod
21    INTEGER :: unit,ok
22    INTEGER :: l
23    CHARACTER(len=255) :: temperature_file
24 
25    temperature_file="profile.in" ! default file name
26    ! but users may want to use some other file name
27    CALL getin("temperature_profile_file",temperature_file)
28   
29    ALLOCATE(t_profile(llm))
30 
31 
32 !$OMP MASTER
33    unit=free_unit()
34    OPEN(unit,file=temperature_file,status="old",action="read",iostat=ok)
35    IF (ok/=0) THEN
36      WRITE(*,*) "getin_etat0 error: input file ",trim(temperature_file)," not found!"
37      CALL dynamico_abort( "Could not open temperature file." )
38    ENDIF
39    ! read in t_profile() line by line, starting from first atmospheric
40    ! layer, up to model top
41    DO l=1,llm
42      READ(unit,fmt=*,iostat=ok) t_profile(l)
43      IF (ok/=0) THEN
44        WRITE(*,*) "getin_etat0 error: failed reading t_profile(l) for l=",l
45        CALL dynamico_abort( "Could not read temperature file. " )
46      ENDIF
47    ENDDO
48   
49    CLOSE(unit)
50    IF (is_mpi_root) THEN
51      WRITE(*,*) "Using input temperature profile from file ",trim(temperature_file),":"
52      DO l=1,llm
53         WRITE(*,*) "  TEMP(l=",l,")=",t_profile(l)
54      ENDDO
55    ENDIF
56!$OMP END MASTER
57
58    IF (omp_in_parallel()) THEN
59      CALL bcast_omp(t_profile)
60    ENDIF
61   
62  END SUBROUTINE getin_etat0
63
64  SUBROUTINE compute_etat0(ngrid, phis, ps, temp, ulon, ulat, q)
65    USE earth_const, ONLY: preff
66    INTEGER, INTENT(IN)    :: ngrid
67    REAL(rstd),INTENT(OUT) :: phis(ngrid)
68    REAL(rstd),INTENT(OUT) :: ps(ngrid)
69    REAL(rstd),INTENT(OUT) :: temp(ngrid,llm)
70    REAL(rstd),INTENT(OUT) :: ulon(ngrid,llm)
71    REAL(rstd),INTENT(OUT) :: ulat(ngrid,llm)
72    REAL(rstd),INTENT(OUT) :: q(ngrid,llm,nqtot)
73    INTEGER :: l
74    phis(:)=0
75    ps(:)=preff
76    DO l=1,llm
77      temp(:,l)=t_profile(l)
78    ENDDO
79    ulon(:,:)=0
80    ulat(:,:)=0
81    q(:,:,:)=0
82
83  END SUBROUTINE compute_etat0
84
85END MODULE etat0_temperature_mod
Note: See TracBrowser for help on using the repository browser.