Back to home page

darwin3

 
 

    


File indexing completed on 2025-09-13 12:07:55 UTC

view on githubraw file Latest commit 13ce79fe on 2025-08-04 21:05:34 UTC
367ecbf006 Gael*0001 #include "PROFILES_OPTIONS.h"
6a770e0a24 Patr*0002 
c9bf163375 Ivan*0003 C     ==================================================================
                0004 C     active_file_control_profiles.F: Routines that handle the I/O of
                0005 C                                     active variables for the adjoint
                0006 C                                     calculations, related to netcdf
                0007 C                                     profiles data files
                0008 C
                0009 C     Routines
                0010 C     o  active_read_profile_rl  - Read an active 1 record from file
                0011 C                                  fwd-mode only: including a mask
                0012 C     o  active_write_profile_rl - Write nn active 1D record to file.
                0013 C                                  fwd-mode only: including a mask
                0014 C
                0015 C     started: Gael Forget 15-March-2006
                0016 C     ==================================================================
                0017 
                0018 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0019 CBOP
13ce79fe94 Ivan*0020 C !ROUTINE: ACTIVE_READ_PROFILE_RL
                0021 
                0022 C !INTERFACE:
c9bf163375 Ivan*0023       SUBROUTINE ACTIVE_READ_PROFILE_RL(
6a770e0a24 Patr*0024      I                                fid,
71a5587721 Gael*0025      I                                active_num_file,
6a770e0a24 Patr*0026      I                                nactive_var,
                0027      O                                active_var,
                0028      I                                active_varnum,
                0029      I                                lAdInit,
                0030      I                                irec,
                0031      I                                irecglob,
                0032      I                                theSimulationMode,
                0033      I                                myOptimIter,
71a5587721 Gael*0034      I                                bi,
                0035      I                                bj,
c9bf163375 Ivan*0036      I                                myThid
6a770e0a24 Patr*0037      &                              )
                0038 
c9bf163375 Ivan*0039 C     !DESCRIPTION:
                0040 C     Read an active 1D record from file. In forward-mode
                0041 C     (theSimulationMode = FORWARD_SIMULATION) also read a mask from
                0042 C     file.
6a770e0a24 Patr*0043 
c9bf163375 Ivan*0044 C     !USES:
                0045       IMPLICIT NONE
13ce79fe94 Ivan*0046 C     == Global variables ===
6a770e0a24 Patr*0047 #include "EEPARAMS.h"
                0048 #include "SIZE.h"
                0049 #include "PARAMS.h"
6e4c90fea3 Patr*0050 #ifdef ALLOW_PROFILES
6328b73337 Gael*0051 # include "netcdf.inc"
                0052 # include "PROFILES_SIZE.h"
                0053 # include "profiles.h"
6e4c90fea3 Patr*0054 #endif
6a770e0a24 Patr*0055 
c9bf163375 Ivan*0056 C     !INPUT PARAMETERS:
13ce79fe94 Ivan*0057 C     myThid :: my thread ID number
c9bf163375 Ivan*0058       INTEGER fid
                0059       INTEGER active_num_file, nactive_var, active_varnum
                0060       LOGICAL lAdInit
                0061       INTEGER irec, irecglob
                0062       INTEGER theSimulationMode
                0063       INTEGER myOptimIter
                0064       INTEGER bi, bj, myThid
                0065 C     !OUTPUT PARAMETERS:
                0066       _RL     active_var(nactive_var)
13ce79fe94 Ivan*0067 CEOP
6a770e0a24 Patr*0068 
6e4c90fea3 Patr*0069 #ifdef ALLOW_PROFILES
c9bf163375 Ivan*0070 C     !LOCAL VARIABLES:
13ce79fe94 Ivan*0071       INTEGER err, varId, maskId, vec_start(2), vec_count(2)
c9bf163375 Ivan*0072       INTEGER i, ivar, jrec
                0073       _RL     active_data_t(nactive_var)
                0074       REAL*8  vec_tmp(nactive_var+1)
                0075 
                0076       IF (profilesDoNcOutput) THEN
