/[MITgcm]/MITgcm/pkg/grdchk/grdchk_main.F
ViewVC logotype

Diff of /MITgcm/pkg/grdchk/grdchk_main.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.37 by jmc, Wed Aug 15 23:05:48 2012 UTC revision 1.38 by gforget, Tue Aug 21 14:00:04 2012 UTC
# Line 242  cph) Line 242  cph)
242                itest    = 0                itest    = 0
243              endif              endif
244    
245    c make sure that all procs have correct file records, so that useSingleCpuIO works
246          CALL GLOBAL_SUM_INT( icvrec , myThid )
247          CALL GLOBAL_SUM_INT( layer , myThid )
248    
249  c******************************************************  c******************************************************
250  c--   (A): get gradient component calculated via adjoint  c--   (A): get gradient component calculated via adjoint
251  c******************************************************  c******************************************************
252    
253  c--   get gradient component calculated via adjoint  c--   get gradient component calculated via adjoint
             if ( myProcId .EQ. grdchkwhichproc .AND.  
      &           ierr .EQ. 0 ) then  
254                 call grdchk_getadxx( icvrec,                 call grdchk_getadxx( icvrec,
255       &              itile, jtile, layer,       &              itile, jtile, layer,
256       &              itilepos, jtilepos,       &              itilepos, jtilepos,
257       &              adxxmemo, mythid )       &              adxxmemo, ierr, mythid )
             endif  
258  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
259              _GLOBAL_SUM_RL( adxxmemo, myThid )              _GLOBAL_SUM_RL( adxxmemo, myThid )
260    
# Line 264  c*************************************** Line 265  c***************************************
265  c--  c--
266  c--   1. perturb control vector component: xx(i)=1.  c--   1. perturb control vector component: xx(i)=1.
267    
             if ( myProcId .EQ. grdchkwhichproc .AND.  
      &           ierr .EQ. 0 ) then  
268                 localEps = 1. _d 0                 localEps = 1. _d 0
269                 call grdchk_getxx( icvrec, TANGENT_SIMULATION,                 call grdchk_getxx( icvrec, TANGENT_SIMULATION,
270       &              itile, jtile, layer,       &              itile, jtile, layer,
271       &              itilepos, jtilepos,       &              itilepos, jtilepos,
272       &              xxmemo_ref, xxmemo_pert, localEps,       &              xxmemo_ref, xxmemo_pert, localEps,
273       &              mythid )       &              ierr, mythid )
             else  
               xxmemo_ref  = 0.  
               xxmemo_pert = 0.  
             endif  
274    
275  c--  c--
276  c--   2. perform tangent linear run  c--   2. perform tangent linear run
# Line 302  c--   2. perform tangent linear run Line 297  c--   2. perform tangent linear run
297    
298  c--  c--
299  c--   3. reset control vector  c--   3. reset control vector
             if ( myProcId .EQ. grdchkwhichproc .AND.  
      &           ierr .EQ. 0 ) then  
300                 call grdchk_setxx( icvrec, TANGENT_SIMULATION,                 call grdchk_setxx( icvrec, TANGENT_SIMULATION,
301       &              itile, jtile, layer,       &              itile, jtile, layer,
302       &              itilepos, jtilepos,       &              itilepos, jtilepos,
303       &              xxmemo_ref, mythid )       &              xxmemo_ref, ierr, mythid )
             endif  
304    
305  #endif /* ALLOW_TANGENTLINEAR_RUN */  #endif /* ALLOW_TANGENTLINEAR_RUN */
306    
# Line 321  c--   get control vector component from Line 313  c--   get control vector component from
313  c--   perturb it and write back to file  c--   perturb it and write back to file
314  c--   positive perturbation  c--   positive perturbation
315              localEps = abs(grdchk_eps)              localEps = abs(grdchk_eps)
316              if ( myProcId .EQ. grdchkwhichproc .AND.              call grdchk_getxx( icvrec, FORWARD_SIMULATION,
      &           ierr .EQ. 0 ) then  
                call grdchk_getxx( icvrec, FORWARD_SIMULATION,  
317       &              itile, jtile, layer,       &              itile, jtile, layer,
318       &              itilepos, jtilepos,       &              itilepos, jtilepos,
319       &              xxmemo_ref, xxmemo_pert, localEps,       &              xxmemo_ref, xxmemo_pert, localEps,
320       &              mythid )       &              ierr, mythid )
             else  
               xxmemo_ref  = 0.  
               xxmemo_pert = 0.  
             endif  
