Back to home page

MITgcm

 
 

    


File indexing completed on 2024-03-02 06:10:02 UTC

view on githubraw file Latest commit 5cf43646 on 2024-03-01 18:50:49 UTC
5cf4364659 Mart*0001 #include "CTRL_OPTIONS.h"
4cee17c1be Patr*0002 
                0003       subroutine optim_sub(
                0004      I                 nn
                0005      &               )
                0006 
                0007 c     ==================================================================
                0008 c     SUBROUTINE optim_sub
                0009 c     ==================================================================
                0010 c
                0011 c     o Initialization of optimization run.
                0012 c
                0013 c     started: Christian Eckert eckert@mit.edu 15-Feb-2000
                0014 c
                0015 c     changed: Christian Eckert eckert@mit.edu 10-Mar-2000
                0016 c
                0017 c              - Added ECCO layout.
                0018 c
                0019 c     changed:  Patrick Heimbach heimbach@mit.edu 19-Jun-2000
                0020 c               - finished, revised and debugged
                0021 c
                0022 c     ==================================================================
                0023 c     SUBROUTINE optim_sub
                0024 c     ==================================================================
                0025 
5cf4364659 Mart*0026       IMPLICIT NONE
4cee17c1be Patr*0027 
                0028 c     == global variables ==
                0029 
                0030 #include "EEPARAMS.h"
                0031 #include "SIZE.h"
                0032 
5cf4364659 Mart*0033 #include "CTRL_SIZE.h"
65754df434 Mart*0034 #include "CTRL.h"
4cee17c1be Patr*0035 #include "optim.h"
                0036 
                0037 c     == routine arguments ==
                0038 
                0039       integer nn
                0040 
                0041 c     == local variables ==
                0042 
                0043       _RL   objf
                0044 
                0045 #if defined (DYNAMIC)
                0046       _RL   xx(nn)
                0047       _RL   adxx(nn)
                0048       _RL   dd(nn)
                0049       _RL   gold(nn)
                0050       _RL   xdiff(nn)
                0051 #elif defined (USE_POINTER) || (MAX_INDEPEND == 0)
                0052       _RL   xx
                0053       _RL   adxx
                0054       _RL   dd(1)
                0055       _RL   gold(1)
                0056       _RL   xdiff(1)
                0057       pointer (pxx,xx(1))
                0058       pointer (padxx,adxx(1))
                0059       pointer (pdd,dd)
                0060       pointer (pgold,gold)
                0061       pointer (pxdiff,xdiff)
                0062 #else
                0063       integer nmax
                0064       parameter( nmax = MAX_INDEPEND )
                0065       _RL   xx(nmax)
                0066       _RL   adxx(nmax)
                0067       _RL   dd(nmax)
                0068       _RL   gold(nmax)
                0069       _RL   xdiff(nmax)
                0070 #endif
                0071 
                0072 c--   Allocate memory for the control variables and the gradient vector.
                0073 #if defined(DYNAMIC)
                0074 #elif defined(USE_POINTER) || (MAX_INDEPEND == 0)
                0075       call myalloc( pxx  ,  nn*REAL_BYTE )
                0076       call myalloc( padxx,  nn*REAL_BYTE )
                0077       call myalloc( pdd,    nn*REAL_BYTE )
                0078       call myalloc( pgold,  nn*REAL_BYTE )
                0079       call myalloc( pxdiff, nn*REAL_BYTE )
                0080 #endif
                0081 
                0082       integer ifail
                0083       integer itmax
                0084       logical loffline
                0085 
                0086 c     == external ==
                0087 
                0088       external simul
                0089       external lsline
                0090 
                0091 c     == end of interface ==
                0092 
                0093 c--   Initialisize the model and set a first guess of the control
                0094 c--   variables.
                0095       call optim_initmod( nn, xx )
                0096 
                0097 #if defined (DYNAMIC)
                0098 #elif defined(USE_POINTER) || (MAX_INDEPEND == 0)
                0099 #else
                0100       if (nn .gt. nmax) then
                0101         print*,' OPTIMUM: Not enough space.'
                0102         print*,'          nmax = ',nmax
                0103         print*,'            nn = ',nn
                0104         print*
                0105         print*,'          Set MAX_INDEPEND in Makefile .ge. ',nn
                0106         print*
                0107         stop   ' ... stopped in OPTIMUM.'
                0108       endif
                0109 #endif
                0110 
                0111       print*, ' OPTIMUM: Calling lsopt for iteration: ',optimcycle
                0112       print*, ' OPTIMUM: with nn, REAL_BYTE = ', nn, REAL_BYTE
                0113 
                0114       loffline = .true.
                0115       itmax    = numiter
                0116 
                0117 c--   Large scale optimization --> Gilbert & Lemarechal.
5cf4364659 Mart*0118 #ifdef EXCLUDE_LSOPT_TO_CHECK
                0119       ifail = 0
                0120       call simul( ifail, nn, xx, objf, adxx )
                0121 #else /* EXCLUDE_LSOPT_TO_CHECK */
4cee17c1be Patr*0122       call lsopt_top( nn, xx, objf, adxx
                0123      &              , simul, lsline
                0124      &              , epsx, fmin, epsg
                0125      &              , iprint
                0126      &              , itmax, nfunc, nupdate
                0127      &              , dd, gold, xdiff
                0128      &              , loffline
                0129      &              , ifail )
5cf4364659 Mart*0130 #endif /* EXCLUDE_LSOPT_TO_CHECK */
4cee17c1be Patr*0131 
5cf4364659 Mart*0132       RETURN
                0133       END