/[MITgcm]/MITgcm/pkg/profiles/profiles_init_ncfile.F
ViewVC logotype

Annotation of /MITgcm/pkg/profiles/profiles_init_ncfile.F

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


Revision 1.1 - (hide annotations) (download)
Fri Mar 24 22:58:25 2006 UTC (18 years, 3 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint58d_post
o package cost profiles routines to better modularize them.

1 heimbach 1.1 #include "COST_CPPOPTIONS.h"
2    
3     C o==========================================================o
4     C | subroutine profiles_init_ncfile |
5     C | o initialization of model counterparts files |
6     C | for netcdf profiles data |
7     C | started: Gael Forget 15-March-2006 |
8     C o==========================================================o
9    
10     subroutine profiles_init_ncfile(num_file,fid1,file2,fid2,length,
11     & Zlength,myThid)
12    
13     implicit none
14    
15     C ==================== Global Variables ===========================
16     #include "EEPARAMS.h"
17     #include "SIZE.h"
18     #include "GRID.h"
19     #include "DYNVARS.h"
20     #ifdef ALLOW_PROFILES_CONTRIBUTION
21     # include "profiles.h"
22     # include "netcdf.inc"
23     #endif
24     C ==================== Routine Variables ==========================
25     integer fid1,fid2,dimid1,dimid2,varid(10),varid0
26     integer myThid,err,vecid(2), length, Zlength
27     character*(80) file1, file2
28     integer irec, num_var,num_file
29     real*8 tmp_vec(Zlength+1)
30     c == end of interface ==
31    
32     #ifdef ALLOW_PROFILES_CONTRIBUTION
33    
34     if (profilesfile_equi_type.EQ.1) then
35     c1) creation :
36     err = NF_CREATE(file2 , NF_CLOBBER, fid2)
37     err = NF_DEF_DIM(fid2,'iDEPTH', Zlength ,dimid1)
38     err = NF_DEF_DIM(fid2,'iPROF',length,dimid2)
39     vecid(1)=dimid1
40     vecid(2)=dimid2
41    
42     err = NF_DEF_VAR (fid2,'prof_ind_glob', NF_INT, 1,vecid(2),
43     & varid(1))
44     err = NF_PUT_ATT_INT(fid2,varid(1),'_FillValue',NF_INT,1,0)
45    
46     do num_var=1,4
47     err = NF_INQ_VARID(fid1,prof_names(num_var), varid0 )
48     if (err.EQ.NF_NOERR) then
49    
50     err = NF_DEF_VAR (fid2,prof_names(num_var), NF_DOUBLE, 2,vecid,
51     & varid(2+(num_var-1)*2))
52     err = NF_PUT_ATT_DOUBLE(fid2, varid(2+(num_var-1)*2),'_FillValue',
53     & NF_DOUBLE,1, 0. _d 0 )
54     err = NF_DEF_VAR (fid2,prof_namesmask(num_var),
55     & NF_DOUBLE, 2,vecid, varid(3+(num_var-1)*2))
56     err = NF_PUT_ATT_DOUBLE(fid2,varid(3+(num_var-1)*2),'_FillValue',
57     & NF_DOUBLE,1, 0. _d 0)
58    
59     endif
60     enddo
61    
62     err=NF_ENDDEF(fid2)
63     err=NF_CLOSE(fid2)
64    
65     err = NF_OPEN(file2, NF_WRITE , fid2)
66    
67     else
68    
69     call MDSFINDUNIT( fid2 , mythid )
70     open( fid2, file=file2, form ='unformatted', status='unknown',
71     & access='direct', recl= (Zlength + 1)*WORDLENGTH*2 )
72    
73     do irec=1,Zlength+1
74     tmp_vec(irec)=0
75     enddo
76     #ifdef _BYTESWAPIO
77     call MDS_BYTESWAPR8(Zlength+1,tmp_vec)
78     #endif
79     do irec=length,1,-1
80     do num_var=prof_num_var_tot(num_file),1,-1
81     write(fid2,rec=((irec-1)*prof_num_var_tot(num_file)
82     & +num_var-1)*2 +1) tmp_vec
83     write(fid2,rec=((irec-1)*prof_num_var_tot(num_file)
84     & +num_var-1)*2 +2) tmp_vec
85     enddo
86     enddo
87    
88     endif
89    
90     #endif
91    
92     END

  ViewVC Help
Powered by ViewVC 1.1.22