The TELEMAC-MASCARET system  trunk
example_cpl_t2d_sis.f
Go to the documentation of this file.
1  SUBROUTINE example_cpl_t2d_sis()
2  USE api_interface, ex_lu => lu
5  USE declarations_partel, ONLY : code
7 !
8 #if defined HAVE_MPI
9 !
10 # if defined HAVE_MPI_MOD
11  USE mpi
12  IMPLICIT NONE
13 # else
14  IMPLICIT NONE
15  include 'mpif.h'
16 # endif
17 #endif
18  INTEGER :: I, IERR, ID_SIS, ID_T2D, IDUM, IDUM1
19  INTEGER :: CPL_PERIOD
20  INTEGER :: NTIME_STEPS_T2D
21  CHARACTER(LEN=PATH_LEN) :: GEO_FILE,PRE_FILE
22  CHARACTER(LEN=PATH_LEN) :: REF_FILE_T2D, REF_FILE_SIS
23  CHARACTER(LEN=PATH_LEN) :: CLI_FILE_T2D, CLI_FILE_SIS
24  CHARACTER(LEN=PATH_LEN) :: RES_FILE_T2D, RES_FILE_SIS
25  CHARACTER(LEN=PATH_LEN) :: CAS_FILE_T2D, DICO_FILE_T2D
26  CHARACTER(LEN=PATH_LEN) :: CAS_FILE_SIS, DICO_FILE_SIS
27  CHARACTER(LEN=PATH_LEN) :: DUMMY
28  CHARACTER(LEN=SIS_VAR_LEN) :: VARNAME
29  INTEGER LU,LNG,NPLAN,PARALLEL,REFFILE,PREFILE
30  INTEGER RANK,NCSIZE,PMETHOD,VAR_SIZE,COMM
31  dummy = ' '
32  comm = 0
33 
34 ! OUTPUT FOR WRITING
35  lu=6
36  ! 1 FOR FRENCH 2 FOR ENGLISH
37  lng=2
38  id_sis = 0
39  id_t2d = 0
40  !READING THE FILES NAMES
41  OPEN(unit=12,file='param_api')
42  READ(12,'(A)') dico_file_t2d
43  READ(12,'(A)') dico_file_sis
44  READ(12,*) cas_file_t2d
45  READ(12,*) cas_file_sis
46  READ(12,*) cpl_period
47  READ(12,*) res_file_t2d
48  READ(12,*) res_file_sis
49  READ(12,*) geo_file
50  READ(12,*) cli_file_t2d
51  READ(12,*) cli_file_sis
52  READ(12,*) reffile
53  IF (reffile.EQ.1) THEN
54  READ(12,*) ref_file_t2d
55  READ(12,*) ref_file_sis
56  ELSE
57  READ(12,*)
58  READ(12,*)
59  ENDIF
60  READ(12,*) prefile
61  IF (prefile.EQ.1) THEN
62  READ(12,*) pre_file
63  ELSE
64  READ(12,*)
65  ENDIF
66  READ(12,*) parallel
67  CLOSE(12)
68 
69  print*, "DICO T2D : ",dico_file_t2d
70  print*, "DICO SIS : ",dico_file_sis
71  print*, "CAS T2D : ",cas_file_t2d
72  print*, "CAS SIS : ",cas_file_sis
73  print*, "COUPLING PERIOD : ", cpl_period
74  print*, "RES T2D : ",res_file_t2d
75  print*, "RES SIS : ",res_file_sis
76  print*, "GEO : ",geo_file
77  print*, "CLI T2D : ",cli_file_t2d
78  print*, "CLI SIS : ",cli_file_sis
79  IF(reffile.EQ.1) print*,"REFERENCE FILES PRESENT : ",
80  & ref_file_t2d, ref_file_sis
81  IF(prefile.EQ.1) print*,"PREVIOUS CALCULATIONS FILE PRESENT : ",
82  & pre_file
83  IF(parallel.EQ.0) print*,"MPI : SEQUENTIAL RUN"
84  IF(parallel.EQ.1) print*,"MPI : PARALLEL RUN"
85  print*
86 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
87  IF(parallel.EQ.1) THEN
88  ! Partitioning method to use 1: metis
89  pmethod=1
90 #if defined HAVE_MPI
91  ! Initialising mpi
92 !! COMPAD-DCO-MPICHECK BEGIN JR2016
93 # if defined COMPAD
94  WRITE(lu,*) '(AD) COMPAD :: HOMERE_API.F : DIRECT CALL OF ',
95  & 'MPI_INIT NOT AD-READY'
96  WRITE(lu,*) ' PLEASE CONTACT JR @ ADJOINTWARE'
97  CALL plante(1)
98  stop
99 # endif
100 !! COMPAD-DCO-MPICHECK END JR2016
101  CALL mpi_init(ierr)
102  ! Getting rank
103  CALL mpi_comm_rank(mpi_comm_world,rank,ierr)
104  ! Getting the number of process
105  CALL mpi_comm_size(mpi_comm_world,ncsize,ierr)
106  comm = mpi_comm_world
107 #else
108  rank = -1
109 #endif
110 !
111  code = 'SIS'
112  ! The partitioning is done sequentially
113  IF(rank.EQ.0) THEN
114  ! PARITIONING THE GEOMETRY FILE
115  CALL partel(geo_file,cli_file_sis,ncsize,pmethod,
116  & 'SERAFIN ',' ',' ')
117  IF(reffile.EQ.1) CALL parres(geo_file,ref_file_sis,
118  & ncsize,'SERAFIN ','SERAFIN ')
119  ENDIF
120  code = 'T2D'
121  ! The partitioning is done sequentially
122  IF(rank.EQ.0) THEN
123  ! PARITIONING THE GEOMETRY FILE
124  CALL partel(geo_file,cli_file_t2d,ncsize,pmethod,
125  & 'SERAFIN ',' ',' ')
126  IF(reffile.EQ.1) CALL parres(geo_file,ref_file_t2d,
127  & ncsize,'SERAFIN ','SERAFIN ')
128  IF(prefile.EQ.1) CALL parres(geo_file,pre_file,
129  & ncsize,'SERAFIN ','SERAFIN ')
130  ENDIF
131  ENDIF
132 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
133 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
134 !!!!!!!!!!!!!!!!!!!!!!!!!!!!TELEMAC 2D!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
135  CALL run_set_config_t2d(id_t2d,lu,lng,comm,ierr)
136 
137  CALL run_read_case_t2d(id_t2d,cas_file_t2d,dico_file_t2d,
138  & .true.,ierr,dummy,dummy)
139 
140  ! Changing the name of the result file
141  varname = 'MODEL.RESULTFILE'
142  CALL get_var_size(id_t2d,'T2D',varname,var_size,
143  & idum,idum1,ierr)
144  print *, 'rank:',rank,'VAR_SIZE:',var_size
145  CALL set_string(id_t2d,'T2D',varname,res_file_t2d,var_size,
146  & 0,0,ierr)
147 
148  CALL run_allocation_t2d(id_t2d,ierr)
149 !
150 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
151 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
152 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!SISYPHE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
153  CALL run_set_config_sis(id_sis,lu,lng,comm,ierr)
154 
155  CALL run_read_case_sis(id_sis,'TELEMAC2D ',
156  & cas_file_sis,dico_file_sis,
157  & .false.,ierr)
158 
159  ! Changing the name of the result file
160  varname = 'MODEL.RESULTFILE'
161  CALL get_var_size(id_sis,'SIS',varname,var_size,idum,idum1,ierr)
162  print *, 'rank:',rank,'VAR_SIZE:',var_size
163  CALL set_string(id_sis,'SIS',varname,res_file_sis,var_size,
164  & 0,0,ierr)
165 
166  CALL run_allocation_sis(id_sis,ierr)
167 !
168 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
169 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!TIME LOOP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
170 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
171  CALL run_init_t2d(id_t2d,ierr)
172  varname = 'MODEL.CPL_PERIOD'
173  CALL set_integer(id_t2d, 'T2D', varname, cpl_period,
174  & 0, 0, 0, ierr)
175  CALL cpl_init(id_t2d,ierr)
176  CALL set_var_sis(id_t2d, id_sis, 0, ierr)
177  CALL run_init_sis(id_sis,ierr)
178  CALL set_var_t2d(id_t2d, id_sis, ierr)
179  CALL save_charr_susp(id_t2d, id_sis, ierr)
180 
181  !Get the number of timesteps
182  varname = 'MODEL.NTIMESTEPS'
183  CALL get_integer(id_t2d, 'T2D', varname, ntime_steps_t2d,
184  & 0, 0, 0, ierr)
185 
186  !Get the coupling period
187  varname = 'MODEL.CPL_PERIOD'
188  CALL get_integer(id_t2d,'T2D',varname,cpl_period, 0, 0, 0, ierr)
189 
190  DO i=1,ntime_steps_t2d
191  CALL run_timestep_compute_t2d(id_t2d,ierr)
192  !COUPLAGE
193  IF(cpl_period*(i/cpl_period).EQ.i) THEN
194  CALL run_timestep_sis_cpl(id_t2d, id_sis, ierr)
195  ENDIF
196  CALL run_timestep_res_t2d(id_t2d,ierr)
197  ENDDO
198 !
199 
200 
201 !!!!!!!!!!!!!!!!!!!!!!!!!!!FINALISATION!!!!!!!!!!!!!!!!!!!!!!!!!!!!
202  CALL run_finalize_t2d(id_t2d,ierr)
203  CALL run_finalize_sis(id_sis,ierr)
204 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
205  IF(parallel.EQ.1) THEN
206 ! Mergin step
207  IF(rank.EQ.0) THEN
208  CALL gretel_autop(geo_file,'SERAFIN ',res_file_t2d,
209  & 'SERAFIN ', ncsize,nplan)
210  CALL gretel_autop(geo_file,'SERAFIN ',res_file_sis,
211  & 'SERAFIN ', ncsize,nplan)
212 
213  ENDIF
214 #if defined HAVE_MPI
215 # if defined COMPAD
216  WRITE(lu,*) '(AD) COMPAD :: HOMERE_API.F : DIRECT CALL OF ',
217  & 'MPI_FINALIZE NOT AD-READY'
218  WRITE(lu,*) ' PLEASE CONTACT JR @ ADJOINTWARE'
219  CALL plante(1)
220  stop
221 # endif
222  CALL mpi_finalize(ierr)
223 #endif
224  ENDIF
225 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
226  END SUBROUTINE example_cpl_t2d_sis
subroutine save_charr_susp(ID_T2D, ID_SIS, IERR)
subroutine run_allocation_sis(ID, IERR)
subroutine run_init_sis(ID, IERR)
subroutine get_integer(ID, TAG, VARNAME, VALEUR, INDEX1, INDEX2, INDEX3, IERR)
subroutine parres(NAMEGEO, NAMEINP, NPARTS, GEOFORMAT, INPFORMAT)
Definition: parres.f:6
subroutine run_finalize_t2d(ID, IERR)
subroutine set_integer(ID, TAG, VARNAME, VALEUR, INDEX1, INDEX2, INDEX3, IERR)
subroutine run_timestep_res_t2d(ID, IERR)
subroutine partel(NAMEINP, NAMECLI, NPARTS, PMETHOD, FFORMAT, NAMESEC, NAMEZFI, NAMESEU)
Definition: partel.F:7
subroutine run_timestep_compute_t2d(ID, IERR)
subroutine gretel_autop(GEO, GEOFORMAT, BND, RES, RESFORMAT, NPROC, NPLAN_RES, METHOD)
Definition: gretel_autop.f:6
subroutine run_read_case_sis(ID, CODE, CAS_FILE, DICO_FILE, INIT, IERR)
subroutine cpl_init(ID, IERR)
character(len=3) code
subroutine run_init_t2d(ID, IERR)
subroutine set_string(ID, TAG, VARNAME, VALEUR, VALUELEN, INDEX1, INDEX2, IERR)
subroutine run_set_config_t2d(ID, LU, LNG, COMM, IERR)
subroutine run_allocation_t2d(ID, IERR)
subroutine set_var_sis(ID_T2D, ID_SIS, CALL_TYPE, IERR)
subroutine run_finalize_sis(ID, IERR)
subroutine example_cpl_t2d_sis()
subroutine set_var_t2d(ID_T2D, ID_SIS, IERR)
integer, parameter path_len
subroutine run_read_case_t2d(ID, CAS_FILE, DICO_FILE, INIT, IERR, GAIA_CAS, GAIA_DICO)
subroutine run_set_config_sis(ID, LU, LNG, COMM, IERR)
subroutine run_timestep_sis_cpl(ID_T2D, ID_SIS, IERR)
subroutine get_var_size(ID, TAG, VARNAME, DIM1, DIM2, DIM3, IERR)