13ce79fe94 Ivan*0077         vec_start(1)=1
                0078         vec_start(2)=irec
                0079         vec_count(1)=nactive_var
                0080         vec_count(2)=1
                0081 
                0082 C ESCO: Put a single NF_INQ_VARID for prof_names
                0083         err = NF_INQ_VARID( fid,
                0084      &        prof_names(active_num_file,active_varnum), varId )
                0085         CALL PROFILES_NF_ERROR(
                0086      &       'ACTIVE_READ: NF_INQ_VARID prof_names',
                0087      &       err,bi,bj,myThid )
                0088 
c9bf163375 Ivan*0089       ELSE
13ce79fe94 Ivan*0090         jrec = 2 * ( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
                0091      &       + prof_num_var_cur(active_num_file,active_varnum,bi,bj)
                0092      &       -1 )
                0093 
c9bf163375 Ivan*0094       ENDIF
                0095 
                0096 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
                0097 C     >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
                0098 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
                0099 
                0100       IF (theSimulationMode .EQ. FORWARD_SIMULATION) THEN
                0101 
13ce79fe94 Ivan*0102         _BEGIN_MASTER( myThid )
                0103 
                0104         IF (profilesDoNcOutput) THEN
                0105           err = NF_GET_VARA_DOUBLE( fid, varId, vec_start, vec_count,
                0106      &          active_var )
                0107           CALL PROFILES_NF_ERROR(
                0108      &         'ACTIVE_READ: NF_GET_VARA_DOUBLE active_var',
                0109      &         err,bi,bj,myThid )
                0110 
                0111           err = NF_INQ_VARID( fid,
                0112      &          prof_namesmask(active_num_file,active_varnum),
                0113      &          maskId )
                0114           CALL PROFILES_NF_ERROR(
                0115      &         'ACTIVE_READ: NF_INQ_VARID prof_namesmask',
                0116      &         err,bi,bj,myThid )
                0117           err = NF_GET_VARA_DOUBLE( fid, maskId, vec_start, vec_count,
                0118      &          prof_mask1D_cur(1,bi,bj) )
                0119           CALL PROFILES_NF_ERROR(
                0120      &         'ACTIVE_READ: NF_GET_VARA_DOUBLE prof_mask1D_cur',
                0121      &         err,bi,bj,myThid )
                0122 
                0123         ELSE
                0124 
                0125           READ(fid,rec=jrec+1) vec_tmp
                0126 # ifdef _BYTESWAPIO
                0127           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
                0128 # endif
                0129           DO ivar=1,nactive_var
                0130             active_var(ivar)=vec_tmp(ivar)
                0131           ENDDO
                0132 
                0133           READ(fid,rec=jrec+2) vec_tmp
                0134 # ifdef _BYTESWAPIO
                0135           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
                0136 # endif
                0137           DO ivar=1,nactive_var
                0138             prof_mask1D_cur(ivar,bi,bj)=vec_tmp(ivar)
                0139           ENDDO
                0140 
                0141         ENDIF
                0142 
                0143         _END_MASTER( myThid )
6a770e0a24 Patr*0144 
c9bf163375 Ivan*0145       ENDIF
6a770e0a24 Patr*0146 
c9bf163375 Ivan*0147 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
                0148 C     >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
                0149 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
6a770e0a24 Patr*0150 
c9bf163375 Ivan*0151       IF (theSimulationMode .EQ. REVERSE_SIMULATION) THEN
6a770e0a24 Patr*0152 
13ce79fe94 Ivan*0153         _BEGIN_MASTER( myThid )
6a770e0a24 Patr*0154 
13ce79fe94 Ivan*0155         IF (profilesDoNcOutput) THEN
                0156           err = NF_GET_VARA_DOUBLE( fid, varId, vec_start, vec_count,
                0157      &          active_data_t )
                0158           CALL PROFILES_NF_ERROR(
                0159      &         'ACTIVE_READ: NF_GET_VARA_DOUBLE AD active_data_t',
                0160      &         err,bi,bj,myThid )
6a770e0a24 Patr*0161 
c9bf163375 Ivan*0162 C     Add active_var from appropriate location to data.
13ce79fe94 Ivan*0163           DO i = 1,nactive_var
                0164             active_data_t(i) = active_data_t(i) + active_var(i)
                0165           ENDDO
