SUBROUTINE SUTERM(KULOUT) 1 #if defined (DOC) * ***s/rSUTERM - Termination of Job (close IO/units, deallocate * . memory and verification of the integrity of the heap) * *Author: P. Gauthier *ARMA/AES June 9, 1992 *Revision: * P. Gauthier *ARMA/AES May 25, 1993 * . Update to take into aacount all the new arrays * . Arrays allocated by SUALLO and SUALOBS are optionally * . deallocated when HPCHECK signals an error. * P. Koclas CMC/CMSV January 1997 * . added call to EXFIN * L. Fillion *ARMA/AES Nov 25, 1998 * . Deallocate arrays needed for TL and ADJ observation operators. * C. Charette *ARMA/AES Fev 1999 * . Deallocate arrays in compdg.cdk * C. Charette *ARMA/AES SEP 1999 * - Operator PTOT as a function of latitude * S. Pellerin *ARMA/AES March 2000 * - Close nulstato * S. Pellerin *ARMA/SMC May 2000 * - Logical unit cleanup * - Fix for F90 conversion: * .Illimination of pointer to character*9 CSTNID * .Introduction of distinc pointer for integer * and real cma arrays (ptmobhdr,ptrobhdr,ptmobdata * ,ptrobdata) * S. Pellerin *ARMA/SMC Nov. 2001 * - Deallocation of MVAR and PEXY (4Dvar book keeping vectors) * Bin He *ARMA/SMC DEC. 2006 * - only keep the release of the memory pointed by PTGD. The remain memory * release moved to subroutine "memfree" which is called before varout * * C.Charette *ARMA/AES May 23,2007 * - With respect to version v10.0.2 * 1) Added the deallocation of memory of * PTILON, PTNNP1, PT1SNP1, PTCONPHY, PTCONINA * 2) Removed the deallocation of memory of PTVATRA * * Bin HE *ARMA/SMC - Apr. 2008 * - closed multiple trial files. * * Y.J. Rochon *ARQX/MSC May 2005 * - Added closing of species background stats file. # *Arguments * i KULOUT: unit used for optional printing * #endif C IMPLICIT NONE *implicits #include "comct0.cdk"
#include "pardim.cdk"
#include "comdim.cdk"
#include "comleg.cdk"
#include "comlun.cdk"
#include "comgd0.cdk"
#include "comgd1.cdk"
#include "compdg.cdk"
#include "comsp.cdk"
#include "comsp1.cdk"
#include "comspg.cdk"
#include "comcorr.cdk"
#include "comgem.cdk"
#include "comcva.cdk"
C C* Comdecks associated with the observations C ---------------------------------------- #include "comdimo.cdk"
#include "comoahdr.cdk"
#include "comoabdy.cdk"
#include "commvo.cdk"
#include "commvo1.cdk"
#include "commvog.cdk"
#include "commvohr.cdk"
#include "comoba.cdk"
* INTEGER ISTAMP,IERR, KULOUT, FSTFRM,EXFIN, fclos integer k EXTERNAL HPCHECK, HPDEALLC, FSTFRM,EXFIN C C* 1. Verify the integrity of the heap C 100 CONTINUE C WRITE(KULOUT,FMT='(/,10X," JOB TERMINATION BY SUTERM", S /,20(" *"))') C C* 4. Close RPN standard files (opened in SULUN) C if(nulstd.ne.0) IERR = FSTFRM(NULSTD) if(nulstat.ne.0) ierr = fstfrm(nulstat) if(nulbgst.ne.0) ierr = fstfrm(nulbgst) if(nulinclr.ne.0) ierr = fstfrm(nulinclr) if(nulinchr.ne.0) ierr = fstfrm(nulinchr) if(nulbgstr.ne.0) ierr = fstfrm(nulbgstr) do k=1,ntrials ierr=fstfrm(ninmpg(k)) enddo C C Closing an ASCII file used for diagnostics C c CALL HPCHECK(IERR) C IF(IERR.EQ.0)THEN WRITE(KULOUT,FMT='(5X,10("*")," No memory overflow" S ," detected ",10("*"))') ELSE C C* 2. Verify the arrays allocated within SUALLO C 200 CONTINUE WRITE(KULOUT,1000)IERR 1000 format(10X, 5("*")," Problem with the dynamic memory", & " allocation. IERR =",I3," returned by HPCHECK") C #if defined (NEC) CALL VFLUSH(KULOUT) #endif CALL HPDEALLC(PTILON,IERR,1) IF(IERR.EQ.0)THEN WRITE(KULOUT,FMT='(10X," NILON checked and correct", S ". IERR =",I3)')IERR ELSE WRITE(KULOUT,FMT='(4x,10("*")," Problem detected in", S " NILON. IERR =",I3)')IERR END IF C CALL HPDEALLC(PTNNP1,IERR,1) IF(IERR.EQ.0)THEN WRITE(KULOUT,FMT='(10X," RNNP1 checked and correct", S ". IERR =",I3)')IERR ELSE WRITE(KULOUT,FMT='(4x,10("*")," Problem detected in", S " RNNP1. IERR =",I3)')IERR END IF C CALL HPDEALLC(PT1SNP1,IERR,1) IF(IERR.EQ.0)THEN WRITE(KULOUT,FMT='(10X," R1SNP1 checked and correct", S ". IERR =",I3)')IERR ELSE WRITE(KULOUT,FMT='(4x,10("*")," Problem detected in", S " R1SNP1. IERR =",I3)')IERR END IF C CALL HPDEALLC(PTCONPHY,IERR,1) IF(IERR.EQ.0)THEN WRITE(KULOUT,FMT='(10X," CONPHY checked and correct", S ". IERR =",I3)')IERR ELSE WRITE(KULOUT,FMT='(4x,10("*")," Problem detected in", S " CONPHY. IERR =",I3)')IERR END IF C CALL HPDEALLC(PTCONIMA,IERR,1) IF(IERR.EQ.0)THEN WRITE(KULOUT,FMT='(10X," CONIMA checked and correct", S ". IERR =",I3)')IERR ELSE WRITE(KULOUT,FMT='(4x,10("*")," Problem detected in", S " CONIMA. IERR =",I3)')IERR END IF CALL HPDEALLC(PTGD,IERR,1) IF(IERR.EQ.0)THEN WRITE(KULOUT,FMT='(10X," GD checked and correct", S ". IERR =",I3)')IERR ELSE WRITE(KULOUT,FMT='(4x,10("*")," Problem detected in", S " GD. IERR =",I3)')IERR END IF C C END IF ISTAMP=EXFIN('3DVAR','FIN','SUTERM') C RETURN END