--- MITgcm/pkg/autodiff/active_file_ad.F 2001/09/28 04:19:27 1.2 +++ MITgcm/pkg/autodiff/active_file_ad.F 2003/03/06 23:47:46 1.3 @@ -14,6 +14,11 @@ c o adactive_write_xy - Adjoint of active_write_xy c o adactive_write_xyz - Adjoint of active_write_xyz c +c o adactive_read_xz - Adjoint of active_read_xz +c o adactive_read_yz - Adjoint of active_read_yz +c o adactive_write_xz - Adjoint of active_write_xz +c o adactive_write_yz - Adjoint of active_write_yz +c c o adactive_read_tile_xy - Adjoint of active_read_tile_xy c o adactive_read_tile_xyz - Adjoint of active_read_tile_xyz c o adactive_write_tile_xy - Adjoint of active_write_tile_xy @@ -26,6 +31,8 @@ c changed: Patrick Heimbach heimbach@mit.edu 27-May-2000 c - changed suboutine argument list: c dropped mycurrentiter, mycurrenttime +c changed: heimbach@mit.edu 25-Mar-2002 +c - added active file handling of xz-/yz-arrays c c ================================================================== @@ -185,6 +192,160 @@ end CBOP +C !ROUTINE: adactive_read_xz +C !INTERFACE: + subroutine adactive_read_xz( + I active_var_file, + I irec, + I doglobalread, + I lAdInit, + I myiter, + I mythid, + I adactive_var + & ) + +C !DESCRIPTION: \bv +c ================================================================== +c SUBROUTINE adactive_read_xz +c ================================================================== +c o Adjoint of active_read_xz. +c started: heimbach@mit.edu 05-Mar-2001 +c ================================================================== +c SUBROUTINE adactive_read_xz +c ================================================================== +C \ev + +C !USES: + implicit none + +c == global variables == +#include "EEPARAMS.h" +#include "SIZE.h" + +c == routine arguments == +c active_var_file: filename +c adactive_var: array +c irec: record number +c myIter: number of optimization iteration (default: 0) +c mythid: thread number for this instance +c doglobalread: flag for global or local read/write +c (default: .false.) +c lAdInit: initialisation of corresponding adjoint +c variable and write to active file + character*(*) active_var_file + _RL adactive_var(1-olx:snx+olx,nr,nsx,nsy) + integer irec + integer myiter,mythid + logical doglobalread + logical lAdInit + +C !LOCAL VARIABLES: +c == local variables == + integer mynr + integer il + integer ilnblnk + character*(2) adpref + character*(80) fname + +c == functions == + external ilnblnk + +c == end of interface == +CEOP + + mynr = nr + adpref = 'ad' + write(fname(1:80),'(a)') ' ' + + il = ilnblnk(active_var_file) + + write(fname(1:2),'(a)') adpref + write(fname(3:2+il),'(a)') active_var_file(1:il) + + call active_read_xz_rl( fname, adactive_var, + & doglobalread, lAdInit, irec, mynr, + & REVERSE_SIMULATION, myiter, mythid ) + + end + +CBOP +C !ROUTINE: adactive_read_yz +C !INTERFACE: + subroutine adactive_read_yz( + I active_var_file, + I irec, + I doglobalread, + I lAdInit, + I myiter, + I mythid, + I adactive_var + & ) + +C !DESCRIPTION: \bv +c ================================================================== +c SUBROUTINE adactive_read_yz +c ================================================================== +c o Adjoint of active_read_yz. +c started: heimbach@mit.edu 05-Mar-2001 +c ================================================================== +c SUBROUTINE adactive_read_yz +c ================================================================== +C \ev + +C !USES: + implicit none + +c == global variables == +#include "EEPARAMS.h" +#include "SIZE.h" + +c == routine arguments == +c active_var_file: filename +c adactive_var: array +c irec: record number +c myIter: number of optimization iteration (default: 0) +c mythid: thread number for this instance +c doglobalread: flag for global or local read/write +c (default: .false.) +c lAdInit: initialisation of corresponding adjoint +c variable and write to active file + character*(*) active_var_file + _RL adactive_var(1-oly:sny+oly,nr,nsx,nsy) + integer irec + integer myiter,mythid + logical doglobalread + logical lAdInit + +C !LOCAL VARIABLES: +c == local variables == + integer mynr + integer il + integer ilnblnk + character*(2) adpref + character*(80) fname + +c == functions == + external ilnblnk + +c == end of interface == +CEOP + + mynr = nr + adpref = 'ad' + write(fname(1:80),'(a)') ' ' + + il = ilnblnk(active_var_file) + + write(fname(1:2),'(a)') adpref + write(fname(3:2+il),'(a)') active_var_file(1:il) + + call active_read_yz_rl( fname, adactive_var, + & doglobalread, lAdInit, irec, mynr, + & REVERSE_SIMULATION, myiter, mythid ) + + end + +CBOP C !ROUTINE: adactive_read_xy C !INTERFACE: subroutine adactive_write_xy( @@ -259,7 +420,6 @@ end - CBOP C !ROUTINE: adactive_read_xyz C !INTERFACE: @@ -333,6 +493,156 @@ & globalfile, irec, mynr, & REVERSE_SIMULATION, myiter, mythid ) + end + +CBOP +C !ROUTINE: adactive_read_xz +C !INTERFACE: + subroutine adactive_write_xz( + I active_var_file, + I irec, + I myiter, + I mythid, + U adactive_var, + I dummy + & ) + + +C !DESCRIPTION: \bv +c ================================================================== +c SUBROUTINE adactive_write_xz +c ================================================================== +c o Adjoint of active_write_xz. +c started: heimbach@mit.edu 05-Mar-2001 +c ================================================================== +c SUBROUTINE adactive_write_xz +c ================================================================== +C \ev + +C !USES: + implicit none + +c == global variables == +#include "EEPARAMS.h" +#include "SIZE.h" + +c == routine arguments == +c active_var_file: filename +c adactive_var: array +c irec: record number +c myIter: number of optimization iteration (default: 0) +c mythid: thread number for this instance + character*(*) active_var_file + _RL adactive_var(1-olx:snx+olx,nr,nsx,nsy) + integer irec + integer myiter,mythid + _RL dummy + +C !LOCAL VARIABLES: +c == local variables == + integer mynr + integer il + integer ilnblnk + character*(2) adpref + character*(80) fname + logical globalfile + +c == functions == + external ilnblnk + +c == end of interface == +CEOP + + mynr = nr + adpref = 'ad' + write(fname(1:80),'(a)') ' ' + + il = ilnblnk(active_var_file) + + write(fname(1:2),'(a)') adpref + write(fname(3:2+il),'(a)') active_var_file(1:il) + + globalfile = .false. + + call active_write_xz_rl( fname, adactive_var, + & globalfile, irec, mynr, + & REVERSE_SIMULATION, myiter, mythid ) + + end + +CBOP +C !ROUTINE: adactive_read_yz +C !INTERFACE: + subroutine adactive_write_yz( + I active_var_file, + I irec, + I myiter, + I mythid, + U adactive_var, + I dummy + & ) + + +C !DESCRIPTION: \bv +c ================================================================== +c SUBROUTINE adactive_write_yz +c ================================================================== +c o Adjoint of active_write_yz. +c started: heimbach@mit.edu 05-Mar-2001 +c ================================================================== +c SUBROUTINE adactive_write_yz +c ================================================================== +C \ev + +C !USES: + implicit none + +c == global variables == +#include "EEPARAMS.h" +#include "SIZE.h" + +c == routine arguments == +c active_var_file: filename +c adactive_var: array +c irec: record number +c myIter: number of optimization iteration (default: 0) +c mythid: thread number for this instance + character*(*) active_var_file + _RL adactive_var(1-oly:sny+oly,nr,nsx,nsy) + integer irec + integer myiter,mythid + _RL dummy + +C !LOCAL VARIABLES: +c == local variables == + integer mynr + integer il + integer ilnblnk + character*(2) adpref + character*(80) fname + logical globalfile + +c == functions == + external ilnblnk + +c == end of interface == +CEOP + + mynr = nr + adpref = 'ad' + write(fname(1:80),'(a)') ' ' + + il = ilnblnk(active_var_file) + + write(fname(1:2),'(a)') adpref + write(fname(3:2+il),'(a)') active_var_file(1:il) + + globalfile = .false. + + call active_write_yz_rl( fname, adactive_var, + & globalfile, irec, mynr, + & REVERSE_SIMULATION, myiter, mythid ) + end