c9bf163375 Ivan*0166 C     Store the result on disk.
6a770e0a24 Patr*0167 
13ce79fe94 Ivan*0168           err = NF_PUT_VARA_DOUBLE(fid, varId, vec_start, vec_count,
                0169      &          active_data_t )
                0170           CALL PROFILES_NF_ERROR(
                0171      &         'ACTIVE_READ: NF_PUT_VARA_DOUBLE AD active_data_t',
                0172      &         err,bi,bj,myThid )
6a770e0a24 Patr*0173 
c9bf163375 Ivan*0174 C     Set active_var to zero.
13ce79fe94 Ivan*0175           DO i = 1,nactive_var
                0176             active_var(i) = 0. _d 0
                0177           ENDDO
6a770e0a24 Patr*0178 
13ce79fe94 Ivan*0179         ELSE
6a770e0a24 Patr*0180 
13ce79fe94 Ivan*0181           READ(fid,rec=jrec+1) vec_tmp
                0182 # ifdef _BYTESWAPIO
                0183           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
                0184 # endif
                0185           DO ivar=1,nactive_var
                0186             active_data_t(ivar)=vec_tmp(ivar)
                0187           ENDDO
c9bf163375 Ivan*0188 
                0189 C     Add active_var from appropriate location to data.
13ce79fe94 Ivan*0190           DO i = 1,nactive_var
                0191             active_data_t(i) = active_data_t(i) + active_var(i)
                0192           ENDDO
c9bf163375 Ivan*0193 
                0194 C     Store the result on disk.
13ce79fe94 Ivan*0195           DO ivar=1,nactive_var
                0196             vec_tmp(ivar)=active_data_t(ivar)
                0197           ENDDO
6a770e0a24 Patr*0198 #ifdef _BYTESWAPIO
13ce79fe94 Ivan*0199           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
6a770e0a24 Patr*0200 #endif
13ce79fe94 Ivan*0201           WRITE(fid,rec=jrec+1) vec_tmp
6a770e0a24 Patr*0202 
c9bf163375 Ivan*0203 C     Set active_var to zero.
13ce79fe94 Ivan*0204           DO i = 1,nactive_var
                0205             active_var(i) = 0. _d 0
                0206           ENDDO
6a770e0a24 Patr*0207 
13ce79fe94 Ivan*0208         ENDIF
6a770e0a24 Patr*0209 
13ce79fe94 Ivan*0210         _END_MASTER( myThid )
6a770e0a24 Patr*0211 
c9bf163375 Ivan*0212       ENDIF
6a770e0a24 Patr*0213 
c9bf163375 Ivan*0214 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
                0215 C     >>>>>>>>>>>>>>>>>>> TANGENT RUN <<<<<<<<<<<<<<<<<<<
                0216 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
6a770e0a24 Patr*0217 
c9bf163375 Ivan*0218       IF (theSimulationMode .EQ. TANGENT_SIMULATION) THEN
6a770e0a24 Patr*0219 
13ce79fe94 Ivan*0220         _BEGIN_MASTER( myThid )
6a770e0a24 Patr*0221 
13ce79fe94 Ivan*0222         IF (profilesDoNcOutput) THEN
                0223           err = NF_GET_VARA_DOUBLE( fid, varId, vec_start, vec_count,
                0224      &          active_var )
                0225           CALL PROFILES_NF_ERROR(
                0226      &         'ACTIVE_READ: NF_GET_VARA_DOUBLE TL active_var',
                0227      &         err,bi,bj,myThid )
6a770e0a24 Patr*0228 
13ce79fe94 Ivan*0229         ELSE
6a770e0a24 Patr*0230 
13ce79fe94 Ivan*0231           READ(fid,rec=jrec+1) vec_tmp
                0232 # ifdef _BYTESWAPIO
                0233           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
                0234 # endif
                0235           DO ivar=1,nactive_var
                0236             active_var(ivar)=vec_tmp(ivar)
                0237           ENDDO
6a770e0a24 Patr*0238 
13ce79fe94 Ivan*0239         ENDIF
6a770e0a24 Patr*0240 
13ce79fe94 Ivan*0241         _END_MASTER( myThid )
6a770e0a24 Patr*0242 
c9bf163375 Ivan*0243       ENDIF
6a770e0a24 Patr*0244 
6e4c90fea3 Patr*0245 #endif /* ALLOW_PROFILES */
                0246 
