[1047] | 1 | module eofdump_mod |
---|
| 2 | ! this module controls the production of data for EOFs |
---|
[1528] | 3 | ! it won't work if run in parallel (but it's OK, we don't use it anymore...) |
---|
| 4 | ! Mainly kept for reference. |
---|
[1047] | 5 | implicit none |
---|
| 6 | ! Dump profiles for EOFs every ieofs physics timesteps, |
---|
| 7 | ! starting at first call; |
---|
| 8 | integer :: ieofs |
---|
| 9 | ! Dump profiles every eofskip points in each direction |
---|
| 10 | ! on the model grid. |
---|
| 11 | integer, parameter :: eofskip = 4 |
---|
| 12 | ! Units for writing EOF header and data: |
---|
| 13 | integer, parameter :: uehead = 82, uedata = 83 |
---|
| 14 | |
---|
| 15 | contains |
---|
| 16 | |
---|
| 17 | subroutine eofdump(ngrid,nlayer,u,v,t,rho,ps) |
---|
| 18 | |
---|
[1528] | 19 | use mod_grid_phy_lmdz, only: nbp_lon, nbp_lat |
---|
[1047] | 20 | implicit none |
---|
| 21 | ! |
---|
| 22 | ! Dumps profiles for calculation of variability EOFs |
---|
| 23 | ! Modified to include rho, FF 09/2004 |
---|
| 24 | ! Corrected small bug in sampling rate/count, EM 11/2007 |
---|
| 25 | ! |
---|
| 26 | ! |
---|
| 27 | |
---|
| 28 | integer,intent(in) :: ngrid ! total number of physics grid points |
---|
| 29 | integer,intent(in) :: nlayer ! number of atmospheric layers |
---|
[1130] | 30 | real,intent(in) :: u(ngrid,nlayer) |
---|
| 31 | real,intent(in) :: v(ngrid,nlayer) |
---|
| 32 | real,intent(in) :: t(ngrid,nlayer) |
---|
| 33 | real,intent(in) :: rho(ngrid,nlayer) |
---|
| 34 | real,intent(in) :: ps(ngrid) |
---|
[1047] | 35 | integer,save :: count=0 |
---|
| 36 | integer i,j,l, ig |
---|
| 37 | |
---|
| 38 | LOGICAL,SAVE :: firstcall=.true. |
---|
| 39 | |
---|
| 40 | !------------------------------------------------------- |
---|
| 41 | ! Initialization at first call: |
---|
| 42 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 43 | IF (firstcall) THEN |
---|
| 44 | write(*,*) 'CALL ineofdump' |
---|
| 45 | CALL ineofdump(ngrid,nlayer) |
---|
| 46 | firstcall=.false. |
---|
| 47 | END IF |
---|
| 48 | |
---|
| 49 | !------------------------------------------------------- |
---|
| 50 | ! Dumps every ieofs physics timesteps |
---|
| 51 | ! |
---|
| 52 | ! write(*,*)'eofdump:count=',count,' ps(1)=',ps(1) |
---|
| 53 | ! if ((ieofs.gt.0).and.(mod(count,ieofs).eq.0)) then |
---|
| 54 | if (mod(count+1,ieofs).eq.0) then |
---|
| 55 | ! write(*,*)'eofdump: dump --> ps(1)=',ps(1) |
---|
[1528] | 56 | do i=1,nbp_lon,eofskip |
---|
| 57 | do j=1+eofskip/2,nbp_lat,eofskip |
---|
| 58 | ig = 1+ (j-2)*nbp_lon +i |
---|
[1130] | 59 | #ifdef NC_DOUBLE |
---|
| 60 | write(uedata) (real(u(ig,l)),l=1,nlayer) |
---|
| 61 | write(uedata) (real(v(ig,l)),l=1,nlayer) |
---|
| 62 | write(uedata) (real(t(ig,l)),l=1,nlayer) |
---|
| 63 | write(uedata) (real(rho(ig,l)),l=1,nlayer) |
---|
| 64 | write(uedata) real(ps(ig)) |
---|
| 65 | #else |
---|
[1047] | 66 | write(uedata) (u(ig,l),l=1,nlayer) |
---|
| 67 | write(uedata) (v(ig,l),l=1,nlayer) |
---|
| 68 | write(uedata) (t(ig,l),l=1,nlayer) |
---|
| 69 | write(uedata) (rho(ig,l),l=1,nlayer) |
---|
| 70 | write(uedata) ps(ig) |
---|
[1130] | 71 | #endif |
---|
[1047] | 72 | enddo |
---|
| 73 | enddo |
---|
| 74 | endif |
---|
| 75 | count=count+1 |
---|
| 76 | |
---|
| 77 | end subroutine eofdump |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | subroutine ineofdump(ngrid,nlayer) |
---|
| 81 | |
---|
[1543] | 82 | use geometry_mod, only: longitude, latitude |
---|
[1621] | 83 | use nrtype, only: pi |
---|
[1524] | 84 | use time_phylmdz_mod, only: daysec, dtphys |
---|
[1621] | 85 | USE vertical_layers_mod, ONLY: aps,bps |
---|
[1528] | 86 | use mod_grid_phy_lmdz, only: nbp_lon, nbp_lat |
---|
[1047] | 87 | implicit none |
---|
| 88 | ! |
---|
| 89 | ! Initialise dumping of profiles for EOF calculations |
---|
| 90 | ! |
---|
| 91 | |
---|
| 92 | integer,intent(in) :: ngrid ! total number of physics grid points |
---|
| 93 | integer,intent(in) :: nlayer ! number of atmospheric layers |
---|
| 94 | integer ig,i,j,l |
---|
| 95 | logical,save :: firstcall=.true. |
---|
| 96 | integer,save :: npgrid |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | if (firstcall) then |
---|
[1528] | 100 | npgrid=ngrid+2*(nbp_lon-1) |
---|
[1047] | 101 | firstcall=.false. |
---|
| 102 | endif |
---|
| 103 | |
---|
| 104 | ! |
---|
| 105 | ! Set frequency for dumping at once per day |
---|
| 106 | ! |
---|
| 107 | ieofs=nint(daysec/dtphys) |
---|
| 108 | if (abs(float(ieofs)-daysec/dtphys).gt.1.e-8*daysec) & |
---|
[2022] | 109 | stop 'In ineofdump: 1 day .ne. n physics timesteps' |
---|
[1047] | 110 | ! |
---|
| 111 | ! Header |
---|
| 112 | ! |
---|
| 113 | open(uehead,file='profiles.hdr',form='formatted') |
---|
| 114 | write(uehead,*) 0.E+0,0,0,ieofs,1,0 |
---|
[1528] | 115 | write(uehead,*) nbp_lon,npgrid/nbp_lon,npgrid,nlayer |
---|
[1047] | 116 | |
---|
[1528] | 117 | do i=1,nbp_lon,eofskip |
---|
| 118 | do j=1+eofskip/2,nbp_lat,eofskip |
---|
| 119 | ig = 1+ (j-2)*nbp_lon +i |
---|
[1047] | 120 | if(j.eq.1) stop 'Problem in ineofdump.F' |
---|
[1528] | 121 | if(j.eq.nbp_lat) stop 'Problem in ineofdump.F' |
---|
[1130] | 122 | #ifdef NC_DOUBLE |
---|
[1541] | 123 | write(uehead,*) real(longitude(ig)*180./pi),real(latitude(ig)*180./pi) |
---|
[1130] | 124 | #else |
---|
[1541] | 125 | write(uehead,*) longitude(ig)*180./pi, latitude(ig)*180./pi |
---|
[1130] | 126 | #endif |
---|
[1541] | 127 | ! write(*,*) 'eof grid j=',j,' lat= ', latitude(ig)*180./pi |
---|
[1047] | 128 | enddo |
---|
| 129 | enddo |
---|
| 130 | |
---|
[1130] | 131 | #ifdef NC_DOUBLE |
---|
| 132 | write(uehead,*) real(aps) |
---|
| 133 | write(uehead,*) real(bps) |
---|
| 134 | #else |
---|
[1047] | 135 | write(uehead,*) aps |
---|
| 136 | write(uehead,*) bps |
---|
[1130] | 137 | #endif |
---|
[1047] | 138 | close(uehead) |
---|
| 139 | ! |
---|
| 140 | ! Main profile file |
---|
| 141 | ! |
---|
| 142 | open(uedata,file='profiles.dat',form='unformatted') |
---|
| 143 | end subroutine ineofdump |
---|
| 144 | |
---|
| 145 | end module eofdump_mod |
---|