321    
322  c--   forward run with perturbed control vector  c--   forward run with perturbed control vector
323              mytime = starttime              mytime = starttime
# Line 345  c--   forward run with perturbed control Line 331  c--   forward run with perturbed control
331              print *, 'ph-check fcpertplus  = ', fcpertplus              print *, 'ph-check fcpertplus  = ', fcpertplus
332    
333  c--   Reset control vector.  c--   Reset control vector.
334              if ( myProcId .EQ. grdchkwhichproc .AND.              call grdchk_setxx( icvrec, FORWARD_SIMULATION,
      &           ierr .EQ. 0 ) then  
                call grdchk_setxx( icvrec, FORWARD_SIMULATION,  
335       &              itile, jtile, layer,       &              itile, jtile, layer,
336       &              itilepos, jtilepos,       &              itilepos, jtilepos,
337       &              xxmemo_ref, mythid )       &              xxmemo_ref, ierr, mythid )
             endif  
338    
339              fcpertminus = fcref              fcpertminus = fcref
340              print *, 'ph-check fcpertminus = ', fcpertminus              print *, 'ph-check fcpertminus = ', fcpertminus
# Line 361  c--   Reset control vector. Line 344  c--   Reset control vector.
344  c--   get control vector component from file  c--   get control vector component from file
345  c--   perturb it and write back to file  c--   perturb it and write back to file
346  c--   repeat the proceedure for a negative perturbation  c--   repeat the proceedure for a negative perturbation
347                 if ( myProcId .EQ. grdchkwhichproc .AND.                 localEps = - abs(grdchk_eps)
348       &           ierr .EQ. 0 ) then                 call grdchk_getxx( icvrec, FORWARD_SIMULATION,
                   localEps = - abs(grdchk_eps)  
                   call grdchk_getxx( icvrec, FORWARD_SIMULATION,  
349       &                 itile, jtile, layer,       &                 itile, jtile, layer,
350       &                 itilepos, jtilepos,       &                 itilepos, jtilepos,
351       &                 xxmemo_ref, xxmemo_pert, localEps,       &                 xxmemo_ref, xxmemo_pert, localEps,
352       &                 mythid )       &                 ierr, mythid )
                else  
                  xxmemo_ref  = 0.  
                  xxmemo_pert = 0.  
                endif  
353    
354  c--   forward run with perturbed control vector  c--   forward run with perturbed control vector
355                 mytime = starttime                 mytime = starttime
# Line 385  c--   forward run with perturbed control Line 362  c--   forward run with perturbed control
362  #endif  #endif
363    
364  c--   Reset control vector.  c--   Reset control vector.
365                 if ( myProcId .EQ. grdchkwhichproc .AND.                 call grdchk_setxx( icvrec, FORWARD_SIMULATION,
      &           ierr .EQ. 0 ) then  
                   call grdchk_setxx( icvrec, FORWARD_SIMULATION,  
366       &                 itile, jtile, layer,       &                 itile, jtile, layer,
367       &                 itilepos, jtilepos,       &                 itilepos, jtilepos,
368       &                 xxmemo_ref, mythid )       &                 xxmemo_ref, ierr, mythid )
                endif  
369    
370  c-- end of if useCentralDiff ...  c-- end of if useCentralDiff ...
371              end if              end if
# Line 520  c-- end of if ( ichknum ... Line 494  c-- end of if ( ichknum ...
494  c-- end of do icomp = ...  c-- end of do icomp = ...
495        enddo        enddo
496    
497        if ( myProcId .EQ. grdchkwhichproc ) then        if (myProcId .EQ. grdchkwhichproc .AND. .NOT.useSingleCpuIO) then
498           CALL WRITE_REC_XYZ_RL(           CALL WRITE_REC_XYZ_RL(
499       &        'grd_findiff'   , tmpplot1, 1, 0, myThid)       &        'grd_findiff'   , tmpplot1, 1, 0, myThid)
500           CALL WRITE_REC_XYZ_RL(           CALL WRITE_REC_XYZ_RL(

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

  ViewVC Help
Powered by ViewVC 1.1.22