c9bf163375 Ivan*0247       RETURN
                0248       END
6a770e0a24 Patr*0249 
c9bf163375 Ivan*0250 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                0251 CBOP
13ce79fe94 Ivan*0252 C !ROUTINE: ACTIVE_WRITE_PROFILE_RL
                0253 
                0254 C !INTERFACE:
c9bf163375 Ivan*0255       SUBROUTINE ACTIVE_WRITE_PROFILE_RL(
71a5587721 Gael*0256      I                                 fid,
                0257      I                                 active_num_file,
6a770e0a24 Patr*0258      I                                 nactive_var,
                0259      I                                 active_var,
                0260      I                                 active_varnum,
                0261      I                                 irec,
                0262      I                                 irecglob,
                0263      I                                 theSimulationMode,
                0264      I                                 myOptimIter,
71a5587721 Gael*0265      I                                 bi,
                0266      I                                 bj,
c9bf163375 Ivan*0267      I                                 myThid
6a770e0a24 Patr*0268      &                               )
                0269 
c9bf163375 Ivan*0270 C     !DESCRIPTION:
                0271 C     Write an active 1D record to file. In forward-mode
                0272 C     (theSimulationMode = FORWARD_SIMULATION) also write a mask to file.
6a770e0a24 Patr*0273 
c9bf163375 Ivan*0274 C     !USES:
                0275       IMPLICIT NONE
13ce79fe94 Ivan*0276 C     == Global variables ===
6a770e0a24 Patr*0277 #include "EEPARAMS.h"
                0278 #include "SIZE.h"
                0279 #include "PARAMS.h"
6e4c90fea3 Patr*0280 #ifdef ALLOW_PROFILES
6328b73337 Gael*0281 # include "netcdf.inc"
                0282 # include "PROFILES_SIZE.h"
                0283 # include "profiles.h"
6e4c90fea3 Patr*0284 #endif
6a770e0a24 Patr*0285 
c9bf163375 Ivan*0286 C     !INPUT PARAMETERS:
13ce79fe94 Ivan*0287 C     myThid :: my thread ID number
c9bf163375 Ivan*0288       INTEGER fid
                0289       INTEGER active_num_file, nactive_var, active_varnum
                0290       INTEGER irec, irecglob
                0291       INTEGER theSimulationMode
                0292       INTEGER myOptimIter
                0293       INTEGER bi,bj,myThid
                0294       _RL     active_var(nactive_var)
                0295 C     !OUTPUT PARAMETERS:
13ce79fe94 Ivan*0296 CEOP
6a770e0a24 Patr*0297 
6e4c90fea3 Patr*0298 #ifdef ALLOW_PROFILES
c9bf163375 Ivan*0299 C     !LOCAL VARIABLES:
13ce79fe94 Ivan*0300       INTEGER err, varId, maskId, vec_start(2), vec_count(2)
c9bf163375 Ivan*0301       INTEGER i, ivar, jrec
                0302       _RL     active_data_t(nactive_var)
13ce79fe94 Ivan*0303       real*8  vec_tmp(nactive_var+1)
6a770e0a24 Patr*0304 
c9bf163375 Ivan*0305       IF (profilesDoNcOutput) THEN
13ce79fe94 Ivan*0306         vec_start(1)=1
                0307         vec_start(2)=irec
                0308         vec_count(1)=nactive_var
                0309         vec_count(2)=1
                0310 
                0311 C ESCO: Put a single NF_INQ_VARID for prof_names
                0312         err = NF_INQ_VARID( fid,
                0313      &        prof_names(active_num_file,active_varnum), varId )
                0314         CALL PROFILES_NF_ERROR(
                0315      &       'ACTIVE_WRITE: NF_INQ_VARID prof_names',
                0316      &       err,bi,bj,myThid )
                0317 
c9bf163375 Ivan*0318       ELSE
13ce79fe94 Ivan*0319         jrec = 2 * ( (irec-1)*prof_num_var_tot(active_num_file,bi,bj)
                0320      &       + prof_num_var_cur(active_num_file,active_varnum,bi,bj)
                0321      &       -1 )
                0322 
