33 character(6) :: opt_method
44 real(kind=kind(1.0d0)) :: cg_eps
48 real(kind=kind(1.0d0)) :: lbfgs_factr
66 real(kind=kind(1.0d0)) :: lbfgs_pgtol
78 real(kind=kind(1.0d0)),
dimension(:),
allocatable :: l,u,x0
79 integer,
dimension(:),
allocatable :: nbd
82 integer :: total_timesteps
85 integer,
allocatable,
dimension(:) :: ny
101 write(emp_o,
'(A)')
'Opening namelist file to read var_params'
105 write(emp_o,
'(A)')
'var_params successfully read from nml file to control pf code.'
142 character(*),
parameter :: filename=
'vardata.nml'
143 character(*),
parameter :: filename2=
'empire.nml'
146 character(6) :: opt_method=
'CG'
147 integer :: cg_method=2
148 real(kind=kind(1.0d0)) :: cg_eps=1.0d-5
149 real(kind=kind(1.0d0)) :: lbfgs_factr=1.0d+7
150 real(kind=kind(1.0d0)) :: lbfgs_pgtol=1.0d-5
152 integer :: total_timesteps = -1
154 namelist/var_params/opt_method,&
163 vardata%opt_method = opt_method
164 vardata%cg_method = cg_method
165 vardata%cg_eps = cg_eps
166 vardata%lbfgs_factr = lbfgs_factr
167 vardata%lbfgs_pgtol = lbfgs_pgtol
169 vardata%total_timesteps = total_timesteps
173 open(unit_vardata,file=filename,iostat=ios,action=
'read',status=
'old')
175 write(*,*)
'Cannot open ',filename
177 open(unit_vardata,file=filename2,iostat=ios,action=
'read',status=
'old')
180 write(emp_e,*)
'Cannot open ',filename2
181 write(emp_e,*)
'var_data ERROR: no .nml file found. STOPPING.'
185 read(unit_vardata,nml=var_params,iostat=ios)
187 write(emp_e,*)
'var_data ERROR: no var_params namelist found in &
188 &',filename,
' or ',filename2,
'. STOPPING.'
193 read(unit_vardata,nml=var_params,iostat=ios)
196 open(unit_vardata,file=filename2,iostat=ios,action=
'read',status=
'old')
198 write(emp_e,*)
'var_data ERROR: no var_params namelist found &
200 &',filename,
' and could not open ',filename2,
'. STOPPING.'
204 read(unit_vardata,nml=var_params,iostat=ios)
206 write(emp_e,*)
'var_data ERROR: no var_params namelist found in &
207 &',filename,
' or ',filename2,
'. STOPPING.'
230 select case (opt_method)
232 write(*,*)
'VAR_DATA: Nonlinear Conjugate Gradient Method selected'
233 vardata%opt_method = opt_method
235 write(*,*)
'VAR_DATA: Unconstrained L-BFGS Method selected'
236 vardata%opt_method = opt_method
238 write(*,*)
'VAR_DATA: Bound constrained L-BFGS Method selected'
239 vardata%opt_method = opt_method
241 write(emp_e,*)
'VAR_DATA ERROR: opt_method in ',filename,
' incorrect&
242 &ly given as ',opt_method
243 write(emp_e,*)
'VAR_DATA ERROR: Correct inputs are:'
244 write(emp_e,*)
'VAR_DATA ERROR: cg'
245 write(emp_e,*)
'VAR_DATA ERROR: lbfgs'
246 write(emp_e,*)
'VAR_DATA ERROR: lbfgsb'
250 if(cg_method .lt. 1 .or. cg_method .gt. 3)
then
251 write(emp_e,*)
'VAR_DATA ERROR: cg_method in ',filename,
' incorrect&
252 &ly given as ',cg_method
253 write(emp_e,*)
'VAR_DATA ERROR: Correct inputs are:'
254 write(emp_e,*)
'VAR_DATA ERROR: 1 FLETCHER-REEVES '
255 write(emp_e,*)
'VAR_DATA ERROR: 2 POLAK-RIBIERE (DEFAULT)'
256 write(emp_e,*)
'VAR_DATA ERROR: 3 POSITIVE POLAK-RIBIERE ( BETA=MAX{BETA,0} )'
259 vardata%cg_method = cg_method
260 if(vardata%opt_method .eq.
'cg')
then
261 select case (vardata%cg_method)
263 write(*,*)
'CG METHOD 1: FLETCHER-REEVES '
265 write(*,*)
'CG METHOD 2: POLAK-RIBIERE (DEFAULT)'
267 write(*,*)
'CG METHOD 3: POSITIVE POLAK-RIBIERE'
274 if(cg_eps .ne. 1.0d-5)
then
275 if(cg_eps .lt. 0.0d0)
then
276 write(emp_e,*)
'VAR_DATA ERROR: cg_eps read as negative: ',cg_eps
277 write(emp_e,*)
'VAR_DATA ERROR: Please make cg_eps positive (small).'
279 elseif(cg_eps .ge. 0.5d0)
then
280 write(*,*)
'VAR_DATA WARNING: cg_eps read as "large": '&
282 write(*,*)
'VAR_DATA WARNING: cg_eps default is 1.0d-5'
284 write(*,*)
'VAR_DATA: CG tolerance read in as ',cg_eps
285 vardata%cg_eps = cg_eps
288 vardata%cg_eps = 1.0d-5
291 if(lbfgs_factr .ne. 1.0d+7)
then
292 write(*,*)
'VAR_DATA: LBFGS factr read in as ',lbfgs_factr
293 vardata%lbfgs_factr = lbfgs_factr
297 if(lbfgs_pgtol .ne. 1.0d-5)
then
298 write(*,*)
'VAR_DATA: LBFGS pgtol read in as ',lbfgs_pgtol
299 vardata%lbfgs_pgtol = lbfgs_pgtol
315 if(total_timesteps .lt. 1)
then
316 write(emp_e,*)
'VAR_DATA ERROR: total_timesteps < 1'
319 vardata%total_timesteps = total_timesteps
329 allocate(vardata%x0(vardata%n))
331 allocate(vardata%ny(vardata%total_timesteps))
334 if(vardata%opt_method ==
'lbfgsb')
then
335 allocate(vardata%nbd(vardata%n))
336 allocate(vardata%l(vardata%n))
337 allocate(vardata%u(vardata%n))
344 if(
allocated(vardata%x0))
deallocate(vardata%x0)
345 if(
allocated(vardata%ny))
deallocate(vardata%ny)
346 if(
allocated(vardata%nbd))
deallocate(vardata%nbd)
347 if(
allocated(vardata%l))
deallocate(vardata%l)
348 if(
allocated(vardata%u))
deallocate(vardata%u)
362 print*,
'vardata%ny = ',vardata%ny
subroutine allocate_vardata
subroutine to allocate space for 4denvar
subroutine parse_vardata
subroutine to read the namelist file and save it to vardata datatype Here we read vardata...
subroutine deallocate_vardata
subroutine to deallocate space for 4denvar
Module that stores the information about the outputting from empire.
subroutine read_observation_numbers
subroutine to somehow read in observation numbers
subroutine read_lbfgsb_bounds
subroutine to somehow read in bounds data
subroutine set_var_controls
subroutine to ensure vardata is ok
module holding data for variational problems