241 |
icglo = 0 |
icglo = 0 |
242 |
itest = 0 |
itest = 0 |
243 |
endif |
endif |
|
_BARRIER |
|
244 |
|
|
245 |
c****************************************************** |
c****************************************************** |
246 |
c-- (A): get gradient component calculated via adjoint |
c-- (A): get gradient component calculated via adjoint |
256 |
endif |
endif |
257 |
C-- Add a global-sum call so that all proc will get the adjoint gradient |
C-- Add a global-sum call so that all proc will get the adjoint gradient |
258 |
_GLOBAL_SUM_RL( adxxmemo, myThid ) |
_GLOBAL_SUM_RL( adxxmemo, myThid ) |
|
c _BARRIER |
|
259 |
|
|
260 |
#ifdef ALLOW_TANGENTLINEAR_RUN |
#ifdef ALLOW_TANGENTLINEAR_RUN |
261 |
c****************************************************** |
c****************************************************** |
276 |
xxmemo_ref = 0. |
xxmemo_ref = 0. |
277 |
xxmemo_pert = 0. |
xxmemo_pert = 0. |
278 |
endif |
endif |
|
_BARRIER |
|
279 |
|
|
280 |
c-- |
c-- |
281 |
c-- 2. perform tangent linear run |
c-- 2. perform tangent linear run |
294 |
#endif |
#endif |
295 |
|
|
296 |
call g_the_main_loop( mytime, myiter, mythid ) |
call g_the_main_loop( mytime, myiter, mythid ) |
|
_BARRIER |
|
297 |
#ifdef ALLOW_ADMTLM |
#ifdef ALLOW_ADMTLM |
298 |
ftlxxmemo = g_objf_state_final(idep,jdep,1,1,1) |
ftlxxmemo = g_objf_state_final(idep,jdep,1,1,1) |
299 |
#else |
#else |
309 |
& itilepos, jtilepos, |
& itilepos, jtilepos, |
310 |
& xxmemo_ref, mythid ) |
& xxmemo_ref, mythid ) |
311 |
endif |
endif |
|
_BARRIER |
|
312 |
|
|
313 |
#endif /* ALLOW_TANGENTLINEAR_RUN */ |
#endif /* ALLOW_TANGENTLINEAR_RUN */ |
314 |
|
|
332 |
xxmemo_ref = 0. |
xxmemo_ref = 0. |
333 |
xxmemo_pert = 0. |
xxmemo_pert = 0. |
334 |
endif |
endif |
|
_BARRIER |
|
335 |
|
|
336 |
c-- forward run with perturbed control vector |
c-- forward run with perturbed control vector |
337 |
mytime = starttime |
mytime = starttime |
342 |
#else |
#else |
343 |
fcpertplus = fc |
fcpertplus = fc |
344 |
#endif |
#endif |
345 |
print *, 'ph-check fcpertplus = ', fcpertplus |
print *, 'ph-check fcpertplus = ', fcpertplus |
|
_BARRIER |
|
346 |
|
|
347 |
c-- Reset control vector. |
c-- Reset control vector. |
348 |
if ( myProcId .EQ. grdchkwhichproc .AND. |
if ( myProcId .EQ. grdchkwhichproc .AND. |
352 |
& itilepos, jtilepos, |
& itilepos, jtilepos, |
353 |
& xxmemo_ref, mythid ) |
& xxmemo_ref, mythid ) |
354 |
endif |
endif |
|
_BARRIER |
|
355 |
|
|
356 |
fcpertminus = fcref |
fcpertminus = fcref |
357 |
print *, 'ph-check fcpertminus = ', fcpertminus |
print *, 'ph-check fcpertminus = ', fcpertminus |
373 |
xxmemo_ref = 0. |
xxmemo_ref = 0. |
374 |
xxmemo_pert = 0. |
xxmemo_pert = 0. |
375 |
endif |
endif |
|
_BARRIER |
|
376 |
|
|
377 |
c-- forward run with perturbed control vector |
c-- forward run with perturbed control vector |
378 |
mytime = starttime |
mytime = starttime |
379 |
myiter = niter0 |
myiter = niter0 |
380 |
call the_main_loop( mytime, myiter, mythid ) |
call the_main_loop( mytime, myiter, mythid ) |
|
_BARRIER |
|
381 |
#ifdef ALLOW_ADMTLM |
#ifdef ALLOW_ADMTLM |
382 |
fcpertminus = objf_state_final(idep,jdep,1,1,1) |
fcpertminus = objf_state_final(idep,jdep,1,1,1) |
383 |
#else |
#else |
392 |
& itilepos, jtilepos, |
& itilepos, jtilepos, |
393 |
& xxmemo_ref, mythid ) |
& xxmemo_ref, mythid ) |
394 |
endif |
endif |
|
_BARRIER |
|
395 |
|
|
396 |
c-- end of if useCentralDiff ... |
c-- end of if useCentralDiff ... |
397 |
end if |
end if |
479 |
#endif |
#endif |
480 |
endif |
endif |
481 |
#ifdef ALLOW_TANGENTLINEAR_RUN |
#ifdef ALLOW_TANGENTLINEAR_RUN |
482 |
WRITE(msgBuf,'(A34,1PE24.14)') |
WRITE(msgBuf,'(A30,1PE22.14)') |
483 |
& ' TLM precision_derivative_cost =', fcref |
& ' TLM ref_cost_function =', fcref |
484 |
CALL PRINT_MESSAGE |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
485 |
& (msgBuf,standardMessageUnit,SQUEEZE_RIGHT,myThid) |
& SQUEEZE_RIGHT, myThid ) |
486 |
WRITE(msgBuf,'(A34,1PE24.14)') |
WRITE(msgBuf,'(A30,1PE22.14)') |
487 |
& ' TLM precision_derivative_grad =', ftlxxmemo |
& ' TLM tangent-lin_grad =', ftlxxmemo |
488 |
CALL PRINT_MESSAGE |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
489 |
& (msgBuf,standardMessageUnit,SQUEEZE_RIGHT,myThid) |
& SQUEEZE_RIGHT, myThid ) |
490 |
|
WRITE(msgBuf,'(A30,1PE22.14)') |
491 |
|
& ' TLM finite-diff_grad =', gfd |
492 |
|
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
493 |
|
& SQUEEZE_RIGHT, myThid ) |
494 |
#else |
#else |
495 |
WRITE(msgBuf,'(A30,1PE22.14)') |
WRITE(msgBuf,'(A30,1PE22.14)') |
496 |
& ' ADM ref_cost_function =', fcref |
& ' ADM ref_cost_function =', fcref |
510 |
print *, 'ph-grd ierr = ', ierr, ', icomp = ', icomp, |
print *, 'ph-grd ierr = ', ierr, ', icomp = ', icomp, |
511 |
& ', ichknum = ', ichknum |
& ', ichknum = ', ichknum |
512 |
|
|
|
_BARRIER |
|
|
|
|
513 |
c-- else of if ( ichknum ... |
c-- else of if ( ichknum ... |
514 |
else |
else |
515 |
ierr_grdchk = -1 |
ierr_grdchk = -1 |
530 |
endif |
endif |
531 |
|
|
532 |
c-- Everyone has to wait for the component to be reset. |
c-- Everyone has to wait for the component to be reset. |
533 |
_BARRIER |
c _BARRIER |
534 |
|
|
535 |
c-- Print the results of the gradient check. |
c-- Print the results of the gradient check. |
536 |
call grdchk_print( ichknum, ierr_grdchk, mythid ) |
call grdchk_print( ichknum, ierr_grdchk, mythid ) |