c9bf163375 Ivan*0323       ENDIF
6a770e0a24 Patr*0324 
c9bf163375 Ivan*0325 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
                0326 C     >>>>>>>>>>>>>>>>>>> FORWARD RUN <<<<<<<<<<<<<<<<<<<
                0327 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
6a770e0a24 Patr*0328 
c9bf163375 Ivan*0329       IF (theSimulationMode .EQ. FORWARD_SIMULATION) THEN
6a770e0a24 Patr*0330 
13ce79fe94 Ivan*0331         _BEGIN_MASTER( myThid )
                0332 
                0333         IF (profilesDoNcOutput) THEN
                0334           err = NF_PUT_VARA_DOUBLE( fid, varId, vec_start, vec_count,
                0335      &          active_var )
                0336           CALL PROFILES_NF_ERROR(
                0337      &         'ACTIVE_WRITE: NF_PUT_VARA_DOUBLE active_var',
                0338      &         err,bi,bj,myThid )
                0339 
                0340           err = NF_INQ_VARID( fid,
                0341      &          prof_namesmask(active_num_file,active_varnum),
                0342      &          maskId )
                0343           CALL PROFILES_NF_ERROR(
                0344      &         'ACTIVE_WRITE: NF_INQ_VARID prof_namesmask',
                0345      &         err,bi,bj,myThid )
                0346           err = NF_PUT_VARA_DOUBLE(fid, maskId, vec_start, vec_count,
                0347      &          prof_mask1D_cur(1,bi,bj) )
                0348           CALL PROFILES_NF_ERROR(
                0349      &         'ACTIVE_WRITE: NF_PUT_VARA_DOUBLE prof_mask1D_cur',
                0350      &         err,bi,bj,myThid )
                0351 
                0352           err = NF_INQ_VARID( fid, 'prof_ind_glob', maskId )
                0353           CALL PROFILES_NF_ERROR(
                0354      &         'ACTIVE_WRITE: NF_INQ_VARID prof_ind_glob',
                0355      &         err,bi,bj,myThid )
                0356           err = NF_PUT_VAR1_INT( fid, maskId, vec_start(2), irecglob )
                0357           CALL PROFILES_NF_ERROR(
                0358      &         'ACTIVE_WRITE: NF_PUT_VAR1_INT irecglob',
                0359      &         err,bi,bj,myThid )
                0360 
                0361         ELSE
                0362 
                0363           DO ivar=1,nactive_var
                0364             vec_tmp(ivar)=active_var(ivar)
                0365           ENDDO
                0366           vec_tmp(nactive_var+1)=irecglob
                0367 # ifdef _BYTESWAPIO
                0368           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
                0369 # endif
                0370           WRITE(fid,rec=jrec+1) vec_tmp
                0371           DO ivar=1,nactive_var
                0372             vec_tmp(ivar)=prof_mask1D_cur(ivar,bi,bj)
                0373           ENDDO
                0374           vec_tmp(nactive_var+1)=irecglob
                0375 # ifdef _BYTESWAPIO
                0376           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
                0377 # endif
                0378           WRITE(fid,rec=jrec+2) vec_tmp
                0379 
                0380         ENDIF
                0381 
                0382         _END_MASTER( myThid )
6a770e0a24 Patr*0383 
c9bf163375 Ivan*0384       ENDIF
6a770e0a24 Patr*0385 
c9bf163375 Ivan*0386 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
                0387 C     >>>>>>>>>>>>>>>>>>> ADJOINT RUN <<<<<<<<<<<<<<<<<<<
                0388 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
6a770e0a24 Patr*0389 
c9bf163375 Ivan*0390       IF (theSimulationMode .EQ. REVERSE_SIMULATION) THEN
6a770e0a24 Patr*0391 
13ce79fe94 Ivan*0392         _BEGIN_MASTER( myThid )
6a770e0a24 Patr*0393 
13ce79fe94 Ivan*0394         IF (profilesDoNcOutput) THEN
                0395           err = NF_GET_VARA_DOUBLE( fid, varId, vec_start, vec_count,
                0396      &          active_data_t )
                0397           CALL PROFILES_NF_ERROR(
                0398      &         'ACTIVE_WRITE: NF_GET_VARA_DOUBLE AD active_data_t',
                0399      &         err,bi,bj,myThid )
