8 subroutine bump_main(n1,arg1,n2,arg2) bind (c,name='bump_main_f90')
10 use fckit_mpi_module,
only: fckit_mpi_comm
12 use iso_fortran_env,
only : output_unit
21 integer(c_int),
intent(in) :: n1
22 character(c_char),
intent(in) :: arg1(n1)
23 integer(c_int),
intent(in) :: n2
24 character(c_char),
intent(in) :: arg2(n2)
27 integer :: i,ppos,iproc,ie,ifileunit
28 character(len=1024) :: inputfile,logdir,ext,filename
30 type(fckit_mpi_comm) :: f_comm
36 f_comm = fckit_mpi_comm()
41 inputfile(i:i) = arg1(i)
59 call bump%nam%init(mpl%nproc)
62 ppos = scan(inputfile,
".",back=.true.)
63 ext = inputfile(ppos+1:)
64 select case (trim(ext))
67 call bump%nam%read(mpl,inputfile)
70 call bump%nam%read_yaml(mpl,inputfile)
73 write(output_unit,
'(a)')
'Error: input file has a wrong extension (should be .nam or .yaml)'
74 call flush(output_unit)
79 call bump%nam%bcast(mpl)
83 if ((trim(bump%nam%verbosity)==
'all').or.((trim(bump%nam%verbosity)==
'main').and.(iproc==mpl%rootproc)))
then
84 if (iproc==mpl%myproc)
then
86 call mpl%newunit(mpl%lunit)
89 write(filename,
'(a,i6.6,a)') trim(bump%nam%prefix)//
'.',mpl%myproc-1,
'.out'
90 inquire(file=filename,number=ifileunit)
92 open(unit=mpl%lunit,file=trim(logdir)//
'/'//trim(filename),action=
'write',status=
'replace')
95 open(unit=mpl%lunit,file=trim(logdir)//
'/'//trim(filename),action=
'write',status=
'replace')
98 call mpl%f_comm%barrier
103 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
105 write(mpl%info,
'(a)')
'--- You are running the BUMP main program -------------------------'
109 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
111 write(mpl%info,
'(a)')
'--- Setup model'
113 call model%setup(mpl,bump%nam)
116 if (bump%nam%ens1_ne>0)
then
117 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
119 write(mpl%info,
'(a)')
'--- Load ensemble 1'
121 call model%load_ens(mpl,bump%nam,
'ens1')
123 if (bump%nam%ens2_ne>0)
then
124 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
126 write(mpl%info,
'(a)')
'--- Load ensemble 2'
128 call model%load_ens(mpl,bump%nam,
'ens2')
131 if (bump%nam%new_obsop)
then
133 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
135 write(mpl%info,
'(a)')
'--- Generate observations locations'
137 call model%generate_obs(mpl,bump%nam)
141 if (bump%nam%new_obsop)
then
142 call bump%setup(f_comm,model%afunctionspace,model%fieldset, &
143 & nobs=model%nobsa,lonobs=model%lonobs,latobs=model%latobs, &
144 & lunit=mpl%lunit,msvali=mpl%msv%vali,msvalr=mpl%msv%valr)
146 call bump%setup(f_comm,model%afunctionspace,model%fieldset, &
147 & lunit=mpl%lunit,msvali=mpl%msv%vali,msvalr=mpl%msv%valr)
151 if (bump%nam%ens1_ne>0)
then
152 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
154 write(mpl%info,
'(a)')
'--- Add members of ensemble 1'
156 do ie=1,bump%nam%ens1_ne
157 write(mpl%info,
'(a7,a,i4,a,i4)')
'',
'Member ',ie,
' / ',bump%nam%ens1_ne
159 call bump%add_member(model%ens1(ie),ie,1)
162 if (bump%nam%ens2_ne>0)
then
163 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
165 write(mpl%info,
'(a)')
'--- Add members of ensemble 2'
167 do ie=1,bump%nam%ens2_ne
168 write(mpl%info,
'(a7,a,i4,a,i4)')
'',
'Member ',ie,
' / ',bump%nam%ens2_ne
170 call bump%add_member(model%ens2(ie),ie,2)
175 if (bump%nam%check_set_param_cor.or.bump%nam%check_set_param_hyb.or.bump%nam%check_set_param_lct)
then
176 write(bump%mpl%info,
'(a)')
'-------------------------------------------------------------------'
178 write(bump%mpl%info,
'(a)')
'--- Test set_parameters interfaces'
179 call bump%mpl%flush()
180 call bump%test_set_parameter
181 if (bump%nam%default_seed)
call bump%rng%reseed(mpl)
185 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
187 write(mpl%info,
'(a)')
'--- Run drivers'
189 call bump%run_drivers
192 if (bump%nam%check_get_param_cor.or.bump%nam%check_get_param_hyb.or.bump%nam%check_get_param_Dloc &
193 & .or.bump%nam%check_get_param_lct)
then
194 write(bump%mpl%info,
'(a)')
'-------------------------------------------------------------------'
196 write(bump%mpl%info,
'(a)')
'--- Test get_parameter interfaces'
197 call bump%mpl%flush()
198 call bump%test_get_parameter
199 if (bump%nam%default_seed)
call bump%rng%reseed(mpl)
203 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
205 write(mpl%info,
'(a)')
'--- Release memory (partial)'
207 call bump%partial_dealloc
210 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
212 write(mpl%info,
'(a)')
'--- Test apply interfaces'
214 call bump%test_apply_interfaces
217 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
219 write(mpl%info,
'(a)')
'--- Execution stats'
220 call timer%display(mpl)
223 if ((trim(bump%nam%verbosity)==
'all').or.((trim(bump%nam%verbosity)==
'main').and.mpl%main))
then
225 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
227 write(mpl%info,
'(a)')
'--- Close listings'
229 write(mpl%info,
'(a)')
'-------------------------------------------------------------------'
231 close(unit=mpl%lunit)