ESCOMP / PUMAS

Parameterization for Unified Microphysics Across Scales
9 stars 12 forks source link

File open in micro_pumas_utils.F90 is not legal in CAM #49

Open cacraigucar opened 1 year ago

cacraigucar commented 1 year ago

There is a file open using unit 10 to read in lkuptable_filename. CAM can not guarantee that unit 10 won't already be open with some other file. See below for newunit which should be used

Obsolete comment - kept for documentation purposes, but should not be done._The unit number should be passed into the init_lookuptable subroutine and provided by the host model.

gold2718 commented 1 year ago

The unit number should be passed into the init_lookup_table subroutine and provided by the host model.

I do not understand this. Why can't this just use newunit?

open(newunit=unitn,file=lkuptable_filename,status='old')

With an integer, unitn, defined as a local variable and used in the read and close statements.

cacraigucar commented 1 year ago

"My bad" - I'd forgotten about newunit. I edited the original comment appropriately.

@gold2718 - As an aside, looking forward to CCPP'izing PUMAS, what are the current constraints for reading within a scheme? I believe we relaxed the rule about schemes being forbidden from doing reads at least at initialization, but wanted to confirm the rule (since I've demonstrated my memory is not 100% accurate).

Katetc commented 1 year ago

Ok, I have fixed the unit=10 problem, but this has alerted me to the fact that micro_pumas_utils is kind of a mess with various debugging states of unified ice code (previously known as MG4). I don't think this het ice nucleation tag is the right place for a full pumas_utils cleanup, and since we still plan to bring that in, I want to leave this here. But know that it will be getting a lot of clean up. And also that these functions aren't used in the PUMAS version in Cam.

gold2718 commented 1 year ago

As an aside, looking forward to CCPP'izing PUMAS, what are the current constraints for reading within a scheme? I believe we relaxed the rule about schemes being forbidden from doing reads at least at initialization, but wanted to confirm the rule (since I've demonstrated my memory is not 100% accurate).

I don't think there was ever a rule. As a followup to our recent call, here is the text from the CCPP Framework rules for compliant physics schemes

The init phase, which performs actions needed to set up the scheme before the model integration begins. Examples of actions needed in this phase include the reading/computation of lookup tables, setting of constants (as described in Section 2.6), etc.

So I think it is okay to read non-gridded data at init time (or any phase except the run phase).