6a770e0a24 Patr*0400 
c9bf163375 Ivan*0401 C     Add active_var to data.
13ce79fe94 Ivan*0402           DO i = 1,nactive_var
                0403             active_var(i) = active_var(i) + active_data_t(i)
                0404             active_data_t(i) = 0. _d 0
                0405           ENDDO
                0406 
                0407           err = NF_PUT_VARA_DOUBLE( fid, varId, vec_start, vec_count,
                0408      &          active_data_t )
                0409           CALL PROFILES_NF_ERROR(
                0410      &         'ACTIVE_WRITE: NF_PUT_VARA_DOUBLE AD active_data_t',
                0411      &         err,bi,bj,myThid )
                0412 
                0413         ELSE
                0414 
                0415           READ(fid,rec=jrec+1) vec_tmp
                0416 # ifdef _BYTESWAPIO
                0417           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
                0418 # endif
                0419           DO ivar=1,nactive_var
                0420             active_data_t(ivar)=vec_tmp(ivar)
                0421           ENDDO
                0422 
                0423 C         Add active_var from appropriate location to data.
                0424           DO i = 1,nactive_var
                0425             active_var(i) = active_var(i) + active_data_t(i)
                0426             active_data_t(i) = 0. _d 0
                0427           ENDDO
                0428 
                0429 C         Store the result on disk.
                0430           DO ivar=1,nactive_var
                0431             vec_tmp(ivar)=active_data_t(ivar)
                0432           ENDDO
                0433 # ifdef _BYTESWAPIO
                0434           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
                0435 # endif
                0436           WRITE(fid,rec=jrec+1) vec_tmp
                0437 
                0438         ENDIF
                0439 
                0440         _END_MASTER( myThid )
6a770e0a24 Patr*0441 
c9bf163375 Ivan*0442       ENDIF
6a770e0a24 Patr*0443 
c9bf163375 Ivan*0444 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
                0445 C     >>>>>>>>>>>>>>>>>>> TANGENT RUN <<<<<<<<<<<<<<<<<<<
                0446 C     >>>>>>>>>>>>>>>>>>>             <<<<<<<<<<<<<<<<<<<
6a770e0a24 Patr*0447 
c9bf163375 Ivan*0448       IF (theSimulationMode .EQ. TANGENT_SIMULATION) THEN
6a770e0a24 Patr*0449 
13ce79fe94 Ivan*0450         _BEGIN_MASTER( myThid )
6a770e0a24 Patr*0451 
13ce79fe94 Ivan*0452         IF (profilesDoNcOutput) THEN
                0453           err = NF_PUT_VARA_DOUBLE( fid, varId, vec_start, vec_count,
                0454      &          active_var )
                0455           CALL PROFILES_NF_ERROR(
                0456      &         'ACTIVE_WRITE: NF_PUT_VARA_DOUBLE TL active_var',
                0457      &         err,bi,bj,myThid )
6a770e0a24 Patr*0458 
13ce79fe94 Ivan*0459         ELSE
6a770e0a24 Patr*0460 
13ce79fe94 Ivan*0461           DO ivar=1,nactive_var
                0462             vec_tmp(ivar)=active_var(ivar)
                0463           ENDDO
                0464           vec_tmp(nactive_var+1)=irecglob
                0465 # ifdef _BYTESWAPIO
                0466           CALL MDS_BYTESWAPR8(nactive_var+1,vec_tmp)
                0467 # endif
                0468           WRITE(fid,rec=jrec+1) vec_tmp
6a770e0a24 Patr*0469 
13ce79fe94 Ivan*0470         ENDIF
6a770e0a24 Patr*0471 
13ce79fe94 Ivan*0472         _END_MASTER( myThid )
6a770e0a24 Patr*0473 
c9bf163375 Ivan*0474       ENDIF
6a770e0a24 Patr*0475 
6e4c90fea3 Patr*0476 #endif /* ALLOW_PROFILES */
                0477 
c9bf163375 Ivan*0478       RETURN
                0479       END